-
Notifications
You must be signed in to change notification settings - Fork 0
/
tb_avm_arbit.vhd
333 lines (295 loc) · 12.6 KB
/
tb_avm_arbit.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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity tb_avm_arbit is
generic (
G_SINGLE_REQUEST_ONLY : boolean := true;
G_PREFER_SWAP : boolean := true;
G_M0_START : integer := 11;
G_M1_START : integer := 10;
G_REQ_PAUSE : integer := 3;
G_RESP_PAUSE : integer := 4
);
end entity tb_avm_arbit;
architecture simulation of tb_avm_arbit is
constant C_DATA_SIZE : integer := 16;
constant C_ADDRESS_SIZE : integer := 6;
constant C_CLK_PERIOD : time := 10 ns;
signal clk : std_logic := '1';
signal rst : std_logic := '1';
signal running : std_logic := '1';
signal m0_avm_has_started : std_logic := '0';
signal m0_avm_start : std_logic;
signal m0_avm_wait : std_logic;
signal m0_avm_waitrequest : std_logic;
signal m0_avm_write : std_logic;
signal m0_avm_read : std_logic;
signal m0_avm_address : std_logic_vector(C_ADDRESS_SIZE - 1 downto 0);
signal m0_avm_writedata : std_logic_vector(C_DATA_SIZE - 1 downto 0);
signal m0_avm_byteenable : std_logic_vector(C_DATA_SIZE / 8 - 1 downto 0);
signal m0_avm_burstcount : std_logic_vector(7 downto 0);
signal m0_avm_readdata : std_logic_vector(C_DATA_SIZE - 1 downto 0);
signal m0_avm_readdatavalid : std_logic;
signal m1_avm_has_started : std_logic := '0';
signal m1_avm_start : std_logic;
signal m1_avm_wait : std_logic;
signal m1_avm_waitrequest : std_logic;
signal m1_avm_write : std_logic;
signal m1_avm_read : std_logic;
signal m1_avm_address : std_logic_vector(C_ADDRESS_SIZE - 1 downto 0);
signal m1_avm_writedata : std_logic_vector(C_DATA_SIZE - 1 downto 0);
signal m1_avm_byteenable : std_logic_vector(C_DATA_SIZE / 8 - 1 downto 0);
signal m1_avm_burstcount : std_logic_vector(7 downto 0);
signal m1_avm_readdata : std_logic_vector(C_DATA_SIZE - 1 downto 0);
signal m1_avm_readdatavalid : std_logic;
signal s_avm_waitrequest : std_logic;
signal s_avm_write : std_logic;
signal s_avm_read : std_logic;
signal s_avm_address : std_logic_vector(C_ADDRESS_SIZE downto 0);
signal s_avm_writedata : std_logic_vector(C_DATA_SIZE - 1 downto 0);
signal s_avm_byteenable : std_logic_vector(C_DATA_SIZE / 8 - 1 downto 0);
signal s_avm_burstcount : std_logic_vector(7 downto 0);
signal s_avm_readdata : std_logic_vector(C_DATA_SIZE - 1 downto 0);
signal s_avm_readdatavalid : std_logic;
signal pipe_avm_waitrequest : std_logic;
signal pipe_avm_write : std_logic;
signal pipe_avm_read : std_logic;
signal pipe_avm_address : std_logic_vector(C_ADDRESS_SIZE downto 0);
signal pipe_avm_writedata : std_logic_vector(C_DATA_SIZE - 1 downto 0);
signal pipe_avm_byteenable : std_logic_vector(C_DATA_SIZE / 8 - 1 downto 0);
signal pipe_avm_burstcount : std_logic_vector(7 downto 0);
signal pipe_avm_readdata : std_logic_vector(C_DATA_SIZE - 1 downto 0);
signal pipe_avm_readdatavalid : std_logic;
begin
---------------------------------------------------------
-- Controller clock and reset
---------------------------------------------------------
clk <= running and not clk after C_CLK_PERIOD / 2;
rst <= '1', '0' after 10 * C_CLK_PERIOD;
m0_avm_start_proc : process
begin
m0_avm_start <= '0';
wait until rst = '0';
for i in 0 to G_M0_START loop
wait until clk = '1';
end loop;
m0_avm_start <= '1';
wait until clk = '1';
m0_avm_start <= '0';
wait;
end process m0_avm_start_proc;
m1_avm_start_proc : process
begin
m1_avm_start <= '0';
wait until rst = '0';
for i in 0 to G_M1_START loop
wait until clk = '1';
end loop;
m1_avm_start <= '1';
wait until clk = '1';
m1_avm_start <= '0';
wait;
end process m1_avm_start_proc;
has_started_proc : process (clk)
begin
if rising_edge(clk) then
if m0_avm_start = '1' then
m0_avm_has_started <= '1';
end if;
if m1_avm_start = '1' then
m1_avm_has_started <= '1';
end if;
end if;
end process has_started_proc;
stop_test_proc : process
begin
wait until m0_avm_has_started = '1' and m1_avm_has_started = '1';
wait until m0_avm_wait = '0' and m1_avm_wait = '0';
wait until clk = '1';
running <= '0';
wait;
end process stop_test_proc;
---------------------------------------------------------
-- Instantiate Master 0
---------------------------------------------------------
avm_master3_0_inst : entity work.avm_master3
generic map (
G_SINGLE_REQUEST_ONLY => G_SINGLE_REQUEST_ONLY,
G_SEED => X"CAFEBABEDEADBEEF",
G_INIT_FIRST => true,
G_ADDRESS_SIZE => C_ADDRESS_SIZE,
G_DATA_SIZE => C_DATA_SIZE
)
port map (
clk_i => clk,
rst_i => rst,
start_i => m0_avm_start,
wait_o => m0_avm_wait,
m_avm_waitrequest_i => m0_avm_waitrequest,
m_avm_write_o => m0_avm_write,
m_avm_read_o => m0_avm_read,
m_avm_address_o => m0_avm_address,
m_avm_writedata_o => m0_avm_writedata,
m_avm_byteenable_o => m0_avm_byteenable,
m_avm_burstcount_o => m0_avm_burstcount,
m_avm_readdata_i => m0_avm_readdata,
m_avm_readdatavalid_i => m0_avm_readdatavalid
); -- avm_master3_0_inst
avm_verifier_0_inst : entity work.avm_verifier
generic map (
G_INIT_ZEROS => false,
G_ADDRESS_SIZE => C_ADDRESS_SIZE,
G_DATA_SIZE => C_DATA_SIZE
)
port map (
clk_i => clk,
rst_i => rst,
avm_waitrequest_i => m0_avm_waitrequest,
avm_write_i => m0_avm_write,
avm_read_i => m0_avm_read,
avm_address_i => m0_avm_address,
avm_writedata_i => m0_avm_writedata,
avm_byteenable_i => m0_avm_byteenable,
avm_burstcount_i => m0_avm_burstcount,
avm_readdata_i => m0_avm_readdata,
avm_readdatavalid_i => m0_avm_readdatavalid
); -- avm_verifier_0_inst
---------------------------------------------------------
-- Instantiate Master 1
---------------------------------------------------------
avm_master3_1_inst : entity work.avm_master3
generic map (
G_SINGLE_REQUEST_ONLY => G_SINGLE_REQUEST_ONLY,
G_SEED => X"BABEDEADBEEFCAFE",
G_INIT_FIRST => true,
G_ADDRESS_SIZE => C_ADDRESS_SIZE,
G_DATA_SIZE => C_DATA_SIZE
)
port map (
clk_i => clk,
rst_i => rst,
start_i => m1_avm_start,
wait_o => m1_avm_wait,
m_avm_waitrequest_i => m1_avm_waitrequest,
m_avm_write_o => m1_avm_write,
m_avm_read_o => m1_avm_read,
m_avm_address_o => m1_avm_address,
m_avm_writedata_o => m1_avm_writedata,
m_avm_byteenable_o => m1_avm_byteenable,
m_avm_burstcount_o => m1_avm_burstcount,
m_avm_readdata_i => m1_avm_readdata,
m_avm_readdatavalid_i => m1_avm_readdatavalid
); -- avm_master3_1_inst
avm_verifier_1_inst : entity work.avm_verifier
generic map (
G_INIT_ZEROS => false,
G_ADDRESS_SIZE => C_ADDRESS_SIZE,
G_DATA_SIZE => C_DATA_SIZE
)
port map (
clk_i => clk,
rst_i => rst,
avm_waitrequest_i => m1_avm_waitrequest,
avm_write_i => m1_avm_write,
avm_read_i => m1_avm_read,
avm_address_i => m1_avm_address,
avm_writedata_i => m1_avm_writedata,
avm_byteenable_i => m1_avm_byteenable,
avm_burstcount_i => m1_avm_burstcount,
avm_readdata_i => m1_avm_readdata,
avm_readdatavalid_i => m1_avm_readdatavalid
); -- avm_verifier_1_inst
---------------------------------------------------------
-- DUT
---------------------------------------------------------
avm_arbit_inst : entity work.avm_arbit
generic map (
G_PREFER_SWAP => G_PREFER_SWAP,
G_ADDRESS_SIZE => C_ADDRESS_SIZE + 1,
G_DATA_SIZE => C_DATA_SIZE
)
port map (
clk_i => clk,
rst_i => rst,
s0_avm_waitrequest_o => m0_avm_waitrequest,
s0_avm_write_i => m0_avm_write,
s0_avm_read_i => m0_avm_read,
s0_avm_address_i => "0" & m0_avm_address,
s0_avm_writedata_i => m0_avm_writedata,
s0_avm_byteenable_i => m0_avm_byteenable,
s0_avm_burstcount_i => m0_avm_burstcount,
s0_avm_readdata_o => m0_avm_readdata,
s0_avm_readdatavalid_o => m0_avm_readdatavalid,
s1_avm_waitrequest_o => m1_avm_waitrequest,
s1_avm_write_i => m1_avm_write,
s1_avm_read_i => m1_avm_read,
s1_avm_address_i => "1" & m1_avm_address,
s1_avm_writedata_i => m1_avm_writedata,
s1_avm_byteenable_i => m1_avm_byteenable,
s1_avm_burstcount_i => m1_avm_burstcount,
s1_avm_readdata_o => m1_avm_readdata,
s1_avm_readdatavalid_o => m1_avm_readdatavalid,
m_avm_waitrequest_i => s_avm_waitrequest,
m_avm_write_o => s_avm_write,
m_avm_read_o => s_avm_read,
m_avm_address_o => s_avm_address,
m_avm_writedata_o => s_avm_writedata,
m_avm_byteenable_o => s_avm_byteenable,
m_avm_burstcount_o => s_avm_burstcount,
m_avm_readdata_i => s_avm_readdata,
m_avm_readdatavalid_i => s_avm_readdatavalid
); -- avm_arbit_inst
---------------------------------------------------------
-- Instantiate avm_pipe
---------------------------------------------------------
avm_pipe_inst : entity work.avm_pipe
generic map (
G_ADDRESS_SIZE => C_ADDRESS_SIZE + 1,
G_DATA_SIZE => C_DATA_SIZE
)
port map (
clk_i => clk,
rst_i => rst,
s_avm_waitrequest_o => s_avm_waitrequest,
s_avm_write_i => s_avm_write,
s_avm_read_i => s_avm_read,
s_avm_address_i => s_avm_address,
s_avm_writedata_i => s_avm_writedata,
s_avm_byteenable_i => s_avm_byteenable,
s_avm_burstcount_i => s_avm_burstcount,
s_avm_readdata_o => s_avm_readdata,
s_avm_readdatavalid_o => s_avm_readdatavalid,
m_avm_waitrequest_i => pipe_avm_waitrequest,
m_avm_write_o => pipe_avm_write,
m_avm_read_o => pipe_avm_read,
m_avm_address_o => pipe_avm_address,
m_avm_writedata_o => pipe_avm_writedata,
m_avm_byteenable_o => pipe_avm_byteenable,
m_avm_burstcount_o => pipe_avm_burstcount,
m_avm_readdata_i => pipe_avm_readdata,
m_avm_readdatavalid_i => pipe_avm_readdatavalid
); -- avm_pipe_inst
---------------------------------------------------------
-- Instantiate Slave
---------------------------------------------------------
avm_memory_pause_inst : entity work.avm_memory_pause
generic map (
G_REQ_PAUSE => G_REQ_PAUSE,
G_RESP_PAUSE => G_RESP_PAUSE,
G_ADDRESS_SIZE => C_ADDRESS_SIZE + 1,
G_DATA_SIZE => C_DATA_SIZE
)
port map (
clk_i => clk,
rst_i => rst,
avm_waitrequest_o => pipe_avm_waitrequest,
avm_write_i => pipe_avm_write,
avm_read_i => pipe_avm_read,
avm_address_i => pipe_avm_address,
avm_writedata_i => pipe_avm_writedata,
avm_byteenable_i => pipe_avm_byteenable,
avm_burstcount_i => pipe_avm_burstcount,
avm_readdata_o => pipe_avm_readdata,
avm_readdatavalid_o => pipe_avm_readdatavalid
); -- avm_memory_pause_inst
end architecture simulation;