Motion FPGA
Motion FPGA for the MachX02-7000HE Breakout Board
delay_line_tb.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 --! @file
3 --! @brief Delay-line test bench
4 -------------------------------------------------------------------------------
5 
6 --! Using IEEE library
7 LIBRARY ieee;
8 
9 --! Using IEEE standard logic components
10 USE ieee.std_logic_1164.ALL;
11 
12 --! @brief delay-line test bench
13 ENTITY delay_line_tb IS
14 END ENTITY delay_line_tb;
15 
16 --! Architecture tb of delay_line_tb entity
17 ARCHITECTURE tb OF delay_line_tb IS
18 
19  --! Stimulus record type
20  TYPE t_stimulus IS RECORD
21  name : string(1 TO 20); --! Stimulus name
22  rst : std_logic_vector(0 TO 7); --! rst input to uut
23  sig_in : std_logic_vector(0 TO 7); --! signal input
24  sig_out : std_logic_vector(0 TO 7); --! Expected signal output
25  END RECORD t_stimulus;
26 
27  --! Stimulus array type
28  TYPE t_stimulus_array IS ARRAY(natural RANGE <>) OF t_stimulus;
29 
30  --! Test bench clock period
31  CONSTANT c_clk_period : time := 10 ns;
32 
33  --! Test stimulus
35  (
36  (
37  name => "Hold in reset ",
38  rst => "11111111",
39  sig_in => "01010101",
40  sig_out => "00000000"
41  ),
42  (
43  name => "Active ",
44  rst => "00000000",
45  sig_in => "01111000",
46  sig_out => "00011110"
47  )
48  );
49 
50  -- Signals to delay-line uut
51  SIGNAL clk : std_logic; --! Clock
52  SIGNAL rst : std_logic; --! Reset
53  SIGNAL sig_in : std_logic; --! Signal in to uut
54  SIGNAL sig_out : std_logic; --! Signal out from uut
55 
56 BEGIN
57 
58  --! Instantiate delay_line as unit under test
59  i_uut : ENTITY work.delay_line(rtl)
60  GENERIC MAP (
61  count => 2
62  )
63  PORT MAP (
64  clk_in => clk,
65  rst_in => rst,
66  sig_in => sig_in,
67  sig_out => sig_out
68  );
69 
70  --! @brief Clock generation process
71  pr_clock : PROCESS IS
72  BEGIN
73 
74  -- Low for 1/2 clock period
75  clk <= '0';
76  WAIT FOR c_clk_period / 2;
77 
78  -- High for 1/2 clock period
79  clk <= '1';
80  WAIT FOR c_clk_period / 2;
81 
82  END PROCESS pr_clock;
83 
84  --! @brief Stimulus process to drive PWM unit under test
85  pr_stimulus : PROCESS IS
86  BEGIN
87 
88  -- Initialize entity inputs
89  rst <= '1';
90  sig_in <= '0';
91  WAIT FOR c_clk_period;
92 
93  -- Loop over stimulus
94  FOR s IN c_stimulus'range LOOP
95  -- Log start of stimulus
96  REPORT "Starting: " & c_stimulus(s).name SEVERITY note;
97 
98  -- Loop for test stimulus
99  FOR t IN 0 TO 7 LOOP
100  -- Set inputs then wait for clock to rise
101  rst <= c_stimulus(s).rst(t);
102  sig_in <= c_stimulus(s).sig_in(t);
103  WAIT UNTIL clk = '1';
104 
105  -- Wait for clk to fall
106  WAIT UNTIL clk = '0';
107 
108  -- Assert outputs
109  ASSERT sig_out = c_stimulus(s).sig_out(t)
110  REPORT "At time " & integer'image(t)
111  & " expected sig_out = " & std_logic'image(c_stimulus(s).sig_out(t))
112  & " but got " & std_logic'image(sig_out)
113  SEVERITY error;
114  END LOOP;
115  END LOOP;
116 
117  -- Log end of test
118  REPORT "Finished" SEVERITY note;
119 
120  -- Finish the simulation
121  std.env.finish;
122 
123  END PROCESS pr_stimulus;
124 
125 END ARCHITECTURE tb;
Delay-line entity.
Definition: delay_line.vhd:15
in sig_instd_logic
Input signal.
Definition: delay_line.vhd:22
std_logic_vector( 0 TO 7) sig_in
signal input
time := 10 ns c_clk_period
Test bench clock period.
std_logic clk
Clock.
countnatural range 1 TO natural'high:= 2
Delay length.
Definition: delay_line.vhd:18
delay-line test bench
_library_ ieeeieee
Using IEEE library.
Definition: clk_div_n_tb.vhd:7
out sig_outstd_logic
Output signal.
Definition: delay_line.vhd:24
t_stimulus
Stimulus record type.
in clk_instd_logic
Clock.
Definition: delay_line.vhd:20
t_stimulus_array :=((name => "Hold in reset ",rst => "11111111",sig_in => "01010101",sig_out => "00000000"),(name => "Active ",rst => "00000000",sig_in => "01111000",sig_out => "00011110")) c_stimulus
Test stimulus.
string( 1 TO 20) name
Stimulus name.
std_logic_vector( 0 TO 7) rst
rst input to uut
in rst_instd_logic
Asynchronous reset.
Definition: delay_line.vhd:21
array(natural range <> ) of t_stimulus t_stimulus_array
Stimulus array type.
std_logic_vector( 0 TO 7) sig_out
Expected signal output.