-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskid_buffer_test.sv
156 lines (144 loc) · 3.14 KB
/
skid_buffer_test.sv
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
module skid_buffer_test #();
localparam int DWIDTH = 8;
reg clk;
reg rstn;
reg reset_done;
reg o_valid_tb;
reg [DWIDTH-1:0] o_data_tb;
reg o_ready_tb;
wire i_ready_tb;
wire i_valid_tb;
wire [DWIDTH-1:0] i_data_tb;
int i;
int valid;
skid_buffer #(
.DWIDTH(DWIDTH)
)
dut
(.clk(clk),
.rstn(rstn),
.i_valid(o_valid_tb),
.i_data(o_data_tb),
.o_ready(i_ready_tb),
.o_valid(i_valid_tb),
.o_data(i_data_tb),
.i_ready(o_ready_tb)
);
initial begin
clk = 1;
forever #5 clk = ~clk;
end
initial begin
#1000 $finish;
end
initial begin
reset_done = '0;
rstn = '1;
i = 1;
@(negedge clk);
rstn = '0;
@(negedge clk);
rstn = '1;
reset_done = '1;
o_valid_tb = '0;
end
/* AXI-S Bus Functional Model */
initial begin
@(posedge reset_done);
@(posedge clk);
forever begin
valid = $urandom;
if ((valid % 2) == 0) begin
o_valid_tb <= '0;
@(posedge clk);
end
else begin
/* AXI-S protocol: Assert valid and wait for ready */
o_valid_tb <= '1;
o_data_tb <= i;
do begin
@(posedge clk);
end
while (i_ready_tb !== '1);
end
end
end
/* Handshake done modify data */
always @(negedge clk) begin
if ((o_valid_tb == '1) && (i_ready_tb == '1)) begin
i <= i + 1;
end
end
initial begin
@(posedge reset_done);
@(posedge clk);
forever begin
o_ready_tb <= $urandom % 2;
@(posedge clk);
end
end
// initial begin
// reset_done = '0;
// rstn = '1;
// i = 1;
// @(posedge clk);
// rstn = '0;
// o_valid_tb = '0;
// @(posedge clk)
// @(posedge clk);
// rstn = '1;
// reset_done = '1;
// end
//
// initial begin
// @(posedge clk);
// o_valid_tb <= '0;
// @(posedge clk);
// @(posedge clk);
// @(posedge clk);
// forever begin
// /* AXI-S protocol: Assert valid and wait for ready */
// o_valid_tb <= '1;
// o_data_tb <= i;
// do begin
// @(posedge clk);
// end
// while (i_ready_tb !== '1);
// end
// end
//
// initial begin
// @(posedge clk);
// o_ready_tb <= '0;
// @(posedge clk);
// @(posedge clk);
// @(posedge clk);
// o_ready_tb <= '1;
// @(posedge clk);
// o_ready_tb <= '0;
// @(posedge clk);
// @(posedge clk);
// o_ready_tb <= '1;
// @(posedge clk);
// @(posedge clk);
// o_ready_tb <= '0;
// @(posedge clk);
// @(posedge clk);
// o_ready_tb <= '1;
// @(posedge clk);
// o_ready_tb <= '0;
// @(posedge clk);
// o_ready_tb <= '1;
// @(posedge clk);
// @(posedge clk);
// @(posedge clk);
// o_ready_tb <= '0;
// @(posedge clk);
// @(posedge clk);
// @(posedge clk);
// o_ready_tb <= '1;
// @(posedge clk);
// @(posedge clk);
// o_ready_tb <= '0;
// end
endmodule