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
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";
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);
--*************
-- 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";
--
--*************
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
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";
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(
(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,
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';
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;
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;
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
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";
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;
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";
when CLEANUP =>
state <= x"9";
dissect_next_state <= IDLE;
+
+ when others =>
+ state <= x"1";
+ dissect_next_state <= IDLE;
end case;
end process DISSECT_MACHINE;
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;
+
+
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;
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');
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
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;
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;