/
spi_master_tb.v
98 lines (82 loc) · 1.41 KB
/
spi_master_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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 13:12:38 07/29/2017
// Design Name: spi_master
// Module Name: E:/ISEProjece/SPI/spi_master_tb.v
// Project Name: SPI
// Target Device:
// Tool versions:
// Description:
//
// Verilog Test Fixture created by ISE for module: spi_master
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
////////////////////////////////////////////////////////////////////////////////
module spi_master_tb;
// Inputs
reg [7:0] in_data;
reg clk;
reg [1:0] addr;
reg wr;
reg rd;
reg cs;
reg miso;
// Outputs
wire [7:0] out_data;
// Bidirs
wire mosi;
wire sclk;
// Instantiate the Unit Under Test (UUT)
spi_master uut (
.in_data(in_data),
.clk(clk),
.addr(addr),
.wr(wr),
.rd(rd),
.cs(cs),
.out_data(out_data),
.mosi(mosi),
.miso(miso),
.sclk(sclk)
);
initial begin
// Initialize Inputs
in_data = 0;
clk = 0;
addr = 0;
wr = 0;
rd = 0;
cs = 0;
miso = 0;
// set clk_div , and out by out_data
#40;
addr = 0;
in_data = 8'haa;
wr = 1;
cs = 1;
// write data
#20 ;
wr = 0;
cs = 0;
#360 ;
wr = 1;
cs = 1;
in_data = 8'h91;
#20 ;
wr = 0;
cs = 0;
end
// define clock
initial begin
clk = 0;
forever #10 clk = ~clk;
end
endmodule