-
Notifications
You must be signed in to change notification settings - Fork 0
/
tb.v
131 lines (118 loc) · 2.01 KB
/
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
`timescale 1ns/1ns
module tb;
wire [7:0] data = 8'b11111101;
wire [7:0] op_data ;
reg clk;
wire idle;
wire start;
wire stop;
wire op_bit;
wire finish;
wire [2:0] comm_a;
wire [2:0] comm_b;
task display_vals;
begin
$display("Idle = %b", idle);
$display("Start = %b", start);
$display("Stop = %b", stop);
$display("Output Bit = %b", op_bit);
$display("Output Data = %b", op_data);
$display("Finish = %b", finish);
$display("Communication Wire A = %b", comm_a);
$display("Communication Wire B = %b", comm_b);
end
endtask
task display_op_bit;
begin
$display("Output Bit = %b", op_bit);
end
endtask
task display_start_bit;
begin
$display("Start = %b", start);
end
endtask
task display_stop_bit;
begin
$display("Stop = %b", stop);
end
endtask
task display_idle_bit;
begin
$display("Idle = %b", idle);
end
endtask
task display_op_data;
begin
$display("Output Data = %b", op_data);
end
endtask
rs232_transmitter rs232_t(
.data(data),
.clk(clk),
.idle(idle),
.start(start),
.stop(stop),
.op_bit(op_bit)
);
rs424_transmitter rs424_t(
.clk(clk),
.ip_bit(op_bit),
.tda(comm_a),
.tdb(comm_b)
);
rs424_receiver rs424_r(
.clk(clk),
.rda(comm_a),
.rdb(comm_b),
.op_bit(op_bit)
);
rs232_receiver rs232_r(
.clk(clk),
.ip_bit(op_bit),
.op_data(op_data),
.finish(finish)
);
initial begin
clk = 0;
#20;
clk = 1;
#40;
display_vals;
clk = 0;
#20;
clk = 1;
#40;
display_vals;
clk = 0;
#20;
clk = 1;
#40;
display_vals;
clk = 0;
#20;
clk = 1;
#40;
display_vals;
clk = 0;
#20;
clk = 1;
#40;
display_vals;
clk = 0;
#20;
clk = 1;
#40;
display_vals;
clk = 0;
#20;
clk = 1;
#40;
display_vals;
clk = 0;
#20;
clk = 1;
#40;
display_vals;
end
endmodule