-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmux5_tb.vhd
62 lines (53 loc) · 1.8 KB
/
mux5_tb.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity mux5_tb is
end mux5_tb;
architecture behv of mux5_tb is
component mux5
port(x,y: in std_logic_vector(4 downto 0);
sel: in std_logic;
z : out std_logic_vector(4 downto 0));
end component;
--test signals
signal sel: std_logic;
signal x, y, z : std_logic_vector(4 downto 0);
begin
mux5_dut : mux5 port map (x => x, y => y, sel => sel, z => z);
process
type pattern_type is record
-- The inputs of the device.
x : std_logic_vector(4 downto 0);
y : std_logic_vector(4 downto 0);
sel : std_logic;
-- The expected outputs of the device.
z : std_logic_vector(4 downto 0);
end record;
-- The patterns to apply.
type pattern_array is array (natural range <>) of pattern_type;
constant patterns : pattern_array :=
(('0' & X"1", '0' & X"0", '0', '0' & X"1"),
('0' & X"0", '0' & X"1", '0', '0' & X"0"),
('0' & X"1", '0' & X"0", '1', '0' & X"0"),
('0' & X"1", '0' & X"1", '1', '0' & X"1"),
('0' & X"1", '0' & X"0", '0', '0' & X"1"),
('0' & X"0", '0' & X"1", '0', '0' & X"0"),
('0' & X"1", '0' & X"0", '1', '0' & X"0"),
('0' & X"1", '0' & X"1", '1', '0' & X"1"));
begin
-- Check each pattern.
for i in patterns'range loop
-- Set the inputs.
x <= patterns(i).x;
y <= patterns(i).y;
sel <= patterns(i).sel;
-- Wait for the results.
wait for 1 ns;
-- Check the outputs.
assert z = patterns(i).z
report "bad mux value" severity error;
end loop;
assert false report "end of test" severity note;
-- Wait forever; this will finish the simulation.
wait;
end process;
end behv;