forked from nanamake/vcd2json
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.v
More file actions
81 lines (64 loc) · 1.39 KB
/
Copy pathtimer.v
File metadata and controls
81 lines (64 loc) · 1.39 KB
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
`timescale 1ns/1ns
module timer (
input clock,
input reset,
output reg pulse
);
reg [3:0] count;
wire count_eq11;
always @(posedge clock) begin
if (reset | count_eq11) begin
count <= 4'd0;
end else begin
count <= count + 1'b1;
end
end
assign count_eq11 = (count == 4'd11);
always @(posedge clock) begin
pulse <= count_eq11;
end
endmodule
module tb_timer;
reg clock;
reg reset;
wire pulse;
timer u_timer (
.clock (clock ),
.reset (reset ),
.pulse (pulse )
);
initial begin
forever begin
clock = 0; #10;
clock = 1; #10;
end
end
initial begin
reset = 0;
repeat(5) @(posedge clock);
reset <= 1;
repeat(5) @(posedge clock);
reset <= 0;
end
initial begin
forever begin
@(reset);
$display("reset=%b at time %0d", reset, $time);
end
end
initial begin
forever begin
@(pulse);
$display("pulse=%b at time %0d", pulse, $time);
end
end
initial begin
#1000;
$display("Simulation finished.");
$finish;
end
initial begin
$dumpfile("timer.vcd");
$dumpvars(0, tb_timer);
end
endmodule