1 |
3 |
rehayes |
////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
//
|
3 |
|
|
// WISHBONE revB.2 compliant Programable Interval Timer - Test Bench
|
4 |
|
|
//
|
5 |
|
|
// Author: Bob Hayes
|
6 |
|
|
// rehayes@opencores.org
|
7 |
|
|
//
|
8 |
|
|
// Downloaded from: http://www.opencores.org/projects/pit.....
|
9 |
|
|
//
|
10 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
11 |
|
|
// Copyright (c) 2009, Robert Hayes
|
12 |
|
|
//
|
13 |
|
|
// All rights reserved.
|
14 |
|
|
//
|
15 |
|
|
// Redistribution and use in source and binary forms, with or without
|
16 |
|
|
// modification, are permitted provided that the following conditions are met:
|
17 |
|
|
// * Redistributions of source code must retain the above copyright
|
18 |
|
|
// notice, this list of conditions and the following disclaimer.
|
19 |
|
|
// * Redistributions in binary form must reproduce the above copyright
|
20 |
|
|
// notice, this list of conditions and the following disclaimer in the
|
21 |
|
|
// documentation and/or other materials provided with the distribution.
|
22 |
|
|
// * Neither the name of the <organization> nor the
|
23 |
|
|
// names of its contributors may be used to endorse or promote products
|
24 |
|
|
// derived from this software without specific prior written permission.
|
25 |
|
|
//
|
26 |
|
|
// THIS SOFTWARE IS PROVIDED BY Robert Hayes ''AS IS'' AND ANY
|
27 |
|
|
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
28 |
|
|
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
29 |
|
|
// DISCLAIMED. IN NO EVENT SHALL Robert Hayes BE LIABLE FOR ANY
|
30 |
|
|
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
31 |
|
|
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
32 |
|
|
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
33 |
|
|
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
34 |
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
35 |
|
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
36 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
37 |
|
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
`include "timescale.v"
|
41 |
|
|
|
42 |
|
|
module tst_bench_top();
|
43 |
|
|
|
44 |
|
|
//
|
45 |
|
|
// wires && regs
|
46 |
|
|
//
|
47 |
|
|
reg mstr_test_clk;
|
48 |
|
|
reg [19:0] vector;
|
49 |
|
|
reg [ 7:0] test_num;
|
50 |
|
|
reg rstn;
|
51 |
|
|
reg sync_reset;
|
52 |
|
|
|
53 |
|
|
wire [31:0] adr;
|
54 |
|
|
wire [15:0] dat_i, dat_o, dat0_i, dat1_i, dat2_i, dat3_i;
|
55 |
|
|
wire we;
|
56 |
|
|
wire stb;
|
57 |
|
|
wire cyc;
|
58 |
|
|
wire ack;
|
59 |
|
|
wire inta_1, inta_2, inta_3, inta_4;
|
60 |
|
|
wire count_en_1;
|
61 |
|
|
wire count_flag_1;
|
62 |
|
|
|
63 |
|
|
reg [15:0] q, qq;
|
64 |
|
|
|
65 |
|
|
wire scl, scl0_o, scl0_oen, scl1_o, scl1_oen;
|
66 |
|
|
wire sda, sda0_o, sda0_oen, sda1_o, sda1_oen;
|
67 |
|
|
|
68 |
|
|
// Name Address Locations
|
69 |
|
|
parameter PIT_CNTRL = 5'b0_0000;
|
70 |
|
|
parameter PIT_MOD = 5'b0_0001;
|
71 |
|
|
parameter PIT_COUNT = 5'b0_0010;
|
72 |
|
|
|
73 |
|
|
parameter RD = 1'b1;
|
74 |
|
|
parameter WR = 1'b0;
|
75 |
|
|
parameter SADR = 7'b0010_000;
|
76 |
|
|
|
77 |
|
|
parameter CTR_EN = 8'b1000_0000; // core enable bit
|
78 |
|
|
parameter CTR_IEN = 8'b0100_0000; // core interrupt enable bit
|
79 |
|
|
|
80 |
|
|
parameter PIT_CNTRL_SLAVE = 16'h8000; // PIT Slave mode
|
81 |
|
|
parameter PIT_CNTRL_FLAG = 16'h0004; // PIT Rollover Flag
|
82 |
|
|
parameter PIT_CNTRL_IRQEN = 16'h0002; // PIT Interupt Enable
|
83 |
|
|
parameter PIT_CNTRL_ENA = 16'h0001; // PIT Enable
|
84 |
|
|
|
85 |
|
|
parameter SLAVE_0_CNTRL = 5'b0_1000;
|
86 |
|
|
parameter SLAVE_0_MOD = 5'b0_1001;
|
87 |
|
|
parameter SLAVE_0_COUNT = 5'b0_1010;
|
88 |
|
|
|
89 |
|
|
parameter SLAVE_1_CNTRL = 5'b1_0000;
|
90 |
|
|
parameter SLAVE_1_MOD = 5'b1_0001;
|
91 |
|
|
parameter SLAVE_1_COUNT = 5'b1_0010;
|
92 |
|
|
|
93 |
|
|
parameter SLAVE_2_CNTRL_0 = 5'b1_1000;
|
94 |
|
|
parameter SLAVE_2_CNTRL_1 = 5'b1_1001;
|
95 |
|
|
parameter SLAVE_2_MOD_0 = 5'b1_1010;
|
96 |
|
|
parameter SLAVE_2_MOD_1 = 5'b1_1011;
|
97 |
|
|
parameter SLAVE_2_COUNT_0 = 5'b1_1100;
|
98 |
|
|
parameter SLAVE_2_COUNT_1 = 5'b1_1101;
|
99 |
|
|
|
100 |
|
|
// initial values and testbench setup
|
101 |
|
|
initial
|
102 |
|
|
begin
|
103 |
|
|
mstr_test_clk = 0;
|
104 |
|
|
vector = 0;
|
105 |
|
|
test_num = 0;
|
106 |
|
|
|
107 |
|
|
`ifdef WAVES
|
108 |
|
|
$shm_open("waves");
|
109 |
|
|
$shm_probe("AS",tst_bench_top,"AS");
|
110 |
|
|
$display("\nINFO: Signal dump enabled ...\n\n");
|
111 |
|
|
`endif
|
112 |
|
|
|
113 |
|
|
`ifdef WAVES_V
|
114 |
|
|
$dumpfile ("pit_wave_dump.lxt");
|
115 |
|
|
$dumpvars (0, tst_bench_top);
|
116 |
|
|
$dumpon;
|
117 |
|
|
$display("\nINFO: VCD Signal dump enabled ...\n\n");
|
118 |
|
|
`endif
|
119 |
|
|
|
120 |
|
|
end
|
121 |
|
|
|
122 |
|
|
// generate clock
|
123 |
|
|
always #20 mstr_test_clk = ~mstr_test_clk;
|
124 |
|
|
|
125 |
|
|
always @(posedge mstr_test_clk)
|
126 |
|
|
vector = vector + 1;
|
127 |
|
|
|
128 |
|
|
// hookup wishbone master model
|
129 |
|
|
wb_master_model #(.dwidth(16), .awidth(32))
|
130 |
|
|
u0 (
|
131 |
|
|
.clk(mstr_test_clk),
|
132 |
|
|
.rst(rstn),
|
133 |
|
|
.adr(adr),
|
134 |
|
|
.din(dat_i),
|
135 |
|
|
.dout(dat_o),
|
136 |
|
|
.cyc(cyc),
|
137 |
|
|
.stb(stb),
|
138 |
|
|
.we(we),
|
139 |
|
|
.sel(),
|
140 |
|
|
.ack(ack),
|
141 |
|
|
.err(1'b0),
|
142 |
|
|
.rty(1'b0)
|
143 |
|
|
);
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
// Address decoding for different PIT module instances
|
147 |
|
|
wire stb0 = stb && ~adr[4] && ~adr[3];
|
148 |
|
|
wire stb1 = stb && ~adr[4] && adr[3];
|
149 |
|
|
wire stb2 = stb && adr[4] && ~adr[3];
|
150 |
|
|
wire stb3 = stb && adr[4] && adr[3];
|
151 |
|
|
|
152 |
|
|
// Create the Read Data Bus
|
153 |
|
|
assign dat_i = ({16{stb0}} & dat0_i) |
|
154 |
|
|
({16{stb1}} & dat1_i) |
|
155 |
|
|
({16{stb2}} & dat2_i) |
|
156 |
|
|
({16{stb3}} & {8'b0, dat3_i[7:0]});
|
157 |
|
|
|
158 |
|
|
// hookup wishbone_PIT_master core - Parameters take all default values
|
159 |
|
|
// Async Reset, 16 bit Bus, 16 bit Granularity
|
160 |
|
|
pit_top pit_1(
|
161 |
|
|
// wishbone interface
|
162 |
|
|
.wb_clk_i(mstr_test_clk),
|
163 |
|
|
.wb_rst_i(1'b0),
|
164 |
|
|
.arst_i(rstn),
|
165 |
|
|
.wb_adr_i(adr[2:0]),
|
166 |
|
|
.wb_dat_i(dat_o),
|
167 |
|
|
.wb_dat_o(dat0_i),
|
168 |
|
|
.wb_we_i(we),
|
169 |
|
|
.wb_stb_i(stb0),
|
170 |
|
|
.wb_cyc_i(cyc),
|
171 |
|
|
.wb_sel_i( 2'b11 ),
|
172 |
|
|
.wb_ack_o(ack),
|
173 |
|
|
.pit_irq_o(inta_1),
|
174 |
|
|
|
175 |
|
|
.pit_o(pit_1_out),
|
176 |
|
|
.ext_sync_i(1'b0),
|
177 |
|
|
.cnt_sync_o(count_en_1),
|
178 |
|
|
.cnt_flag_o(count_flag_1)
|
179 |
|
|
);
|
180 |
|
|
|
181 |
|
|
// hookup wishbone_PIT_slave core - Parameters take all default values
|
182 |
|
|
// Sync Reset, 16 bit Bus, 16 bit Granularity
|
183 |
|
|
pit_top #(.ARST_LVL(1'b1))
|
184 |
|
|
pit_2(
|
185 |
|
|
// wishbone interface
|
186 |
|
|
.wb_clk_i(mstr_test_clk),
|
187 |
|
|
.wb_rst_i(sync_reset),
|
188 |
|
|
.arst_i(1'b0),
|
189 |
|
|
.wb_adr_i(adr[2:0]),
|
190 |
|
|
.wb_dat_i(dat_o),
|
191 |
|
|
.wb_dat_o(dat1_i),
|
192 |
|
|
.wb_we_i(we),
|
193 |
|
|
.wb_stb_i(stb1),
|
194 |
|
|
.wb_cyc_i(cyc),
|
195 |
|
|
.wb_sel_i( 2'b11 ),
|
196 |
|
|
.wb_ack_o(ack),
|
197 |
|
|
.pit_irq_o(inta_2),
|
198 |
|
|
|
199 |
|
|
.pit_o(pit_2_out),
|
200 |
|
|
.ext_sync_i(count_en_1),
|
201 |
|
|
.cnt_sync_o(count_en_2),
|
202 |
|
|
.cnt_flag_o(count_flag_2)
|
203 |
|
|
);
|
204 |
|
|
|
205 |
|
|
// hookup wishbone_PIT_slave core
|
206 |
|
|
// 16 bit Bus, 16 bit Granularity
|
207 |
|
|
pit_top #(.NO_PRESCALE(1'b1))
|
208 |
|
|
pit_3(
|
209 |
|
|
// wishbone interface
|
210 |
|
|
.wb_clk_i(mstr_test_clk),
|
211 |
|
|
.wb_rst_i(sync_reset),
|
212 |
|
|
.arst_i(1'b1),
|
213 |
|
|
.wb_adr_i(adr[2:0]),
|
214 |
|
|
.wb_dat_i(dat_o),
|
215 |
|
|
.wb_dat_o(dat2_i),
|
216 |
|
|
.wb_we_i(we),
|
217 |
|
|
.wb_stb_i(stb2),
|
218 |
|
|
.wb_cyc_i(cyc),
|
219 |
|
|
.wb_sel_i( 2'b11 ),
|
220 |
|
|
.wb_ack_o(ack),
|
221 |
|
|
.pit_irq_o(inta_3),
|
222 |
|
|
|
223 |
|
|
.pit_o(pit_3_out),
|
224 |
|
|
.ext_sync_i(count_en_1),
|
225 |
|
|
.cnt_sync_o(count_en_3),
|
226 |
|
|
.cnt_flag_o(count_flag_3)
|
227 |
|
|
);
|
228 |
|
|
|
229 |
|
|
// hookup wishbone_PIT_slave core
|
230 |
|
|
// 8 bit Bus, 8 bit Granularity
|
231 |
|
|
pit_top #(.DWIDTH(8))
|
232 |
|
|
pit_4(
|
233 |
|
|
// wishbone interface
|
234 |
|
|
.wb_clk_i(mstr_test_clk),
|
235 |
|
|
.wb_rst_i(sync_reset),
|
236 |
|
|
.arst_i(1'b1),
|
237 |
|
|
.wb_adr_i(adr[2:0]),
|
238 |
|
|
.wb_dat_i(dat_o[7:0]),
|
239 |
|
|
.wb_dat_o(dat3_i[7:0]),
|
240 |
|
|
.wb_we_i(we),
|
241 |
|
|
.wb_stb_i(stb3),
|
242 |
|
|
.wb_cyc_i(cyc),
|
243 |
|
|
.wb_sel_i( 2'b11 ),
|
244 |
|
|
.wb_ack_o(ack),
|
245 |
|
|
.pit_irq_o(inta_4),
|
246 |
|
|
|
247 |
|
|
.pit_o(pit_4_out),
|
248 |
|
|
.ext_sync_i(count_en_1),
|
249 |
|
|
.cnt_sync_o(count_en_4),
|
250 |
|
|
.cnt_flag_o(count_flag_4)
|
251 |
|
|
);
|
252 |
|
|
|
253 |
|
|
// Test Program
|
254 |
|
|
initial
|
255 |
|
|
begin
|
256 |
|
|
$display("\nstatus: %t Testbench started", $time);
|
257 |
|
|
|
258 |
|
|
// reset system
|
259 |
|
|
rstn = 1'b1; // negate reset
|
260 |
|
|
repeat(1) @(posedge mstr_test_clk);
|
261 |
|
|
sync_reset = 1'b1; // Make the sync reset 1 clock cycle long
|
262 |
|
|
#2; // move the async reset away from the clock edge
|
263 |
|
|
rstn = 1'b0; // assert async reset
|
264 |
|
|
#5; // Keep the async reset pulse with less than a clock cycle
|
265 |
|
|
rstn = 1'b1; // negate async reset
|
266 |
|
|
repeat(1) @(posedge mstr_test_clk);
|
267 |
|
|
sync_reset = 1'b0;
|
268 |
|
|
|
269 |
|
|
$display("\nstatus: %t done reset", $time);
|
270 |
|
|
test_num = test_num + 1;
|
271 |
|
|
|
272 |
|
|
repeat(2) @(posedge mstr_test_clk);
|
273 |
|
|
|
274 |
|
|
//
|
275 |
|
|
// program core
|
276 |
|
|
//
|
277 |
|
|
|
278 |
|
|
reg_test_16;
|
279 |
|
|
|
280 |
|
|
reg_test_8;
|
281 |
|
|
|
282 |
|
|
u0.wb_write(1, SLAVE_0_CNTRL, PIT_CNTRL_SLAVE); // Enable Slave Mode
|
283 |
|
|
u0.wb_write(1, SLAVE_1_CNTRL, PIT_CNTRL_SLAVE); // Enable Slave Mode
|
284 |
|
|
u0.wb_write(1, SLAVE_2_CNTRL_1, 16'h0080); // Enable Slave Mode
|
285 |
|
|
u0.wb_write(1, SLAVE_0_MOD, 16'h000a); // load Modulo
|
286 |
|
|
u0.wb_write(1, SLAVE_1_MOD, 16'h0010); // load Modulo
|
287 |
|
|
u0.wb_write(1, SLAVE_2_MOD_0, 16'h0010); // load Modulo
|
288 |
|
|
|
289 |
|
|
// Set Master Mode PS=0, Modulo=16
|
290 |
|
|
test_num = test_num + 1;
|
291 |
|
|
$display("TEST #%d Starts at vector=%d, ms_test", test_num, vector);
|
292 |
|
|
|
293 |
|
|
u0.wb_write(1, PIT_MOD, 16'h0010); // load prescaler hi-byte
|
294 |
|
|
u0.wb_write(1, PIT_CNTRL, PIT_CNTRL_ENA); // Enable to start counting
|
295 |
|
|
$display("status: %t programmed registers", $time);
|
296 |
|
|
|
297 |
|
|
wait_flag_set; // Wait for Counter to tomeout
|
298 |
|
|
u0.wb_write(1, PIT_CNTRL, PIT_CNTRL_FLAG | PIT_CNTRL_ENA); //
|
299 |
|
|
|
300 |
|
|
wait_flag_set; // Wait for Counter to tomeout
|
301 |
|
|
u0.wb_write(1, PIT_CNTRL, PIT_CNTRL_FLAG | PIT_CNTRL_ENA); //
|
302 |
|
|
|
303 |
|
|
repeat(10) @(posedge mstr_test_clk);
|
304 |
|
|
u0.wb_write(1, PIT_CNTRL, 16'b0); //
|
305 |
|
|
|
306 |
|
|
repeat(10) @(posedge mstr_test_clk);
|
307 |
|
|
|
308 |
|
|
mstr_psx_modx(2,4);
|
309 |
|
|
|
310 |
|
|
mstr_psx_modx(4,0);
|
311 |
|
|
|
312 |
|
|
repeat(100) @(posedge mstr_test_clk);
|
313 |
|
|
$display("\nTestbench done at vector=%d\n", vector);
|
314 |
|
|
$finish;
|
315 |
|
|
end
|
316 |
|
|
|
317 |
|
|
// Poll for flag set
|
318 |
|
|
task wait_flag_set;
|
319 |
|
|
begin
|
320 |
|
|
u0.wb_read(1, PIT_CNTRL, q);
|
321 |
|
|
while(~|(q & PIT_CNTRL_FLAG))
|
322 |
|
|
u0.wb_read(1, PIT_CNTRL, q); // poll it until it is set
|
323 |
|
|
$display("PIT Flag set detected at vector =%d", vector);
|
324 |
|
|
end
|
325 |
|
|
endtask
|
326 |
|
|
|
327 |
|
|
// check register bits - reset, read/write
|
328 |
|
|
task reg_test_16;
|
329 |
|
|
begin
|
330 |
|
|
test_num = test_num + 1;
|
331 |
|
|
$display("TEST #%d Starts at vector=%d, reg_test_16", test_num, vector);
|
332 |
|
|
u0.wb_cmp(0, PIT_CNTRL, 16'h4000); // verify reset
|
333 |
|
|
u0.wb_cmp(0, PIT_MOD, 16'h0000); // verify reset
|
334 |
|
|
u0.wb_cmp(0, PIT_COUNT, 16'h0001); // verify reset
|
335 |
|
|
|
336 |
|
|
u0.wb_write(1, PIT_CNTRL, 16'hfffe); // load prescaler lo-byte
|
337 |
|
|
u0.wb_cmp( 0, PIT_CNTRL, 16'hCf02); // verify write data
|
338 |
|
|
u0.wb_write(1, PIT_CNTRL, 16'h0000); // load prescaler lo-byte
|
339 |
|
|
u0.wb_cmp( 0, PIT_CNTRL, 16'h4000); // verify write data
|
340 |
|
|
|
341 |
|
|
u0.wb_write(1, PIT_MOD, 16'h5555); // load prescaler lo-byte
|
342 |
|
|
u0.wb_cmp( 0, PIT_MOD, 16'h5555); // verify write data
|
343 |
|
|
u0.wb_write(1, PIT_MOD, 16'haaaa); // load prescaler lo-byte
|
344 |
|
|
u0.wb_cmp( 0, PIT_MOD, 16'haaaa); // verify write data
|
345 |
|
|
|
346 |
|
|
u0.wb_write(0, PIT_COUNT, 16'hfffe);
|
347 |
|
|
u0.wb_cmp( 0, PIT_COUNT, 16'h0001); // verify register not writable
|
348 |
|
|
end
|
349 |
|
|
endtask
|
350 |
|
|
|
351 |
|
|
task reg_test_8;
|
352 |
|
|
begin
|
353 |
|
|
test_num = test_num + 1;
|
354 |
|
|
$display("TEST #%d Starts at vector=%d, reg_test_8", test_num, vector);
|
355 |
|
|
u0.wb_cmp(0, SLAVE_2_CNTRL_0, 16'h0000); // verify reset
|
356 |
|
|
u0.wb_cmp(0, SLAVE_2_CNTRL_1, 16'h0040); // verify reset
|
357 |
|
|
u0.wb_cmp(0, SLAVE_2_MOD_0, 16'h0000); // verify reset
|
358 |
|
|
u0.wb_cmp(0, SLAVE_2_MOD_1, 16'h0000); // verify reset
|
359 |
|
|
u0.wb_cmp(0, SLAVE_2_COUNT_0, 16'h0001); // verify reset
|
360 |
|
|
u0.wb_cmp(0, SLAVE_2_COUNT_1, 16'h0000); // verify reset
|
361 |
|
|
|
362 |
|
|
u0.wb_write(1, SLAVE_2_CNTRL_0, 16'hfffe); // load prescaler lo-byte
|
363 |
|
|
u0.wb_cmp( 0, SLAVE_2_CNTRL_0, 16'h0002); // verify write data
|
364 |
|
|
u0.wb_write(1, SLAVE_2_CNTRL_0, 16'h0000); // load prescaler lo-byte
|
365 |
|
|
u0.wb_cmp( 0, SLAVE_2_CNTRL_0, 16'h0000); // verify write data
|
366 |
|
|
u0.wb_cmp( 0, SLAVE_2_CNTRL_1, 16'h0040); // verify write data
|
367 |
|
|
|
368 |
|
|
u0.wb_write(1, SLAVE_2_MOD_0, 16'hff55); // load prescaler lo-byte
|
369 |
|
|
u0.wb_cmp( 0, SLAVE_2_MOD_0, 16'h0055); // verify write data
|
370 |
|
|
u0.wb_write(1, SLAVE_2_MOD_0, 16'hffaa); // load prescaler lo-byte
|
371 |
|
|
u0.wb_cmp( 0, SLAVE_2_MOD_0, 16'h00aa); // verify write data
|
372 |
|
|
u0.wb_write(1, SLAVE_2_MOD_1, 16'hff66); // load prescaler lo-byte
|
373 |
|
|
u0.wb_cmp( 0, SLAVE_2_MOD_1, 16'h0066); // verify write data
|
374 |
|
|
u0.wb_write(1, SLAVE_2_MOD_1, 16'hff99); // load prescaler lo-byte
|
375 |
|
|
u0.wb_cmp( 0, SLAVE_2_MOD_1, 16'h0099); // verify write data
|
376 |
|
|
u0.wb_write(1, SLAVE_2_MOD_1, 16'hff00); // load prescaler lo-byte
|
377 |
|
|
|
378 |
|
|
u0.wb_write(0, SLAVE_2_COUNT_0, 16'hfffe);
|
379 |
|
|
u0.wb_cmp( 0, SLAVE_2_COUNT_0, 16'h0001); // verify register not writable
|
380 |
|
|
u0.wb_write(0, SLAVE_2_COUNT_1, 16'hfffe);
|
381 |
|
|
u0.wb_cmp( 0, SLAVE_2_COUNT_1, 16'h0000); // verify register not writable
|
382 |
|
|
end
|
383 |
|
|
endtask
|
384 |
|
|
|
385 |
|
|
task mstr_psx_modx;
|
386 |
|
|
input [ 3:0] ps_val;
|
387 |
|
|
input [15:0] mod_val;
|
388 |
|
|
reg [15:0] cntrl_val;
|
389 |
|
|
begin
|
390 |
|
|
test_num = test_num + 1;
|
391 |
|
|
$display("TEST #%d Starts at vector=%d, mstr_psx_modx Pre=%h, Mod=%h",
|
392 |
|
|
test_num, vector, ps_val, mod_val);
|
393 |
|
|
// program internal registers
|
394 |
|
|
|
395 |
|
|
cntrl_val = {1'b0, 3'b0, ps_val, 8'b0} | PIT_CNTRL_IRQEN;
|
396 |
|
|
u0.wb_write(1, PIT_MOD, mod_val); // load modulo
|
397 |
|
|
u0.wb_write(1, PIT_CNTRL, ( cntrl_val | PIT_CNTRL_ENA)); // Enable to start counting
|
398 |
|
|
|
399 |
|
|
wait_flag_set; // Wait for Counter to timeout
|
400 |
|
|
u0.wb_write(1, PIT_CNTRL, cntrl_val | PIT_CNTRL_FLAG | PIT_CNTRL_ENA); //
|
401 |
|
|
|
402 |
|
|
wait_flag_set; // Wait for Counter to timeout
|
403 |
|
|
u0.wb_write(1, PIT_CNTRL, cntrl_val | PIT_CNTRL_FLAG | PIT_CNTRL_ENA); //
|
404 |
|
|
|
405 |
|
|
repeat(10) @(posedge mstr_test_clk);
|
406 |
|
|
|
407 |
|
|
u0.wb_write(1, PIT_CNTRL, 16'b0); //
|
408 |
|
|
|
409 |
|
|
end
|
410 |
|
|
endtask
|
411 |
|
|
|
412 |
|
|
|
413 |
|
|
endmodule // tst_bench_top
|
414 |
|
|
|