-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathblink_tb.v
57 lines (46 loc) · 984 Bytes
/
blink_tb.v
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
module testbench;
reg r_clk;
reg r_rst;
always #2 r_clk = (r_clk === 1'b0);
wire w_led_r;
wire w_led_g;
wire w_led_b;
// Instanciate the module
blink #(
.p_bit_r(9),
.p_bit_g(10),
.p_bit_b(11),
.p_bit_dev(4)
) uut (
.i_clk(r_clk),
.i_rst(r_rst),
.o_led_r(w_led_r),
.o_led_g(w_led_g),
.o_led_b(w_led_b)
);
reg [4095:0] vcdfile;
initial begin
r_rst = 1'b1;
// Clear reset after 20 time units
#10 r_rst = 1'b0;
end
initial begin
$timeformat(3, 2, " ns", 20);
if ($value$plusargs("vcd=%s", vcdfile)) begin
$dumpfile(vcdfile);
$dumpvars(0, testbench);
end
end
initial begin
repeat (1000) @(posedge r_clk);
if( uut.r_count == 0 ) begin
$display("%0t: %d", $time, uut.r_count);
$stop;
end
end
initial begin
repeat (10000) @(posedge r_clk);
$display("SUCCESS: Simulation run for 10000 cycles/ %0t.", $time);
$finish;
end
endmodule