-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_LZcountshift.vhd
108 lines (75 loc) · 2.42 KB
/
test_LZcountshift.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.all;
entity test_LZcountshift is
end test_LZcountshift;
architecture test of test_LZcountshift is
component LZcountshift
port (
-- Input vector
x : in std_logic_vector(13 downto 0);
-- Number of leading zeros
nlzeros : out unsigned(3 downto 0);
-- Output vector left-shifted nlzeros bits
y : out std_logic_vector(13 downto 0)
);
end component;
signal x : std_logic_vector(13 downto 0);
signal nlzeros : unsigned(3 downto 0);
signal y : std_logic_vector(13 downto 0);
begin
DUT: LZcountshift
port map(
x => x,
nlzeros => nlzeros,
y => y
);
process
begin
x <= "1" & (12 downto 0 => '0');
wait for 1 ns;
assert(nlzeros = 0)
report "1 & zeros and nlzeros != 0"
severity error;
assert(y = x)
report "1 & zeros and y != x"
severity error;
----------
x <= (12 downto 0 => '0') & "1";
wait for 1 ns;
assert(nlzeros = 13)
report "zeros & 1 and nlzeros != 13"
severity error;
assert(y = ("1" & (12 downto 0 => '0')))
report "zeros & 1 and y != 1 & zeros"
severity error;
----------
x <= (13 downto 0 => '0');
wait for 1 ns;
assert(nlzeros = 14)
report "zeros and nlzeros != 14"
severity error;
assert(y = (13 downto 0 => '0'))
report "zeros and y != zeros"
severity error;
----------
x <= "00000111001100";
wait for 1 ns;
assert(nlzeros = 5)
report "00000111001100 and nlzeros != 5"
severity error;
assert(y = "11100110000000")
report "00000111001100 and wrong y"
severity error;
----------
x <= "01010011011000";
wait for 1 ns;
assert(nlzeros = 1)
report "01010011011000 and nlzeros != 1"
severity error;
assert(y = "10100110110000")
report "01010011011000 and wrong y"
severity error;
end process;
end test;