From d4d9839175f8fcb877320574404566ab6165ae16 Mon Sep 17 00:00:00 2001 From: hadeshyp Date: Fri, 14 Sep 2012 10:51:26 +0000 Subject: [PATCH] *** empty log message *** --- gbe2_ecp3/tb_frame_receiver.vhd | 320 +++++++++++++++++- gbe2_ecp3/trb_net16_gbe_buf.vhd | 26 +- gbe2_ecp3/trb_net16_gbe_frame_receiver.vhd | 5 + gbe2_ecp3/trb_net16_gbe_main_control.vhd | 19 +- gbe2_ecp3/trb_net16_gbe_protocol_selector.vhd | 282 ++++++++++++--- ...trb_net16_gbe_response_constructor_ARP.vhd | 5 + ...rb_net16_gbe_response_constructor_DHCP.vhd | 20 +- ...rb_net16_gbe_response_constructor_Ping.vhd | 7 +- ...b_net16_gbe_response_constructor_SCTRL.vhd | 11 +- ...rb_net16_gbe_response_constructor_Stat.vhd | 11 +- gbe2_ecp3/trb_net_gbe_components.vhd | 1 + 11 files changed, 613 insertions(+), 94 deletions(-) diff --git a/gbe2_ecp3/tb_frame_receiver.vhd b/gbe2_ecp3/tb_frame_receiver.vhd index d83b807..8b0ed20 100644 --- a/gbe2_ecp3/tb_frame_receiver.vhd +++ b/gbe2_ecp3/tb_frame_receiver.vhd @@ -11,10 +11,10 @@ use work.trb_net_std.all; use work.trb_net_components.all; use work.trb_net16_hub_func.all; -entity testbench is -end testbench; +entity tb_frame_receiver is +end tb_frame_receiver; -architecture behavior of testbench is +architecture behavior of tb_frame_receiver is component trb_net16_hub_streaming_port_sctrl is generic( @@ -692,7 +692,319 @@ begin --for i in 0 to 1000 loop - wait for 200 ns; + wait for 400 ns; + + -- FIRST FRAME UDP - DHCP Offer + wait until rising_edge(RX_MAC_CLK); + MAC_RX_EN_IN <= '1'; +-- dest mac + MAC_RXD_IN <= x"02"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"be"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); +-- src mac + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"aa"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"bb"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"cc"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"dd"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"ee"; + wait until rising_edge(RX_MAC_CLK); +-- frame type + MAC_RXD_IN <= x"08"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); +-- ip headers + MAC_RXD_IN <= x"45"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"10"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"01"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"5a"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"49"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"ff"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"11"; -- udp + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"cc"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"cc"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"c0"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"a8"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"01"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"c0"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"a8"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"02"; +-- udp headers + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"43"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"44"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"02"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"2c"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"aa"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"bb"; +-- dhcp data + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"02"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"01"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"06"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"de"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"ad"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"fa"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"ce"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"c0"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"a8"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"10"; + + for i in 0 to 219 loop + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + end loop; + + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"35"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"01"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"02"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RX_EOF_IN <= '1'; + + wait until rising_edge(RX_MAC_CLK); + MAC_RX_EN_IN <='0'; + MAC_RX_EOF_IN <= '0'; + + wait for 1 us; + + -- FIRST FRAME UDP - DHCP Offer + wait until rising_edge(RX_MAC_CLK); + MAC_RX_EN_IN <= '1'; +-- dest mac + MAC_RXD_IN <= x"02"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"be"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); +-- src mac + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"aa"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"bb"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"cc"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"dd"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"ee"; + wait until rising_edge(RX_MAC_CLK); +-- frame type + MAC_RXD_IN <= x"08"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); +-- ip headers + MAC_RXD_IN <= x"45"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"10"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"01"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"5a"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"49"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"ff"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"11"; -- udp + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"cc"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"cc"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"c0"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"a8"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"01"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"c0"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"a8"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"02"; +-- udp headers + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"43"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"44"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"02"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"2c"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"aa"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"bb"; +-- dhcp data + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"02"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"01"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"06"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"de"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"ad"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"fa"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"ce"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"c0"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"a8"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"10"; + + for i in 0 to 219 loop + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + end loop; + + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"35"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"01"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"05"; + wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"00"; + wait until rising_edge(RX_MAC_CLK); + MAC_RX_EOF_IN <= '1'; + + wait until rising_edge(RX_MAC_CLK); + MAC_RX_EN_IN <='0'; + MAC_RX_EOF_IN <= '0'; + + + + wait; -- FIRST FRAME (ARP Request) diff --git a/gbe2_ecp3/trb_net16_gbe_buf.vhd b/gbe2_ecp3/trb_net16_gbe_buf.vhd index 96b2a08..5346147 100755 --- a/gbe2_ecp3/trb_net16_gbe_buf.vhd +++ b/gbe2_ecp3/trb_net16_gbe_buf.vhd @@ -605,20 +605,15 @@ attribute syn_preserve of timeout_noticed : signal is true; begin ---my_mac <= x"efbeefbe0000"; -- temporary - stage_ctrl_regs <= STAGE_CTRL_REGS_IN; -- gk 23.04.10 LED_PACKET_SENT_OUT <= timeout_noticed; --pc_ready; -LED_AN_DONE_N_OUT <= not link_ok; --not pcs_an_complete; +LED_AN_DONE_N_OUT <= not link_ok; --not pcs_an_complete; --- FrameConstructor fixed magic values ---fc_type <= x"0008"; -fc_ihl_version <= x"45"; -fc_tos <= x"10"; -fc_ttl <= x"ff"; ---fc_protocol <= x"11"; +fc_ihl_version <= x"45"; +fc_tos <= x"10"; +fc_ttl <= x"ff"; MAIN_CONTROL : trb_net16_gbe_main_control @@ -1171,7 +1166,6 @@ port map( ); - RECEIVE_CONTROLLER : trb_net16_gbe_receive_control port map( CLK => CLK, @@ -1217,7 +1211,6 @@ port map( ); dbg_q(15 downto 9) <= (others => '0'); - FRAME_TRANSMITTER: trb_net16_gbe_frame_trans port map( CLK => CLK, @@ -1246,7 +1239,6 @@ port map( --DEBUG_OUT(31 downto 0) => open, --DEBUG_OUT(63 downto 32) => open ); - FRAME_RECEIVER : trb_net16_gbe_frame_receiver port map( @@ -1698,7 +1690,7 @@ discfrm_sync : signal_sync --*************** -- LOGIC ANALYZER SIGNALS --*************** ---analyzer_debug <= pcs_stat_debug; +ANALYZER_DEBUG_OUT <= dbg_mc or dbg_tc or (dbg_fc1 & dbg_fc2) or rc_debug or dbg_ft or dbg_fr(63 downto 0) or (dbg_fr(95 downto 64) & x"00000000"); -- Outputs FEE_READ_OUT <= fee_read; @@ -1711,13 +1703,5 @@ CTS_ERROR_PATTERN_OUT <= cts_error_pattern; STAGE_STAT_REGS_OUT <= stage_stat_regs; -ANALYZER_DEBUG_OUT <= analyzer_debug; ---analyzer_debug(0) <= serdes_clk_125; ---analyzer_debug(1) <= not pcs_stat_debug(22); ---analyzer_debug(2) <= SFP_PRSNT_N_IN; ---analyzer_debug(3) <= SFP_LOS_IN; ---analyzer_debug(63 downto 4) <= (others => '0'); -analyzer_debug(3 downto 0) <= dbg_mc(15 downto 12); - end architecture; diff --git a/gbe2_ecp3/trb_net16_gbe_frame_receiver.vhd b/gbe2_ecp3/trb_net16_gbe_frame_receiver.vhd index 79cb01e..4e381c8 100644 --- a/gbe2_ecp3/trb_net16_gbe_frame_receiver.vhd +++ b/gbe2_ecp3/trb_net16_gbe_frame_receiver.vhd @@ -109,6 +109,11 @@ signal ok_frames_ctr : std_logic_vector(15 downto 0); signal rx_data : std_logic_vector(8 downto 0); +attribute syn_preserve : boolean; +attribute syn_keep : boolean; +attribute syn_keep of rec_fifo_empty, rec_fifo_full, state, sizes_fifo_empty, sizes_fifo_full : signal is true; +attribute syn_preserve of rec_fifo_empty, rec_fifo_full, state, sizes_fifo_empty, sizes_fifo_full : signal is true; + begin DEBUG_OUT(0) <= rec_fifo_empty; diff --git a/gbe2_ecp3/trb_net16_gbe_main_control.vhd b/gbe2_ecp3/trb_net16_gbe_main_control.vhd index 91c678f..1fbeea9 100644 --- a/gbe2_ecp3/trb_net16_gbe_main_control.vhd +++ b/gbe2_ecp3/trb_net16_gbe_main_control.vhd @@ -186,10 +186,14 @@ signal unique_id : std_logic_vector(63 downto 0); signal nothing_sent : std_logic; signal nothing_sent_ctr : std_logic_vector(31 downto 0); +signal dbg_ps : std_Logic_vector(63 downto 0); + attribute syn_preserve : boolean; attribute syn_keep : boolean; -attribute syn_keep of unique_id, nothing_sent : signal is true; -attribute syn_preserve of unique_id, nothing_sent : signal is true; +attribute syn_keep of unique_id, nothing_sent, link_state, state, redirect_state : signal is true; +attribute syn_preserve of unique_id, nothing_sent, link_state, state, redirect_state : signal is true; + +signal mc_busy : std_logic; begin @@ -232,6 +236,7 @@ port map( TC_FLAGS_OFFSET_OUT => TC_FLAGS_OFFSET_OUT, TC_BUSY_IN => TC_BUSY_IN, + MC_BUSY_IN => mc_busy, RECEIVED_FRAMES_OUT => SELECT_REC_FRAMES_OUT, SENT_FRAMES_OUT => SELECT_SENT_FRAMES_OUT, @@ -260,7 +265,7 @@ port map( STAT_DATA_ACK_OUT => stat_ack, - DEBUG_OUT => open + DEBUG_OUT => dbg_ps ); TC_FRAME_TYPE_OUT <= frame_type when flow_current_state = TRANSMIT_CTRL else x"0008"; @@ -476,6 +481,8 @@ end process FLOW_MACHINE; TC_TRANSMIT_DATA_OUT <= '1' when (flow_current_state = TRANSMIT_DATA) else '0'; TC_TRANSMIT_CTRL_OUT <= '1' when (flow_current_state = TRANSMIT_CTRL) else '0'; +mc_busy <= '0' when flow_current_state = IDLE else '1'; + NOTHING_SENT_CTR_PROC : process(CLK) begin if rising_edge(CLK) then @@ -508,7 +515,7 @@ begin if (g_SIMULATE = 0) then link_current_state <= INACTIVE; else - link_current_state <= ACTIVE; + link_current_state <= GET_ADDRESS; --ACTIVE; end if; else link_current_state <= link_next_state; @@ -827,14 +834,14 @@ begin end process SAVE_VALUES_PROC; -DEBUG_OUT(3 downto 0) <= mac_control_debug(3 downto 0); +DEBUG_OUT(3 downto 0) <= link_state; DEBUG_OUT(7 downto 4) <= state; DEBUG_OUT(11 downto 8) <= redirect_state; DEBUG_OUT(15 downto 12) <= link_state; DEBUG_OUT(23 downto 16) <= frame_waiting_ctr(7 downto 0); DEBUG_OUT(27 downto 24) <= (others => '0'); --ps_busy_q; DEBUG_OUT(31 downto 28) <= (others => '0'); --rc_frame_proto_q; -DEBUG_OUT(63 downto 32) <= (others => '0'); +DEBUG_OUT(63 downto 32) <= dbg_ps(31 downto 0) or dbg_ps(63 downto 32); -- **** diff --git a/gbe2_ecp3/trb_net16_gbe_protocol_selector.vhd b/gbe2_ecp3/trb_net16_gbe_protocol_selector.vhd index eed8439..0a2344d 100644 --- a/gbe2_ecp3/trb_net16_gbe_protocol_selector.vhd +++ b/gbe2_ecp3/trb_net16_gbe_protocol_selector.vhd @@ -56,6 +56,7 @@ port ( TC_FLAGS_OFFSET_OUT : out std_logic_vector(15 downto 0); TC_BUSY_IN : in std_logic; + MC_BUSY_IN : in std_logic; -- counters from response constructors RECEIVED_FRAMES_OUT : out std_logic_vector(c_MAX_PROTOCOLS * 16 - 1 downto 0); @@ -119,21 +120,19 @@ signal tc_ip_size : std_logic_vector((c_MAX_PROTOCOLS + 1) * 16 - signal tc_udp_size : std_logic_vector((c_MAX_PROTOCOLS + 1) * 16 - 1 downto 0); signal tc_flags_size : std_logic_vector((c_MAX_PROTOCOLS + 1) * 16 - 1 downto 0); --- temporary -signal gsc_init_dataready : std_logic; -signal gsc_init_data : std_logic_vector(15 downto 0); -signal gsc_init_packet_num : std_logic_vector(2 downto 0); -signal gsc_init_read : std_logic; -signal gsc_reply_dataready : std_logic; -signal gsc_reply_data : std_logic_vector(15 downto 0); -signal gsc_reply_packet_num : std_logic_vector(2 downto 0); -signal gsc_reply_read : std_logic; -signal gsc_busy : std_logic; + +type select_states is (IDLE, LOOP_OVER, SELECT_ONE, PROCESS_REQUEST, CLEANUP); +signal select_current_state, select_next_state : select_states; + +signal state : std_logic_vector(3 downto 0); +signal index : integer range 0 to c_MAX_PROTOCOLS - 1; + +signal mult : std_logic; attribute syn_preserve : boolean; attribute syn_keep : boolean; -attribute syn_keep of gsc_busy, gsc_reply_read, gsc_reply_packet_num, gsc_reply_data, gsc_init_read, gsc_reply_dataready, gsc_init_packet_num, gsc_init_data, gsc_init_dataready : signal is true; -attribute syn_preserve of gsc_busy, gsc_reply_read, gsc_reply_packet_num, gsc_reply_data, gsc_init_read, gsc_reply_dataready, gsc_init_packet_num, gsc_init_data, gsc_init_dataready : signal is true; +attribute syn_keep of state, mult : signal is true; +attribute syn_preserve of state, mult : signal is true; begin @@ -429,16 +428,85 @@ stat_addr((c_MAX_PROTOCOLS + 1) * 8 - 1 downto c_MAX_PROTOCOLS * 8) <= STAT_AD stat_rdy(c_MAX_PROTOCOLS) <= STAT_DATA_RDY_IN; STAT_DATA_ACK_OUT <= stat_ack(c_MAX_PROTOCOLS); +mult <= or_all(resp_ready(2 downto 0)) and or_all(resp_ready(4 downto 3)); + PS_BUSY_OUT <= busy; -SELECTOR_PROC : process(CLK) - variable found : boolean := false; +SELECT_MACHINE_PROC : process(CLK) begin if rising_edge(CLK) then + if (RESET = '1') then + select_current_state <= IDLE; + else + select_current_state <= select_next_state; + end if; + end if; +end process SELECT_MACHINE_PROC; + +SELECT_MACHINE : process(select_current_state, MC_BUSY_IN, resp_ready, index) +begin + + case (select_current_state) is + + when IDLE => + state <= x"1"; + if (MC_BUSY_IN = '0') then + select_next_state <= LOOP_OVER; + else + select_next_state <= IDLE; + end if; + + when LOOP_OVER => + state <= x"2"; + if (or_all(resp_ready) = '1') then + if (resp_ready(index) = '1') then + select_next_state <= SELECT_ONE; + elsif (index = c_MAX_PROTOCOLS) then + select_next_state <= CLEANUP; + end if; + else + select_next_state <= CLEANUP; + end if; + + when SELECT_ONE => + state <= x"3"; + if (MC_BUSY_IN = '1') then + select_next_state <= PROCESS_REQUEST; + else + select_next_state <= SELECT_ONE; + end if; + + when PROCESS_REQUEST => + state <= x"4"; + if (MC_BUSY_IN = '0') then + select_next_state <= CLEANUP; + else + select_next_state <= PROCESS_REQUEST; + end if; + + when CLEANUP => + state <= x"5"; + select_next_state <= IDLE; - selected <= (others => '0'); + end case; +end process SELECT_MACHINE; + +INDEX_PROC : process(CLK) +begin + if rising_edge(CLK) then + if (RESET = '1') or (select_current_state = IDLE) then + index <= 0; + elsif (select_current_state = LOOP_OVER and resp_ready(index) = '0' and (or_all(resp_ready) = '1' or mult = '1')) then + index <= index + 1; + end if; + end if; +end process INDEX_PROC; + +SELECTOR_PROC : process(CLK) +begin + if rising_edge(CLK) then if (RESET = '1') then TC_DATA_OUT <= (others => '0'); TC_FRAME_SIZE_OUT <= (others => '0'); @@ -455,53 +523,155 @@ begin TC_FLAGS_OFFSET_OUT <= (others => '0'); PS_RESPONSE_READY_OUT <= '0'; selected <= (others => '0'); - found := false; - else - if (or_all(resp_ready) = '1') then - for i in 0 to c_MAX_PROTOCOLS - 1 loop - if (resp_ready(i) = '1') then - TC_DATA_OUT <= tc_data((i + 1) * 9 - 1 downto i * 9); - TC_FRAME_SIZE_OUT <= tc_size((i + 1) * 16 - 1 downto i * 16); - TC_FRAME_TYPE_OUT <= tc_type((i + 1) * 16 - 1 downto i * 16); - TC_DEST_MAC_OUT <= tc_mac((i + 1) * 48 - 1 downto i * 48); - TC_DEST_IP_OUT <= tc_ip((i + 1) * 32 - 1 downto i * 32); - TC_DEST_UDP_OUT <= tc_udp((i + 1) * 16 - 1 downto i * 16); - TC_SRC_MAC_OUT <= tc_src_mac((i + 1) * 48 - 1 downto i * 48); - TC_SRC_IP_OUT <= tc_src_ip((i + 1) * 32 - 1 downto i * 32); - TC_SRC_UDP_OUT <= tc_src_udp((i + 1) * 16 - 1 downto i * 16); - TC_IP_PROTOCOL_OUT <= tc_ip_proto((i + 1) * 8 - 1 downto i * 8); - TC_IP_SIZE_OUT <= tc_ip_size((i + 1) * 16 - 1 downto i * 16); - TC_UDP_SIZE_OUT <= tc_udp_size((i + 1) * 16 - 1 downto i * 16); - TC_FLAGS_OFFSET_OUT <= tc_flags_size((i + 1) * 16 - 1 downto i * 16); - PS_RESPONSE_READY_OUT <= '1'; - selected(i) <= '1'; - found := true; - elsif (i = c_MAX_PROTOCOLS - 1) and (resp_ready(i) = '0') and (found = false) then - found := false; - PS_RESPONSE_READY_OUT <= '0'; - end if; - end loop; + elsif (select_current_state = SELECT_ONE or select_current_state = PROCESS_REQUEST) then + TC_DATA_OUT <= tc_data((index + 1) * 9 - 1 downto index * 9); + TC_FRAME_SIZE_OUT <= tc_size((index + 1) * 16 - 1 downto index * 16); + TC_FRAME_TYPE_OUT <= tc_type((index + 1) * 16 - 1 downto index * 16); + TC_DEST_MAC_OUT <= tc_mac((index + 1) * 48 - 1 downto index * 48); + TC_DEST_IP_OUT <= tc_ip((index + 1) * 32 - 1 downto index * 32); + TC_DEST_UDP_OUT <= tc_udp((index + 1) * 16 - 1 downto index * 16); + TC_SRC_MAC_OUT <= tc_src_mac((index + 1) * 48 - 1 downto index * 48); + TC_SRC_IP_OUT <= tc_src_ip((index + 1) * 32 - 1 downto index * 32); + TC_SRC_UDP_OUT <= tc_src_udp((index + 1) * 16 - 1 downto index * 16); + TC_IP_PROTOCOL_OUT <= tc_ip_proto((index + 1) * 8 - 1 downto index * 8); + TC_IP_SIZE_OUT <= tc_ip_size((index + 1) * 16 - 1 downto index * 16); + TC_UDP_SIZE_OUT <= tc_udp_size((index + 1) * 16 - 1 downto index * 16); + TC_FLAGS_OFFSET_OUT <= tc_flags_size((index + 1) * 16 - 1 downto index * 16); + if (select_current_state = SELECT_ONE) then + PS_RESPONSE_READY_OUT <= '1'; else - TC_DATA_OUT <= (others => '0'); - TC_FRAME_SIZE_OUT <= (others => '0'); - TC_FRAME_TYPE_OUT <= (others => '0'); - TC_DEST_MAC_OUT <= (others => '0'); - TC_DEST_IP_OUT <= (others => '0'); - TC_DEST_UDP_OUT <= (others => '0'); - TC_SRC_MAC_OUT <= (others => '0'); - TC_SRC_IP_OUT <= (others => '0'); - TC_SRC_UDP_OUT <= (others => '0'); - TC_IP_PROTOCOL_OUT <= (others => '0'); - TC_IP_SIZE_OUT <= (others => '0'); - TC_UDP_SIZE_OUT <= (others => '0'); - TC_FLAGS_OFFSET_OUT <= (others => '0'); PS_RESPONSE_READY_OUT <= '0'; - found := false; end if; + selected(index) <= '1'; + else + TC_DATA_OUT <= (others => '0'); + TC_FRAME_SIZE_OUT <= (others => '0'); + TC_FRAME_TYPE_OUT <= (others => '0'); + TC_DEST_MAC_OUT <= (others => '0'); + TC_DEST_IP_OUT <= (others => '0'); + TC_DEST_UDP_OUT <= (others => '0'); + TC_SRC_MAC_OUT <= (others => '0'); + TC_SRC_IP_OUT <= (others => '0'); + TC_SRC_UDP_OUT <= (others => '0'); + TC_IP_PROTOCOL_OUT <= (others => '0'); + TC_IP_SIZE_OUT <= (others => '0'); + TC_UDP_SIZE_OUT <= (others => '0'); + TC_FLAGS_OFFSET_OUT <= (others => '0'); + PS_RESPONSE_READY_OUT <= '0'; + selected <= (others => '0'); end if; - end if; end process SELECTOR_PROC; + +--SELECTOR_PROC : process(CLK) +-- variable found : boolean := false; +-- variable index : integer range 0 to c_MAX_PROTOCOLS - 1 := 0; +--begin +-- if rising_edge(CLK) then +-- +-- selected <= (others => '0'); +-- +-- if (RESET = '1') then +-- TC_DATA_OUT <= (others => '0'); +-- TC_FRAME_SIZE_OUT <= (others => '0'); +-- TC_FRAME_TYPE_OUT <= (others => '0'); +-- TC_DEST_MAC_OUT <= (others => '0'); +-- TC_DEST_IP_OUT <= (others => '0'); +-- TC_DEST_UDP_OUT <= (others => '0'); +-- TC_SRC_MAC_OUT <= (others => '0'); +-- TC_SRC_IP_OUT <= (others => '0'); +-- TC_SRC_UDP_OUT <= (others => '0'); +-- TC_IP_PROTOCOL_OUT <= (others => '0'); +-- TC_IP_SIZE_OUT <= (others => '0'); +-- TC_UDP_SIZE_OUT <= (others => '0'); +-- TC_FLAGS_OFFSET_OUT <= (others => '0'); +-- PS_RESPONSE_READY_OUT <= '0'; +-- selected <= (others => '0'); +-- found := false; +-- index := 0; +-- else +-- if (or_all(resp_ready) = '1' and MC_BUSY_IN = '0') then +-- for i in 0 to c_MAX_PROTOCOLS - 1 loop +-- if (resp_ready(i) = '1' and found = false) then +-- TC_DATA_OUT <= tc_data((i + 1) * 9 - 1 downto i * 9); +-- TC_FRAME_SIZE_OUT <= tc_size((i + 1) * 16 - 1 downto i * 16); +-- TC_FRAME_TYPE_OUT <= tc_type((i + 1) * 16 - 1 downto i * 16); +-- TC_DEST_MAC_OUT <= tc_mac((i + 1) * 48 - 1 downto i * 48); +-- TC_DEST_IP_OUT <= tc_ip((i + 1) * 32 - 1 downto i * 32); +-- TC_DEST_UDP_OUT <= tc_udp((i + 1) * 16 - 1 downto i * 16); +-- TC_SRC_MAC_OUT <= tc_src_mac((i + 1) * 48 - 1 downto i * 48); +-- TC_SRC_IP_OUT <= tc_src_ip((i + 1) * 32 - 1 downto i * 32); +-- TC_SRC_UDP_OUT <= tc_src_udp((i + 1) * 16 - 1 downto i * 16); +-- TC_IP_PROTOCOL_OUT <= tc_ip_proto((i + 1) * 8 - 1 downto i * 8); +-- TC_IP_SIZE_OUT <= tc_ip_size((i + 1) * 16 - 1 downto i * 16); +-- TC_UDP_SIZE_OUT <= tc_udp_size((i + 1) * 16 - 1 downto i * 16); +-- TC_FLAGS_OFFSET_OUT <= tc_flags_size((i + 1) * 16 - 1 downto i * 16); +-- PS_RESPONSE_READY_OUT <= '1'; +-- selected(i) <= '1'; +-- index := i; +-- found := true; +---- elsif (i = c_MAX_PROTOCOLS - 1) and (resp_ready(i) = '0') and (found = false) then +---- found := false; +---- PS_RESPONSE_READY_OUT <= '0'; +-- end if; +-- end loop; +-- elsif (or_all(resp_ready) = '1' and MC_BUSY_IN = '1') then +-- TC_DATA_OUT <= tc_data((index + 1) * 9 - 1 downto index * 9); +-- TC_FRAME_SIZE_OUT <= tc_size((index + 1) * 16 - 1 downto index * 16); +-- TC_FRAME_TYPE_OUT <= tc_type((index + 1) * 16 - 1 downto index * 16); +-- TC_DEST_MAC_OUT <= tc_mac((index + 1) * 48 - 1 downto index * 48); +-- TC_DEST_IP_OUT <= tc_ip((index + 1) * 32 - 1 downto index * 32); +-- TC_DEST_UDP_OUT <= tc_udp((index + 1) * 16 - 1 downto index * 16); +-- TC_SRC_MAC_OUT <= tc_src_mac((index + 1) * 48 - 1 downto index * 48); +-- TC_SRC_IP_OUT <= tc_src_ip((index + 1) * 32 - 1 downto index * 32); +-- TC_SRC_UDP_OUT <= tc_src_udp((index + 1) * 16 - 1 downto index * 16); +-- TC_IP_PROTOCOL_OUT <= tc_ip_proto((index + 1) * 8 - 1 downto index * 8); +-- TC_IP_SIZE_OUT <= tc_ip_size((index + 1) * 16 - 1 downto index * 16); +-- TC_UDP_SIZE_OUT <= tc_udp_size((index + 1) * 16 - 1 downto index * 16); +-- TC_FLAGS_OFFSET_OUT <= tc_flags_size((index + 1) * 16 - 1 downto index * 16); +-- PS_RESPONSE_READY_OUT <= '1'; +-- selected(index) <= '1'; +-- index := index; +-- found := true; +-- elsif (MC_BUSY_IN = '0') then +-- TC_DATA_OUT <= (others => '0'); +-- TC_FRAME_SIZE_OUT <= (others => '0'); +-- TC_FRAME_TYPE_OUT <= (others => '0'); +-- TC_DEST_MAC_OUT <= (others => '0'); +-- TC_DEST_IP_OUT <= (others => '0'); +-- TC_DEST_UDP_OUT <= (others => '0'); +-- TC_SRC_MAC_OUT <= (others => '0'); +-- TC_SRC_IP_OUT <= (others => '0'); +-- TC_SRC_UDP_OUT <= (others => '0'); +-- TC_IP_PROTOCOL_OUT <= (others => '0'); +-- TC_IP_SIZE_OUT <= (others => '0'); +-- TC_UDP_SIZE_OUT <= (others => '0'); +-- TC_FLAGS_OFFSET_OUT <= (others => '0'); +-- PS_RESPONSE_READY_OUT <= '0'; +-- found := false; +-- index := 0; +-- else +-- TC_DATA_OUT <= (others => '0'); +-- TC_FRAME_SIZE_OUT <= (others => '0'); +-- TC_FRAME_TYPE_OUT <= (others => '0'); +-- TC_DEST_MAC_OUT <= (others => '0'); +-- TC_DEST_IP_OUT <= (others => '0'); +-- TC_DEST_UDP_OUT <= (others => '0'); +-- TC_SRC_MAC_OUT <= (others => '0'); +-- TC_SRC_IP_OUT <= (others => '0'); +-- TC_SRC_UDP_OUT <= (others => '0'); +-- TC_IP_PROTOCOL_OUT <= (others => '0'); +-- TC_IP_SIZE_OUT <= (others => '0'); +-- TC_UDP_SIZE_OUT <= (others => '0'); +-- TC_FLAGS_OFFSET_OUT <= (others => '0'); +-- PS_RESPONSE_READY_OUT <= '0'; +-- found := false; +-- index := 0; +-- end if; +-- end if; +-- +-- end if; +--end process SELECTOR_PROC; -- ************ end trb_net16_gbe_protocol_selector; diff --git a/gbe2_ecp3/trb_net16_gbe_response_constructor_ARP.vhd b/gbe2_ecp3/trb_net16_gbe_response_constructor_ARP.vhd index 7bc222d..5c29a45 100644 --- a/gbe2_ecp3/trb_net16_gbe_response_constructor_ARP.vhd +++ b/gbe2_ecp3/trb_net16_gbe_response_constructor_ARP.vhd @@ -92,6 +92,11 @@ signal rec_frames : std_logic_vector(15 downto 0); signal sent_frames : std_logic_vector(15 downto 0); signal stat_data_temp : std_logic_vector(31 downto 0); +attribute syn_preserve : boolean; +attribute syn_keep : boolean; +attribute syn_keep of state : signal is true; +attribute syn_preserve of state : signal is true; + begin values(15 downto 0) <= x"0100"; -- hardware type diff --git a/gbe2_ecp3/trb_net16_gbe_response_constructor_DHCP.vhd b/gbe2_ecp3/trb_net16_gbe_response_constructor_DHCP.vhd index 5690a36..34d7f18 100644 --- a/gbe2_ecp3/trb_net16_gbe_response_constructor_DHCP.vhd +++ b/gbe2_ecp3/trb_net16_gbe_response_constructor_DHCP.vhd @@ -123,6 +123,11 @@ signal discarded_ctr : std_logic_vector(15 downto 0); signal stat_data_temp : std_logic_vector(31 downto 0); +attribute syn_preserve : boolean; +attribute syn_keep : boolean; +attribute syn_keep of state : signal is true; +attribute syn_preserve of state : signal is true; + begin @@ -259,7 +264,7 @@ end process WAIT_CTR_PROC; DHCP_DONE_OUT <= '1' when main_current_state = ESTABLISHED else '0'; --- **** MESSAGES RECEIVEING PART +-- **** MESSAGES RECEIVING PART RECEIVE_MACHINE_PROC : process(CLK) begin @@ -448,7 +453,7 @@ begin end if; end process CONSTRUCT_MACHINE_PROC; -CONSTRUCT_MACHINE : process(construct_current_state, main_current_state, load_ctr) +CONSTRUCT_MACHINE : process(construct_current_state, main_current_state, load_ctr, TC_BUSY_IN, PS_SELECTED_IN) begin case construct_current_state is @@ -460,6 +465,15 @@ begin construct_next_state <= IDLE; end if; +-- when WAIT_FOR_LOAD => +-- state <= x"2"; +-- if (TC_BUSY_IN = '0' and PS_SELECTED_IN = '1') then +-- construct_next_state <= BOOTP_HEADERS; +-- else +-- construct_next_state <= WAIT_FOR_LOAD; +-- end if; + + when BOOTP_HEADERS => state <= x"3"; if (load_ctr = 11) then @@ -634,7 +648,7 @@ end process; PS_RESPONSE_SYNC : process(CLK) begin if rising_edge(CLK) then - if (construct_current_state = IDLE) then + if (construct_current_state = IDLE or construct_current_state = CLEANUP) then PS_RESPONSE_READY_OUT <= '0'; else PS_RESPONSE_READY_OUT <= '1'; diff --git a/gbe2_ecp3/trb_net16_gbe_response_constructor_Ping.vhd b/gbe2_ecp3/trb_net16_gbe_response_constructor_Ping.vhd index 6e1e527..5161932 100644 --- a/gbe2_ecp3/trb_net16_gbe_response_constructor_Ping.vhd +++ b/gbe2_ecp3/trb_net16_gbe_response_constructor_Ping.vhd @@ -106,6 +106,11 @@ signal fifo_q : std_logic_vector(7 downto 0); signal stat_data_temp : std_logic_vector(31 downto 0); +attribute syn_preserve : boolean; +attribute syn_keep : boolean; +attribute syn_keep of state : signal is true; +attribute syn_preserve of state : signal is true; + begin DISSECT_MACHINE_PROC : process(CLK) @@ -141,7 +146,7 @@ begin when WAIT_FOR_LOAD => state <= x"3"; - if (TC_BUSY_IN = '0') then + if (TC_BUSY_IN = '0' and PS_SELECTED_IN = '1') then dissect_next_state <= LOAD_FRAME; else dissect_next_state <= WAIT_FOR_LOAD; diff --git a/gbe2_ecp3/trb_net16_gbe_response_constructor_SCTRL.vhd b/gbe2_ecp3/trb_net16_gbe_response_constructor_SCTRL.vhd index f9e76cf..07ef1d1 100644 --- a/gbe2_ecp3/trb_net16_gbe_response_constructor_SCTRL.vhd +++ b/gbe2_ecp3/trb_net16_gbe_response_constructor_SCTRL.vhd @@ -564,8 +564,6 @@ begin make_reset <= '0'; elsif (dissect_current_state = CLEANUP and reset_detected = '1') then make_reset <= '1'; - else - make_reset <= '0'; end if; end if; end process MAKE_RESET_PROC; @@ -687,4 +685,13 @@ end process STAT_SYNC; -- end of statistics +-- **** debug +DEBUG_OUT(3 downto 0) <= state; +DEBUG_OUT(4) <= '0'; +DEBUG_OUT(7 downto 5) <= "000"; +DEBUG_OUT(8) <= '0'; +DEBUG_OUT(11 downto 9) <= "000"; +DEBUG_OUT(31 downto 12) <= (others => '0'); +-- **** + end architecture RTL; diff --git a/gbe2_ecp3/trb_net16_gbe_response_constructor_Stat.vhd b/gbe2_ecp3/trb_net16_gbe_response_constructor_Stat.vhd index 2ec472e..ebe1370 100644 --- a/gbe2_ecp3/trb_net16_gbe_response_constructor_Stat.vhd +++ b/gbe2_ecp3/trb_net16_gbe_response_constructor_Stat.vhd @@ -114,7 +114,7 @@ signal pause : integer range 0 to 28; signal stat_data_temp : std_logic_vector(31 downto 0); begin -pause <= 10 when g_SIMULATE = 1 else 28; +pause <= 10 when g_SIMULATE = 1 else 20; mem : statts_mem @@ -323,5 +323,14 @@ TC_IP_SIZE_OUT <= x"0100"; TC_UDP_SIZE_OUT <= x"0100"; TC_FLAGS_OFFSET_OUT <= (others => '0'); +-- **** debug +DEBUG_OUT(3 downto 0) <= state; +DEBUG_OUT(4) <= '0'; +DEBUG_OUT(7 downto 5) <= "000"; +DEBUG_OUT(8) <= '0'; +DEBUG_OUT(11 downto 9) <= "000"; +DEBUG_OUT(31 downto 12) <= (others => '0'); +-- **** + end Behavioral; diff --git a/gbe2_ecp3/trb_net_gbe_components.vhd b/gbe2_ecp3/trb_net_gbe_components.vhd index 5bbb2d9..94c3f33 100644 --- a/gbe2_ecp3/trb_net_gbe_components.vhd +++ b/gbe2_ecp3/trb_net_gbe_components.vhd @@ -183,6 +183,7 @@ port ( TC_FLAGS_OFFSET_OUT : out std_logic_vector(15 downto 0); TC_BUSY_IN : in std_logic; + MC_BUSY_IN : in std_logic; -- counters from response constructors RECEIVED_FRAMES_OUT : out std_logic_vector(c_MAX_PROTOCOLS * 16 - 1 downto 0); -- 2.43.0