diff --git a/libraries/base/dp/tb/vhdl/dp_statistics.vhd b/libraries/base/dp/tb/vhdl/dp_statistics.vhd index 084885e730bd37efa0f986d5ff9b908a2bc4b184..f9616b725b37a7e688fb5d3a05183eb8fc075af4 100644 --- a/libraries/base/dp/tb/vhdl/dp_statistics.vhd +++ b/libraries/base/dp/tb/vhdl/dp_statistics.vhd @@ -23,6 +23,17 @@ -- . Daniel van der Schuur -- Purpose: -- . Provide a generic DP bus checking stage for simulation. +-- Remark: +-- . EK 17 dec 2021: +-- . removed g_disable_failures, to simplify the component, because default +-- ERROR level is used in practise +-- . removed g_check_data_rate_mbps, to simplify the component, because +-- measuring the average data rate exactly is difficult and requires +-- receiving at least 2 snk_in.sops, to be able to derive mpbs from +-- valid_count / cycle_count between 2 snk_in.sops. +-- . I changed dp_done to end at eop (instead of at next sop), so that an +-- extra next packet is not needed, which reduces the sim time. +-- LIBRARY IEEE, common_lib, work, technology_lib; USE IEEE.STD_LOGIC_1164.ALL; @@ -35,14 +46,10 @@ 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 - g_dp_clk_freq_khz : NATURAL := 200000; -- Used to calculate data rate + g_check_nof_valid : BOOLEAN := FALSE; -- True enables valid count checking at dp_done. Reports Failure in case of mismatch. + g_check_nof_valid_ref : NATURAL := 0; -- Reference (= expected) valid count g_dp_word_w : NATURAL := 32 -- Used to calculate data rate ); PORT ( @@ -58,29 +65,28 @@ END dp_statistics; ARCHITECTURE str OF dp_statistics IS - CONSTANT c_severity_level : SEVERITY_LEVEL := sel_a_b(g_disable_failures, WARNING, ERROR); - 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 valid_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; + SIGNAL timeout : STD_LOGIC; + + SIGNAL dp_done : STD_LOGIC := '0'; + SIGNAL nxt_dp_done : STD_LOGIC; BEGIN + -- Make sure tb_end will not cause dp_clk to be stopped before dp_done has + -- been evaluated in p_dp_done_check + tb_end <= dp_done WHEN rising_edge(dp_clk); + ------------------------------------------------------------------------------ -- Counters ------------------------------------------------------------------------------ nxt_packet_count <= packet_count+1 WHEN snk_in.sop='1' ELSE packet_count; nxt_valid_count <= valid_count+1 WHEN snk_in.valid='1'ELSE valid_count; - nxt_cycle_count <= cycle_count+1 WHEN packet_count>0 OR (packet_count=0 AND snk_in.sop='1') ELSE cycle_count; ------------------------------------------------------------------------------ -- Assert timeout after user specified time @@ -88,50 +94,31 @@ BEGIN -- 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; + timeout <= '0', '1' AFTER g_runtime_timeout; ------------------------------------------------------------------------------ - -- Assert tb_end if we've seen g_runtime_nof_packets packets + -- Assert dp_done 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 snk_in.sop='1') ELSE '0'; - tb_end <= i_tb_end; + nxt_dp_done <= '1' WHEN packet_count = g_runtime_nof_packets AND snk_in.eop = '1' ELSE '0'; ------------------------------------------------------------------------------ - -- Derive some interesting statistics + -- On dp_done; do the checks defined in the generics ------------------------------------------------------------------------------ - p_tb_end_calc: PROCESS(nxt_tb_end, timeout) + p_dp_done_check: PROCESS(dp_clk) BEGIN - IF nxt_tb_end='1' AND timeout='0' THEN --Don't calc anything if a timeout occured - data_rate_mbps <= g_dp_clk_freq_khz * g_dp_word_w / 1000 * valid_count / cycle_count; - END IF; - END PROCESS; - - ------------------------------------------------------------------------------ - -- On tb_end; do the checks defined in the generics - ------------------------------------------------------------------------------ - p_tb_end_check: PROCESS(dp_clk) - BEGIN - IF timeout='1' AND nxt_tb_end='0' THEN - REPORT "[dp_statistics] Timeout occured!" SEVERITY c_severity_level; -- report ERROR to have Error in log + IF timeout = '1' AND dp_done = '0' THEN + REPORT "[dp_statistics] Timeout occured!" SEVERITY ERROR; -- report ERROR to have Error in log REPORT "[dp_statistics] Timeout occured!" SEVERITY FAILURE; -- report FAILURE to stop simulation - ELSIF nxt_tb_end='1' THEN - IF falling_edge(dp_clk) THEN + ELSIF dp_done = '1' THEN + IF rising_edge(dp_clk) THEN -- report valid count - IF g_check_nof_valid =TRUE THEN - IF valid_count /=g_check_nof_valid_ref THEN - REPORT "[dp_statistics] Valid count " & INTEGER'IMAGE(valid_count) & " does not match reference " & INTEGER'IMAGE(g_check_nof_valid_ref) SEVERITY c_severity_level; + IF g_check_nof_valid = TRUE THEN + IF valid_count /= g_check_nof_valid_ref THEN + REPORT "[dp_statistics] Valid count " & INTEGER'IMAGE(valid_count) & " does not match reference " & INTEGER'IMAGE(g_check_nof_valid_ref) SEVERITY ERROR; ELSE REPORT "[dp_statistics] Valid count " & INTEGER'IMAGE(valid_count) & " is OK" SEVERITY NOTE; -- Note to show that the check indeed did happen END IF; END IF; - -- report data rate - IF g_check_data_rate_mbps=TRUE THEN - IF data_rate_mbps/=g_check_data_rate_mbps_ref THEN - REPORT "[dp_statistics] data rate " & INTEGER'IMAGE(data_rate_mbps) & " does not match reference " & INTEGER'IMAGE(g_check_data_rate_mbps_ref) SEVERITY c_severity_level; - ELSE - REPORT "[dp_statistics] data rate " & INTEGER'IMAGE(data_rate_mbps) & " is OK" SEVERITY NOTE; -- Note to show that the check indeed did happen - END IF; - END IF; END IF; END IF; END PROCESS; @@ -141,16 +128,14 @@ BEGIN ------------------------------------------------------------------------------ p_dp_clk: PROCESS(dp_clk, dp_rst) BEGIN - IF dp_rst='1' THEN + IF dp_rst = '1' THEN packet_count <= 0; valid_count <= 0; - cycle_count <= 0; - i_tb_end <= '0'; + dp_done <= '0'; ELSIF(rising_edge(dp_clk)) THEN packet_count <= nxt_packet_count; valid_count <= nxt_valid_count; - cycle_count <= nxt_cycle_count; - i_tb_end <= nxt_tb_end; + dp_done <= nxt_dp_done; END IF; END PROCESS; diff --git a/libraries/io/eth/src/vhdl/eth_statistics.vhd b/libraries/io/eth/src/vhdl/eth_statistics.vhd index 9f3bd8c9bac21e811bebdcfd467b0653c5fb4f02..31f58dbcc0d4ba99571143812e1fdfd335b0032b 100644 --- a/libraries/io/eth/src/vhdl/eth_statistics.vhd +++ b/libraries/io/eth/src/vhdl/eth_statistics.vhd @@ -50,13 +50,10 @@ 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_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_check_nof_valid_ref : NATURAL := 0 -- Reference (= expected) valid count ); PORT ( eth_serial_in : IN STD_LOGIC; @@ -68,7 +65,6 @@ END eth_statistics; ARCHITECTURE str OF eth_statistics IS - CONSTANT c_eth_clk_freq_khz : NATURAL := 125000; CONSTANT c_eth_word_w : NATURAL := 32; CONSTANT c_eth_clk_period : TIME := 8 ns; @@ -130,14 +126,10 @@ BEGIN ------------------------------------------------------------------------------ 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 ( diff --git a/libraries/io/tr_10GbE/src/vhdl/tr_10GbE_statistics.vhd b/libraries/io/tr_10GbE/src/vhdl/tr_10GbE_statistics.vhd index 77b857a1ac4256172a7fa16604e6bc9f2f06b077..ec8c1875469e857eca50cd486c49c161e64ea58e 100644 --- a/libraries/io/tr_10GbE/src/vhdl/tr_10GbE_statistics.vhd +++ b/libraries/io/tr_10GbE/src/vhdl/tr_10GbE_statistics.vhd @@ -38,14 +38,11 @@ USE tech_pll_lib.tech_pll_component_pkg.ALL; ENTITY tr_10GbE_statistics IS GENERIC ( g_technology : NATURAL := c_tech_select_default; - g_disable_failures : BOOLEAN := FALSE; --TRUE: report warnings instead of failures - does not stop sim. + g_dp_clk_freq_khz : NATURAL := 200000; -- default dp_clk 200 MHz, 5 ns period 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_dp_clk_freq_khz : NATURAL := 200000; -- default dp_clk 200 MHz, 5 ns period 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_check_nof_valid_ref : NATURAL := 0 -- Reference (= expected) valid count ); PORT ( xaui_in : IN STD_LOGIC_VECTOR(3 DOWNTO 0) := (others=>'0'); @@ -196,14 +193,10 @@ BEGIN ------------------------------------------------------------------------------ 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 => g_dp_clk_freq_khz, g_dp_word_w => c_dp_word_w ) PORT MAP (