-LIBRARY IEEE;\r
-USE IEEE.std_logic_1164.ALL;\r
-USE IEEE.numeric_std.ALL;\r
-USE IEEE.std_logic_UNSIGNED.ALL;\r
+library IEEE;\r
+use IEEE.std_logic_1164.ALL;\r
+use IEEE.numeric_std.ALL;\r
+use IEEE.std_logic_UNSIGNED.ALL;\r
\r
library work;\r
use work.trb_net_std.all;\r
use work.trb_net_components.all;\r
-use work.trb_net16_hub_func.all;\r
+\r
+-- Builds one ethernet frame, and stores it in an external FIFO for transmission.\r
+-- Changed to 125MHz clock only.\r
\r
entity trb_net16_gbe_frame_constr is\r
- generic (\r
- FRAME_BUFFER_SIZE : integer range 1 to 4 := 1\r
- );\r
-port( \r
- -- ports for user logic\r
- RESET : in std_logic;\r
- CLK : in std_logic;\r
- LINK_OK_IN : in std_logic; -- gk 03.08.10\r
- --\r
- WR_EN_IN : in std_logic;\r
- DATA_IN : in std_logic_vector(7 downto 0);\r
- START_OF_DATA_IN : in std_logic;\r
- END_OF_DATA_IN : in std_logic;\r
- IP_F_SIZE_IN : in std_logic_vector(15 downto 0);\r
- UDP_P_SIZE_IN : in std_logic_vector(15 downto 0); -- needed for fragmentation\r
- HEADERS_READY_OUT : out std_logic;\r
- READY_OUT : out std_logic;\r
- DEST_MAC_ADDRESS_IN : in std_logic_vector(47 downto 0);\r
- DEST_IP_ADDRESS_IN : in std_logic_vector(31 downto 0);\r
- DEST_UDP_PORT_IN : in std_logic_vector(15 downto 0);\r
- SRC_MAC_ADDRESS_IN : in std_logic_vector(47 downto 0);\r
- SRC_IP_ADDRESS_IN : in std_logic_vector(31 downto 0);\r
- SRC_UDP_PORT_IN : in std_logic_vector(15 downto 0);\r
- FRAME_TYPE_IN : in std_logic_vector(15 downto 0);\r
- IHL_VERSION_IN : in std_logic_vector(7 downto 0);\r
- TOS_IN : in std_logic_vector(7 downto 0);\r
- IDENTIFICATION_IN : in std_logic_vector(15 downto 0);\r
- FLAGS_OFFSET_IN : in std_logic_vector(15 downto 0);\r
- TTL_IN : in std_logic_vector(7 downto 0);\r
- PROTOCOL_IN : in std_logic_vector(7 downto 0);\r
- FRAME_DELAY_IN : in std_logic_vector(31 downto 0); -- gk 09.12.10\r
- -- ports for packetTransmitter\r
- RD_CLK : in std_logic; -- 125MHz clock!!!\r
- FT_TX_DATA_OUT : out std_logic_vector(8 downto 0);\r
- FT_TX_WR_OUT : out std_logic;\r
- FT_TX_FIFOFULL_IN : in std_logic;\r
- --\r
- MONITOR_TX_BYTES_OUT : out std_logic_vector(31 downto 0);\r
- MONITOR_TX_FRAMES_OUT : out std_logic_vector(31 downto 0)\r
-);\r
-end trb_net16_gbe_frame_constr;\r
+ port( \r
+ -- ports for user logic\r
+ RESET : in std_logic;\r
+ CLK : in std_logic; -- 125MHz clock\r
+ LINK_OK_IN : in std_logic; \r
+ -- frame stuff\r
+ WR_EN_IN : in std_logic;\r
+ DATA_IN : in std_logic_vector(7 downto 0);\r
+ START_OF_DATA_IN : in std_logic;\r
+ END_OF_DATA_IN : in std_logic;\r
+ IP_F_SIZE_IN : in std_logic_vector(15 downto 0);\r
+ UDP_P_SIZE_IN : in std_logic_vector(15 downto 0); -- needed for fragmentation\r
+ HEADERS_READY_OUT : out std_logic;\r
+ READY_OUT : out std_logic;\r
+ DEST_MAC_ADDRESS_IN : in std_logic_vector(47 downto 0);\r
+ DEST_IP_ADDRESS_IN : in std_logic_vector(31 downto 0);\r
+ DEST_UDP_PORT_IN : in std_logic_vector(15 downto 0);\r
+ SRC_MAC_ADDRESS_IN : in std_logic_vector(47 downto 0);\r
+ SRC_IP_ADDRESS_IN : in std_logic_vector(31 downto 0);\r
+ SRC_UDP_PORT_IN : in std_logic_vector(15 downto 0);\r
+ FRAME_TYPE_IN : in std_logic_vector(15 downto 0);\r
+ IHL_VERSION_IN : in std_logic_vector(7 downto 0);\r
+ TOS_IN : in std_logic_vector(7 downto 0);\r
+ IDENTIFICATION_IN : in std_logic_vector(15 downto 0);\r
+ FLAGS_OFFSET_IN : in std_logic_vector(15 downto 0);\r
+ TTL_IN : in std_logic_vector(7 downto 0);\r
+ PROTOCOL_IN : in std_logic_vector(7 downto 0);\r
+ FRAME_DELAY_IN : in std_logic_vector(31 downto 0);\r
+ -- port for "RX ringbuffer"\r
+ FT_TX_DATA_OUT : out std_logic_vector(8 downto 0);\r
+ FT_TX_WR_OUT : out std_logic;\r
+ FT_TX_FIFOFULL_IN : in std_logic;\r
+ -- monitoring\r
+ MONITOR_TX_BYTES_OUT : out std_logic_vector(31 downto 0);\r
+ MONITOR_TX_FRAMES_OUT : out std_logic_vector(31 downto 0)\r
+ );\r
+end entity trb_net16_gbe_frame_constr;\r
\r
architecture trb_net16_gbe_frame_constr of trb_net16_gbe_frame_constr is\r
\r
attribute syn_encoding : string;\r
\r
-type constructStates is (IDLE, DEST_MAC_ADDR, SRC_MAC_ADDR, FRAME_TYPE_S, VERSION,\r
- TOS_S, IP_LENGTH, IDENT, FLAGS, TTL_S, PROTO, HEADER_CS,\r
- SRC_IP_ADDR, DEST_IP_ADDR, SRC_PORT, DEST_PORT, UDP_LENGTH,\r
- UDP_CS, SAVE_DATA, CLEANUP, DELAY);\r
+type constructStates is (IDLE, DEST_MAC_ADDR, SRC_MAC_ADDR, FRAME_TYPE_S, VERSION,\r
+ TOS_S, IP_LENGTH, IDENT, FLAGS, TTL_S, PROTO, HEADER_CS,\r
+ SRC_IP_ADDR, DEST_IP_ADDR, SRC_PORT, DEST_PORT, UDP_LENGTH,\r
+ UDP_CS, SAVE_DATA, CLEANUP, DELAY);\r
signal constructCurrentState, constructNextState : constructStates;\r
-signal bsm_constr : std_logic_vector(7 downto 0);\r
attribute syn_encoding of constructCurrentState: signal is "onehot";\r
\r
signal headers_int_counter : integer range 0 to 6;\r
signal fpf_data : std_logic_vector(7 downto 0);\r
-signal fpf_empty : std_logic;\r
-signal fpf_full : std_logic;\r
signal fpf_wr_en : std_logic;\r
signal fpf_rd_en : std_logic;\r
signal fpf_rd_en_q : std_logic;\r
signal ready : std_logic;\r
signal headers_ready : std_logic;\r
\r
-signal cur_max : integer range 0 to 10;\r
-\r
-signal ip_cs_temp_right : std_logic_vector(15 downto 0); -- gk 29.03.10\r
+signal cur_max : integer range 0 to 10;\r
\r
-signal fpf_reset : std_logic; -- gk 01.01.01\r
-signal link_ok_125, link_ok_q : std_logic;\r
+signal ip_cs_temp_right : std_logic_vector(15 downto 0);\r
\r
--- gk 09.12.10\r
signal delay_ctr : std_logic_vector(31 downto 0);\r
signal frame_delay_reg : std_logic_vector(31 downto 0);\r
signal fpf_data_q : std_logic_vector(7 downto 0);\r
-signal fpf_wr_en_q, fpf_eod : std_logic;\r
+signal fpf_wr_en_q : std_logic;\r
+signal fpf_eod_q : std_logic;\r
\r
-signal mon_sent_frames, mon_sent_bytes : std_logic_vector(31 downto 0);\r
+signal mon_sent_frames : unsigned(31 downto 0);\r
+signal mon_sent_bytes : unsigned(31 downto 0);\r
\r
begin\r
\r
--- Fakes\r
-udp_checksum <= x"0000"; -- no checksum test needed\r
+-- No checksum test needed\r
+udp_checksum <= x"0000";\r
\r
-process(CLK)\r
+-- frame constructor ready\r
+THE_READY_PROC: process( CLK )\r
begin\r
-if rising_edge(CLK) then\r
- if constructCurrentState = IDLE then\r
+if( rising_edge(CLK) )then\r
+ if( constructCurrentState = IDLE ) then\r
ready <= '1';\r
else\r
ready <= '0';\r
end if;\r
\r
- if (constructCurrentState = SAVE_DATA) then\r
+ if( constructCurrentState = SAVE_DATA ) then\r
headers_ready <= '1';\r
else\r
headers_ready <= '0';\r
end if;\r
end if;\r
end process;\r
- \r
-sizeProc: process(CLK)\r
+\r
+-- Calculate UDP and IP sizes\r
+THE_SIZE_PROC: process( CLK )\r
begin\r
- if rising_edge(CLK) then\r
- if( put_udp_headers = '1' ) and (DEST_UDP_PORT_IN /= x"0000") then\r
+ if( rising_edge(CLK) ) then\r
+ if( (put_udp_headers = '1') and (DEST_UDP_PORT_IN /= x"0000") ) then\r
ip_size <= IP_F_SIZE_IN + x"14" + x"8";\r
udp_size <= UDP_P_SIZE_IN + x"8";\r
else\r
udp_size <= UDP_P_SIZE_IN;\r
end if;\r
end if;\r
-end process sizeProc;\r
+end process THE_SIZE_PROC;\r
\r
-ipCsProc : process(CLK)\r
+THE_IP_CS_PROC : process( CLK )\r
begin\r
- if rising_edge(CLK) then\r
- if (constructCurrentState = IDLE) then\r
- ip_checksum <= x"00000000";\r
- else\r
- case constructCurrentState is\r
- when DEST_MAC_ADDR =>\r
- case headers_int_counter is\r
- when 0 =>\r
- ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + SRC_IP_ADDRESS_IN(7 downto 0);\r
- when 1 =>\r
- ip_checksum <= ip_checksum + SRC_IP_ADDRESS_IN(15 downto 8);\r
- when 2 =>\r
- ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + SRC_IP_ADDRESS_IN(23 downto 16);\r
- when 3 =>\r
- ip_checksum <= ip_checksum + SRC_IP_ADDRESS_IN(31 downto 24);\r
- when 4 =>\r
- ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + DEST_IP_ADDRESS_IN(7 downto 0);\r
- when 5 =>\r
- ip_checksum <= ip_checksum + DEST_IP_ADDRESS_IN(15 downto 8);\r
- when others => null;\r
- end case;\r
- when SRC_MAC_ADDR =>\r
- case headers_int_counter is\r
- when 0 =>\r
- ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + DEST_IP_ADDRESS_IN(23 downto 16);\r
- when 1 =>\r
- ip_checksum <= ip_checksum + DEST_IP_ADDRESS_IN(31 downto 24);\r
- when 2 =>\r
- ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + IHL_VERSION_IN;\r
- when 3 =>\r
- ip_checksum <= ip_checksum + TOS_IN;\r
- when 4 =>\r
- ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + ip_size(15 downto 8);\r
- when 5 =>\r
- ip_checksum <= ip_checksum + ip_size(7 downto 0);\r
- when others => null;\r
- end case;\r
- when VERSION =>\r
- if headers_int_counter = 0 then\r
- ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + IDENTIFICATION_IN(7 downto 0);\r
- end if;\r
- when TOS_S =>\r
- if headers_int_counter = 0 then\r
- ip_checksum <= ip_checksum + IDENTIFICATION_IN(15 downto 8);\r
- end if;\r
- when IP_LENGTH =>\r
- if headers_int_counter = 0 then\r
- ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + FLAGS_OFFSET_IN(15 downto 8);\r
- elsif headers_int_counter = 1 then\r
- ip_checksum <= ip_checksum + FLAGS_OFFSET_IN(7 downto 0);\r
- end if;\r
- when IDENT =>\r
- if headers_int_counter = 0 then\r
- ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + TTL_IN;\r
- elsif headers_int_counter = 1 then\r
- ip_checksum <= ip_checksum + PROTOCOL_IN;\r
- end if;\r
- -- gk 29.03.10 corrected the bug with bad checksums when sum larger than 16b\r
- when FLAGS =>\r
- if headers_int_counter = 0 then\r
- ip_cs_temp_right <= ip_checksum(31 downto 16);\r
- elsif headers_int_counter = 1 then\r
- ip_checksum(31 downto 16) <= (others => '0');\r
- end if;\r
- when TTL_S =>\r
- if headers_int_counter = 0 then\r
- ip_checksum <= ip_checksum + ip_cs_temp_right;\r
- end if;\r
- when PROTO =>\r
- if headers_int_counter = 0 then\r
- ip_checksum(15 downto 0) <= ip_checksum(15 downto 0) + ip_checksum(31 downto 16);\r
- end if;\r
- when others => null;\r
- end case;\r
- end if;\r
- end if;\r
-end process ipCsProc;\r
-\r
-\r
-constructMachineProc: process(RESET, CLK )\r
+ if( rising_edge(CLK) ) then\r
+ if( constructCurrentState = IDLE ) then\r
+ ip_checksum <= x"00000000";\r
+ else\r
+ case constructCurrentState is\r
+ when DEST_MAC_ADDR =>\r
+ case headers_int_counter is\r
+ when 0 =>\r
+ ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + SRC_IP_ADDRESS_IN(7 downto 0);\r
+ when 1 =>\r
+ ip_checksum <= ip_checksum + SRC_IP_ADDRESS_IN(15 downto 8);\r
+ when 2 =>\r
+ ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + SRC_IP_ADDRESS_IN(23 downto 16);\r
+ when 3 =>\r
+ ip_checksum <= ip_checksum + SRC_IP_ADDRESS_IN(31 downto 24);\r
+ when 4 =>\r
+ ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + DEST_IP_ADDRESS_IN(7 downto 0);\r
+ when 5 =>\r
+ ip_checksum <= ip_checksum + DEST_IP_ADDRESS_IN(15 downto 8);\r
+ when others => null;\r
+ end case;\r
+ when SRC_MAC_ADDR =>\r
+ case headers_int_counter is\r
+ when 0 =>\r
+ ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + DEST_IP_ADDRESS_IN(23 downto 16);\r
+ when 1 =>\r
+ ip_checksum <= ip_checksum + DEST_IP_ADDRESS_IN(31 downto 24);\r
+ when 2 =>\r
+ ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + IHL_VERSION_IN;\r
+ when 3 =>\r
+ ip_checksum <= ip_checksum + TOS_IN;\r
+ when 4 =>\r
+ ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + ip_size(15 downto 8);\r
+ when 5 =>\r
+ ip_checksum <= ip_checksum + ip_size(7 downto 0);\r
+ when others => null;\r
+ end case;\r
+ when VERSION =>\r
+ if( headers_int_counter = 0 ) then\r
+ ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + IDENTIFICATION_IN(7 downto 0);\r
+ end if;\r
+ when TOS_S =>\r
+ if( headers_int_counter = 0 ) then\r
+ ip_checksum <= ip_checksum + IDENTIFICATION_IN(15 downto 8);\r
+ end if;\r
+ when IP_LENGTH =>\r
+ if( headers_int_counter = 0 ) then\r
+ ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + FLAGS_OFFSET_IN(15 downto 8);\r
+ elsif headers_int_counter = 1 then\r
+ ip_checksum <= ip_checksum + FLAGS_OFFSET_IN(7 downto 0);\r
+ end if;\r
+ when IDENT =>\r
+ if headers_int_counter = 0 then\r
+ ip_checksum(31 downto 8) <= ip_checksum(31 downto 8) + TTL_IN;\r
+ elsif headers_int_counter = 1 then\r
+ ip_checksum <= ip_checksum + PROTOCOL_IN;\r
+ end if;\r
+ -- gk 29.03.10 corrected the bug with bad checksums when sum larger than 16b\r
+ when FLAGS =>\r
+ if ( headers_int_counter = 0 ) then\r
+ ip_cs_temp_right <= ip_checksum(31 downto 16);\r
+ elsif( headers_int_counter = 1 ) then\r
+ ip_checksum(31 downto 16) <= (others => '0');\r
+ end if;\r
+ when TTL_S =>\r
+ if( headers_int_counter = 0 ) then\r
+ ip_checksum <= ip_checksum + ip_cs_temp_right;\r
+ end if;\r
+ when PROTO =>\r
+ if( headers_int_counter = 0 ) then\r
+ ip_checksum(15 downto 0) <= ip_checksum(15 downto 0) + ip_checksum(31 downto 16);\r
+ end if;\r
+ when others => null;\r
+ end case;\r
+ end if;\r
+ end if;\r
+end process THE_IP_CS_PROC;\r
+\r
+\r
+THE_CONSTRUCT_PROC: process( CLK )\r
begin\r
- if RESET = '1' then\r
- constructCurrentState <= IDLE;\r
- elsif( rising_edge(CLK) ) then\r
- constructCurrentState <= constructNextState;\r
- end if;\r
-end process constructMachineProc;\r
+ if( rising_edge(CLK) ) then\r
+ if( RESET = '1' ) then\r
+ constructCurrentState <= IDLE;\r
+ else\r
+ constructCurrentState <= constructNextState;\r
+ end if;\r
+ end if;\r
+end process THE_CONSTRUCT_PROC;\r
\r
--find next state of construct machine\r
-constructMachine: process( constructCurrentState, delay_ctr, FRAME_DELAY_IN, START_OF_DATA_IN, END_OF_DATA_IN, headers_int_counter, put_udp_headers, CUR_MAX, FRAME_TYPE_IN, DEST_UDP_PORT_IN)\r
+constructMachine: process( constructCurrentState, delay_ctr, FRAME_DELAY_IN, START_OF_DATA_IN, \r
+ END_OF_DATA_IN, headers_int_counter, put_udp_headers, CUR_MAX, \r
+ FRAME_TYPE_IN, DEST_UDP_PORT_IN)\r
begin\r
- constructNextState <= constructCurrentState;\r
- if( headers_int_counter = cur_max ) then --can be checked everytime - if not in use, counter and cur_max are 0\r
- case constructCurrentState is\r
- when IDLE =>\r
- if( START_OF_DATA_IN = '1' ) then\r
- constructNextState <= DEST_MAC_ADDR;\r
- end if;\r
- when DEST_MAC_ADDR =>\r
- constructNextState <= SRC_MAC_ADDR;\r
- when SRC_MAC_ADDR =>\r
- constructNextState <= FRAME_TYPE_S;\r
- when FRAME_TYPE_S =>\r
- --if (DEST_IP_ADDRESS_IN /= x"0000_0000") then -- in case of ip frame continue with ip/udp headers\r
- if (FRAME_TYPE_IN = x"0008") then \r
- constructNextState <= VERSION;\r
- else -- otherwise transmit data as pure ethernet frame\r
- constructNextState <= SAVE_DATA;\r
- end if;\r
- when VERSION =>\r
- constructNextState <= TOS_S;\r
- when TOS_S =>\r
- constructNextState <= IP_LENGTH;\r
- when IP_LENGTH =>\r
- constructNextState <= IDENT;\r
- when IDENT =>\r
- constructNextState <= FLAGS;\r
- when FLAGS =>\r
- constructNextState <= TTL_S;\r
- when TTL_S =>\r
- constructNextState <= PROTO;\r
- when PROTO =>\r
- constructNextState <= HEADER_CS;\r
- when HEADER_CS =>\r
- constructNextState <= SRC_IP_ADDR;\r
- when SRC_IP_ADDR =>\r
- constructNextState <= DEST_IP_ADDR;\r
- when DEST_IP_ADDR =>\r
- if (put_udp_headers = '1') and (DEST_UDP_PORT_IN /= x"0000") then\r
- constructNextState <= SRC_PORT;\r
- else\r
- constructNextState <= SAVE_DATA;\r
- end if;\r
- when SRC_PORT =>\r
- constructNextState <= DEST_PORT;\r
- when DEST_PORT =>\r
- constructNextState <= UDP_LENGTH;\r
- when UDP_LENGTH =>\r
- constructNextState <= UDP_CS;\r
- when UDP_CS =>\r
- constructNextState <= SAVE_DATA;\r
- when SAVE_DATA =>\r
- if (END_OF_DATA_IN = '1') then\r
- constructNextState <= CLEANUP;\r
- end if;\r
- when CLEANUP =>\r
- --constructNextState <= IDLE;\r
- constructNextState <= DELAY; -- gk 10.12.10 IDLE;\r
- -- gk 09.12.10\r
- when DELAY =>\r
- if (delay_ctr = FRAME_DELAY_IN) then\r
- constructNextState <= IDLE;\r
- else\r
- constructNextState <= DELAY;\r
- end if;\r
-\r
- when others =>\r
- constructNextState <= IDLE;\r
- end case;\r
- end if;\r
+ constructNextState <= constructCurrentState;\r
+ if( headers_int_counter = cur_max ) then --can be checked everytime - if not in use, counter and cur_max are 0\r
+ case constructCurrentState is\r
+ when IDLE =>\r
+ if( START_OF_DATA_IN = '1' ) then\r
+ constructNextState <= DEST_MAC_ADDR;\r
+ end if;\r
+ when DEST_MAC_ADDR =>\r
+ constructNextState <= SRC_MAC_ADDR;\r
+ when SRC_MAC_ADDR =>\r
+ constructNextState <= FRAME_TYPE_S;\r
+ when FRAME_TYPE_S =>\r
+ if( FRAME_TYPE_IN = x"0008" ) then \r
+ constructNextState <= VERSION;\r
+ else -- otherwise transmit data as pure ethernet frame\r
+ constructNextState <= SAVE_DATA;\r
+ end if;\r
+ when VERSION =>\r
+ constructNextState <= TOS_S;\r
+ when TOS_S =>\r
+ constructNextState <= IP_LENGTH;\r
+ when IP_LENGTH =>\r
+ constructNextState <= IDENT;\r
+ when IDENT =>\r
+ constructNextState <= FLAGS;\r
+ when FLAGS =>\r
+ constructNextState <= TTL_S;\r
+ when TTL_S =>\r
+ constructNextState <= PROTO;\r
+ when PROTO =>\r
+ constructNextState <= HEADER_CS;\r
+ when HEADER_CS =>\r
+ constructNextState <= SRC_IP_ADDR;\r
+ when SRC_IP_ADDR =>\r
+ constructNextState <= DEST_IP_ADDR;\r
+ when DEST_IP_ADDR =>\r
+ if( (put_udp_headers = '1') and (DEST_UDP_PORT_IN /= x"0000") ) then\r
+ constructNextState <= SRC_PORT;\r
+ else\r
+ constructNextState <= SAVE_DATA;\r
+ end if;\r
+ when SRC_PORT =>\r
+ constructNextState <= DEST_PORT;\r
+ when DEST_PORT =>\r
+ constructNextState <= UDP_LENGTH;\r
+ when UDP_LENGTH =>\r
+ constructNextState <= UDP_CS;\r
+ when UDP_CS =>\r
+ constructNextState <= SAVE_DATA;\r
+ when SAVE_DATA =>\r
+ if( END_OF_DATA_IN = '1' ) then\r
+ constructNextState <= CLEANUP;\r
+ end if;\r
+ when CLEANUP =>\r
+ constructNextState <= DELAY;\r
+ when DELAY =>\r
+ if (delay_ctr = FRAME_DELAY_IN) then\r
+ constructNextState <= IDLE;\r
+ else\r
+ constructNextState <= DELAY;\r
+ end if;\r
+ \r
+ when others =>\r
+ constructNextState <= IDLE;\r
+ end case;\r
+ end if;\r
end process constructMachine;\r
\r
--- gk 09.12.10\r
-delayCtrProc : process(CLK)\r
+THE_DELAY_CTR_PROC: process( CLK )\r
begin\r
- if rising_edge(CLK) then\r
- if (constructCurrentState = IDLE) or (constructCurrentState = CLEANUP) then\r
- delay_ctr <= (others => '0');\r
- elsif (constructCurrentState = DELAY) then\r
- delay_ctr <= delay_ctr + x"1";\r
- end if;\r
-\r
- frame_delay_reg <= FRAME_DELAY_IN;\r
- end if;\r
-end process delayCtrProc;\r
+ if( rising_edge(CLK) ) then\r
+ if ( (constructCurrentState = IDLE) or (constructCurrentState = CLEANUP) ) then\r
+ delay_ctr <= (others => '0');\r
+ elsif( constructCurrentState = DELAY ) then\r
+ delay_ctr <= delay_ctr + x"1";\r
+ end if;\r
\r
+ frame_delay_reg <= FRAME_DELAY_IN;\r
+ end if;\r
+end process THE_DELAY_CTR_PROC;\r
\r
-bsmConstrProc : process(constructCurrentState)\r
+THE_BSM_CONSTR_PROC: process( constructCurrentState )\r
begin\r
--find maximum time in each state & set state bits\r
- case constructCurrentState is\r
- when IDLE => cur_max <= 0; bsm_constr <= x"01";\r
- when DEST_MAC_ADDR => cur_max <= 5; bsm_constr <= x"02";\r
- when SRC_MAC_ADDR => cur_max <= 5; bsm_constr <= x"03";\r
- when FRAME_TYPE_S => cur_max <= 1; bsm_constr <= x"04";\r
- when VERSION => cur_max <= 0; bsm_constr <= x"05";\r
- when TOS_S => cur_max <= 0; bsm_constr <= x"06";\r
- when IP_LENGTH => cur_max <= 1; bsm_constr <= x"07";\r
- when IDENT => cur_max <= 1; bsm_constr <= x"08";\r
- when FLAGS => cur_max <= 1; bsm_constr <= x"09";\r
- when TTL_S => cur_max <= 0; bsm_constr <= x"0a";\r
- when PROTO => cur_max <= 0; bsm_constr <= x"0b";\r
- when HEADER_CS => cur_max <= 1; bsm_constr <= x"0c";\r
- when SRC_IP_ADDR => cur_max <= 3; bsm_constr <= x"0d";\r
- when DEST_IP_ADDR => cur_max <= 3; bsm_constr <= x"0e";\r
- when SRC_PORT => cur_max <= 1; bsm_constr <= x"0f";\r
- when DEST_PORT => cur_max <= 1; bsm_constr <= x"10";\r
- when UDP_LENGTH => cur_max <= 1; bsm_constr <= x"11";\r
- when UDP_CS => cur_max <= 1; bsm_constr <= x"12";\r
- when SAVE_DATA => cur_max <= 0; bsm_constr <= x"13";\r
- when CLEANUP => cur_max <= 0; bsm_constr <= x"14";\r
- when DELAY => cur_max <= 0; bsm_constr <= x"15";\r
- when others => cur_max <= 0; bsm_constr <= x"1f";\r
- end case;\r
-end process;\r
-\r
-\r
-headersIntProc : process(CLK)\r
+ case constructCurrentState is\r
+ when IDLE => cur_max <= 0;\r
+ when DEST_MAC_ADDR => cur_max <= 5;\r
+ when SRC_MAC_ADDR => cur_max <= 5;\r
+ when FRAME_TYPE_S => cur_max <= 1;\r
+ when VERSION => cur_max <= 0;\r
+ when TOS_S => cur_max <= 0;\r
+ when IP_LENGTH => cur_max <= 1;\r
+ when IDENT => cur_max <= 1;\r
+ when FLAGS => cur_max <= 1;\r
+ when TTL_S => cur_max <= 0;\r
+ when PROTO => cur_max <= 0;\r
+ when HEADER_CS => cur_max <= 1;\r
+ when SRC_IP_ADDR => cur_max <= 3;\r
+ when DEST_IP_ADDR => cur_max <= 3;\r
+ when SRC_PORT => cur_max <= 1;\r
+ when DEST_PORT => cur_max <= 1;\r
+ when UDP_LENGTH => cur_max <= 1;\r
+ when UDP_CS => cur_max <= 1;\r
+ when SAVE_DATA => cur_max <= 0;\r
+ when CLEANUP => cur_max <= 0;\r
+ when DELAY => cur_max <= 0;\r
+ when others => cur_max <= 0;\r
+end case;\r
+end process THE_BSM_CONSTR_PROC;\r
+\r
+\r
+THE_HEADERS_INT_PROC: process( CLK )\r
begin\r
- if rising_edge(CLK) then\r
- if (constructCurrentState = IDLE) then\r
- headers_int_counter <= 0;\r
- else\r
- if (headers_int_counter = cur_max) then\r
- headers_int_counter <= 0;\r
- else\r
- headers_int_counter <= headers_int_counter + 1;\r
- end if;\r
- end if;\r
- end if;\r
-end process headersIntProc;\r
-\r
-putUdpHeadersProc : process(CLK)\r
+ if( rising_edge(CLK) ) then\r
+ if( constructCurrentState = IDLE ) then\r
+ headers_int_counter <= 0;\r
+ else\r
+ if( headers_int_counter = cur_max ) then\r
+ headers_int_counter <= 0;\r
+ else\r
+ headers_int_counter <= headers_int_counter + 1;\r
+ end if;\r
+ end if;\r
+end if;\r
+end process THE_HEADERS_INT_PROC;\r
+\r
+THE_PUT_UDP_HEADERS_PROC: process( CLK )\r
begin\r
- if rising_edge(CLK) then\r
- if (FLAGS_OFFSET_IN(12 downto 0) = "0000000000000") then\r
- put_udp_headers <= '1';\r
- else\r
- put_udp_headers <= '0';\r
- end if;\r
- end if;\r
-end process putUdpHeadersProc;\r
-\r
-fpfWrEnProc : process(constructCurrentState, WR_EN_IN, LINK_OK_IN)\r
+ if( rising_edge(CLK) ) then\r
+ if( FLAGS_OFFSET_IN(12 downto 0) = "0000000000000" ) then\r
+ put_udp_headers <= '1';\r
+ else\r
+ put_udp_headers <= '0';\r
+ end if;\r
+ end if;\r
+end process THE_PUT_UDP_HEADERS_PROC;\r
+\r
+THE_FPF_WREN_PROC : process( constructCurrentState, WR_EN_IN, LINK_OK_IN )\r
begin\r
- if (LINK_OK_IN = '0') then -- gk 01.10.10\r
- fpf_wr_en <= '0';\r
- elsif (constructCurrentState /= IDLE) and (constructCurrentState /= CLEANUP) and (constructCurrentState /= SAVE_DATA) and (constructCurrentState /= DELAY) then\r
- fpf_wr_en <= '1';\r
- elsif (constructCurrentState = SAVE_DATA) and (WR_EN_IN = '1') then\r
- fpf_wr_en <= '1';\r
- else\r
- fpf_wr_en <= '0';\r
- end if;\r
-end process fpfWrEnProc;\r
-\r
-fpfDataProc : process(constructCurrentState, DEST_MAC_ADDRESS_IN, SRC_MAC_ADDRESS_IN, FRAME_TYPE_IN, IHL_VERSION_IN,\r
- TOS_IN, ip_size, IDENTIFICATION_IN, FLAGS_OFFSET_IN, TTL_IN, PROTOCOL_IN,\r
- ip_checksum, SRC_IP_ADDRESS_IN, DEST_IP_ADDRESS_IN,\r
- SRC_UDP_PORT_IN, DEST_UDP_PORT_IN, udp_size, udp_checksum, headers_int_counter, DATA_IN)\r
+ if ( LINK_OK_IN = '0' ) then\r
+ fpf_wr_en <= '0';\r
+ elsif( (constructCurrentState /= IDLE) and (constructCurrentState /= CLEANUP) and (constructCurrentState /= SAVE_DATA) and (constructCurrentState /= DELAY) ) then\r
+ fpf_wr_en <= '1';\r
+ elsif( (constructCurrentState = SAVE_DATA) and (WR_EN_IN = '1') ) then\r
+ fpf_wr_en <= '1';\r
+ else\r
+ fpf_wr_en <= '0';\r
+ end if;\r
+end process THE_FPF_WREN_PROC;\r
+\r
+THE_FPF_DATA_PROC: process( constructCurrentState, DEST_MAC_ADDRESS_IN, SRC_MAC_ADDRESS_IN, FRAME_TYPE_IN, IHL_VERSION_IN,\r
+ TOS_IN, ip_size, IDENTIFICATION_IN, FLAGS_OFFSET_IN, TTL_IN, PROTOCOL_IN,\r
+ ip_checksum, SRC_IP_ADDRESS_IN, DEST_IP_ADDRESS_IN,\r
+ SRC_UDP_PORT_IN, DEST_UDP_PORT_IN, udp_size, udp_checksum, headers_int_counter, DATA_IN )\r
begin\r
- case constructCurrentState is\r
- when IDLE => fpf_data <= DEST_MAC_ADDRESS_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
- when DEST_MAC_ADDR => fpf_data <= DEST_MAC_ADDRESS_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
- when SRC_MAC_ADDR => fpf_data <= SRC_MAC_ADDRESS_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
- when FRAME_TYPE_S => fpf_data <= FRAME_TYPE_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
- when VERSION => fpf_data <= IHL_VERSION_IN;\r
- when TOS_S => fpf_data <= TOS_IN;\r
- when IP_LENGTH => fpf_data <= ip_size(15 - headers_int_counter * 8 downto 8 - headers_int_counter * 8);\r
- when IDENT => fpf_data <= IDENTIFICATION_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
- when FLAGS => fpf_data <= FLAGS_OFFSET_IN(15 - headers_int_counter * 8 downto 8 - headers_int_counter * 8);\r
- when TTL_S => fpf_data <= TTL_IN;\r
- when PROTO => fpf_data <= PROTOCOL_IN;\r
- when HEADER_CS => fpf_data <= x"ff" - ip_checksum(15 - headers_int_counter * 8 downto 8 - headers_int_counter * 8);\r
- when SRC_IP_ADDR => fpf_data <= SRC_IP_ADDRESS_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
- when DEST_IP_ADDR => fpf_data <= DEST_IP_ADDRESS_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
- when SRC_PORT => fpf_data <= SRC_UDP_PORT_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
- when DEST_PORT => fpf_data <= DEST_UDP_PORT_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
- when UDP_LENGTH => fpf_data <= udp_size(15 - headers_int_counter * 8 downto 8 - headers_int_counter * 8);\r
- when UDP_CS => fpf_data <= udp_checksum(15 - headers_int_counter * 8 downto 8 - headers_int_counter * 8);\r
- when SAVE_DATA => fpf_data <= DATA_IN;\r
- when CLEANUP => fpf_data <= x"ab";\r
- when DELAY => fpf_data <= x"ac";\r
- when others => fpf_data <= x"00";\r
- end case;\r
-end process fpfDataProc;\r
-\r
-syncProc : process( CLK )\r
+ case constructCurrentState is\r
+ when IDLE => fpf_data <= DEST_MAC_ADDRESS_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
+ when DEST_MAC_ADDR => fpf_data <= DEST_MAC_ADDRESS_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
+ when SRC_MAC_ADDR => fpf_data <= SRC_MAC_ADDRESS_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
+ when FRAME_TYPE_S => fpf_data <= FRAME_TYPE_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
+ when VERSION => fpf_data <= IHL_VERSION_IN;\r
+ when TOS_S => fpf_data <= TOS_IN;\r
+ when IP_LENGTH => fpf_data <= ip_size(15 - headers_int_counter * 8 downto 8 - headers_int_counter * 8);\r
+ when IDENT => fpf_data <= IDENTIFICATION_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
+ when FLAGS => fpf_data <= FLAGS_OFFSET_IN(15 - headers_int_counter * 8 downto 8 - headers_int_counter * 8);\r
+ when TTL_S => fpf_data <= TTL_IN;\r
+ when PROTO => fpf_data <= PROTOCOL_IN;\r
+ when HEADER_CS => fpf_data <= x"ff" - ip_checksum(15 - headers_int_counter * 8 downto 8 - headers_int_counter * 8);\r
+ when SRC_IP_ADDR => fpf_data <= SRC_IP_ADDRESS_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
+ when DEST_IP_ADDR => fpf_data <= DEST_IP_ADDRESS_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
+ when SRC_PORT => fpf_data <= SRC_UDP_PORT_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
+ when DEST_PORT => fpf_data <= DEST_UDP_PORT_IN(headers_int_counter * 8 + 7 downto headers_int_counter * 8);\r
+ when UDP_LENGTH => fpf_data <= udp_size(15 - headers_int_counter * 8 downto 8 - headers_int_counter * 8);\r
+ when UDP_CS => fpf_data <= udp_checksum(15 - headers_int_counter * 8 downto 8 - headers_int_counter * 8);\r
+ when SAVE_DATA => fpf_data <= DATA_IN;\r
+ when CLEANUP => fpf_data <= x"ab";\r
+ when DELAY => fpf_data <= x"ac";\r
+ when others => fpf_data <= x"00";\r
+ end case;\r
+end process THE_FPF_DATA_PROC;\r
+\r
+THE_SYNC_PROC: process( CLK )\r
begin\r
- if rising_edge(CLK) then\r
+ if( rising_edge(CLK) ) then\r
fpf_data_q <= fpf_data;\r
fpf_wr_en_q <= fpf_wr_en;\r
- fpf_eod <= END_OF_DATA_IN;\r
+ fpf_eod_q <= END_OF_DATA_IN;\r
+ end if;\r
+end process THE_SYNC_PROC;\r
+\r
+-- count bytes sent\r
+THE_MON_SENT_BYTES_PROC: process( CLK )\r
+begin\r
+ if( rising_edge(CLK) ) then\r
+ if( LINK_OK_IN = '0' ) then\r
+ mon_sent_bytes <= (others => '0');\r
+ elsif( fpf_rd_en = '1' ) then\r
+ mon_sent_bytes <= mon_sent_bytes + 1;\r
+ else\r
+ mon_sent_bytes <= mon_sent_bytes;\r
+ end if;\r
end if;\r
-end process syncProc;\r
+end process THE_MON_SENT_BYTES_PROC;\r
+\r
+-- count frames sent\r
+THE_MON_SENT_FRAMES_PROC: process( CLK )\r
+begin\r
+ if( rising_edge(CLK) )then\r
+ if ( LINK_OK_IN = '0' ) then\r
+ mon_sent_frames <= (others => '0');\r
+ elsif( (fpf_wr_en_q = '1') and (fpf_eod_q = '1') ) then -- TO BE TESTED\r
+ mon_sent_frames <= mon_sent_frames + 1;\r
+ else\r
+ mon_sent_frames <= mon_sent_frames;\r
+ end if;\r
+ end if;\r
+end process THE_MON_SENT_FRAMES_PROC;\r
+\r
+-- Outputs\r
\r
FT_TX_DATA_OUT(7 downto 0) <= fpf_data_q;\r
-FT_TX_DATA_OUT(8) <= fpf_eod;\r
+FT_TX_DATA_OUT(8) <= fpf_eod_q;\r
FT_TX_WR_OUT <= fpf_wr_en_q;\r
\r
-READY_OUT <= ready;\r
-HEADERS_READY_OUT <= headers_ready;\r
-\r
-MONITOR_TX_BYTES_OUT <= mon_sent_bytes;\r
-MONITOR_TX_FRAMES_OUT <= mon_sent_frames;\r
+READY_OUT <= ready;\r
+HEADERS_READY_OUT <= headers_ready;\r
\r
-process(RD_CLK)\r
-begin\r
- if rising_edge(RD_CLK) then\r
- if (LINK_OK_IN = '0') then\r
- mon_sent_bytes <= (others => '0');\r
- elsif (fpf_rd_en = '1') then\r
- mon_sent_bytes <= mon_sent_bytes + x"1";\r
- else\r
- mon_sent_bytes <= mon_sent_bytes;\r
- end if;\r
- end if;\r
-end process;\r
+MONITOR_TX_BYTES_OUT <= std_logic_vector(mon_sent_bytes);\r
+MONITOR_TX_FRAMES_OUT <= std_logic_vector(mon_sent_frames);\r
\r
end trb_net16_gbe_frame_constr;\r