1 |
2 |
acastong |
//vc_ht_tunnel_l1_tb.cpp
|
2 |
|
|
|
3 |
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
4 |
|
|
* Version: MPL 1.1
|
5 |
|
|
*
|
6 |
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
7 |
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
8 |
|
|
* the License. You may obtain a copy of the License at
|
9 |
|
|
* http://www.mozilla.org/MPL/
|
10 |
|
|
*
|
11 |
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
12 |
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
13 |
|
|
* for the specific language governing rights and limitations under the
|
14 |
|
|
* License.
|
15 |
|
|
*
|
16 |
|
|
* The Original Code is HyperTransport Tunnel IP Core.
|
17 |
|
|
*
|
18 |
|
|
* The Initial Developer of the Original Code is
|
19 |
|
|
* Ecole Polytechnique de Montreal.
|
20 |
|
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
21 |
|
|
* the Initial Developer. All Rights Reserved.
|
22 |
|
|
*
|
23 |
|
|
* Contributor(s):
|
24 |
|
|
* Ami Castonguay <acastong@grm.polymtl.ca>
|
25 |
|
|
*
|
26 |
|
|
* Alternatively, the contents of this file may be used under the terms
|
27 |
|
|
* of the Polytechnique HyperTransport Tunnel IP Core Source Code License
|
28 |
|
|
* (the "PHTICSCL License", see the file PHTICSCL.txt), in which case the
|
29 |
|
|
* provisions of PHTICSCL License are applicable instead of those
|
30 |
|
|
* above. If you wish to allow use of your version of this file only
|
31 |
|
|
* under the terms of the PHTICSCL License and not to allow others to use
|
32 |
|
|
* your version of this file under the MPL, indicate your decision by
|
33 |
|
|
* deleting the provisions above and replace them with the notice and
|
34 |
|
|
* other provisions required by the PHTICSCL License. If you do not delete
|
35 |
|
|
* the provisions above, a recipient may use your version of this file
|
36 |
|
|
* under either the MPL or the PHTICSCL License."
|
37 |
|
|
*
|
38 |
|
|
* ***** END LICENSE BLOCK ***** */
|
39 |
|
|
|
40 |
|
|
#include "vc_ht_tunnel_l1_tb.h"
|
41 |
|
|
#include "PhysicalLayer.h"
|
42 |
|
|
#include "LogicalLayer.h"
|
43 |
|
|
#include "InterfaceLayer.h"
|
44 |
|
|
|
45 |
|
|
#include "../core/RequestPacket.h"
|
46 |
|
|
|
47 |
|
|
vc_ht_tunnel_l1_tb::vc_ht_tunnel_l1_tb(sc_module_name name) : sc_module(name){
|
48 |
|
|
SC_THREAD(manage_memories);
|
49 |
|
|
sensitive_pos(clk);
|
50 |
|
|
|
51 |
|
|
SC_METHOD(drive_async_outputs);
|
52 |
|
|
sensitive_neg(clk);
|
53 |
|
|
|
54 |
|
|
SC_THREAD(run);
|
55 |
|
|
sensitive_pos(clk);
|
56 |
|
|
|
57 |
|
|
cout << "Constructing testbench" << endl;
|
58 |
|
|
|
59 |
|
|
physicalLayer0 = new PhysicalLayer("physicalLayer0");
|
60 |
|
|
physicalLayer0->clk(clk);
|
61 |
|
|
physicalLayer0->resetx(resetx);
|
62 |
|
|
physicalLayer0->phy_available_lk(phy0_available_lk0_buf);
|
63 |
|
|
physicalLayer0->phy_ctl_lk(phy0_ctl_lk0_buf);
|
64 |
|
|
for(int n = 0; n < CAD_IN_WIDTH; n++){
|
65 |
|
|
physicalLayer0->phy_cad_lk[n](phy0_cad_lk0_buf[n]);
|
66 |
|
|
}
|
67 |
|
|
physicalLayer0->lk_ctl_phy(lk0_ctl_phy0);
|
68 |
|
|
for(int n = 0; n < CAD_OUT_WIDTH; n++){
|
69 |
|
|
physicalLayer0->lk_cad_phy[n](lk0_cad_phy0[n]);
|
70 |
|
|
}
|
71 |
|
|
physicalLayer0->phy_consume_lk(phy0_consume_lk0_buf);
|
72 |
|
|
physicalLayer0->lk_disable_drivers_phy(lk0_disable_drivers_phy0);
|
73 |
|
|
physicalLayer0->lk_disable_receivers_phy(lk0_disable_receivers_phy0);
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
logicalLayer0 = new LogicalLayer("logicalLayer0");
|
77 |
|
|
logicalLayer0->clk(clk);
|
78 |
|
|
logicalLayer0->resetx(resetx);
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
physicalLayer1= new PhysicalLayer("physicalLayer1");
|
82 |
|
|
physicalLayer1->clk(clk);
|
83 |
|
|
physicalLayer1->resetx(resetx);
|
84 |
|
|
physicalLayer1->phy_available_lk(phy1_available_lk1_buf);
|
85 |
|
|
physicalLayer1->phy_ctl_lk(phy1_ctl_lk1_buf);
|
86 |
|
|
for(int n = 0; n < CAD_IN_WIDTH; n++){
|
87 |
|
|
physicalLayer1->phy_cad_lk[n](phy1_cad_lk1_buf[n]);
|
88 |
|
|
}
|
89 |
|
|
physicalLayer1->lk_ctl_phy(lk1_ctl_phy1);
|
90 |
|
|
for(int n = 0; n < CAD_OUT_WIDTH; n++){
|
91 |
|
|
physicalLayer1->lk_cad_phy[n](lk1_cad_phy1[n]);
|
92 |
|
|
}
|
93 |
|
|
physicalLayer1->phy_consume_lk(phy1_consume_lk1_buf);
|
94 |
|
|
physicalLayer1->lk_disable_drivers_phy(lk1_disable_drivers_phy1);
|
95 |
|
|
physicalLayer1->lk_disable_receivers_phy(lk1_disable_receivers_phy1);
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
logicalLayer1 = new LogicalLayer("logicalLayer1");
|
99 |
|
|
logicalLayer1->clk(clk);
|
100 |
|
|
logicalLayer1->resetx(resetx);
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
interfaceLayer = new InterfaceLayer("interfaceLayer");
|
104 |
|
|
interfaceLayer->clk(clk);
|
105 |
|
|
interfaceLayer->resetx(resetx);
|
106 |
|
|
interfaceLayer->ui_packet_usr(ui_packet_usr);
|
107 |
|
|
interfaceLayer->ui_vc_usr(ui_vc_usr);
|
108 |
|
|
interfaceLayer->ui_side_usr(ui_side_usr);
|
109 |
|
|
interfaceLayer->ui_directroute_usr(ui_directroute_usr);
|
110 |
|
|
interfaceLayer->ui_eop_usr(ui_eop_usr);
|
111 |
|
|
interfaceLayer->ui_available_usr(ui_available_usr);
|
112 |
|
|
interfaceLayer->ui_output_64bits_usr(ui_output_64bits_usr);
|
113 |
|
|
interfaceLayer->usr_consume_ui(usr_consume_ui_buf);
|
114 |
|
|
interfaceLayer->usr_packet_ui(usr_packet_ui_buf);
|
115 |
|
|
interfaceLayer->usr_available_ui(usr_available_ui_buf);
|
116 |
|
|
interfaceLayer->usr_side_ui(usr_side_ui_buf);
|
117 |
|
|
interfaceLayer->ui_freevc0_usr(ui_freevc0_usr);
|
118 |
|
|
interfaceLayer->ui_freevc1_usr(ui_freevc1_usr);
|
119 |
|
|
interfaceLayer->usr_receivedResponseError_csr(usr_receivedResponseError_csr_buf);
|
120 |
|
|
|
121 |
|
|
logicalLayer0->setInterface(this);
|
122 |
|
|
logicalLayer0->setPhysicalLayer(physicalLayer0);
|
123 |
|
|
logicalLayer1->setInterface(this);
|
124 |
|
|
logicalLayer1->setPhysicalLayer(physicalLayer1);
|
125 |
|
|
interfaceLayer->setInterfaceLayerEventHandler(this);
|
126 |
|
|
|
127 |
|
|
count_side0 = 0;
|
128 |
|
|
count_side1 = 0;
|
129 |
|
|
count_interface = 0;
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
vc_ht_tunnel_l1_tb::~vc_ht_tunnel_l1_tb(){
|
133 |
|
|
delete physicalLayer0;
|
134 |
|
|
delete logicalLayer0;
|
135 |
|
|
delete physicalLayer1;
|
136 |
|
|
delete logicalLayer1;
|
137 |
|
|
delete interfaceLayer;
|
138 |
|
|
}
|
139 |
|
|
|
140 |
|
|
void vc_ht_tunnel_l1_tb::manage_memories(){
|
141 |
|
|
while(true){
|
142 |
|
|
//UI memories
|
143 |
|
|
ui_memory_read_data0 = ui_memory0[ui_memory_read_address0.read().to_int()];
|
144 |
|
|
ui_memory_read_data1 = ui_memory1[ui_memory_read_address1.read().to_int()];
|
145 |
|
|
if(ui_memory_write0.read()) ui_memory0[ui_memory_write_address.read().to_int()] =
|
146 |
|
|
ui_memory_write_data.read().to_int();
|
147 |
|
|
if(ui_memory_write1.read()) ui_memory1[ui_memory_write_address.read().to_int()] =
|
148 |
|
|
ui_memory_write_data.read().to_int();
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
#ifdef RETRY_MODE_ENABLED
|
152 |
|
|
//////////////////////////////////////////
|
153 |
|
|
// History memories
|
154 |
|
|
/////////////////////////////////////////
|
155 |
|
|
history_memory_output0 = history_memory0[history_memory_read_address0.read().to_int()];
|
156 |
|
|
history_memory_output1 = history_memory1[history_memory_read_address1.read().to_int()];
|
157 |
|
|
if(history_memory_write0.read()) history_memory0[history_memory_write_address0.read().to_int()] =
|
158 |
|
|
history_memory_write_data0.read().to_int();
|
159 |
|
|
if(history_memory_write1.read()) history_memory1[history_memory_write_address1.read().to_int()] =
|
160 |
|
|
history_memory_write_data1.read().to_int();
|
161 |
|
|
|
162 |
|
|
#endif
|
163 |
|
|
|
164 |
|
|
////////////////////////////////////
|
165 |
|
|
// DataBuffer Memories
|
166 |
|
|
////////////////////////////////////
|
167 |
|
|
for(int n = 0; n < 2; n++){
|
168 |
|
|
memory_output0[n] = databuffer_memory0[memory_read_address_vc0[n].read().to_int()]
|
169 |
|
|
[memory_read_address_buffer0[n].read().to_int()]
|
170 |
|
|
[memory_read_address_pos0[n].read().to_int()];
|
171 |
|
|
memory_output1[n] = databuffer_memory1[memory_read_address_vc1[n].read().to_int()]
|
172 |
|
|
[memory_read_address_buffer1[n].read().to_int()]
|
173 |
|
|
[memory_read_address_pos1[n].read().to_int()];
|
174 |
|
|
|
175 |
|
|
}
|
176 |
|
|
|
177 |
|
|
if(memory_write0) databuffer_memory0[memory_write_address_vc0.read()]
|
178 |
|
|
[memory_write_address_buffer0.read()][memory_write_address_pos0.read()] =
|
179 |
|
|
memory_write_data0.read().to_int();
|
180 |
|
|
if(memory_write1) databuffer_memory1[memory_write_address_vc1.read()]
|
181 |
|
|
[memory_write_address_buffer1.read()][memory_write_address_pos1.read()] =
|
182 |
|
|
memory_write_data1.read().to_int();
|
183 |
|
|
|
184 |
|
|
////////////////////////////////////
|
185 |
|
|
// CoommandBuffer Memories
|
186 |
|
|
////////////////////////////////////
|
187 |
|
|
for(int n = 0; n < 2; n++){
|
188 |
|
|
command_packet_rd_data_ro0[n] =
|
189 |
|
|
command_memory0[ro0_command_packet_rd_addr[n].read().to_int()];
|
190 |
|
|
command_packet_rd_data_ro1[n] =
|
191 |
|
|
command_memory1[ro1_command_packet_rd_addr[n].read().to_int()];
|
192 |
|
|
|
193 |
|
|
}
|
194 |
|
|
|
195 |
|
|
if(ro0_command_packet_write.read())
|
196 |
|
|
command_memory0[ro0_command_packet_wr_addr.read().to_int()] =
|
197 |
|
|
ro0_command_packet_wr_data.read();
|
198 |
|
|
if(ro1_command_packet_write.read())
|
199 |
|
|
command_memory1[ro1_command_packet_wr_addr.read().to_int()] =
|
200 |
|
|
ro1_command_packet_wr_data.read();
|
201 |
|
|
|
202 |
|
|
wait();
|
203 |
|
|
}
|
204 |
|
|
|
205 |
|
|
}
|
206 |
|
|
|
207 |
|
|
void vc_ht_tunnel_l1_tb::run(){
|
208 |
|
|
cout << "TestBench Running" << endl;
|
209 |
|
|
cout << "Sending reset" << endl;
|
210 |
|
|
|
211 |
|
|
pwrok_buf = false;
|
212 |
|
|
resetx_buf = false;
|
213 |
|
|
ldtstopx_buf = true;
|
214 |
|
|
|
215 |
|
|
for(int n = 0; n < 4; n++)wait();
|
216 |
|
|
|
217 |
|
|
pwrok_buf = true;
|
218 |
|
|
|
219 |
|
|
for(int n = 0; n < 4; n++)wait();
|
220 |
|
|
|
221 |
|
|
resetx_buf = true;
|
222 |
|
|
|
223 |
|
|
//////////////////////////////////////////////////
|
224 |
|
|
// Change the UnitID to 1
|
225 |
|
|
//////////////////////////////////////////////////
|
226 |
|
|
|
227 |
|
|
sc_bv<38> write_address;
|
228 |
|
|
write_address.range(29,0) = (sc_uint<30>) (sc_uint<32>(0xFE000040).range(31,2));
|
229 |
|
|
write_address.range(37,30) = sc_uint<8>(0xFD);
|
230 |
|
|
int * write_data = new int[1];
|
231 |
|
|
write_data[0] = 0x00010000;
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
WritePacket* write = new WritePacket(0/*seqID*/,0 /*unitID*/,0 /*srcTag*/,
|
235 |
|
|
0/*count*/,write_address,
|
236 |
|
|
true /*doubleWordDataLength*/);
|
237 |
|
|
|
238 |
|
|
logicalLayer0->sendPacket(write,write_data);
|
239 |
|
|
cout << "sending a first write: " << *write << endl;
|
240 |
|
|
cout << "with 1 data: " << write_data[0] << endl;
|
241 |
|
|
|
242 |
|
|
//////////////////////////////////////////////////
|
243 |
|
|
// Wait for a response that the UnitID has been changed
|
244 |
|
|
//////////////////////////////////////////////////
|
245 |
|
|
while(!count_side0) wait();
|
246 |
|
|
|
247 |
|
|
//////////////////////////////////////////////////
|
248 |
|
|
// Send another write to UID 0, should go through
|
249 |
|
|
//////////////////////////////////////////////////
|
250 |
|
|
cout << "sending a second write" << endl;
|
251 |
|
|
|
252 |
|
|
write_data = new int[1];
|
253 |
|
|
write_data[0] = 0x00010000;
|
254 |
|
|
write = new WritePacket(0/*seqID*/,0 /*unitID*/,0 /*srcTag*/,
|
255 |
|
|
0/*count*/,write_address,
|
256 |
|
|
true /*doubleWordDataLength*/);
|
257 |
|
|
|
258 |
|
|
logicalLayer0->sendPacket(write,write_data);
|
259 |
|
|
|
260 |
|
|
//////////////////////////////////////////////////
|
261 |
|
|
// Setup the BAR address and enable memory and io space
|
262 |
|
|
// and bus master enable
|
263 |
|
|
//////////////////////////////////////////////////
|
264 |
|
|
write_address.range(29,0) = (sc_uint<30>) (sc_uint<32>(0xFE000804).range(31,2));
|
265 |
|
|
write_address.range(37,30) = sc_uint<8>(0xFD);
|
266 |
|
|
write_data = new int[4];
|
267 |
|
|
write_data[0] = 7;
|
268 |
|
|
write_data[1] = 0;
|
269 |
|
|
write_data[2] = 0;
|
270 |
|
|
write_data[3] = 0x12345000;
|
271 |
|
|
write = new WritePacket(0/*seqID*/,0 /*unitID*/,0 /*srcTag*/,
|
272 |
|
|
3/*count*/,write_address,
|
273 |
|
|
true /*doubleWordDataLength*/);
|
274 |
|
|
|
275 |
|
|
received_side0 = false;
|
276 |
|
|
logicalLayer0->sendPacket(write,write_data);
|
277 |
|
|
|
278 |
|
|
//////////////////////////////////////////////////
|
279 |
|
|
// Wait for an answer
|
280 |
|
|
//////////////////////////////////////////////////
|
281 |
|
|
while(!received_side0) wait();
|
282 |
|
|
|
283 |
|
|
//////////////////////////////////////////////////
|
284 |
|
|
// Send message to the user of the tunnel
|
285 |
|
|
//////////////////////////////////////////////////
|
286 |
|
|
received_side0 = false;
|
287 |
|
|
write_address.range(29,0) = (sc_uint<30>) (sc_uint<32>(0x12345124).range(31,2));
|
288 |
|
|
write_address.range(37,30) = sc_uint<8>(0x00);
|
289 |
|
|
write_data = new int[4];
|
290 |
|
|
write_data[0] = 0x97351728;
|
291 |
|
|
write_data[1] = 0x24762655;
|
292 |
|
|
write_data[2] = 0x22267436;
|
293 |
|
|
write_data[3] = 0x07907544;
|
294 |
|
|
write = new WritePacket(0/*seqID*/,0 /*unitID*/,1 /*srcTag*/,
|
295 |
|
|
3/*count*/,write_address,
|
296 |
|
|
true /*doubleWordDataLength*/);
|
297 |
|
|
logicalLayer0->sendPacket(write,write_data);
|
298 |
|
|
|
299 |
|
|
//////////////////////////////////////////////////
|
300 |
|
|
// Send a packet that should generate an error
|
301 |
|
|
//////////////////////////////////////////////////
|
302 |
|
|
ReadPacket* read = new ReadPacket(0,0,0,2,0,true);
|
303 |
|
|
AddressExtensionPacket *addrExt = new AddressExtensionPacket(0x121234,read->getVector());
|
304 |
|
|
delete read;
|
305 |
|
|
logicalLayer0->sendPacket(addrExt,NULL);
|
306 |
|
|
|
307 |
|
|
while(!received_side0) wait();
|
308 |
|
|
count_side0 = 0;
|
309 |
|
|
//////////////////////////////////////////////////
|
310 |
|
|
// Send a message from the interface
|
311 |
|
|
//////////////////////////////////////////////////
|
312 |
|
|
|
313 |
|
|
cout << "Sending packet from interface!" << endl;
|
314 |
|
|
|
315 |
|
|
write_address.range(29,0) = (sc_uint<30>) (sc_uint<32>(0x00014230).range(31,2));
|
316 |
|
|
write_address.range(37,30) = sc_uint<8>(0x00);
|
317 |
|
|
write_data = new int[2];
|
318 |
|
|
write_data[1] = 0x76543210;
|
319 |
|
|
write_data[0] = 0x00073360;
|
320 |
|
|
write = new WritePacket(0/*seqID*/,1 /*unitID*/,1/*count*/,
|
321 |
|
|
write_address,
|
322 |
|
|
true /*doubleWordDataLength*/);
|
323 |
|
|
interfaceLayer->sendPacket(write,write_data,false);
|
324 |
|
|
|
325 |
|
|
///////////////////////////////////////////////////
|
326 |
|
|
// Attempting LDTSTOP sequence (without retry mode)
|
327 |
|
|
///////////////////////////////////////////////////
|
328 |
|
|
|
329 |
|
|
cout << "Attempting LDTSTOP sequence" << endl;
|
330 |
|
|
|
331 |
|
|
logicalLayer0->flush();
|
332 |
|
|
ldtstopx_buf.write(false);
|
333 |
|
|
NopPacket * disconNop = new NopPacket(0,0,0,0,0,0,true);
|
334 |
|
|
logicalLayer0->sendPacket(disconNop,NULL);
|
335 |
|
|
physicalLayer0->ldtstopDisconnect();
|
336 |
|
|
physicalLayer1->ldtstopDisconnect();
|
337 |
|
|
|
338 |
|
|
for(int n = 0; n < 150; n++) wait();
|
339 |
|
|
ldtstopx_buf.write(true);
|
340 |
|
|
physicalLayer0->ldtstopConnect();
|
341 |
|
|
physicalLayer1->ldtstopConnect();
|
342 |
|
|
|
343 |
|
|
cout << "LDTSTOP sequence done" << endl;
|
344 |
|
|
|
345 |
|
|
#ifdef RETRY_MODE_ENABLED
|
346 |
|
|
//////////////////////////////////////////////////////
|
347 |
|
|
// Set the retry mode in the tunnel for link 1
|
348 |
|
|
//////////////////////////////////////////////////////
|
349 |
|
|
write_address.range(29,0) = (sc_uint<30>) (sc_uint<32>(0xFE000800+ErrorRetry_Pointer+4).range(31,2));
|
350 |
|
|
write_address.range(37,30) = sc_uint<8>(0xFD);
|
351 |
|
|
write_data = new int[1];
|
352 |
|
|
write_data[0] = 0x00C000C1;
|
353 |
|
|
|
354 |
|
|
|
355 |
|
|
write = new WritePacket(0/*seqID*/,0 /*unitID*/,5 /*srcTag*/,
|
356 |
|
|
0/*count*/,write_address,
|
357 |
|
|
true /*doubleWordDataLength*/);
|
358 |
|
|
|
359 |
|
|
logicalLayer0->sendPacket(write,write_data);
|
360 |
|
|
|
361 |
|
|
while(count_side0 != 2) wait();
|
362 |
|
|
count_side0 = 0;
|
363 |
|
|
|
364 |
|
|
logicalLayer0->setRetryMode(true);
|
365 |
|
|
resetx_buf = false;
|
366 |
|
|
|
367 |
|
|
|
368 |
|
|
//////////////////////////////////////////////////////
|
369 |
|
|
// Enter retry mode
|
370 |
|
|
//////////////////////////////////////////////////////
|
371 |
|
|
|
372 |
|
|
for(int n = 0; n < 3; n++)wait();
|
373 |
|
|
|
374 |
|
|
resetx_buf = true;
|
375 |
|
|
|
376 |
|
|
count_side1 = 0;
|
377 |
|
|
|
378 |
|
|
//////////////////////////////////////////////////
|
379 |
|
|
// Send a write to UID 1, should go through
|
380 |
|
|
//////////////////////////////////////////////////
|
381 |
|
|
cout << "sending a second write" << endl;
|
382 |
|
|
|
383 |
|
|
write_address.range(29,0) = (sc_uint<30>) (sc_uint<32>(0xFE000840).range(31,2));
|
384 |
|
|
write_address.range(37,30) = sc_uint<8>(0xFD);
|
385 |
|
|
write_data = new int[1];
|
386 |
|
|
write_data[0] = 1;
|
387 |
|
|
write = new WritePacket(0/*seqID*/,0 /*unitID*/,0 /*srcTag*/,
|
388 |
|
|
0/*count*/,write_address,
|
389 |
|
|
true /*doubleWordDataLength*/);
|
390 |
|
|
|
391 |
|
|
logicalLayer0->sendPacket(write,write_data);
|
392 |
|
|
|
393 |
|
|
while(!count_side1) wait();
|
394 |
|
|
|
395 |
|
|
//////////////////////////////////////////////////
|
396 |
|
|
// Setup the BAR address and enable memory and io space
|
397 |
|
|
// and bus master enable
|
398 |
|
|
//////////////////////////////////////////////////
|
399 |
|
|
write_address.range(29,0) = (sc_uint<30>) (sc_uint<32>(0xFE000004).range(31,2));
|
400 |
|
|
write_address.range(37,30) = sc_uint<8>(0xFD);
|
401 |
|
|
write_data = new int[4];
|
402 |
|
|
write_data[0] = 7;
|
403 |
|
|
write_data[1] = 0;
|
404 |
|
|
write_data[2] = 0;
|
405 |
|
|
write_data[3] = 0x12345000;
|
406 |
|
|
write = new WritePacket(0/*seqID*/,0 /*unitID*/,0 /*srcTag*/,
|
407 |
|
|
3/*count*/,write_address,
|
408 |
|
|
true /*doubleWordDataLength*/);
|
409 |
|
|
|
410 |
|
|
received_side0 = false;
|
411 |
|
|
logicalLayer0->sendPacket(write,write_data);
|
412 |
|
|
|
413 |
|
|
//////////////////////////////////////////////////
|
414 |
|
|
// Wait for an answer
|
415 |
|
|
//////////////////////////////////////////////////
|
416 |
|
|
while(!received_side0) wait();
|
417 |
|
|
|
418 |
|
|
//////////////////////////////////////////////////
|
419 |
|
|
// Attempt a retry sequence
|
420 |
|
|
// Send multiple packets, but ignore them
|
421 |
|
|
// Then initiate retry sequence
|
422 |
|
|
// Packets should be resent
|
423 |
|
|
//////////////////////////////////////////////////
|
424 |
|
|
|
425 |
|
|
cout << "Testing retry sequence!" << endl;
|
426 |
|
|
|
427 |
|
|
//Start by sending packets
|
428 |
|
|
for(int n = 0; n < 4; n++){
|
429 |
|
|
write_address.range(29,0) = (sc_uint<30>) (sc_uint<32>(0x00014230).range(31,2));
|
430 |
|
|
write_address.range(37,30) = sc_uint<8>(0x00);
|
431 |
|
|
|
432 |
|
|
write_data = new int[2];
|
433 |
|
|
write_data[1] = 4635 +56*n;
|
434 |
|
|
write_data[0] = 586955 +12556*n;
|
435 |
|
|
write = new WritePacket(n/*seqID*/,1 /*unitID*/,1/*count*/,
|
436 |
|
|
write_address,
|
437 |
|
|
true /*doubleWordDataLength*/);
|
438 |
|
|
interfaceLayer->sendPacket(write,write_data,false);
|
439 |
|
|
}
|
440 |
|
|
logicalLayer0->setIgnoreIncoming(true);
|
441 |
|
|
|
442 |
|
|
//Make sure that all packets are sent
|
443 |
|
|
cout << "Flushing packets sent..." ;
|
444 |
|
|
interfaceLayer->flush();
|
445 |
|
|
cout << "done" << endl;
|
446 |
|
|
|
447 |
|
|
cout << "Waiting some cycles." ;
|
448 |
|
|
//Wait some cycles to make sure packets are really sent out
|
449 |
|
|
for(int n = 0; n < 50; n++) wait();
|
450 |
|
|
|
451 |
|
|
cout << "Initiate retry sequence" << endl ;
|
452 |
|
|
logicalLayer0->initiateRetrySequence();
|
453 |
|
|
for(int n = 0; n < 5; n++) wait();
|
454 |
|
|
|
455 |
|
|
cout << "Stop ignore input" << endl ;
|
456 |
|
|
logicalLayer0->setIgnoreIncoming(false);
|
457 |
|
|
|
458 |
|
|
for(int n = 0; n < 150; n++) wait();
|
459 |
|
|
|
460 |
|
|
#endif
|
461 |
|
|
|
462 |
|
|
//logicalLayer0->displayReceivedDword = true;
|
463 |
|
|
|
464 |
|
|
|
465 |
|
|
|
466 |
|
|
//////////////////////////////////////////////////
|
467 |
|
|
// Done
|
468 |
|
|
//////////////////////////////////////////////////
|
469 |
|
|
while(true) wait();
|
470 |
|
|
}
|
471 |
|
|
|
472 |
|
|
void vc_ht_tunnel_l1_tb::receivedHtPacketEvent(const ControlPacket * packet,
|
473 |
|
|
const int * data,LogicalLayer* origin)
|
474 |
|
|
{
|
475 |
|
|
cout << "Received HT Packet: " << *packet << endl;
|
476 |
|
|
if(origin == logicalLayer0){
|
477 |
|
|
cout << "From side 0" << endl;
|
478 |
|
|
count_side0++;
|
479 |
|
|
received_side0 = true;
|
480 |
|
|
}
|
481 |
|
|
else{
|
482 |
|
|
cout << "From side 1" << endl;
|
483 |
|
|
count_side1++;
|
484 |
|
|
}
|
485 |
|
|
int length = (int)packet->getDataLengthm1()+1;
|
486 |
|
|
if(!packet->hasDataAssociated())length = 0;
|
487 |
|
|
cout << "with " << length << " data: " << endl;
|
488 |
|
|
for(int n = 0; n < length; n++){
|
489 |
|
|
cout << sc_uint<32>(data[n]).to_string(SC_HEX) << endl;
|
490 |
|
|
}
|
491 |
|
|
|
492 |
|
|
}
|
493 |
|
|
|
494 |
|
|
void vc_ht_tunnel_l1_tb::crcErrorDetected(){
|
495 |
|
|
cout << "CRC ERROR detected" << endl;
|
496 |
|
|
resetx = false;
|
497 |
|
|
}
|
498 |
|
|
|
499 |
|
|
void vc_ht_tunnel_l1_tb::receivedInterfacePacketEvent(const ControlPacket * packet,const int * data,
|
500 |
|
|
bool directRoute,bool side,InterfaceLayer* origin)
|
501 |
|
|
{
|
502 |
|
|
cout << "Received Interface Packet: " << *packet << endl;
|
503 |
|
|
int length = (int)packet->getDataLengthm1()+1;
|
504 |
|
|
if(!packet->hasDataAssociated())length = 0;
|
505 |
|
|
cout << "with " << length << " data: " << endl;
|
506 |
|
|
for(int n = 0; n < length; n++){
|
507 |
|
|
cout << sc_uint<32>(data[n]).to_string(SC_HEX) << endl;
|
508 |
|
|
}
|
509 |
|
|
count_interface++;
|
510 |
|
|
}
|
511 |
|
|
|
512 |
|
|
void vc_ht_tunnel_l1_tb::drive_async_outputs(){
|
513 |
|
|
resetx = resetx_buf;
|
514 |
|
|
pwrok = pwrok_buf;
|
515 |
|
|
ldtstopx = ldtstopx_buf;
|
516 |
|
|
usr_consume_ui = usr_consume_ui_buf;
|
517 |
|
|
usr_packet_ui = usr_packet_ui_buf;
|
518 |
|
|
usr_available_ui = usr_available_ui_buf;
|
519 |
|
|
usr_side_ui = usr_side_ui_buf;
|
520 |
|
|
usr_receivedResponseError_csr = usr_receivedResponseError_csr_buf;
|
521 |
|
|
|
522 |
|
|
phy0_available_lk0 = phy0_available_lk0_buf;
|
523 |
|
|
phy0_ctl_lk0 = phy0_ctl_lk0_buf;
|
524 |
|
|
for(int n = 0; n < CAD_IN_WIDTH; n++){
|
525 |
|
|
phy0_cad_lk0[n] = phy0_cad_lk0_buf[n];
|
526 |
|
|
}
|
527 |
|
|
phy0_consume_lk0 = phy0_consume_lk0_buf;
|
528 |
|
|
|
529 |
|
|
phy1_available_lk1 = phy1_available_lk1_buf;
|
530 |
|
|
phy1_ctl_lk1 = phy1_ctl_lk1_buf;
|
531 |
|
|
for(int n = 0; n < CAD_IN_WIDTH; n++){
|
532 |
|
|
phy1_cad_lk1[n] = phy1_cad_lk1_buf[n];
|
533 |
|
|
}
|
534 |
|
|
phy1_consume_lk1 = phy1_consume_lk1_buf;
|
535 |
|
|
}
|
536 |
|
|
|
537 |
|
|
|