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(
--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)
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
);
-
RECEIVE_CONTROLLER : trb_net16_gbe_receive_control
port map(
CLK => CLK,
);
dbg_q(15 downto 9) <= (others => '0');
-
FRAME_TRANSMITTER: trb_net16_gbe_frame_trans
port map(
CLK => CLK,
--DEBUG_OUT(31 downto 0) => open,
--DEBUG_OUT(63 downto 32) => open
);
-
FRAME_RECEIVER : trb_net16_gbe_frame_receiver
port map(
--***************
-- 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;
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;
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;
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
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,
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";
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
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;
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);
-- ****
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);
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
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');
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;
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
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
DHCP_DONE_OUT <= '1' when main_current_state = ESTABLISHED else '0';
--- **** MESSAGES RECEIVEING PART
+-- **** MESSAGES RECEIVING PART
RECEIVE_MACHINE_PROC : process(CLK)
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
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
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';
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)
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;
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;
-- 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;
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
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;
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);