-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestbench.vht
172 lines (163 loc) · 5.65 KB
/
testbench.vht
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
library IEEE;
use IEEE.STD_LOGIC_1164.all;
ENTITY FSMctrl_vhd_tst IS
END FSMctrl_vhd_tst;
ARCHITECTURE FSMctrl_arch OF FSMctrl_vhd_tst IS
type test_vector is record
wave_type: std_logic_vector(1 downto 0);
wave_period: std_logic_vector(1 downto 0);
wave_datapoints: std_logic_vector(1 downto 0);
val: real;
end record;
type test_vector_array is array (natural range <>) of test_vector;
--Define array values for sin wave with period 1ms, 100 sample rate
constant test_vectors : test_vector_array := (
("00","00","00",0.0),
("00","00","00",0.0627905195293134),
("00","00","00",0.125333233564304),
("00","00","00",0.187381314585725),
("00","00","00",0.248689887164855),
("00","00","00",0.309016994374947),
("00","00","00",0.368124552684678),
("00","00","00",0.425779291565073),
("00","00","00",0.481753674101715),
("00","00","00",0.535826794978997),
("00","00","00",0.587785252292473),
("00","00","00",0.637423989748690),
("00","00","00",0.684547105928689),
("00","00","00",0.728968627421412),
("00","00","00",0.770513242775789),
("00","00","00",0.809016994374948),
("00","00","00",0.844327925502015),
("00","00","00",0.876306680043864),
("00","00","00",0.904827052466020),
("00","00","00",0.929776485888251),
("00","00","00",0.951056516295154),
("00","00","00",0.968583161128631),
("00","00","00",0.982287250728689),
("00","00","00",0.992114701314478),
("00","00","00",0.998026728428272),
("00","00","00",1.0),
("00","00","00",0.998026728428272),
("00","00","00",0.992114701314478),
("00","00","00",0.982287250728689),
("00","00","00",0.968583161128631),
("00","00","00",0.951056516295154),
("00","00","00",0.929776485888252),
("00","00","00",0.904827052466020),
("00","00","00",0.876306680043864),
("00","00","00",0.844327925502015),
("00","00","00",0.809016994374948),
("00","00","00",0.770513242775789),
("00","00","00",0.728968627421411),
("00","00","00",0.684547105928689),
("00","00","00",0.637423989748690),
("00","00","00",0.587785252292473),
("00","00","00",0.535826794978997),
("00","00","00",0.481753674101716),
("00","00","00",0.425779291565073),
("00","00","00",0.368124552684678),
("00","00","00",0.309016994374948),
("00","00","00",0.248689887164855),
("00","00","00",0.187381314585725),
("00","00","00",0.125333233564304),
("00","00","00",0.0627905195293131),
("00","00","00",1.01064309961486e-15),
("00","00","00",-0.0627905195293125),
("00","00","00",-0.125333233564303),
("00","00","00",-0.187381314585724),
("00","00","00",-0.248689887164854),
("00","00","00",-0.309016994374946),
("00","00","00",-0.368124552684678),
("00","00","00",-0.425779291565072),
("00","00","00",-0.481753674101715),
("00","00","00",-0.535826794978996),
("00","00","00",-0.587785252292473),
("00","00","00",-0.637423989748689),
("00","00","00",-0.684547105928688),
("00","00","00",-0.728968627421411),
("00","00","00",-0.770513242775789),
("00","00","00",-0.809016994374947),
("00","00","00",-0.844327925502015),
("00","00","00",-0.876306680043864),
("00","00","00",-0.904827052466019),
("00","00","00",-0.929776485888251),
("00","00","00",-0.951056516295154),
("00","00","00",-0.968583161128631),
("00","00","00",-0.982287250728689),
("00","00","00",-0.992114701314478),
("00","00","00",-0.998026728428272),
("00","00","00",-1.0),
("00","00","00",-0.998026728428272),
("00","00","00",-0.992114701314478),
("00","00","00",-0.982287250728689),
("00","00","00",-0.968583161128631),
("00","00","00",-0.951056516295154),
("00","00","00",-0.929776485888252),
("00","00","00",-0.904827052466020),
("00","00","00",-0.876306680043864),
("00","00","00",-0.844327925502016),
("00","00","00",-0.809016994374948),
("00","00","00",-0.770513242775790),
("00","00","00",-0.728968627421412),
("00","00","00",-0.684547105928689),
("00","00","00",-0.637423989748690),
("00","00","00",-0.587785252292474),
("00","00","00",-0.535826794978997),
("00","00","00",-0.481753674101715),
("00","00","00",-0.425779291565074),
("00","00","00",-0.368124552684679),
("00","00","00",-0.309016994374948),
("00","00","00",-0.248689887164855),
("00","00","00",-0.187381314585726),
("00","00","00",-0.125333233564305),
("00","00","00",-0.0627905195293142));
signal CLOCK_50 : std_logic := '0';
constant clk_period_half : time := 10 ns;
signal reset: std_logic:='1';
signal start: std_logic:='1';
signal wave_type: std_logic_vector(1 downto 0);
signal wave_period: std_logic_vector(1 downto 0);
signal wave_datapoints: std_logic_vector(1 downto 0);
signal val: real;
component top
port (
CLOCK_50: in std_logic;
reset: in std_logic;
start: in std_logic;
wave_type: in std_logic_vector(1 downto 0);
wave_period: in std_logic_vector(1 downto 0);
wave_datapoints: in std_logic_vector(1 downto 0);
val: out real
);
end component;
BEGIN
uut: top PORT MAP( --Top Routing
CLOCK_50 => CLOCK_50,
reset => reset,
start => start,
wave_type => wave_type,
wave_period => wave_period,
wave_datapoints => wave_datapoints,
val => val
);
test : process
begin
wave_period <= test_vectors(0).wave_period;
wave_type <= test_vectors(0).wave_type;
wave_datapoints <= test_vectors(0).wave_datapoints;
for i in 0 to 99 loop
wait for 10 us;
assert( (val = test_vectors(i).val))
report "test_vector " & integer'image(i) & " failed "
severity error;
end loop;
end process test;
always :process -- Clock process definitions
begin
CLOCK_50 <= not CLOCK_50;
wait for 10 ns;
CLOCK_50 <= not CLOCK_50;
wait for 10 ns;
end process;
END FSMctrl_arch;