ELGIP-73 - Moved queue_and_delay testbench from SMB repository. Improved cs_bus_itf testbench
This commit is contained in:
parent
77d2808fd7
commit
79ecc46cd8
4 changed files with 829 additions and 14 deletions
39
generic_ip/common/0/sim/sim_queue_delay.do
Normal file
39
generic_ip/common/0/sim/sim_queue_delay.do
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# Simulation macro
|
||||
|
||||
.main clear
|
||||
|
||||
set SRC_PATH ./../src
|
||||
|
||||
vlib ./work
|
||||
vmap work ./work
|
||||
|
||||
|
||||
|
||||
# Compile the UUT
|
||||
vcom -work work $SRC_PATH/common_pkg.vhd
|
||||
vcom -work work $SRC_PATH/altera/sync_fifo.vhd
|
||||
vcom -2008 -work work $SRC_PATH/queue_and_delay.vhd
|
||||
|
||||
# Compile the Testbench
|
||||
vcom -2008 -work work $SRC_PATH/test/queue_and_delay_tb.vhd
|
||||
|
||||
# Simulate
|
||||
vsim -t ps work.queue_and_delay_tb
|
||||
|
||||
#add wave /queue_and_delay_tb/*
|
||||
#add wave /queue_and_delay_tb/iUUT/*
|
||||
|
||||
# remove warnings from standard numeric/arithmetic packages (speed-up simulation)
|
||||
set StdArithNoWarnings 1
|
||||
set NumericStdNoWarnings 1
|
||||
|
||||
do wave_queue_delay.do
|
||||
|
||||
when -label end_of_simulation {completed == true} {echo "Simulation Completed"; stop ;}
|
||||
run -all
|
||||
|
||||
#run 100 us;
|
||||
|
||||
|
||||
|
||||
|
||||
64
generic_ip/common/0/sim/wave_queue_delay.do
Normal file
64
generic_ip/common/0/sim/wave_queue_delay.do
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
onerror {resume}
|
||||
quietly WaveActivateNextPane {} 0
|
||||
add wave -noupdate /queue_and_delay_tb/rstN
|
||||
add wave -noupdate /queue_and_delay_tb/clk
|
||||
add wave -noupdate /queue_and_delay_tb/init
|
||||
add wave -noupdate /queue_and_delay_tb/cnt_dir
|
||||
add wave -noupdate /queue_and_delay_tb/pIO_MNG/loc_cnt
|
||||
add wave -noupdate -radix unsigned /queue_and_delay_tb/delay
|
||||
add wave -noupdate -radix decimal /queue_and_delay_tb/ext_time
|
||||
add wave -noupdate /queue_and_delay_tb/kickstart
|
||||
add wave -noupdate /queue_and_delay_tb/kickstart_ref
|
||||
add wave -noupdate /queue_and_delay_tb/wave_in
|
||||
add wave -noupdate /queue_and_delay_tb/wave_delayed
|
||||
add wave -noupdate /queue_and_delay_tb/wave_out
|
||||
add wave -noupdate /queue_and_delay_tb/wave_ref
|
||||
add wave -noupdate /queue_and_delay_tb/wave_error
|
||||
add wave -noupdate /queue_and_delay_tb/error_detected
|
||||
add wave -noupdate -radix decimal /queue_and_delay_tb/init_time
|
||||
add wave -noupdate /queue_and_delay_tb/offset
|
||||
add wave -noupdate /queue_and_delay_tb/pulse_width
|
||||
add wave -noupdate /queue_and_delay_tb/passed
|
||||
add wave -noupdate /queue_and_delay_tb/failed
|
||||
add wave -noupdate /queue_and_delay_tb/completed
|
||||
add wave -noupdate /queue_and_delay_tb/ovf_error
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/rstN
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/clk
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/init
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/cnt_dir
|
||||
add wave -noupdate -radix unsigned /queue_and_delay_tb/iUUT/delay
|
||||
add wave -noupdate -radix decimal /queue_and_delay_tb/iUUT/ext_time
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/wave_in
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/wave_out
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/ovf_error
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/toggle_in
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/toggle_out
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/time_elapsed
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/wave_in_d
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/wave_out_i
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/wave_out_i_d
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/new_event
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/pending_trans
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/fifo_rd_en
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/fifo_empty
|
||||
add wave -noupdate /queue_and_delay_tb/iUUT/fifo_full
|
||||
add wave -noupdate -radix unsigned /queue_and_delay_tb/iUUT/int_time
|
||||
add wave -noupdate -radix decimal /queue_and_delay_tb/iUUT/event_time
|
||||
TreeUpdate [SetDefaultTree]
|
||||
WaveRestoreCursors {{Cursor 1} {5695000 ps} 0}
|
||||
quietly wave cursor active 1
|
||||
configure wave -namecolwidth 343
|
||||
configure wave -valuecolwidth 100
|
||||
configure wave -justifyvalue left
|
||||
configure wave -signalnamewidth 0
|
||||
configure wave -snapdistance 10
|
||||
configure wave -datasetprefix 0
|
||||
configure wave -rowmargin 4
|
||||
configure wave -childrowmargin 2
|
||||
configure wave -gridoffset 0
|
||||
configure wave -gridperiod 1
|
||||
configure wave -griddelta 40
|
||||
configure wave -timeline 0
|
||||
configure wave -timelineunits ps
|
||||
update
|
||||
WaveRestoreZoom {814844 ps} {2822428 ps}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
-- Author : GMG
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2019-07-10
|
||||
-- Last update: 2019-07-12
|
||||
-- Last update: 2019-07-17
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'2008
|
||||
-------------------------------------------------------------------------------
|
||||
|
|
@ -372,30 +372,122 @@ begin -- architecture behav
|
|||
log_header("Repeating the test without pauses between accesses:", VLOW);
|
||||
|
||||
wait_latency(clk, 20);
|
||||
|
||||
|
||||
/*
|
||||
wr_data(0, 4, X"A2A2B1B1", avs_s, avs_m, true);
|
||||
/*
|
||||
if(blk_0_wr_data /= X"A2A2B1B1") then
|
||||
log("ERROR : Expecting written data A2A2B1B1 on block 0", VLOW);
|
||||
error_flag := true;
|
||||
end if;
|
||||
*/
|
||||
|
||||
wr_data(1, 8, X"C2C2D1D1", avs_s, avs_m, true);
|
||||
/*
|
||||
if(blk_1_wr_data /= X"C2C2D1D1") then
|
||||
log("ERROR : Expecting written data C2C2D1D1 on block 1", VLOW);
|
||||
error_flag := true;
|
||||
end if;
|
||||
*/
|
||||
wr_data(2, 0, X"EE00FF11", avs_s, avs_m, true);
|
||||
wr_data(7, 0, X"EE00FF11", avs_s, avs_m, true);
|
||||
|
||||
|
||||
for blk_num in 0 to 7 loop
|
||||
rd_data(blk_num, 16, data, avs_s, avs_m, true);
|
||||
log("Read Data 0x" & to_hstring(data) & " from block " & to_string(blk_num), VLOW);
|
||||
end loop; -- blk_num
|
||||
end loop; -- blk_num
|
||||
*/
|
||||
|
||||
-- manually drive the master signals
|
||||
wait until clk = '1' and clk'event;
|
||||
avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(0,4)) & std_logic_vector(to_unsigned(4,11));
|
||||
avs_m.mm_writedata <= X"A2A2B1B1";
|
||||
avs_m.mm_write <= '1';
|
||||
wait until clk = '0' and clk'event;
|
||||
while avs_s.mm_waitrequest = '1' loop
|
||||
wait until clk = '0' and clk'event;
|
||||
end loop;
|
||||
wait until clk = '1' and clk'event;
|
||||
-- transfer is concluded, but don't de-assert the write enable, just move
|
||||
-- to the next data
|
||||
avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(1,4)) & std_logic_vector(to_unsigned(8,11));
|
||||
avs_m.mm_writedata <= X"C2C2D1D1";
|
||||
avs_m.mm_write <= '1';
|
||||
wait until clk = '0' and clk'event;
|
||||
-- Check first the data written before:
|
||||
if(blk_0_wr_data /= X"A2A2B1B1") then
|
||||
log("ERROR : Expecting written data A2A2B1B1 on block 0", VLOW);
|
||||
error_flag := true;
|
||||
end if;
|
||||
while avs_s.mm_waitrequest = '1' loop
|
||||
wait until clk = '0' and clk'event;
|
||||
end loop;
|
||||
wait until clk = '1' and clk'event;
|
||||
-- transfer is concluded, but don't de-assert the write enable, just move
|
||||
-- to the next data
|
||||
avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(2,4)) & std_logic_vector(to_unsigned(0,11));
|
||||
avs_m.mm_writedata <= X"EE00FF11";
|
||||
avs_m.mm_write <= '1';
|
||||
wait until clk = '0' and clk'event;
|
||||
-- Check first the data written before:
|
||||
if(blk_1_wr_data /= X"C2C2D1D1") then
|
||||
log("ERROR : Expecting written data C2C2D1D1 on block 1", VLOW);
|
||||
error_flag := true;
|
||||
end if;
|
||||
while avs_s.mm_waitrequest = '1' loop
|
||||
wait until clk = '0' and clk'event;
|
||||
end loop;
|
||||
wait until clk = '1' and clk'event;
|
||||
-- transfer is concluded, but don't de-assert the write enable, just move
|
||||
-- to the next data
|
||||
avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(7,4)) & std_logic_vector(to_unsigned(0,11));
|
||||
avs_m.mm_writedata <= X"FF11EE00";
|
||||
avs_m.mm_write <= '1';
|
||||
wait until clk = '0' and clk'event;
|
||||
while avs_s.mm_waitrequest = '1' loop
|
||||
wait until clk = '0' and clk'event;
|
||||
end loop;
|
||||
wait until clk = '1' and clk'event;
|
||||
-- disable write and start immediately reading
|
||||
avs_m.mm_write <= '0';
|
||||
for n in 0 to 7 loop
|
||||
avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(n,4)) & std_logic_vector(to_unsigned(16,11));
|
||||
avs_m.mm_read <= '1';
|
||||
wait until clk = '0' and clk'event;
|
||||
while avs_s.mm_waitrequest = '1' loop
|
||||
wait until clk = '0' and clk'event;
|
||||
end loop;
|
||||
log("Read Data 0x" & to_hstring(avs_s.mm_readdata) & " from block " & to_string(n), VLOW);
|
||||
wait until clk = '1' and clk'event;
|
||||
end loop; -- n
|
||||
avs_m.mm_read <= '0';
|
||||
|
||||
wait until clk = '1' and clk'event;
|
||||
wait until clk = '1' and clk'event;
|
||||
wait until clk = '1' and clk'event;
|
||||
wait until clk = '1' and clk'event;
|
||||
|
||||
-- now do a loop with read-write-read without interruption
|
||||
for n in 0 to 7 loop
|
||||
avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(n,4)) & std_logic_vector(to_unsigned(16,11));
|
||||
avs_m.mm_read <= '1';
|
||||
wait until clk = '0' and clk'event;
|
||||
while avs_s.mm_waitrequest = '1' loop
|
||||
wait until clk = '0' and clk'event;
|
||||
end loop;
|
||||
log("Read Data 0x" & to_hstring(avs_s.mm_readdata) & " from block " & to_string(n), VLOW);
|
||||
wait until clk = '1' and clk'event;
|
||||
avs_m.mm_read <= '0';
|
||||
avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(0,4)) & std_logic_vector(to_unsigned(4,11));
|
||||
avs_m.mm_writedata <= X"A2A2B1B1";
|
||||
avs_m.mm_write <= '1';
|
||||
wait until clk = '0' and clk'event;
|
||||
while avs_s.mm_waitrequest = '1' loop
|
||||
wait until clk = '0' and clk'event;
|
||||
end loop;
|
||||
wait until clk = '1' and clk'event;
|
||||
avs_m.mm_write <= '0';
|
||||
avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(7,4)) & std_logic_vector(to_unsigned(8,11));
|
||||
avs_m.mm_read <= '1';
|
||||
wait until clk = '0' and clk'event;
|
||||
while avs_s.mm_waitrequest = '1' loop
|
||||
wait until clk = '0' and clk'event;
|
||||
end loop;
|
||||
log("Read Data 0x" & to_hstring(avs_s.mm_readdata) & " from block " & to_string(7), VLOW);
|
||||
wait until clk = '1' and clk'event;
|
||||
|
||||
|
||||
end loop; -- n
|
||||
avs_m.mm_read <= '0';
|
||||
|
||||
|
||||
|
||||
wait_latency(clk, 50);
|
||||
running <= false;
|
||||
|
|
|
|||
620
generic_ip/common/0/src/test/queue_and_delay_tb.vhd
Normal file
620
generic_ip/common/0/src/test/queue_and_delay_tb.vhd
Normal file
|
|
@ -0,0 +1,620 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : Testbench for queue_and_delay
|
||||
-- Project : project independent
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : .vhd
|
||||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2016-11-01
|
||||
-- Last update: 2017-11-06
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'93
|
||||
-------------------------------------------------------------------------------
|
||||
-- Description:
|
||||
-- Simple Testbench for the queue and delay: Only corner cases of the delay
|
||||
-- mechanism are checked: wrapping around of the counter, usage of the external
|
||||
-- reference for the counter, up and down counting.
|
||||
-- Check also latency issues when using the external counter: what happens if
|
||||
-- the external counter is not updated every clock cycles.
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
entity queue_and_delay_tb is
|
||||
-- ...
|
||||
end queue_and_delay_tb;
|
||||
|
||||
architecture behav of queue_and_delay_tb is
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Component declarations
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
component queue_and_delay
|
||||
generic (
|
||||
use_ext_time : boolean;
|
||||
queue_size : natural range 16 to 8192);
|
||||
port (
|
||||
rstN : in std_logic;
|
||||
clk : in std_logic;
|
||||
init : in std_logic;
|
||||
cnt_dir : in std_logic;
|
||||
delay : in std_logic_vector(31 downto 0);
|
||||
ext_time : in std_logic_vector(31 downto 0);
|
||||
wave_in : in std_logic;
|
||||
wave_out : out std_logic;
|
||||
ovf_error : out std_logic);
|
||||
end component;
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Constant, types and signals
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
constant clk_period : time := 10.0 ns; -- ems clock
|
||||
|
||||
signal rstN : std_logic;
|
||||
signal clk : std_logic := '0';
|
||||
signal init : std_logic;
|
||||
signal cnt_dir : std_logic;
|
||||
signal delay : std_logic_vector(31 downto 0);
|
||||
signal ext_time : std_logic_vector(31 downto 0);
|
||||
signal wave_in : std_logic;
|
||||
signal wave_out : std_logic;
|
||||
signal ovf_error : std_logic;
|
||||
--
|
||||
signal wave_delayed : std_logic;
|
||||
signal wave_delayed_d : std_logic;
|
||||
signal wave_ref : std_logic;
|
||||
signal wave_error : std_logic;
|
||||
signal init_time : std_logic_vector(31 downto 0);
|
||||
signal offset : integer;
|
||||
signal pulse_width : integer;
|
||||
signal passed : boolean;
|
||||
signal failed : boolean;
|
||||
signal completed : boolean;
|
||||
signal kickstart : std_logic;
|
||||
signal kickstart_ref : std_logic;
|
||||
signal error_detected : std_logic;
|
||||
|
||||
begin -- behav
|
||||
|
||||
-- clock generation
|
||||
clk <= not clk after 0.5*clk_period;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- UUT
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
iUUT: queue_and_delay
|
||||
generic map (
|
||||
use_ext_time => true,
|
||||
queue_size => 128)
|
||||
port map (
|
||||
rstN => rstN,
|
||||
clk => clk,
|
||||
init => init,
|
||||
cnt_dir => cnt_dir,
|
||||
delay => delay,
|
||||
ext_time => ext_time,
|
||||
wave_in => wave_in,
|
||||
wave_out => wave_out,
|
||||
ovf_error => ovf_error);
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Stimuli generator and output checker
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
pIO_MNG: process(rstN, init, clk)
|
||||
variable loc_cnt : integer;
|
||||
begin
|
||||
if(rstN = '0') then
|
||||
loc_cnt := 0;
|
||||
ext_time <= (others => '0');
|
||||
kickstart <= '0';
|
||||
kickstart_ref <= '0';
|
||||
wave_error <= '0';
|
||||
elsif(init = '1') then
|
||||
loc_cnt := 0;
|
||||
ext_time <= init_time;
|
||||
kickstart <= '0';
|
||||
kickstart_ref <= '0';
|
||||
wave_error <= '0';
|
||||
elsif(clk = '1' and clk'event) then
|
||||
loc_cnt := loc_cnt+1;
|
||||
if(cnt_dir = '0') then
|
||||
ext_time <= std_logic_vector(signed(ext_time)+1);
|
||||
else
|
||||
ext_time <= std_logic_vector(signed(ext_time)-1);
|
||||
end if;
|
||||
if(loc_cnt = offset) then
|
||||
kickstart <= '1';
|
||||
else
|
||||
kickstart <= '0';
|
||||
end if;
|
||||
--if(loc_cnt = (offset + to_integer(unsigned(delay))+1)) then
|
||||
-- wave_delayed <= '1';
|
||||
--elsif(loc_cnt = offset + pulse_width + to_integer(unsigned(delay)+1)) then
|
||||
-- wave_delayed <= '0';
|
||||
--end if;
|
||||
if(loc_cnt = (offset + to_integer(unsigned(delay))+3)) then
|
||||
kickstart_ref <= '1';
|
||||
--elsif(loc_cnt = offset + pulse_width + to_integer(unsigned(delay)+2)) then
|
||||
else
|
||||
kickstart_ref <= '0';
|
||||
end if;
|
||||
if(wave_out /= wave_ref) then
|
||||
wave_error <= '1';
|
||||
end if;
|
||||
end if;
|
||||
end process pIO_MNG;
|
||||
|
||||
pREP : process(clk)
|
||||
begin
|
||||
if(clk = '1' and clk'event) then
|
||||
wave_delayed_d <= wave_delayed;
|
||||
if(init = '1') then
|
||||
error_detected <= '0';
|
||||
elsif(wave_error = '1') then
|
||||
error_detected <= '1';
|
||||
end if;
|
||||
end if;
|
||||
end process pREP;
|
||||
|
||||
-- Generate the input wave
|
||||
pWAVE_IN_GEN : process
|
||||
begin
|
||||
wave_in <= '0';
|
||||
-- wait for the kickstart
|
||||
wait until kickstart = '1' and kickstart'event;
|
||||
-- send pulse #1
|
||||
wave_in <= '1';
|
||||
for n in 1 to pulse_width loop
|
||||
wait until clk = '1' and clk'event;
|
||||
end loop; -- n
|
||||
wave_in <= '0';
|
||||
-- send pulse #2
|
||||
for n in 1 to 6 loop
|
||||
wait until ext_time'event;
|
||||
end loop; -- n
|
||||
wave_in <= '1';
|
||||
for n in 1 to pulse_width loop
|
||||
wait until clk = '1' and clk'event;
|
||||
end loop; -- n
|
||||
wave_in <= '0';
|
||||
/*
|
||||
-- send pulse #3
|
||||
for n in 1 to 3 loop
|
||||
wait until ext_time'event;
|
||||
end loop; -- n
|
||||
wave_in <= '1';
|
||||
for n in 1 to pulse_width loop
|
||||
wait until clk = '1' and clk'event;
|
||||
end loop; -- n
|
||||
wave_in <= '0';
|
||||
*/
|
||||
end process pWAVE_IN_GEN;
|
||||
|
||||
-- Generate the reference wave
|
||||
pWAVE_REF_GEN : process
|
||||
begin
|
||||
wave_delayed <= '0';
|
||||
-- wait for the kickstart
|
||||
wait until kickstart_ref = '1' and kickstart_ref'event;
|
||||
-- send pulse #1
|
||||
wave_delayed <= '1';
|
||||
for n in 1 to pulse_width loop
|
||||
wait until clk = '1' and clk'event;
|
||||
end loop; -- n
|
||||
wave_delayed <= '0';
|
||||
-- send pulse #2
|
||||
for n in 1 to 6 loop
|
||||
wait until ext_time'event;
|
||||
end loop; -- n
|
||||
wave_delayed <= '1';
|
||||
for n in 1 to pulse_width loop
|
||||
wait until clk = '1' and clk'event;
|
||||
end loop; -- n
|
||||
wave_delayed <= '0';
|
||||
/*
|
||||
-- send pulse #3
|
||||
for n in 1 to 3 loop
|
||||
wait until ext_time'event;
|
||||
end loop; -- n
|
||||
wave_delayed <= '1';
|
||||
for n in 1 to pulse_width loop
|
||||
wait until clk = '1' and clk'event;
|
||||
end loop; -- n
|
||||
wave_delayed <= '0';
|
||||
*/
|
||||
end process pWAVE_REF_GEN;
|
||||
|
||||
wave_ref <= wave_delayed and not wave_delayed_d;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Test the block via configuration & control through the C&S bus
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
pCFG_and_CTRL : process
|
||||
begin
|
||||
|
||||
passed <= false;
|
||||
failed <= false;
|
||||
completed <= false;
|
||||
|
||||
init <= '0';
|
||||
offset <= 0;
|
||||
pulse_width <= 0;
|
||||
cnt_dir <= '0';
|
||||
delay <= (others => '0');
|
||||
init_time <= (others => '0');
|
||||
|
||||
-- Apply reset
|
||||
rstN <= '0';
|
||||
wait for 20*clk_period;
|
||||
--
|
||||
wait for 10*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
rstN <= '1';
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- Test-Case #1
|
||||
---------------------------------------------------------------------------
|
||||
-- Count Up, init count positive, no-wrapping all
|
||||
|
||||
-- Configure
|
||||
init <= '1';
|
||||
--
|
||||
offset <= 50;
|
||||
pulse_width <= 3;
|
||||
cnt_dir <= '0';
|
||||
delay <= std_logic_vector(to_signed(10, 32));
|
||||
init_time <= std_logic_vector(to_signed(0, 32));
|
||||
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
init <= '0';
|
||||
|
||||
-- run the test case
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
|
||||
-- check the results
|
||||
wait until clk = '1' and clk'event;
|
||||
if(error_detected = '1') then
|
||||
failed <= true;
|
||||
assert false report "ERROR on TC#1" severity error;
|
||||
completed <= true;
|
||||
else
|
||||
assert false report "TC#1 passed" severity note;
|
||||
end if;
|
||||
|
||||
passed <= true;
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- Test-Case #2
|
||||
---------------------------------------------------------------------------
|
||||
-- Count Up, init count negative, no-wrapping at all
|
||||
|
||||
-- Configure
|
||||
init <= '1';
|
||||
--
|
||||
offset <= 50;
|
||||
pulse_width <= 3;
|
||||
cnt_dir <= '0';
|
||||
delay <= std_logic_vector(to_signed(10, 32));
|
||||
init_time <= std_logic_vector(to_signed(-100, 32));
|
||||
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
init <= '0';
|
||||
|
||||
-- run the test case
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
|
||||
-- check the results
|
||||
wait until clk = '1' and clk'event;
|
||||
if(error_detected = '1') then
|
||||
failed <= true;
|
||||
assert false report "ERROR on TC#2" severity error;
|
||||
completed <= true;
|
||||
else
|
||||
assert false report "TC#2 passed" severity note;
|
||||
end if;
|
||||
|
||||
passed <= true;
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- Test-Case #3
|
||||
---------------------------------------------------------------------------
|
||||
-- Count Up, init count negative, counter wrapping between the rising and
|
||||
-- falling edge of the input pulse
|
||||
|
||||
-- Configure
|
||||
init <= '1';
|
||||
--
|
||||
offset <= 50;
|
||||
pulse_width <= 3;
|
||||
cnt_dir <= '0';
|
||||
delay <= std_logic_vector(to_signed(10, 32));
|
||||
init_time <= std_logic_vector(to_signed(-52, 32));
|
||||
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
init <= '0';
|
||||
|
||||
-- run the test case
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
|
||||
-- check the results
|
||||
wait until clk = '1' and clk'event;
|
||||
if(error_detected = '1') then
|
||||
failed <= true;
|
||||
assert false report "ERROR on TC#3" severity error;
|
||||
completed <= true;
|
||||
else
|
||||
assert false report "TC#3 passed" severity note;
|
||||
end if;
|
||||
|
||||
passed <= true;
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- Test-Case #4
|
||||
---------------------------------------------------------------------------
|
||||
-- Count Up, init count negative, counter wrapping between the rising and
|
||||
-- falling edge of the output pulse
|
||||
|
||||
-- Configure
|
||||
init <= '1';
|
||||
--
|
||||
offset <= 50;
|
||||
pulse_width <= 3;
|
||||
cnt_dir <= '0';
|
||||
delay <= std_logic_vector(to_signed(10, 32));
|
||||
init_time <= std_logic_vector(to_signed(-62, 32));
|
||||
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
init <= '0';
|
||||
|
||||
-- run the test case
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
|
||||
-- check the results
|
||||
wait until clk = '1' and clk'event;
|
||||
if(error_detected = '1') then
|
||||
failed <= true;
|
||||
assert false report "ERROR on TC#4" severity error;
|
||||
completed <= true;
|
||||
else
|
||||
assert false report "TC#4 passed" severity note;
|
||||
end if;
|
||||
|
||||
passed <= true;
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- Test-Case #5
|
||||
---------------------------------------------------------------------------
|
||||
-- Count Down, init count positive, no-wrapping all
|
||||
|
||||
-- Configure
|
||||
init <= '1';
|
||||
--
|
||||
offset <= 50;
|
||||
pulse_width <= 3;
|
||||
cnt_dir <= '1';
|
||||
delay <= std_logic_vector(to_signed(10, 32));
|
||||
init_time <= std_logic_vector(to_signed(100, 32));
|
||||
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
init <= '0';
|
||||
|
||||
-- run the test case
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
|
||||
-- check the results
|
||||
wait until clk = '1' and clk'event;
|
||||
if(error_detected = '1') then
|
||||
failed <= true;
|
||||
assert false report "ERROR on TC#5" severity error;
|
||||
completed <= true;
|
||||
else
|
||||
assert false report "TC#5 passed" severity note;
|
||||
end if;
|
||||
|
||||
passed <= true;
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- Test-Case #6
|
||||
---------------------------------------------------------------------------
|
||||
-- Count Down, init count negative, no-wrapping at all
|
||||
|
||||
-- Configure
|
||||
init <= '1';
|
||||
--
|
||||
offset <= 50;
|
||||
pulse_width <= 3;
|
||||
cnt_dir <= '1';
|
||||
delay <= std_logic_vector(to_signed(10, 32));
|
||||
init_time <= std_logic_vector(to_signed(-100, 32));
|
||||
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
init <= '0';
|
||||
|
||||
-- run the test case
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
|
||||
-- check the results
|
||||
wait until clk = '1' and clk'event;
|
||||
if(error_detected = '1') then
|
||||
failed <= true;
|
||||
assert false report "ERROR on TC#6" severity error;
|
||||
completed <= true;
|
||||
else
|
||||
assert false report "TC#6 passed" severity note;
|
||||
end if;
|
||||
|
||||
passed <= true;
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- Test-Case #7
|
||||
---------------------------------------------------------------------------
|
||||
-- Count Down, init count positive, counter wrapping between the rising and
|
||||
-- falling edge of the input pulse
|
||||
|
||||
-- Configure
|
||||
init <= '1';
|
||||
--
|
||||
offset <= 50;
|
||||
pulse_width <= 3;
|
||||
cnt_dir <= '1';
|
||||
delay <= std_logic_vector(to_signed(10, 32));
|
||||
init_time <= std_logic_vector(to_signed(51, 32));
|
||||
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
init <= '0';
|
||||
|
||||
-- run the test case
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
|
||||
-- check the results
|
||||
wait until clk = '1' and clk'event;
|
||||
if(error_detected = '1') then
|
||||
failed <= true;
|
||||
assert false report "ERROR on TC#7" severity error;
|
||||
completed <= true;
|
||||
else
|
||||
assert false report "TC#7 passed" severity note;
|
||||
end if;
|
||||
|
||||
passed <= true;
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- Test-Case #8
|
||||
---------------------------------------------------------------------------
|
||||
-- Count Down, init count positive, counter wrapping between the rising and
|
||||
-- falling edge of the output pulse
|
||||
|
||||
-- Configure
|
||||
init <= '1';
|
||||
--
|
||||
offset <= 50;
|
||||
pulse_width <= 3;
|
||||
cnt_dir <= '1';
|
||||
delay <= std_logic_vector(to_signed(10, 32));
|
||||
init_time <= std_logic_vector(to_signed(62, 32));
|
||||
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
init <= '0';
|
||||
|
||||
-- run the test case
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
|
||||
-- check the results
|
||||
wait until clk = '1' and clk'event;
|
||||
if(error_detected = '1') then
|
||||
failed <= true;
|
||||
assert false report "ERROR on TC#8" severity error;
|
||||
completed <= true;
|
||||
else
|
||||
assert false report "TC#8 passed" severity note;
|
||||
end if;
|
||||
|
||||
passed <= true;
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- Test-Case #9
|
||||
---------------------------------------------------------------------------
|
||||
-- Check the minimum latency
|
||||
|
||||
-- Configure
|
||||
init <= '1';
|
||||
--
|
||||
offset <= 50;
|
||||
pulse_width <= 3;
|
||||
cnt_dir <= '1';
|
||||
delay <= std_logic_vector(to_signed(3, 32));
|
||||
init_time <= std_logic_vector(to_signed(62, 32));
|
||||
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
init <= '0';
|
||||
|
||||
-- run the test case
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
wait until wave_ref = '1';
|
||||
wait until wave_ref = '0';
|
||||
|
||||
-- check the results
|
||||
wait until clk = '1' and clk'event;
|
||||
if(error_detected = '1') then
|
||||
failed <= true;
|
||||
assert false report "ERROR on TC#9" severity error;
|
||||
completed <= true;
|
||||
else
|
||||
assert false report "TC#9 passed" severity note;
|
||||
end if;
|
||||
|
||||
passed <= true;
|
||||
wait for 5*clk_period;
|
||||
wait until clk = '1' and clk'event;
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- End of Testing
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
completed <= true;
|
||||
|
||||
wait for 1 ms;
|
||||
|
||||
end process pCFG_and_CTRL;
|
||||
|
||||
end behav;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue