--------------------------------------------------------------------------------------------
- TIMEOUT_CTR_PROC : process(serdes_clk_125)
+ TIMEOUT_CTR_PROC : process(CLK)
begin
- if rising_edge(serdes_clk_125) then
- if (RESEt = '1' or mac_tx_done = '1') then
+ if rising_edge(CLK) then
+ if (RESET = '1' or mac_tx_done = '1') then
timeout_ctr <= (others => '0');
else
timeout_ctr <= timeout_ctr + x"1";
end if;
end process TIMEOUT_CTR_PROC;
- TIMEOUT_NOTICED_PROC : process(serdes_clk_125)
+ TIMEOUT_NOTICED_PROC : process(CLK)
begin
- if rising_edge(serdes_clk_125) then
+ if rising_edge(CLK) then
if (RESET = '1') then
timeout_noticed <= '0';
- elsif (timeout_ctr(29) = '1') then
+ elsif (timeout_ctr(30) = '1') then
timeout_noticed <= '1';
end if;
end if;
signal parsed_frames_ctr : std_logic_vector(15 downto 0);
signal ok_frames_ctr : std_logic_vector(15 downto 0);
+signal rx_data : std_logic_vector(8 downto 0);
+
begin
DEBUG_OUT(0) <= rec_fifo_empty;
port map(
Data(7 downto 0) => MAC_RXD_IN,
Data(8) => MAC_RX_EOF_IN,
+-- Data => rx_data,
WrClock => RX_MAC_CLK,
RdClock => CLK,
WrEn => fifo_wr_en,
((filter_current_state = REMOVE_VTYPE and remove_ctr = x"f") or
(filter_current_state = DECIDE and frame_type_valid = '1')))
else '0';
+
+--RX_FIFO_SYNC : process(RX_MAC_CLK)
+--begin
+-- if rising_edge(RX_MAC_CLK) then
+--
+-- rx_data(8) <= MAC_RX_EOF_IN;
+-- rx_data(7 downto 0) <= MAC_RXD_IN;
+--
+-- if (MAC_RX_EN_IN = '1') then
+-- if (filter_current_state = SAVE_FRAME) then
+-- fifo_wr_en <= '1';
+-- elsif (filter_current_state = REMOVE_VTYPE and remove_ctr = x"f") then
+-- fifo_wr_en <= '1';
+-- elsif (filter_current_state = DECIDE and frame_type_valid = '1') then
+-- fifo_wr_en <= '1';
+-- else
+-- fifo_wr_en <= '0';
+-- end if;
+-- else
+-- fifo_wr_en <= '0';
+-- end if;
+--
+-- end if;
+--end process RX_FIFO_SYNC;
MAC_RX_FIFO_FULL_OUT <= rec_fifo_full;
end if;
end process TC_DATA_SYNC;
-PS_BUSY_OUT <= '0' when (dissect_current_state = IDLE) else '1';
+--PS_BUSY_OUT <= '0' when (dissect_current_state = IDLE) else '1';
+--PS_RESPONSE_READY_OUT <= '1' when (dissect_current_state = WAIT_FOR_LOAD or dissect_current_state = LOAD_FRAME or dissect_current_state = CLEANUP) else '0';
+
+PS_RESPONSE_SYNC : process(CLK)
+begin
+ if rising_edge(CLK) then
+ if (dissect_current_state = WAIT_FOR_LOAD or dissect_current_state = LOAD_FRAME or dissect_current_state = CLEANUP) then
+ PS_RESPONSE_READY_OUT <= '1';
+ else
+ PS_RESPONSE_READY_OUT <= '0';
+ end if;
+
+ if (dissect_current_state = IDLE) then
+ PS_BUSY_OUT <= '0';
+ else
+ PS_BUSY_OUT <= '1';
+ end if;
+ end if;
+end process PS_RESPONSE_SYNC;
+
-PS_RESPONSE_READY_OUT <= '1' when (dissect_current_state = WAIT_FOR_LOAD or dissect_current_state = LOAD_FRAME or dissect_current_state = CLEANUP) else '0';
TC_FRAME_SIZE_OUT <= x"001c"; -- fixed frame size
end process STATS_MACHINE;
-SELECTOR : process(stats_current_state)
+SELECTOR : process(CLK)
begin
-
- case(stats_current_state) is
-
- when LOAD_SENT =>
- stat_data_temp <= x"0601" & sent_frames;
- STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE, 8));
+ if rising_edge(CLK) then
+ case(stats_current_state) is
- when LOAD_RECEIVED =>
- stat_data_temp <= x"0602" & rec_frames;
- STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE + 1, 8));
+ when LOAD_SENT =>
+ stat_data_temp <= x"0601" & sent_frames;
+ STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE, 8));
+
+ when LOAD_RECEIVED =>
+ stat_data_temp <= x"0602" & rec_frames;
+ STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE + 1, 8));
+
+ when others =>
+ stat_data_temp <= (others => '0');
+ STAT_ADDR_OUT <= (others => '0');
- when others =>
- stat_data_temp <= (others => '0');
- STAT_ADDR_OUT <= (others => '0');
-
- end case;
-
+ end case;
+ end if;
end process SELECTOR;
STAT_DATA_OUT(7 downto 0) <= stat_data_temp(31 downto 24);
STAT_DATA_OUT(23 downto 16) <= stat_data_temp(15 downto 8);
STAT_DATA_OUT(31 downto 24) <= stat_data_temp(7 downto 0);
-STAT_DATA_RDY_OUT <= '1' when stats_current_state /= IDLE and stats_current_state /= CLEANUP else '0';
+STAT_SYNC : process(CLK)
+begin
+ if rising_edge(CLK) then
+ if (stats_current_state /= IDLE and stats_current_state /= CLEANUP) then
+ STAT_DATA_RDY_OUT <= '1';
+ else
+ STAT_DATA_RDY_OUT <= '0';
+ end if;
+ end if;
+end process STAT_SYNC;
+--STAT_DATA_RDY_OUT <= '1' when stats_current_state /= IDLE and stats_current_state /= CLEANUP else '0';
-- **** debug
DEBUG_OUT(3 downto 0) <= state;
--end process TC_DATA_SYNC;
-PS_BUSY_OUT <= '0' when (construct_current_state = IDLE) else '1';
+--PS_BUSY_OUT <= '0' when (construct_current_state = IDLE) else '1';
+--PS_RESPONSE_READY_OUT <= '0' when (construct_current_state = IDLE) else '1';
-PS_RESPONSE_READY_OUT <= '0' when (construct_current_state = IDLE) else '1';
+PS_RESPONSE_SYNC : process(CLK)
+begin
+ if rising_edge(CLK) then
+ if (construct_current_state = IDLE) then
+ PS_RESPONSE_READY_OUT <= '0';
+ else
+ PS_RESPONSE_READY_OUT <= '1';
+ end if;
+
+ if (construct_current_state = IDLE) then
+ PS_BUSY_OUT <= '0';
+ else
+ PS_BUSY_OUT <= '1';
+ end if;
+ end if;
+end process PS_RESPONSE_SYNC;
-- fixed sizes for discover and request messages
TC_FRAME_SIZE_OUT <= x"0103" when (main_current_state = SENDING_DISCOVER) else x"0109";
end process STATS_MACHINE;
-SELECTOR : process(stats_current_state)
+SELECTOR : process(CLK)
begin
-
- case(stats_current_state) is
-
- when LOAD_SENT =>
- stat_data_temp <= x"0101" & sent_frames;
- STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE, 8));
-
- when LOAD_RECEIVED =>
- stat_data_temp <= x"0102" & rec_frames;
- STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE + 1, 8));
+ if rising_edge(CLK) then
+ case(stats_current_state) is
- when LOAD_DISCARDED =>
- stat_data_temp <= x"0103" & discarded_ctr;
- STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE + 2, 8));
+ when LOAD_SENT =>
+ stat_data_temp <= x"0101" & sent_frames;
+ STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE, 8));
+
+ when LOAD_RECEIVED =>
+ stat_data_temp <= x"0102" & rec_frames;
+ STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE + 1, 8));
+
+ when LOAD_DISCARDED =>
+ stat_data_temp <= x"0103" & discarded_ctr;
+ STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE + 2, 8));
+
+ when others =>
+ stat_data_temp <= (others => '0');
+ STAT_ADDR_OUT <= (others => '0');
- when others =>
- stat_data_temp <= (others => '0');
- STAT_ADDR_OUT <= (others => '0');
-
- end case;
+ end case;
+ end if;
end process SELECTOR;
STAT_DATA_OUT(23 downto 16) <= stat_data_temp(15 downto 8);
STAT_DATA_OUT(31 downto 24) <= stat_data_temp(7 downto 0);
-STAT_DATA_RDY_OUT <= '1' when stats_current_state /= IDLE and stats_current_state /= CLEANUP else '0';
+STAT_SYNC : process(CLK)
+begin
+ if rising_edge(CLK) then
+ if (stats_current_state /= IDLE and stats_current_state /= CLEANUP) then
+ STAT_DATA_RDY_OUT <= '1';
+ else
+ STAT_DATA_RDY_OUT <= '0';
+ end if;
+ end if;
+end process STAT_SYNC;
+--STAT_DATA_RDY_OUT <= '1' when stats_current_state /= IDLE and stats_current_state /= CLEANUP else '0';
-- ****
end process TC_DATA_SYNC;
-PS_BUSY_OUT <= '0' when (dissect_current_state = IDLE) else '1';
+--PS_BUSY_OUT <= '0' when (dissect_current_state = IDLE) else '1';
+--PS_RESPONSE_READY_OUT <= '1' when (dissect_current_state = WAIT_FOR_LOAD or dissect_current_state = LOAD_FRAME or dissect_current_state = CLEANUP) else '0';
-PS_RESPONSE_READY_OUT <= '1' when (dissect_current_state = WAIT_FOR_LOAD or dissect_current_state = LOAD_FRAME or dissect_current_state = CLEANUP) else '0';
+PS_RESPONSE_SYNC : process(CLK)
+begin
+ if rising_edge(CLK) then
+ if (dissect_current_state = WAIT_FOR_LOAD or dissect_current_state = LOAD_FRAME or dissect_current_state = CLEANUP) then
+ PS_RESPONSE_READY_OUT <= '1';
+ else
+ PS_RESPONSE_READY_OUT <= '0';
+ end if;
+
+ if (dissect_current_state = IDLE) then
+ PS_BUSY_OUT <= '0';
+ else
+ PS_BUSY_OUT <= '1';
+ end if;
+ end if;
+end process PS_RESPONSE_SYNC;
TC_FRAME_SIZE_OUT <= std_logic_vector(to_unsigned(data_length, 16));
TC_IP_SIZE_OUT <= std_logic_vector(to_unsigned(data_length, 16));
end process STATS_MACHINE;
-SELECTOR : process(stats_current_state)
+SELECTOR : process(CLK)
begin
-
- case(stats_current_state) is
-
- when LOAD_SENT =>
- stat_data_temp <= x"0401" & sent_frames;
- STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE, 8));
+ if rising_edge(CLK) then
+ case(stats_current_state) is
- when LOAD_RECEIVED =>
- stat_data_temp <= x"0402" & rec_frames;
- STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE + 1, 8));
+ when LOAD_SENT =>
+ stat_data_temp <= x"0401" & sent_frames;
+ STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE, 8));
+
+ when LOAD_RECEIVED =>
+ stat_data_temp <= x"0402" & rec_frames;
+ STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE + 1, 8));
+
+ when others =>
+ stat_data_temp <= (others => '0');
+ STAT_ADDR_OUT <= (others => '0');
- when others =>
- stat_data_temp <= (others => '0');
- STAT_ADDR_OUT <= (others => '0');
-
- end case;
-
+ end case;
+ end if;
end process SELECTOR;
STAT_DATA_OUT(7 downto 0) <= stat_data_temp(31 downto 24);
STAT_DATA_OUT(23 downto 16) <= stat_data_temp(15 downto 8);
STAT_DATA_OUT(31 downto 24) <= stat_data_temp(7 downto 0);
-STAT_DATA_RDY_OUT <= '1' when stats_current_state /= IDLE and stats_current_state /= CLEANUP else '0';
+STAT_SYNC : process(CLK)
+begin
+ if rising_edge(CLK) then
+ if (stats_current_state /= IDLE and stats_current_state /= CLEANUP) then
+ STAT_DATA_RDY_OUT <= '1';
+ else
+ STAT_DATA_RDY_OUT <= '0';
+ end if;
+ end if;
+end process STAT_SYNC;
+--STAT_DATA_RDY_OUT <= '1' when stats_current_state /= IDLE and stats_current_state /= CLEANUP else '0';
-- **** debug
DEBUG_OUT(3 downto 0) <= state;
signal too_much_data : std_logic;
+signal rx_fifo_data : std_logic_vector(8 downto 0);
+
begin
RPReset => RESET,
WrClock => CLK,
RdClock => CLK,
- Data => PS_DATA_IN,
+ Data => rx_fifo_data, --PS_DATA_IN,
WrEn => rx_fifo_wr,
RdEn => rx_fifo_rd,
Q => rx_fifo_q,
Empty => rx_empty
);
-rx_fifo_wr <= '1' when PS_WR_EN_IN = '1' and PS_ACTIVATE_IN = '1' else '0';
-
+--rx_fifo_wr <= '1' when PS_WR_EN_IN = '1' and PS_ACTIVATE_IN = '1' else '0';
rx_fifo_rd <= '1' when (gsc_init_dataready = '1' and dissect_current_state = LOAD_TO_HUB) or
(gsc_init_dataready = '1' and dissect_current_state = WAIT_FOR_HUB and GSC_INIT_READ_IN = '1') or
(dissect_current_state = READ_FRAME and PS_DATA_IN(8) = '1')
else '0'; -- preload first word
+
+RX_FIFO_SYNC : process(CLK)
+begin
+ if rising_edge(CLK) then
+
+ if (PS_WR_EN_IN = '1' and PS_ACTIVATE_IN = '1') then
+ rx_fifo_wr <= '1';
+ else
+ rx_fifo_wr <= '0';
+ end if;
+
+-- if (gsc_init_dataready = '1' and dissect_current_state = LOAD_TO_HUB) then
+-- rx_fifo_rd <= '1';
+-- elsif (gsc_init_dataready = '1' and dissect_current_state = WAIT_FOR_HUB and GSC_INIT_READ_IN = '1') then
+-- rx_fifo_rd <= '1';
+-- elsif (dissect_current_state = READ_FRAME and PS_DATA_IN(8) = '1') then
+-- rx_fifo_rd <= '1';
+-- else
+-- rx_fifo_rd <= '0';
+-- end if;
+
+ rx_fifo_data <= PS_DATA_IN;
+ end if;
+end process RX_FIFO_SYNC;
GSC_INIT_DATA_OUT(7 downto 0) <= rx_fifo_q(16 downto 9);
GSC_INIT_DATA_OUT(15 downto 8) <= rx_fifo_q(7 downto 0);
end if;
end process TX_LOADED_CTR_PROC;
-PS_BUSY_OUT <= '0' when (dissect_current_state = IDLE) else '1';
-
-PS_RESPONSE_READY_OUT <= '1' when (dissect_current_state = WAIT_FOR_LOAD or dissect_current_state = LOAD_FRAME or
- dissect_current_state = CLEANUP or dissect_current_state = WAIT_FOR_LOAD_ACK or
- dissect_current_state = LOAD_ACK or dissect_current_state = DIVIDE) and (too_much_data = '0')
- else '0';
+--PS_BUSY_OUT <= '0' when (dissect_current_state = IDLE) else '1';
+--
+--PS_RESPONSE_READY_OUT <= '1' when (dissect_current_state = WAIT_FOR_LOAD or dissect_current_state = LOAD_FRAME or
+-- dissect_current_state = CLEANUP or dissect_current_state = WAIT_FOR_LOAD_ACK or
+-- dissect_current_state = LOAD_ACK or dissect_current_state = DIVIDE) and (too_much_data = '0')
+-- else '0';
+
+PS_RESPONSE_SYNC : process(CLK)
+begin
+ if rising_edge(CLK) then
+ if (too_much_data = '0') then
+ if (dissect_current_state = WAIT_FOR_LOAD or dissect_current_state = LOAD_FRAME or dissect_current_state = CLEANUP) then
+ PS_RESPONSE_READY_OUT <= '1';
+ elsif (dissect_current_state = WAIT_FOR_LOAD_ACK or dissect_current_state = LOAD_ACK or dissect_current_state = DIVIDE) then
+ PS_RESPONSE_READY_OUT <= '1';
+ else
+ PS_RESPONSE_READY_OUT <= '0';
+ end if;
+ end if;
+
+ if (dissect_current_state = IDLE) then
+ PS_BUSY_OUT <= '0';
+ else
+ PS_BUSY_OUT <= '1';
+ end if;
+ end if;
+end process PS_RESPONSE_SYNC;
TC_FRAME_TYPE_OUT <= x"0008";
TC_DEST_MAC_OUT <= PS_SRC_MAC_ADDRESS_IN;
end process STATS_MACHINE;
-SELECTOR : process(stats_current_state)
+SELECTOR : process(CLK)
begin
-
- case(stats_current_state) is
-
- when LOAD_RECEIVED =>
- stat_data_temp <= x"0502" & rec_frames;
- STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE, 8));
-
- when LOAD_REPLY =>
- stat_data_temp <= x"0503" & reply_ctr;
- STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE + 1, 8));
+ if rising_edge(CLK) then
+ case(stats_current_state) is
- when others =>
- stat_data_temp <= (others => '0');
- STAT_ADDR_OUT <= (others => '0');
-
- end case;
-
+ when LOAD_RECEIVED =>
+ stat_data_temp <= x"0502" & rec_frames;
+ STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE, 8));
+
+ when LOAD_REPLY =>
+ stat_data_temp <= x"0503" & reply_ctr;
+ STAT_ADDR_OUT <= std_logic_vector(to_unsigned(STAT_ADDRESS_BASE + 1, 8));
+
+ when others =>
+ stat_data_temp <= (others => '0');
+ STAT_ADDR_OUT <= (others => '0');
+
+ end case;
+ end if;
end process SELECTOR;
STAT_DATA_OUT(7 downto 0) <= stat_data_temp(31 downto 24);
STAT_DATA_OUT(23 downto 16) <= stat_data_temp(15 downto 8);
STAT_DATA_OUT(31 downto 24) <= stat_data_temp(7 downto 0);
-STAT_DATA_RDY_OUT <= '1' when stats_current_state /= IDLE and stats_current_state /= CLEANUP else '0';
+STAT_SYNC : process(CLK)
+begin
+ if rising_edge(CLK) then
+ if (stats_current_state /= IDLE and stats_current_state /= CLEANUP) then
+ STAT_DATA_RDY_OUT <= '1';
+ else
+ STAT_DATA_RDY_OUT <= '0';
+ end if;
+ end if;
+end process STAT_SYNC;
+--STAT_DATA_RDY_OUT <= '1' when stats_current_state /= IDLE and stats_current_state /= CLEANUP else '0';
-- end of statistics
end process TC_DATA_SYNC;
-PS_BUSY_OUT <= '0' when (construct_current_state = IDLE) else '1';
-PS_RESPONSE_READY_OUT <= '0' when (construct_current_state = IDLE) else '1';
+--PS_BUSY_OUT <= '0' when (construct_current_state = IDLE) else '1';
+--PS_RESPONSE_READY_OUT <= '0' when (construct_current_state = IDLE) else '1';
+
+PS_RESPONSE_SYNC : process(CLK)
+begin
+ if rising_edge(CLK) then
+ if (construct_current_state = IDLE) then
+ PS_RESPONSE_READY_OUT <= '0';
+ else
+ PS_RESPONSE_READY_OUT <= '1';
+ end if;
+
+ if (construct_current_state = IDLE) then
+ PS_BUSY_OUT <= '0';
+ else
+ PS_BUSY_OUT <= '1';
+ end if;
+ end if;
+end process PS_RESPONSE_SYNC;
TC_FRAME_SIZE_OUT <= x"0100";
TC_FRAME_TYPE_OUT <= x"0008"; -- frame type: ip