From f604ffd51853fcc669d85d55ec46d335c91bb8bb Mon Sep 17 00:00:00 2001 From: hadeshyp Date: Fri, 15 Jun 2012 07:40:46 +0000 Subject: [PATCH] *** empty log message *** --- gbe2_ecp3/tb_frame_receiver.vhd | 268 ++++++++++++------ gbe2_ecp3/trb_net16_gbe_main_control.vhd | 3 +- ...trb_net16_gbe_response_constructor_ARP.vhd | 2 +- ...b_net16_gbe_response_constructor_SCTRL.vhd | 154 +++++++--- ...rb_net16_gbe_response_constructor_Stat.vhd | 6 +- gbe2_ecp3/trb_net16_gbe_transmit_control.vhd | 23 +- gbe2_ecp3/trb_net_gbe_protocols.vhd | 2 +- 7 files changed, 321 insertions(+), 137 deletions(-) diff --git a/gbe2_ecp3/tb_frame_receiver.vhd b/gbe2_ecp3/tb_frame_receiver.vhd index 5e13920..d83b807 100644 --- a/gbe2_ecp3/tb_frame_receiver.vhd +++ b/gbe2_ecp3/tb_frame_receiver.vhd @@ -695,8 +695,7 @@ begin wait for 200 ns; - - -- FIRST FRAME UDP - SCTRL READ REQUEST + -- FIRST FRAME (ARP Request) wait until rising_edge(RX_MAC_CLK); MAC_RX_EN_IN <= '1'; -- dest mac @@ -725,114 +724,59 @@ begin wait until rising_edge(RX_MAC_CLK); MAC_RXD_IN <= x"ee"; wait until rising_edge(RX_MAC_CLK); --- frame type +-- arp 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"; + MAC_RXD_IN <= x"06"; wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"10"; +-- hardware type + 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"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"; +-- protocol 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); - 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"; +-- hardware size + MAC_RXD_IN <= x"06"; wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"a8"; +-- protocol size + MAC_RXD_IN <= x"04"; wait until rising_edge(RX_MAC_CLK); +-- opcode (request) 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); +-- sender mac 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"61"; - wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"a8"; - 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"; --- sctrl data - wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"00"; - wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"31"; - wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"ff"; - wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"ff"; - wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"ff"; - wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"ff"; wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"ff"; - wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"ff"; + MAC_RXD_IN <= x"cc"; wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"00"; + MAC_RXD_IN <= x"dd"; wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"08"; + MAC_RXD_IN <= x"ee"; wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"00"; +-- sender ip + MAC_RXD_IN <= x"c0"; wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"30"; + MAC_RXD_IN <= x"a9"; wait until rising_edge(RX_MAC_CLK); MAC_RXD_IN <= x"00"; wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"00"; + MAC_RXD_IN <= x"01"; wait until rising_edge(RX_MAC_CLK); +-- target mac MAC_RXD_IN <= x"00"; wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"50"; - wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"af"; - wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"fe"; - 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"00"; wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"33"; - wait until rising_edge(RX_MAC_CLK); MAC_RXD_IN <= x"00"; wait until rising_edge(RX_MAC_CLK); MAC_RXD_IN <= x"00"; @@ -841,18 +785,178 @@ begin wait until rising_edge(RX_MAC_CLK); MAC_RXD_IN <= x"00"; wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"00"; +-- target ip + MAC_RXD_IN <= x"c0"; wait until rising_edge(RX_MAC_CLK); - MAC_RXD_IN <= x"00"; + 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"08"; - MAC_RX_EOF_IN <= '1'; - wait until rising_edge(RX_MAC_CLK); + MAC_RXD_IN <= x"65"; + MAC_RX_EOF_IN <= '1'; + wait until rising_edge(RX_MAC_CLK); MAC_RX_EN_IN <='0'; MAC_RX_EOF_IN <= '0'; + + + -- FIRST FRAME UDP - SCTRL READ REQUEST +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RX_EN_IN <= '1'; +---- dest mac +-- MAC_RXD_IN <= x"ff"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"ff"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"ff"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"ff"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"ff"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"ff"; +-- 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"61"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"a8"; +-- 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"; +---- sctrl data +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"00"; --MAC_RXD_IN <= x"00"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"31"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"ff"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"ff"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"ff"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"ff"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"ff"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"ff"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"00"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"08"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"00"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"30"; +-- 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"50"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"af"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"fe"; +-- 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"00"; +-- wait until rising_edge(RX_MAC_CLK); +-- MAC_RXD_IN <= x"33"; +-- 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"08"; +-- MAC_RX_EOF_IN <= '1'; +-- wait until rising_edge(RX_MAC_CLK); +-- +-- MAC_RX_EN_IN <='0'; +-- MAC_RX_EOF_IN <= '0'; -- wait until rising_edge(gsc_init_dataready); diff --git a/gbe2_ecp3/trb_net16_gbe_main_control.vhd b/gbe2_ecp3/trb_net16_gbe_main_control.vhd index 8f248e5..6ee2915 100644 --- a/gbe2_ecp3/trb_net16_gbe_main_control.vhd +++ b/gbe2_ecp3/trb_net16_gbe_main_control.vhd @@ -621,8 +621,9 @@ MC_LINK_OK_OUT <= link_ok; --************* -- GENERATE MAC_ADDRESS ---TODO: take the unique id from regio and generate a mac address g_MY_MAC <= unique_id(15 downto 0) & x"efbe0000"; + +g_MAX_FRAME_SIZE <= x"0040"; -- --************* diff --git a/gbe2_ecp3/trb_net16_gbe_response_constructor_ARP.vhd b/gbe2_ecp3/trb_net16_gbe_response_constructor_ARP.vhd index c818698..f1add73 100644 --- a/gbe2_ecp3/trb_net16_gbe_response_constructor_ARP.vhd +++ b/gbe2_ecp3/trb_net16_gbe_response_constructor_ARP.vhd @@ -137,7 +137,7 @@ begin when DECIDE => state <= x"3"; - if (saved_target_ip = g_MY_IP) then + if (saved_target_ip = g_MY_IP or g_SIMULATE = 1) then dissect_next_state <= WAIT_FOR_LOAD; -- in case the request is not for me, drop it else diff --git a/gbe2_ecp3/trb_net16_gbe_response_constructor_SCTRL.vhd b/gbe2_ecp3/trb_net16_gbe_response_constructor_SCTRL.vhd index 021a34b..880b060 100644 --- a/gbe2_ecp3/trb_net16_gbe_response_constructor_SCTRL.vhd +++ b/gbe2_ecp3/trb_net16_gbe_response_constructor_SCTRL.vhd @@ -82,7 +82,7 @@ architecture RTL of trb_net16_gbe_response_constructor_SCTRL is attribute syn_encoding : string; -type dissect_states is (IDLE, READ_FRAME, WAIT_FOR_HUB, LOAD_TO_HUB, WAIT_FOR_RESPONSE, SAVE_RESPONSE, LOAD_FRAME, DIVIDE, WAIT_FOR_LOAD, CLEANUP, WAIT_FOR_LOAD_ACK, LOAD_ACK); +type dissect_states is (IDLE, READ_FRAME, WAIT_FOR_HUB, LOAD_TO_HUB, WAIT_FOR_RESPONSE, SAVE_RESPONSE, LOAD_FRAME, WAIT_FOR_TC, DIVIDE, WAIT_FOR_LOAD, CLEANUP, WAIT_FOR_LOAD_ACK, LOAD_ACK); signal dissect_current_state, dissect_next_state : dissect_states; attribute syn_encoding of dissect_current_state: signal is "safe,gray"; @@ -120,12 +120,20 @@ signal rx_full, tx_full : std_logic; signal size_left : std_logic_vector(15 downto 0); -signal make_reset : std_logic; +signal reset_detected : std_logic := '0'; +signal make_reset : std_logic := '0'; + + +attribute syn_preserve : boolean; +attribute syn_keep : boolean; +attribute syn_keep of tx_data_ctr, tx_loaded_ctr : signal is true; +attribute syn_preserve of tx_data_ctr, tx_loaded_ctr : signal is true; + begin -make_reset <= '0'; +MAKE_RESET_OUT <= make_reset; receive_fifo : fifo_2048x8x16 PORT map( @@ -154,7 +162,7 @@ gsc_init_dataready <= '1' when (GSC_INIT_READ_IN = '1' and dissect_current_state (dissect_current_state = WAIT_FOR_HUB) else '0'; GSC_INIT_DATAREADY_OUT <= gsc_init_dataready; -transmit_fifo : fifo_65536x18x9 --fifo_1024x16x8 +transmit_fifo : fifo_65536x18x9 PORT map( Reset => RESET, RPReset => RESET, @@ -174,18 +182,24 @@ transmit_fifo : fifo_65536x18x9 --fifo_1024x16x8 tx_fifo_wr <= '1' when GSC_REPLY_DATAREADY_IN = '1' and gsc_reply_read = '1' else '0'; tx_fifo_rd <= '1' when TC_RD_EN_IN = '1' and dissect_current_state = LOAD_FRAME else '0'; -TC_DATA_PROC : process(dissect_current_state, tx_loaded_ctr, tx_data_ctr) +TC_DATA_PROC : process(dissect_current_state, tx_loaded_ctr, tx_data_ctr, tx_frame_loaded, g_MAX_FRAME_SIZE) begin if (dissect_current_state = LOAD_FRAME) then + TC_DATA_OUT(7 downto 0) <= tx_fifo_q(7 downto 0); + + --if (tx_loaded_ctr = tx_data_ctr + x"1" or tx_frame_loaded = g_MAX_FRAME_SIZE + x"1") then if (tx_loaded_ctr = tx_data_ctr or tx_frame_loaded = g_MAX_FRAME_SIZE - x"1") then TC_DATA_OUT(8) <= '1'; else TC_DATA_OUT(8) <= '0'; end if; + elsif (dissect_current_state = LOAD_ACK) then + TC_DATA_OUT(7 downto 0) <= tx_loaded_ctr(7 downto 0); - if (tx_loaded_ctr = x"0010" - x"1") then + + if (tx_loaded_ctr = x"0010" + x"1") then TC_DATA_OUT(8) <= '1'; else TC_DATA_OUT(8) <= '0'; @@ -249,34 +263,40 @@ TC_IP_PROTOCOL_OUT <= x"11"; FRAME_SIZE_PROC : process(CLK) begin if rising_edge(CLK) then - if (RESET = '1') then + if (RESET = '1' or dissect_current_state = IDLE) then TC_FRAME_SIZE_OUT <= (others => '0'); + TC_IP_SIZE_OUT <= (others => '0'); elsif (dissect_current_state = WAIT_FOR_LOAD or dissect_current_state = DIVIDE) then if (size_left >= g_MAX_FRAME_SIZE) then TC_FRAME_SIZE_OUT <= g_MAX_FRAME_SIZE; + TC_IP_SIZE_OUT <= g_MAX_FRAME_SIZE; else - TC_FRAME_SIZE_OUT <= size_left; + TC_FRAME_SIZE_OUT <= size_left(15 downto 0); + TC_IP_SIZE_OUT <= size_left(15 downto 0); end if; elsif (dissect_current_state = WAIT_FOR_LOAD_ACK) then TC_FRAME_SIZE_OUT <= x"0010"; + TC_IP_SIZE_OUT <= x"0010"; end if; end if; end process FRAME_SIZE_PROC; +--TC_FRAME_SIZE_OUT <= tx_data_ctr when (dissect_current_state = WAIT_FOR_LOAD or dissect_current_state = LOAD_FRAME) else x"0010"; + +--IP_SIZE_PROC : process(CLK) +--begin +-- if rising_edge(CLK) then +-- if (RESET= '1' or dissect_current_state = IDLE) then +-- TC_IP_SIZE_OUT <= (others => '0'); +-- elsif ((dissect_current_state = DIVIDE and TC_RD_EN_IN = '1' and PS_SELECTED_IN = '1') or (dissect_current_state = WAIT_FOR_LOAD or dissect_current_state = WAIT_FOR_TC)) then +-- if (size_left >= g_MAX_FRAME_SIZE) then +-- TC_IP_SIZE_OUT <= g_MAX_FRAME_SIZE; +-- else +-- TC_IP_SIZE_OUT <= size_left(15 downto 0); +-- end if; +-- end if; +-- end if; +--end process IP_SIZE_PROC; -IP_SIZE_PROC : process(CLK) -begin - if rising_edge(CLK) then - if (RESET= '1') then - TC_IP_SIZE_OUT <= (others => '0'); - elsif ((dissect_current_state = DIVIDE and TC_RD_EN_IN = '1' and PS_SELECTED_IN = '1') or (dissect_current_state = WAIT_FOR_LOAD)) then - if (size_left >= g_MAX_FRAME_SIZE) then - TC_IP_SIZE_OUT <= g_MAX_FRAME_SIZE; - else - TC_IP_SIZE_OUT <= size_left(15 downto 0); - end if; - end if; - end if; -end process IP_SIZE_PROC; TC_UDP_SIZE_OUT <= tx_data_ctr; @@ -302,7 +322,7 @@ begin if (RESET = '1') or (dissect_current_state = IDLE) or (dissect_current_state = CLEANUP) then TC_FLAGS_OFFSET_OUT(12 downto 0) <= (others => '0'); elsif (dissect_current_state = DIVIDE and TC_BUSY_IN = '0' and PS_SELECTED_IN = '1') then - TC_FLAGS_OFFSET_OUT(12 downto 0) <= tx_loaded_ctr(15 downto 3); + TC_FLAGS_OFFSET_OUT(12 downto 0) <= tx_loaded_ctr(15 downto 3) + x"1"; end if; end if; end process OFFSET_PROC; @@ -337,7 +357,7 @@ begin end if; end process DISSECT_MACHINE_PROC; -DISSECT_MACHINE : process(dissect_current_state, make_reset, PS_WR_EN_IN, PS_ACTIVATE_IN, PS_DATA_IN, TC_BUSY_IN, data_ctr, PS_SELECTED_IN, GSC_INIT_READ_IN, GSC_REPLY_DATAREADY_IN, tx_loaded_ctr, tx_data_ctr, rx_fifo_q, GSC_BUSY_IN, tx_frame_loaded, g_MAX_FRAME_SIZE) +DISSECT_MACHINE : process(dissect_current_state, reset_detected, PS_WR_EN_IN, PS_ACTIVATE_IN, PS_DATA_IN, TC_BUSY_IN, data_ctr, PS_SELECTED_IN, GSC_INIT_READ_IN, GSC_REPLY_DATAREADY_IN, tx_loaded_ctr, tx_data_ctr, rx_fifo_q, GSC_BUSY_IN, tx_frame_loaded, g_MAX_FRAME_SIZE) begin case dissect_current_state is @@ -352,30 +372,30 @@ begin when READ_FRAME => state <= x"2"; if (PS_DATA_IN(8) = '1') then - if (make_reset = '1') then -- send ack only if reset command came - dissect_next_state <= WAIT_FOR_LOAD_ACK; - else + --if (reset_detected = '1') then -- send ack only if reset command came + -- dissect_next_state <= WAIT_FOR_LOAD_ACK; + --else dissect_next_state <= WAIT_FOR_HUB; - end if; + --end if; else dissect_next_state <= READ_FRAME; end if; - when WAIT_FOR_LOAD_ACK => - state <= x"a"; - if (TC_BUSY_IN = '0' and PS_SELECTED_IN = '1') then - dissect_next_state <= LOAD_ACK; - else - dissect_next_state <= WAIT_FOR_LOAD_ACK; - end if; - - when LOAD_ACK => - state <= x"b"; - if (tx_loaded_ctr = x"0010") then - dissect_next_state <= WAIT_FOR_HUB; - else - dissect_next_state <= LOAD_ACK; - end if; +-- when WAIT_FOR_LOAD_ACK => +-- state <= x"a"; +-- if (TC_BUSY_IN = '0' and PS_SELECTED_IN = '1') then +-- dissect_next_state <= LOAD_ACK; +-- else +-- dissect_next_state <= WAIT_FOR_LOAD_ACK; +-- end if; +-- +-- when LOAD_ACK => +-- state <= x"b"; +-- if (tx_loaded_ctr = x"0010") then +-- dissect_next_state <= WAIT_FOR_HUB; --CLEANUP; +-- else +-- dissect_next_state <= LOAD_ACK; +-- end if; when WAIT_FOR_HUB => state <= x"3"; @@ -388,7 +408,11 @@ begin when LOAD_TO_HUB => state <= x"4"; if (rx_fifo_q(17) = '1') then - dissect_next_state <= WAIT_FOR_RESPONSE; + if (reset_detected = '1') then + dissect_next_state <= CLEANUP; + else + dissect_next_state <= WAIT_FOR_RESPONSE; + end if; else dissect_next_state <= LOAD_TO_HUB; end if; @@ -421,11 +445,19 @@ begin state <= x"8"; if (tx_loaded_ctr = tx_data_ctr) then dissect_next_state <= CLEANUP; - elsif (tx_frame_loaded = g_MAX_FRAME_SIZE - x"1") then - dissect_next_state <= DIVIDE; + elsif (tx_frame_loaded = g_MAX_FRAME_SIZE) then + dissect_next_state <= DIVIDE; --WAIT_FOR_TC; --DIVIDE; else dissect_next_state <= LOAD_FRAME; end if; + +-- when WAIT_FOR_TC => +-- state <= x"d"; +-- if (TC_BUSY_IN = '0') then +-- dissect_next_state <= DIVIDE; +-- else +-- dissect_next_state <= WAIT_FOR_TC; +-- end if; when DIVIDE => state <= x"c"; @@ -438,6 +470,10 @@ begin when CLEANUP => state <= x"9"; dissect_next_state <= IDLE; + + when others => + state <= x"1"; + dissect_next_state <= IDLE; end case; end process DISSECT_MACHINE; @@ -469,6 +505,32 @@ begin end process SIZE_LEFT_PROC; +-- reset request packet detection +RESET_DETECTED_PROC : process(CLK) +begin + if rising_edge(CLK) then + if (RESET = '1' or dissect_current_state = CLEANUP) then + reset_detected <= '0'; + elsif (PS_DATA_IN(7 downto 0) = x"80" and dissect_current_state = IDLE and PS_WR_EN_IN = '1' and PS_ACTIVATE_IN = '1') then -- first byte as 0x80 + reset_detected <= '1'; + end if; + end if; +end process RESET_DETECTED_PROC; + +MAKE_RESET_PROC : process(CLK) +begin + if rising_edge(CLK) then + if (RESET = '1') then + 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; + + diff --git a/gbe2_ecp3/trb_net16_gbe_response_constructor_Stat.vhd b/gbe2_ecp3/trb_net16_gbe_response_constructor_Stat.vhd index 476b879..c175c06 100644 --- a/gbe2_ecp3/trb_net16_gbe_response_constructor_Stat.vhd +++ b/gbe2_ecp3/trb_net16_gbe_response_constructor_Stat.vhd @@ -197,7 +197,11 @@ begin if (RESET = '1') then construct_current_state <= IDLE; else - construct_current_state <= construct_next_state; + if (g_SIMULATE = 1) then + construct_current_state <= IDLE; + else + construct_current_state <= construct_next_state; + end if; end if; end if; end process CONSTRUCT_MACHINE_PROC; diff --git a/gbe2_ecp3/trb_net16_gbe_transmit_control.vhd b/gbe2_ecp3/trb_net16_gbe_transmit_control.vhd index f14ba49..ba837ca 100644 --- a/gbe2_ecp3/trb_net16_gbe_transmit_control.vhd +++ b/gbe2_ecp3/trb_net16_gbe_transmit_control.vhd @@ -113,9 +113,20 @@ signal sent_packets_ctr : std_logic_vector(15 downto 0); signal state : std_logic_vector(3 downto 0); signal state2 : std_logic_vector(3 downto 0); +signal temp_frame_size : std_logic_vector(15 downto 0); +signal temp_ip_size : std_logic_vector(15 downto 0); + +attribute syn_preserve : boolean; +attribute syn_keep : boolean; +attribute syn_keep of temp_frame_size, temp_ip_size : signal is true; +attribute syn_preserve of temp_frame_size, temp_ip_size : signal is true; + begin +temp_frame_size <= MC_FRAME_SIZE_IN; +temp_ip_size <= MC_IP_SIZE_IN; + DEBUG_OUT(3 downto 0) <= state; DEBUG_OUT(7 downto 4) <= state2; DEBUG_OUT(31 downto 8) <= (others => '0'); @@ -228,13 +239,15 @@ begin end if; if (MC_FRAME_TYPE_IN = x"0008") then -- in case of ip - FC_IP_SIZE_OUT <= MC_IP_SIZE_IN; - FC_UDP_SIZE_OUT <= MC_UDP_SIZE_IN; + FC_IP_SIZE_OUT <= MC_IP_SIZE_IN; + FC_UDP_SIZE_OUT <= MC_UDP_SIZE_IN; else - FC_IP_SIZE_OUT <= MC_FRAME_SIZE_IN; - FC_UDP_SIZE_OUT <= MC_FRAME_SIZE_IN; + FC_IP_SIZE_OUT <= temp_frame_size; --MC_FRAME_SIZE_IN; + FC_UDP_SIZE_OUT <= temp_frame_size; --MC_FRAME_SIZE_IN; end if; +-- FC_IP_SIZE_OUT <= temp_frame_size; --MC_FRAME_SIZE_IN; +-- FC_UDP_SIZE_OUT <= temp_frame_size; --MC_FRAME_SIZE_IN; FC_FLAGS_OFFSET_OUT <= MC_FLAGS_OFFSET_IN; --(others => '0'); -- fixed to one-frame packets if (ctrl_construct_current_state = WAIT_FOR_FC) and (FC_H_READY_IN = '1') then @@ -360,7 +373,7 @@ begin if rising_edge(CLK) then if (RESET = '1') then sent_packets_ctr <= (others => '0'); - elsif (tx_current_state = CLEANUP) then + elsif (tx_current_state = CLEANUP and MC_FLAGS_OFFSET_IN(13) = '0') then sent_packets_ctr <= sent_packets_ctr + x"1"; end if; end if; diff --git a/gbe2_ecp3/trb_net_gbe_protocols.vhd b/gbe2_ecp3/trb_net_gbe_protocols.vhd index eb840ca..1895b86 100644 --- a/gbe2_ecp3/trb_net_gbe_protocols.vhd +++ b/gbe2_ecp3/trb_net_gbe_protocols.vhd @@ -15,7 +15,7 @@ signal g_MY_IP : std_logic_vector(31 downto 0); signal g_MY_MAC : std_logic_vector(47 downto 0); -- size of ethernet frame use for fragmentation of outgoing packets -signal g_MAX_FRAME_SIZE : std_logic_vector(15 downto 0) := x"0578"; +signal g_MAX_FRAME_SIZE : std_logic_vector(15 downto 0) := x"0578"; -- truly set up in main controller constant c_MAX_FRAME_TYPES : integer range 1 to 16 := 2; constant c_MAX_PROTOCOLS : integer range 1 to 16 := 5; -- 2.43.0