-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathspi_clgen_tb.v
54 lines (47 loc) · 944 Bytes
/
spi_clgen_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
`include "spi_defines.v"
module spi_clgen_tb;
// Define the signals for the clock generator module
reg wb_clk_in;
reg wb_rst;
reg go;
reg tip;
reg last_clk;
wire sclk_out;
wire cpol_0;
wire cpol_1;
reg [`SPI_DIVIDER_LEN-1:0] divider;
// Instantiate the Device Under Test (DUT)
spi_clgen dut (
.wb_clk_in(wb_clk_in),
.wb_rst(wb_rst),
.go(go),
.tip(tip),
.last_clk(last_clk),
.divider(divider),
.sclk_out(sclk_out),
.cpol_0(cpol_0),
.cpol_1(cpol_1)
);
// Clock generation
always begin
#5 wb_clk_in = ~wb_clk_in; // Toggle the clock every 5 time units
end
// Initialize signals
initial begin
wb_clk_in <= 0;
wb_rst <= 1;
#13;
wb_rst <= 0;
divider <= 1;
tip <= 0;
go <= 0;
#17;
go <= 1;
#10;
tip <= 1;
last_clk <= 0;
end
initial begin
#200;
end
endmodule