-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtb_i2c.v
98 lines (81 loc) · 1.32 KB
/
tb_i2c.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: 23.12.2020 18:08:55
// Design Name:
// Module Name: i2c_tb
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
/////////////////////////////////////////////////////////////////////////////////
module tb_i2c;
// Inputs
reg clk;
reg reset;
reg [6:0] addr;
reg [7:0] in_data;
reg enable;
reg rw;
// Outputs
wire [7:0] out_data;
wire ready;
// Bidirs
wire sda;
wire scl;
// Instantiate the Unit Under Test (UUT)
master_i2c m ( clk,
reset,
addr,
in_data,
enable,
rw,
out_data,
ready,
sda,
scl);
i2c_slave slave (
.sda(sda),
.scl(scl)
);
initial begin
clk = 0;
forever begin
clk = #2 ~clk;
end
end
initial begin
// Initialize Inputs
clk = 0;
reset = 1;
// Wait 100 ns for global reset to finish
#100;
// Add stimulus here
reset = 0;
addr = 7'b0101010;
in_data = 8'b10101010;
rw = 0;
enable = 1;
#20;
enable = 0;
#400
reset =0;
addr = 7'b0101010;
in_data = 8'b10101010;
rw=1;
enable =1;
#10;
enable=0;
#100
$finish;
end
endmodule