-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClock_Divider_tb.v
72 lines (63 loc) · 1.15 KB
/
Clock_Divider_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
69
70
71
72
`timescale 1ns/1ps
module Clock_Divider_tb();
reg I_ref_clk_tb;
reg I_rst_n_tb;
reg I_clk_en_tb;
reg [3:0] I_div_ratio_tb;
wire O_div_clk_tb;
parameter CLK_PER = 10 ;
initial
begin
$dumpfile("Clock_Divider.vcd");
$dumpvars;
initialize();
reset();
divide(2);
reset();
divide(3);
reset();
divide(4);
reset();
divide(5);
reset();
divide(6);
reset();
divide(7);
reset();
divide(8);
reset();
divide(1);
#(10*CLK_PER)
$finish;
end
always #(CLK_PER/2) I_ref_clk_tb = ~I_ref_clk_tb ; // REF_CLK_period = 10 ns REF_CLK_frequency = 100 MHz
task initialize;
begin
I_ref_clk_tb = 0 ;
I_rst_n_tb = 1 ;
I_clk_en_tb = 0 ;
end
endtask
task reset;
begin
I_rst_n_tb = 0 ;
#(2*CLK_PER)
I_rst_n_tb = 1 ;
end
endtask
task divide;
input [3:0] div;
begin
I_clk_en_tb = 1;
I_div_ratio_tb = div ;
#(20*CLK_PER);
end
endtask
Clock_Divider DUT(
.I_ref_clk(I_ref_clk_tb),
.I_rst_n(I_rst_n_tb),
.I_clk_en(I_clk_en_tb),
.I_div_ratio(I_div_ratio_tb),
.O_div_clk(O_div_clk_tb)
);
endmodule