-
Notifications
You must be signed in to change notification settings - Fork 0
/
top_tb.v
68 lines (56 loc) · 883 Bytes
/
top_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
57
58
59
60
61
62
63
64
65
66
67
68
`timescale 1ns / 1ns
module main_tb;
reg clk, rst, en;
wire [4:0] out;
top top (.*);
parameter PERIOD = 20; // 20ns period
parameter ENDTIME = PERIOD * 10; // run for 10 clk cycles
initial begin
$dumpfile("project.vcd");
$dumpvars;
main;
end
// main task
task main;
fork
init;
clk_gen;
rst_gen;
operation;
end_sim;
join
endtask
// initialise inputs
task init;
begin
clk = 0;
en = 'b0;
rst = 'b1;
end
endtask
// generate 50MHz fastclk
task clk_gen;
begin
forever #(PERIOD/2) clk = ~clk;
end
endtask
// reset generation
task rst_gen;
begin
#PERIOD rst = 0;
#PERIOD en = 1;
end
endtask
// operation to test
task operation;
begin
// no operation
end
endtask
// end simulation
task end_sim;
begin
#ENDTIME $finish;
end
endtask
endmodule