1 ------------------------------------------------------------------------------- 3 --! @author Hipolito Guzman-Miranda 4 --! @brief Checks that a specific valid signal is active with expected data rate 5 ------------------------------------------------------------------------------- 7 --! Use IEEE standard definitions library; 9 --! Use std_logic* signal types 10 USE ieee.std_logic_1164.
ALL;
11 --! Allows use of arithmetical operations between integers and vectors 13 --! Allows writing strings to lines and lines to files 15 --! Allows writing std_logic_vector(s) to line(s) in BIN, HEX, OCT and reading BIN, HEX, OCT vector(s) from line(s) 16 use ieee.std_logic_textio.
all;
17 --! For print() function 20 --! @brief Checks that data is valid with a specific data rate 22 --! @detailed Checks that \c valid is active once each \c THROUGHPUT cycles. 23 --! Assumes \c valid is active high. Also reports the total number of 24 --! valid data seen when \c endsim is asserted. Note that this entity does not 25 --! need to know the actual value of the 26 --! data, only the value of the accompanying \c valid signal 29 SIMULATION_LABEL : := "throughputchecker";
--! To separate messages from different instances in simulation 30 DEBUG : := false;
--! Print debug info (developers) 31 THROUGHPUT : := 0 --! Wait cycles between valid data 34 clk : in ;
--! Input data is aligned to this clock 35 valid : in ;
--! Active high, indicates data is valid 36 endsim : in --! Active high, tells the process that last data from datagen was sent 38 end throughputchecker;
40 --! @brief Architecture compares input data rate with expected data rate 42 --! @detailed After first valid data is seen, internally counts from 0 to 43 --! THROUGHPUT - 1 and checks if \c valid is \c '1' when expected 53 report "throughputchecker(" & SIMULATION_LABEL & "): THROUGHPUT must be a positive non-zero integer" 56 --! @brief Computes expected value for valid and reports an error if actual value is different 58 --! @detailed Manages this by waiting for first valid and keeping an internal 59 --! count. When endsim is asserted, reports total valid data seen 60 expecting_valid :
process 64 -- wait until the first valid to start counting down 65 while (valid /= '1') loop 66 wait until rising_edge(clk);
72 report "throughputchecker(" & SIMULATION_LABEL & "): invalid value for valid, should only have '0' or '1'! (got '" & 'image(valid) & "')" 77 report "throughputchecker(" & SIMULATION_LABEL & "): ERROR: data valid " & 'image(cycle_count + 1) & " cycles before expected" severity error;
94 -- Wait for next rising edge of clk 95 -- if endsim is asserted, do not wait for the clk edge, because it will never come 96 wait until rising_edge(clk) or (endsim = '1');
106 end compare_with_expected;
in clkstd_logic
Input data is aligned to this clock.
SIMULATION_LABELstring := "throughputchecker"
To separate messages from different instances in simulation.
_library_ ieeeieee
Use IEEE standard definitions library.
in endsimstd_logic
Active high, tells the process that last data from datagen was sent.
integer := 0 valid_count
Valid data seen.
DEBUGboolean := false
Print debug info (developers)
Checks that data is valid with a specific data rate.
std_logic := '1' expected_valid
Expected value for 'valid'.
THROUGHPUTinteger := 0
Wait cycles between valid data.
in validstd_logic
Active high, indicates data is valid.
integer := THROUGHPUT- 1 cycle_count
Cycles until next expected data.
Allows for text output in simulation.