Skip to content
Snippets Groups Projects
Commit d8e68990 authored by Daniel van der Schuur's avatar Daniel van der Schuur
Browse files

-Improved reuse/structure

 .Instantiated dp_statistics in eth_statistics.
parent 4adf166e
No related branches found
No related tags found
No related merge requests found
......@@ -35,14 +35,15 @@ USE technology_lib.technology_select_pkg.ALL;
ENTITY dp_statistics IS
GENERIC (
g_disable_failures : BOOLEAN := FALSE; --TRUE: report warnings instead of failures - does not stop sim.
g_runtime_nof_packets : NATURAL; -- Run the test bench for nof_packets before asserting tb_end
g_runtime_timeout : TIME; -- Report Failure if g_runtime_nof_packets is not reached before this time
g_check_nof_valid : BOOLEAN := FALSE; -- True enables valid count checking at tb_end. Reports Failure in case of mismatch.
g_check_nof_valid_ref : NATURAL := 0; -- . Specify reference valid count here
g_check_data_rate_mbps : BOOLEAN := FALSE; -- True enables checking of calculated data rate in Mbps
g_check_data_rate_mbps_ref : NATURAL := 0; -- . Specify reference data rate in Mbps here
c_dp_clk_freq_mhz : NATURAL := 200; -- Used to calculate data rate
c_dp_word_w : NATURAL := 32 -- Used to calculate data rate
g_check_nof_valid : BOOLEAN := FALSE; -- True enables valid count checking at tb_end. Reports Failure in case of mismatch.
g_check_nof_valid_ref : NATURAL := 0; -- . Specify reference valid count here
g_check_data_rate_mbps : BOOLEAN := FALSE; -- True enables checking of calculated data rate in Mbps
g_check_data_rate_mbps_ref : NATURAL := 0; -- . Specify reference data rate in Mbps here
g_dp_clk_freq_khz : NATURAL := 200000; -- Used to calculate data rate
g_dp_word_w : NATURAL := 32 -- Used to calculate data rate
);
PORT (
......@@ -57,6 +58,8 @@ END dp_statistics;
ARCHITECTURE str OF dp_statistics IS
CONSTANT c_severity_level : SEVERITY_LEVEL := sel_a_b(g_disable_failures, WARNING, FAILURE);
SIGNAL packet_count : NATURAL := 0;
SIGNAL valid_count : NATURAL := 0;
SIGNAL cycle_count : NATURAL := 0;
......@@ -99,7 +102,7 @@ BEGIN
p_tb_end_calc: PROCESS(nxt_tb_end, timeout)
BEGIN
IF nxt_tb_end='1' AND timeout='0' THEN --Don't calc anything if a timeout occured
data_rate_mbps <= c_dp_clk_freq_mhz * c_dp_word_w * valid_count / cycle_count;
data_rate_mbps <= g_dp_clk_freq_khz * g_dp_word_w / 1000 * valid_count / cycle_count;
END IF;
END PROCESS;
......@@ -112,8 +115,8 @@ BEGIN
REPORT "[dp_statistics] Timeout occured!" SEVERITY FAILURE;
ELSIF nxt_tb_end='1' THEN
IF falling_edge(dp_clk) THEN
IF (g_check_nof_valid =TRUE AND valid_count /=g_check_nof_valid_ref ) THEN REPORT "[dp_statistics] Valid count does not match reference" SEVERITY FAILURE; END IF;
IF (g_check_data_rate_mbps=TRUE AND data_rate_mbps/=g_check_data_rate_mbps_ref) THEN REPORT "[dp_statistics] data rate does not match reference" SEVERITY FAILURE; END IF;
IF (g_check_nof_valid =TRUE AND valid_count /=g_check_nof_valid_ref ) THEN REPORT "[dp_statistics] Valid count does not match reference" SEVERITY c_severity_level; END IF;
IF (g_check_data_rate_mbps=TRUE AND data_rate_mbps/=g_check_data_rate_mbps_ref) THEN REPORT "[dp_statistics] data rate does not match reference" SEVERITY c_severity_level; END IF;
END IF;
END IF;
END PROCESS;
......
......@@ -22,7 +22,7 @@
-- Author:
-- . Daniel van der Schuur
-- Purpose:
-- . Provide a generic Ethernet output checking stage for simulation.
-- . 1GbE wrapper for dp_statistics
LIBRARY IEEE, common_lib, work, technology_lib, dp_lib, tech_tse_lib;
USE IEEE.STD_LOGIC_1164.ALL;
......@@ -36,12 +36,14 @@ USE technology_lib.technology_select_pkg.ALL;
ENTITY eth_statistics IS
GENERIC (
g_disable_failures : BOOLEAN := FALSE; --TRUE: report warnings instead of failures - does not stop sim.
g_runtime_nof_packets : NATURAL; -- Run the test bench for nof_packets before asserting tb_end
g_runtime_timeout : TIME; -- Report Failure if g_runtime_nof_packets is not reached before this time
g_check_nof_valid : BOOLEAN := FALSE; -- True enables valid count checking at tb_end. Reports Failure in case of mismatch.
g_check_nof_valid_ref : NATURAL := 0 -- . Specify reference valid count here
);
g_disable_failures : BOOLEAN := FALSE; --TRUE: report warnings instead of failures - does not stop sim.
g_runtime_nof_packets : NATURAL; -- Run the test bench for nof_packets before asserting tb_end
g_runtime_timeout : TIME; -- Report Failure if g_runtime_nof_packets is not reached before this time
g_check_nof_valid : BOOLEAN := FALSE; -- True enables valid count checking at tb_end. Reports Failure in case of mismatch.
g_check_nof_valid_ref : NATURAL := 0; -- . Specify reference valid count here
g_check_data_rate_mbps : BOOLEAN := FALSE; -- True enables checking of calculated data rate in Mbps
g_check_data_rate_mbps_ref : NATURAL := 0 -- . Specify reference data rate in Mbps here
);
PORT (
eth_serial_in : IN STD_LOGIC;
tb_end : OUT STD_LOGIC -- To be used to stop test-bench generated clocks
......@@ -51,9 +53,7 @@ END eth_statistics;
ARCHITECTURE str OF eth_statistics IS
CONSTANT c_severity_level : SEVERITY_LEVEL := sel_a_b(g_disable_failures, WARNING, FAILURE);
CONSTANT c_eth_clk_freq_mhz : NATURAL := 125;
CONSTANT c_eth_clk_freq_khz : NATURAL := 125000;
CONSTANT c_eth_word_w : NATURAL := 32;
CONSTANT c_eth_clk_period : TIME := 8 ns;
......@@ -62,21 +62,15 @@ ARCHITECTURE str OF eth_statistics IS
SIGNAL tech_tse_rx_src_out : t_dp_sosi;
SIGNAL packet_count : NATURAL := 0;
SIGNAL valid_count : NATURAL := 0;
SIGNAL cycle_count : NATURAL := 0;
SIGNAL i_tb_end : STD_LOGIC;
SIGNAL timeout : STD_LOGIC;
SIGNAL nxt_packet_count : NATURAL := 0;
SIGNAL nxt_valid_count : NATURAL := 0;
SIGNAL nxt_cycle_count : NATURAL := 0;
SIGNAL nxt_tb_end : STD_LOGIC;
SIGNAL data_rate_mbps : NATURAL; -- Data rate in Mbps (natural is only 32b so bps is not possible).
BEGIN
------------------------------------------------------------------------------
-- We're using the tb_end output locally
------------------------------------------------------------------------------
tb_end <= i_tb_end;
------------------------------------------------------------------------------
-- We're generating a clock locally; it happens to be in sync with the 125Mz
-- transmitter clock that is generated from 25MHz by a PLL.
......@@ -117,68 +111,27 @@ BEGIN
);
------------------------------------------------------------------------------
-- Counters
------------------------------------------------------------------------------
nxt_packet_count <= packet_count+1 WHEN tech_tse_rx_src_out.sop='1' ELSE packet_count;
nxt_valid_count <= valid_count+1 WHEN tech_tse_rx_src_out.valid='1'ELSE valid_count;
nxt_cycle_count <= cycle_count+1 WHEN packet_count>0 OR (packet_count=0 AND tech_tse_rx_src_out.sop='1') ELSE cycle_count;
------------------------------------------------------------------------------
-- Assert timeout after user specified time
-- . Note: Using AFTER [time] results in the simulation actually running up to
-- the runtime. This is okay as tb_end='1' makes sure no signals are
-- changing anymore so this does not take extra sim time.
------------------------------------------------------------------------------
timeout <= '0', '1' AFTER g_runtime_timeout;
-- dp_statistics
------------------------------------------------------------------------------
-- Assert tb_end if we've seen g_runtime_nof_packets packets
------------------------------------------------------------------------------
nxt_tb_end <= '1' WHEN packet_count>g_runtime_nof_packets OR (packet_count=g_runtime_nof_packets AND tech_tse_rx_src_out.sop='1') ELSE '0';
tb_end <= i_tb_end;
------------------------------------------------------------------------------
-- Derive some interesting statistics
------------------------------------------------------------------------------
p_tb_end_calc: PROCESS(nxt_tb_end, timeout)
BEGIN
IF nxt_tb_end='1' AND timeout='0' THEN --Don't calc anything if a timeout occured
IF falling_edge(eth_clk) THEN
data_rate_mbps <= c_eth_clk_freq_mhz * c_eth_word_w * valid_count / cycle_count;
END IF;
END IF;
END PROCESS;
------------------------------------------------------------------------------
-- On tb_end; do the checks defined in the generics
------------------------------------------------------------------------------
p_tb_end_check: PROCESS(eth_clk)
BEGIN
IF timeout='1' AND nxt_tb_end='0' THEN
REPORT "[eth_statistics] Timeout occured!" SEVERITY FAILURE;
ELSIF nxt_tb_end='1' THEN
IF falling_edge(eth_clk) THEN
IF (g_check_nof_valid=TRUE AND valid_count/=g_check_nof_valid_ref) THEN REPORT "[eth_statistics] Valid count does not match reference" SEVERITY c_severity_level; END IF;
END IF;
END IF;
END PROCESS;
------------------------------------------------------------------------------
-- Registers
------------------------------------------------------------------------------
p_eth_clk: PROCESS(eth_clk, eth_rst)
BEGIN
IF eth_rst='1' THEN
packet_count <= 0;
valid_count <= 0;
cycle_count <= 0;
i_tb_end <= '0';
ELSIF(rising_edge(eth_clk)) THEN
packet_count <= nxt_packet_count;
valid_count <= nxt_valid_count;
cycle_count <= nxt_cycle_count;
i_tb_end <= nxt_tb_end;
END IF;
END PROCESS;
u_dp_statistics : ENTITY dp_lib.dp_statistics
GENERIC MAP (
g_disable_failures => g_disable_failures,
g_runtime_nof_packets => g_runtime_nof_packets,
g_runtime_timeout => g_runtime_timeout,
g_check_nof_valid => g_check_nof_valid,
g_check_nof_valid_ref => g_check_nof_valid_ref,
g_check_data_rate_mbps => g_check_data_rate_mbps,
g_check_data_rate_mbps_ref => g_check_data_rate_mbps_ref,
g_dp_clk_freq_khz => c_eth_clk_freq_khz,
g_dp_word_w => c_eth_word_w
)
PORT MAP (
dp_clk => eth_clk,
dp_rst => eth_rst,
snk_in => tech_tse_rx_src_out,
tb_end => i_tb_end
);
END str;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment