-
Notifications
You must be signed in to change notification settings - Fork 0
/
tb_axi_stream_sideband_crc.sv
208 lines (160 loc) · 6.18 KB
/
tb_axi_stream_sideband_crc.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module tb_axi_stream_sideband_crc (
);
parameter DATA_WIDTH = 512;
parameter KEEP_BYTES = DATA_WIDTH/8;
parameter CRC_WIDTH = 32;
reg clk;
reg srst;
// AXI-ST signals from source
reg i_s_tlast;
reg i_s_tlast1;
reg [DATA_WIDTH-1:0] i_s_tdata;
reg [DATA_WIDTH/8-1:0] i_s_tkeep;
reg i_s_tvalid;
wire o_s_tready;
reg [CRC_WIDTH-1:0] crc;
// AXI-ST signals to sink
wire o_m_tlast;
wire [DATA_WIDTH-1:0] o_m_tdata;
wire [DATA_WIDTH/8-1:0] o_m_tkeep;
wire o_m_tvalid;
reg i_m_tready;
axi_stream_sideband_crc DUT(
.clk(clk),
.srst(srst),
.i_s_tlast(i_s_tlast),
.i_s_tdata(i_s_tdata),
.i_s_tkeep(i_s_tkeep),
.i_s_tvalid(i_s_tvalid),
.o_s_tready(o_s_tready),
.crc(crc),
.o_m_tlast(o_m_tlast),
.o_m_tdata(o_m_tdata),
.o_m_tkeep(o_m_tkeep),
.o_m_tvalid(o_m_tvalid),
.i_m_tready(i_m_tready)
);
parameter PERIOD = 20;
initial begin
#(PERIOD/2) clk = 1;
forever begin
#(PERIOD/2) clk = ~clk;
end
end
initial begin
i_s_tlast = 0;
i_s_tdata = {{(DATA_WIDTH-64){1'b1}}, 64'hDEAD_BEEF_DEAD_BEEF};
i_s_tkeep = 0;
i_s_tvalid = 0;
i_m_tready = 1;
// reset
#00; srst = 0;
#(PERIOD*2);
srst = 1;
#(PERIOD*4);
srst = 0;
//////////////////////////////////////////////////////////
//
//create 4 words packet to test first CASE
//
//////////////////////////////////////////////////////////
#00; crc = 32'hCECDCBCA;
#(PERIOD*4)
i_s_tvalid = 1;
i_s_tkeep = {(KEEP_BYTES){1'b1}};
i_s_tdata = {64'hDEAD_BEEF_DEAD_BEEF,{(DATA_WIDTH-64){1'b1}}};
#(PERIOD*1)
i_s_tvalid = 1;
i_s_tkeep = {(KEEP_BYTES){1'b1}};
i_s_tdata = {64'hDEAD_BEEF_DEAD_BEEF,{(DATA_WIDTH-64){1'b0}}};
#(PERIOD*1)
i_s_tvalid = 1;
i_s_tkeep = {(KEEP_BYTES){1'b1}};
i_s_tdata = {64'hDEAD_BEEF_DEAD_BEEF,{(DATA_WIDTH-64){1'b1}}};
#(PERIOD*1)
i_s_tvalid = 1;
i_s_tkeep = {8'b0000_0011, {(KEEP_BYTES-8){1'b1}} };
i_s_tdata = {64'h0000_0000_0000_BEEF,{(DATA_WIDTH-64){1'b1}}};
i_s_tlast = 1;
#(PERIOD*1); i_s_tvalid = 0; i_s_tkeep = 0; i_s_tlast = 0; i_s_tkeep = {(KEEP_BYTES){1'b0}};
////////////////////////////////////////////////////////
//
//4 words packet, test 2nd CASE with last 4 bytes empty
//
////////////////////////////////////////////////////////
#00; crc = 32'hABCDEF45;
#(PERIOD*4)
i_s_tvalid = 1;
i_s_tkeep = {(KEEP_BYTES){1'b1}};
i_s_tdata = {64'hDEAD_BEEF_DEAD_BEEF,{(DATA_WIDTH-64){1'b1}}};
#(PERIOD*1)
i_s_tvalid = 1;
i_s_tkeep = {(KEEP_BYTES){1'b1}};
i_s_tdata = {64'hDEAD_BEEF_DEAD_BEEF,{(DATA_WIDTH-64){1'b0}}};
#(PERIOD*1)
i_s_tvalid = 1;
i_s_tkeep = {(KEEP_BYTES){1'b1}};
i_s_tdata = {64'hDEAD_BEEF_DEAD_BEEF,{(DATA_WIDTH-64){1'b1}}};
#(PERIOD*1)
i_s_tvalid = 1;
i_s_tkeep = {8'b0000_1111, {(KEEP_BYTES-8){1'b1}} };
i_s_tdata = {64'h0000_0000_0000_BEEF,{(DATA_WIDTH-64){1'b1}}};
i_s_tlast = 1;
#(PERIOD*1); i_s_tvalid = 0; i_s_tkeep = 0; i_s_tlast = 0; i_s_tkeep = {(KEEP_BYTES){1'b0}};
//////////////////////////////////////////////////////////
//
//4 words packet, test 2nd CASE with only last byte empty
//
//////////////////////////////////////////////////////////
#00; crc = 32'h12CDEF23;
#(PERIOD*4)
i_s_tvalid = 1;
i_s_tkeep = {(KEEP_BYTES){1'b1}};
i_s_tdata = {64'hDEAD_BEEF_DEAD_BEEF,{(DATA_WIDTH-64){1'b1}}};
#(PERIOD*1)
i_s_tvalid = 1;
i_s_tkeep = {(KEEP_BYTES){1'b1}};
i_s_tdata = {64'hDEAD_BEEF_DEAD_BEEF,{(DATA_WIDTH-64){1'b0}}};
#(PERIOD*1)
i_s_tvalid = 1;
i_s_tkeep = {(KEEP_BYTES){1'b1}};
i_s_tdata = {64'hDEAD_BEEF_DEAD_BEEF,{(DATA_WIDTH-64){1'b1}}};
#(PERIOD*1)
i_s_tvalid = 1;
i_s_tkeep = {8'b0111_1111, {(KEEP_BYTES-8){1'b1}} };
i_s_tdata = {64'h0000_0000_0000_BEEF,{(DATA_WIDTH-64){1'b1}}};
i_s_tlast = 1;
#(PERIOD*1); i_s_tvalid = 0; i_s_tkeep = 0; i_s_tlast = 0; i_s_tkeep = {(KEEP_BYTES){1'b0}};
////////////////////////////////////////////////////////////
//
//4 words packet, test 2nd CASE with all last bytes filled
//
////////////////////////////////////////////////////////////
#00; crc = 32'h34CDEF11;
#(PERIOD*4)
i_s_tvalid = 1;
i_s_tkeep = {(KEEP_BYTES){1'b1}};
i_s_tdata = {64'hDEAD_BEEF_DEAD_BEEF,{(DATA_WIDTH-64){1'b1}}};
#(PERIOD*1)
i_s_tvalid = 1;
i_s_tkeep = {(KEEP_BYTES){1'b1}};
i_s_tdata = {64'hDEAD_BEEF_DEAD_BEEF,{(DATA_WIDTH-64){1'b0}}};
#(PERIOD*1)
i_s_tvalid = 1;
i_s_tkeep = {(KEEP_BYTES){1'b1}};
i_s_tdata = {64'hDEAD_BEEF_DEAD_BEEF,{(DATA_WIDTH-64){1'b1}}};
#(PERIOD*1)
i_s_tvalid = 1;
i_s_tkeep = {8'b1111_1111, {(KEEP_BYTES-8){1'b1}} };
i_s_tdata = {64'h0000_0000_0000_BEEF,{(DATA_WIDTH-64){1'b1}}};
i_s_tlast = 1;
#(PERIOD*1); i_s_tvalid = 0; i_s_tkeep = 0; i_s_tlast = 0; i_s_tkeep = {(KEEP_BYTES){1'b0}};
end
endmodule