signal stored_src_port : std_logic_vector(15 downto 0);\r
signal stored_dst_port : std_logic_vector(15 downto 0);\r
\r
- signal fifo_pl_wr_x : std_logic;\r
+-- signal fifo_pl_wr_x : std_logic;\r
signal fifo_pl_wr : std_logic;\r
signal fifo_hd_wr_x : std_logic;\r
signal fifo_hd_wr : std_logic;\r
signal drop_frame_x : std_logic;\r
signal drop_frame : std_logic;\r
\r
+ signal fifo_wr_en : std_logic;\r
+\r
begin\r
\r
-- buffer incoming signals\r
begin\r
if ( RESET = '1' ) then\r
DECODE_CS <= IDLE;\r
- fifo_pl_wr <= '0';\r
+-- fifo_pl_wr <= '0';\r
fifo_hd_wr <= '0';\r
drop_frame <= '0';\r
rst_bytes <= '1';\r
elsif( rising_edge(CLK) ) then\r
DECODE_CS <= DECODE_NS;\r
- fifo_pl_wr <= fifo_pl_wr_x;\r
+-- fifo_pl_wr <= fifo_pl_wr_x;\r
fifo_hd_wr <= fifo_hd_wr_x;\r
drop_frame <= drop_frame_x;\r
rst_bytes <= rst_bytes_x;\r
is_my_mac_x, is_broadcast_x, is_arp_x, is_ipv4_x, is_udp_x,\r
is_version_x, is_sctrl_x, is_icmp_x )\r
begin\r
- fifo_pl_wr_x <= '0';\r
+-- fifo_pl_wr_x <= '0';\r
fifo_hd_wr_x <= '0';\r
drop_frame_x <= '0';\r
rst_bytes_x <= '0';\r
if( (mac_rx_eof_q = '0') ) then\r
-- payload available, store it\r
DECODE_NS <= STORE_FRAME;\r
- fifo_pl_wr_x <= '1';\r
+-- fifo_pl_wr_x <= '1';\r
else\r
-- empty payload, must never happen with ARP, so we drop it\r
DECODE_NS <= LAST_BYTE;\r
if( (mac_rx_eof_q = '0') ) then\r
-- payload available\r
DECODE_NS <= STORE_FRAME;\r
- fifo_pl_wr_x <= '1';\r
+-- fifo_pl_wr_x <= '1';\r
else\r
-- empty payload, must never happen with ICMP, so we drop it\r
DECODE_NS <= LAST_BYTE;\r
if( (mac_rx_eof_q = '0') ) then\r
-- payload available\r
DECODE_NS <= STORE_FRAME;\r
- fifo_pl_wr_x <= '1';\r
+-- fifo_pl_wr_x <= '1';\r
else\r
-- empty payload, store raw frame, check that later?\r
DECODE_NS <= LAST_BYTE;\r
\r
when STORE_FRAME =>\r
decode_fsm <= x"3";\r
- fifo_pl_wr_x <= '1';\r
+-- fifo_pl_wr_x <= '1';\r
if( MAC_RX_EOF_IN = '1' ) then\r
DECODE_NS <= LAST_BYTE;\r
fifo_hd_wr_x <= '1';\r
end case;\r
end process PROC_DECODE_TRANSITIONS;\r
\r
- -- counter for decoding the byte stream\r
- PROC_DECODE_CTR: process( CLK, RESET )\r
- begin\r
- if ( RESET = '1' ) then\r
- decode_ctr <= (others => '0');\r
+-- -- counter for decoding the byte stream\r
+-- PROC_DECODE_CTR: process( CLK, RESET )\r
+-- begin\r
+-- if ( RESET = '1' ) then\r
+-- decode_ctr <= (others => '0');\r
+-- elsif( rising_edge(CLK) ) then\r
+-- if( (DECODE_CS = STORE_HEADER) or (DECODE_CS = STORE_FRAME) ) then\r
+-- decode_ctr <= decode_ctr + 1;\r
+-- else\r
+-- decode_ctr <= (others => '0');\r
+-- end if;\r
+-- end if;\r
+-- end process PROC_DECODE_CTR;\r
+\r
+ -- counter for decoding the byte stream
+ PROC_DECODE_CTR: process( CLK, RESET )
+ begin
+ if ( RESET = '1' ) then
+ decode_ctr <= (others => '0');
elsif( rising_edge(CLK) ) then\r
- if( (DECODE_CS = STORE_HEADER) or (DECODE_CS = STORE_FRAME) ) then\r
- decode_ctr <= decode_ctr + 1;\r
- else\r
- decode_ctr <= (others => '0');\r
- end if;\r
- end if;\r
- end process PROC_DECODE_CTR;\r
+ if ( (DECODE_CS /= STORE_HEADER) and (DECODE_CS /= STORE_FRAME) ) then\r
+ decode_ctr <= (others => '0');
+ elsif( ((DECODE_CS = STORE_HEADER) or (DECODE_CS = STORE_FRAME)) and (MAC_RX_EN_IN = '1') ) then
+ decode_ctr <= decode_ctr + 1;
+ end if;
+ end if;
+ end process PROC_DECODE_CTR;
+\r
+ -- write only if data stream is available!\r
+ PROC_RX_FIFO_SYNC: process( CLK )
+ begin
+ if( rising_edge(CLK) ) then
+ if( MAC_RX_EN_IN = '1' ) then
+ if ( DECODE_NS = STORE_FRAME ) then
+ fifo_pl_wr <= '1';
+ elsif( (DECODE_CS = STORE_FRAME) and (DECODE_NS = LAST_BYTE) ) then
+ fifo_pl_wr <= '1';
+ else
+ fifo_pl_wr <= '0';
+ end if;
+ else
+ fifo_pl_wr <= '0';
+ end if;
+ end if;
+ end process PROC_RX_FIFO_SYNC;\r
\r
-- storing the relevant parts of headers for decision and further usage\r
PROC_STORE_INFO: process( CLK, RESET )\r
stored_src_port <= (others => '0');\r
stored_dst_port <= (others => '0');\r
elsif( rising_edge(CLK) ) then\r
- if( (MAC_RX_EN_IN = '1') and (mac_rx_en_q = '0') ) then\r
- -- early bird\r
- stored_dst_mac(7 downto 0) <= MAC_RXD_IN;\r
- end if;\r
+-- if( (MAC_RX_EN_IN = '1') and (mac_rx_en_q = '0') ) then\r
+-- -- early bird\r
+-- stored_dst_mac(7 downto 0) <= MAC_RXD_IN; -- FUCKING BUG!!!!\r
+-- end if;\r
if( (mac_rx_en_q = '1') and (DECODE_CS = STORE_HEADER) ) then\r
case decode_ctr is\r
when x"00" => stored_dst_mac(15 downto 8) <= MAC_RXD_IN;\r
+ stored_dst_mac(7 downto 0) <= mac_rxd_q;\r
when x"01" => stored_dst_mac(23 downto 16) <= MAC_RXD_IN;\r
when x"02" => stored_dst_mac(31 downto 24) <= MAC_RXD_IN;\r
when x"03" => stored_dst_mac(39 downto 32) <= MAC_RXD_IN;\r
-- CAVEAT: writing to FIFO and reading needs some clock cycles?\r
-- Three is fine, two fails - data arrives late.\r
-- Happens when main control tries to read a frame directly when it was written.\r
- \r
+\r
-- FIFO for header information\r
THE_FIRST_FIFO: entity work.fifo_512x72\r
port map(\r
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--- DEBUG_OUT(31 downto 0) <= (others => '0');
- DEBUG_OUT(31 downto 28) <= debug_fr(31 downto 28); -- frame receiver state
- DEBUG_OUT(27 downto 24) <= debug_rc(3 downto 0); -- receive control state
- DEBUG_OUT(23 downto 20) <= debug_main(23 downto 20); -- redirect state
- DEBUG_OUT(19 downto 16) <= fr_ps_int(3 downto 0); --debug_main(27 downto 24); -- link state
- DEBUG_OUT(15) <= rc_loading_done;
- DEBUG_OUT(14) <= rc_frame_ready;
- DEBUG_OUT(13) <= fr_ps_int(4); --rc_frame_proto(4); -- ICMP
- DEBUG_OUT(12) <= fr_ps_int(1); --rc_frame_proto(1); -- DHCP
- DEBUG_OUT(11) <= fr_ps_int(0); --rc_frame_proto(0); -- ARP
- DEBUG_OUT(10) <= fr_get_frame;
- DEBUG_OUT(9) <= fr_frame_valid;
- DEBUG_OUT(8) <= fr_rd_en;
- DEBUG_OUT(7 downto 0) <= rc_q(7 downto 0);
+---- DEBUG_OUT(31 downto 0) <= (others => '0');
+-- DEBUG_OUT(31 downto 28) <= debug_fr(31 downto 28); -- frame receiver state
+-- DEBUG_OUT(27 downto 24) <= debug_rc(3 downto 0); -- receive control state
+-- DEBUG_OUT(23 downto 20) <= debug_main(23 downto 20); -- redirect state
+-- DEBUG_OUT(19 downto 16) <= fr_ps_int(3 downto 0); --debug_main(27 downto 24); -- link state
+-- DEBUG_OUT(15) <= rc_loading_done;
+-- DEBUG_OUT(14) <= rc_frame_ready;
+-- DEBUG_OUT(13) <= fr_ps_int(4); --rc_frame_proto(4); -- ICMP
+-- DEBUG_OUT(12) <= fr_ps_int(1); --rc_frame_proto(1); -- DHCP
+-- DEBUG_OUT(11) <= fr_ps_int(0); --rc_frame_proto(0); -- ARP
+-- DEBUG_OUT(10) <= fr_get_frame;
+-- DEBUG_OUT(9) <= fr_frame_valid;
+-- DEBUG_OUT(8) <= fr_rd_en;
+-- DEBUG_OUT(7 downto 0) <= rc_q(7 downto 0);
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
-- DEBUG_OUT(31 downto 28) <= debug_fr(31 downto 28);
-- DEBUG_OUT(27 downto 0) <= debug_main(27 downto 0);
+ DEBUG_OUT(31 downto 0) <= debug_main(31 downto 0);
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------\r
-- Debug signals\r
-----------------------------------------------------------------------\r
- DEBUG_OUT(63 downto 28) <= (others => '0');\r
-\r
- DEBUG_OUT(27 downto 24) <= link_state;\r
- DEBUG_OUT(23 downto 20) <= redirect_state;\r
- DEBUG_OUT(19 downto 16) <= flow_state;\r
- DEBUG_OUT(15 downto 0) <= selector_debug(15 downto 0);\r
+-- DEBUG_OUT(63 downto 28) <= (others => '0');\r
+-- DEBUG_OUT(27 downto 24) <= link_state;\r
+-- DEBUG_OUT(23 downto 20) <= redirect_state;\r
+-- DEBUG_OUT(19 downto 16) <= flow_state;\r
+-- DEBUG_OUT(15 downto 0) <= selector_debug(15 downto 0);\r
+ DEBUG_OUT(63 downto 32) <= (others => '0');\r
+ DEBUG_OUT(31 downto 0) <= selector_debug(31 downto 0);\r
\r
-----------------------------------------------------------------------\r
-- Link state machine, high level. Handles DHCP basically\r
MY_IP_OUT <= my_ip;
-- Debug lines
- DEBUG_OUT(63 downto 16) <= (others => '0');
- DEBUG_OUT(15 downto 12) <= state; -- selector state
- DEBUG_OUT(11 downto 0) <= debug_dhcp(11 downto 0); -- FSM states DHCP
+-- DEBUG_OUT(63 downto 16) <= (others => '0');
+-- DEBUG_OUT(15 downto 12) <= state; -- selector state
+-- DEBUG_OUT(11 downto 0) <= debug_dhcp(11 downto 0); -- FSM states DHCP
+ DEBUG_OUT(63 downto 32) <= (others => '0');
+ DEBUG_OUT(31 downto 0) <= debug_dhcp(31 downto 0);
ARP_GEN: if( INCLUDE_ARP = '1' ) generate
-- protocol Nr. 1 ARP
signal CONSTRUCT_CS, CONSTRUCT_NS : discover_states;\r
attribute syn_encoding of CONSTRUCT_CS: signal is "onehot";\r
\r
--- type stats_states is (IDLE, LOAD_SENT, LOAD_RECEIVED, LOAD_DISCARDED, CLEANUP);\r
--- signal STATS_CS, STATS_NS : stats_states;\r
--- attribute syn_encoding of STATS_CS : signal is "onehot";\r
-\r
- signal state : std_logic_vector(3 downto 0);\r
+ signal cons_state : std_logic_vector(3 downto 0);\r
signal rec_frames : std_logic_vector(15 downto 0);\r
signal sent_frames : unsigned(15 downto 0);\r
\r
signal your_ip_reg : std_logic_vector(31 downto 0);\r
signal saved_server_mac : std_logic_vector(47 downto 0);\r
signal saved_server_ip : std_logic_vector(31 downto 0);\r
- signal state2 : std_logic_vector(3 downto 0);\r
- signal state3 : std_logic_vector(3 downto 0);\r
+ signal main_state : std_logic_vector(3 downto 0);\r
+ signal recv_state : std_logic_vector(3 downto 0);\r
signal vendor_values2 : std_logic_vector(47 downto 0);\r
\r
signal discarded_ctr : std_logic_vector(15 downto 0);\r
\r
attribute syn_preserve : boolean;\r
attribute syn_keep : boolean;\r
- attribute syn_keep of state, state2 : signal is true;\r
- attribute syn_preserve of state, state2 : signal is true;\r
+ attribute syn_keep of cons_state, main_state, recv_state : signal is true;\r
+ attribute syn_preserve of cons_state, main_state, recv_state : signal is true;\r
\r
signal wait_value : unsigned(31 downto 0);\r
\r
begin\r
\r
+ DEBUG_OUT(31 downto 28) <= main_state;\r
+ DEBUG_OUT(27 downto 24) <= recv_state;\r
+ DEBUG_OUT(23 downto 20) <= cons_state;\r
+ DEBUG_OUT(19 downto 12) <= PS_DEST_MAC_ADDRESS_IN(7 downto 0);\r
+ DEBUG_OUT(11) <= '0';\r
+ DEBUG_OUT(10) <= PS_WR_EN_IN;\r
+ DEBUG_OUT(9) <= PS_ACTIVATE_IN;\r
+ DEBUG_OUT(8 downto 0) <= PS_DATA_IN;\r
+\r
-- ****\r
-- fixing the constant values for DHCP request headers\r
TC_DEST_MAC_OUT <= x"ffffffffffff" when (MAIN_CS = BOOTING or MAIN_CS = SENDING_DISCOVER) else saved_server_mac;\r
\r
PROC_MAIN_TRANSITIONS : process( MAIN_CS, DHCP_START_IN, CONSTRUCT_CS, wait_ctr, RECEIVE_CS, PS_DATA_IN, wait_value )\r
begin\r
- state2 <= x"0";\r
+ main_state <= x"0";\r
\r
case (MAIN_CS) is\r
\r
when BOOTING =>\r
- state2 <= x"1";\r
+ main_state <= x"1";\r
if( DHCP_START_IN = '1' ) then\r
MAIN_NS <= DELAY;\r
else\r
end if;\r
\r
when DELAY =>\r
- state2 <= x"2";\r
+ main_state <= x"2";\r
if( wait_ctr = wait_value ) then\r
MAIN_NS <= SENDING_DISCOVER;\r
else\r
end if;\r
\r
when SENDING_DISCOVER =>\r
- state2 <= x"3";\r
+ main_state <= x"3";\r
if( CONSTRUCT_CS = CLEANUP ) then\r
MAIN_NS <= WAITING_FOR_OFFER;\r
else\r
end if;\r
\r
when WAITING_FOR_OFFER =>\r
- state2 <= x"4";\r
+ main_state <= x"4";\r
if( (RECEIVE_CS = SAVE_VALUES) and (PS_DATA_IN(8) = '1') ) then\r
MAIN_NS <= SENDING_REQUEST;\r
elsif( wait_ctr = x"2000_0000" ) then\r
end if;\r
\r
when SENDING_REQUEST =>\r
- state2 <= x"5";\r
+ main_state <= x"5";\r
if( CONSTRUCT_CS = CLEANUP ) then\r
MAIN_NS <= WAITING_FOR_ACK;\r
else\r
end if;\r
\r
when WAITING_FOR_ACK =>\r
- state2 <= x"6";\r
+ main_state <= x"6";\r
if( (RECEIVE_CS = SAVE_VALUES) and (PS_DATA_IN(8) = '1') ) then\r
MAIN_NS <= ESTABLISHED;\r
elsif( wait_ctr = x"2000_0000" ) then\r
end if;\r
\r
when ESTABLISHED =>\r
- state2 <= x"7";\r
+ main_state <= x"7";\r
if( DHCP_START_IN = '0' ) then\r
MAIN_NS <= BOOTING;\r
else\r
PROC_RECEIVE_TRANSITIONS: process( RECEIVE_CS, MAIN_CS, bootp_hdr, saved_dhcp_type, saved_transaction_id,\r
PS_DATA_IN, PS_DEST_MAC_ADDRESS_IN, MY_MAC_IN, PS_ACTIVATE_IN, PS_WR_EN_IN, save_ctr )\r
begin\r
- state3 <= x"0";\r
+ recv_state <= x"0";\r
\r
case RECEIVE_CS is\r
\r
when IDLE =>\r
- state3 <= x"1";\r
+ recv_state <= x"1";\r
if( (PS_ACTIVATE_IN = '1') and (PS_WR_EN_IN = '1') ) then\r
if( (MAIN_CS = WAITING_FOR_OFFER) or (MAIN_CS = WAITING_FOR_ACK) ) then -- ready to receive dhcp frame\r
if( PS_DEST_MAC_ADDRESS_IN = MY_MAC_IN ) then -- check if i'm the addressee (discards broadcasts also)\r
end if;\r
\r
when SAVE_VALUES =>\r
- state3 <= x"2";\r
+ recv_state <= x"2";\r
if ( PS_DATA_IN(8) = '1' ) then\r
RECEIVE_NS <= CLEANUP;\r
-- check if the same transaction\r
end if;\r
\r
when DISCARD =>\r
- state3 <= x"3";\r
+ recv_state <= x"3";\r
if( PS_DATA_IN(8) = '1' ) then\r
RECEIVE_NS <= CLEANUP;\r
else\r
end if;\r
\r
when CLEANUP =>\r
- state3 <= x"4";\r
+ recv_state <= x"4";\r
RECEIVE_NS <= IDLE;\r
\r
when others => \r
\r
PROC_CONSTRUCT_TRANSITIONS: process( CONSTRUCT_CS, MAIN_CS, load_ctr, PS_SELECTED_IN )\r
begin\r
- state <= x"0";\r
+ cons_state <= x"0";\r
\r
case CONSTRUCT_CS is\r
\r
when IDLE =>\r
- state <= x"1";\r
+ cons_state <= x"1";\r
if( (MAIN_CS = SENDING_DISCOVER) or (MAIN_CS = SENDING_REQUEST) ) then\r
CONSTRUCT_NS <= WAIT_FOR_LOAD;\r
else\r
end if;\r
\r
when WAIT_FOR_LOAD =>\r
- state <= x"2";\r
+ cons_state <= x"2";\r
if( PS_SELECTED_IN = '1' ) then\r
CONSTRUCT_NS <= BOOTP_HEADERS;\r
else\r
end if;\r
\r
when BOOTP_HEADERS =>\r
- state <= x"3";\r
+ cons_state <= x"3";\r
if( load_ctr = 11 ) then\r
CONSTRUCT_NS <= CLIENT_IP;\r
else\r
end if;\r
\r
when CLIENT_IP =>\r
- state <= x"4";\r
+ cons_state <= x"4";\r
if( load_ctr = 15 ) then\r
CONSTRUCT_NS <= YOUR_IP;\r
else\r
end if;\r
\r
when YOUR_IP =>\r
- state <= x"5";\r
+ cons_state <= x"5";\r
if( load_ctr = 19 ) then\r
CONSTRUCT_NS <= ZEROS1;\r
else\r
end if;\r
\r
when ZEROS1 =>\r
- state <= x"6";\r
+ cons_state <= x"6";\r
if( load_ctr = 27 ) then\r
CONSTRUCT_NS <= MY_MAC;\r
else\r
end if;\r
\r
when MY_MAC =>\r
- state <= x"7";\r
+ cons_state <= x"7";\r
if( load_ctr = 33 ) then\r
CONSTRUCT_NS <= ZEROS2;\r
else\r
end if;\r
\r
when ZEROS2 =>\r
- state <= x"8";\r
+ cons_state <= x"8";\r
if( load_ctr = 235 ) then\r
CONSTRUCT_NS <= VENDOR_VALS;\r
else\r
end if;\r
\r
when VENDOR_VALS =>\r
- state <= x"9";\r
+ cons_state <= x"9";\r
if( load_ctr = 257 ) then\r
-- for discover it's enough of values\r
if( MAIN_CS = SENDING_DISCOVER ) then\r
end if;\r
\r
when VENDOR_VALS2 =>\r
- state <= x"a";\r
+ cons_state <= x"a";\r
if( load_ctr = 263 ) then\r
CONSTRUCT_NS <= TERMINATION;\r
else\r
end if;\r
\r
when TERMINATION =>\r
- state <= x"b";\r
+ cons_state <= x"b";\r
CONSTRUCT_NS <= CLEANUP;\r
\r
when CLEANUP =>\r
- state <= x"c";\r
+ cons_state <= x"c";\r
CONSTRUCT_NS <= IDLE;\r
\r
when others => \r
-- PROC_DEBUG: process( CLK )\r
-- begin\r
-- if( rising_edge(CLK) ) then\r
- DEBUG_OUT(3 downto 0) <= state;\r
- DEBUG_OUT(7 downto 4) <= state2;\r
- DEBUG_OUT(11 downto 8) <= state3;\r
+-- DEBUG_OUT(3 downto 0) <= cons_state;\r
+-- DEBUG_OUT(7 downto 4) <= main_state;\r
+-- DEBUG_OUT(11 downto 8) <= recv_state;\r
-- end if;\r
-- end process PROC_DEBUG;\r
\r
FWD_READY_OUT : out std_logic;
FWD_FULL_OUT : out std_logic;
-- debug
- DEBUG_OUT : out std_logic_vector(31 downto 0)
+ DEBUG_OUT : out std_logic_vector(63 downto 0)
);
end gbe_response_constructor_Forward;
DEBUG_OUT(15 downto 8) <= ff_q(7 downto 0);
DEBUG_OUT(16) <= ff_q(8);
DEBUG_OUT(17) <= local_eop;
- DEBUG_OUT(31 downto 18) <= (others => '0');
+ DEBUG_OUT(63 downto 18) <= (others => '0');
-- ****
end gbe_response_constructor_Forward_arch;