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 |
|
|
#ifndef VC_HT_TUNNEL_L1_TB_H
|
41 |
|
|
#define VC_HT_TUNNEL_L1_TB_H
|
42 |
|
|
|
43 |
|
|
#include "../core/ht_datatypes.h"
|
44 |
|
|
#include "LogicalLayer.h"
|
45 |
|
|
#include "InterfaceLayer.h"
|
46 |
|
|
|
47 |
|
|
///Testbench to test the entire tunnel (vc_ht_tunnel_l1)
|
48 |
|
|
/**
|
49 |
|
|
@class vc_ht_tunnel_l1_tb
|
50 |
|
|
@author Ami Castonguay
|
51 |
|
|
@description Testbench to test the entire tunnel. This is not an
|
52 |
|
|
extensive test. More extensive tests are done on individual
|
53 |
|
|
modules. This testbench is only to test if the design works
|
54 |
|
|
for common types of traffic and operations. It is also not
|
55 |
|
|
an assertive testbench, so the output must be examined by hand.
|
56 |
|
|
|
57 |
|
|
The testbench uses different layer classes to interact with the
|
58 |
|
|
tunnel in an efficient way (InterfaceLayer, PhysicalLayer,
|
59 |
|
|
LogicalLayer)
|
60 |
|
|
*/
|
61 |
|
|
class vc_ht_tunnel_l1_tb : public sc_module , public LogicalLayerInterface,
|
62 |
|
|
public InterfaceLayerEventHandler{
|
63 |
|
|
public:
|
64 |
|
|
|
65 |
|
|
///vc_ht_tunnel_l1 IO to test
|
66 |
|
|
//@{
|
67 |
|
|
|
68 |
|
|
/// The Clock, LDTSTOP and reset signals
|
69 |
|
|
sc_in<bool> clk;
|
70 |
|
|
sc_out<bool> resetx;
|
71 |
|
|
sc_out<bool> pwrok;
|
72 |
|
|
sc_out<bool> ldtstopx;
|
73 |
|
|
|
74 |
|
|
//Link0 signals
|
75 |
|
|
//sc_out<bool > receive_clk0;
|
76 |
|
|
sc_out<bool> phy0_available_lk0;
|
77 |
|
|
sc_out<sc_bv<CAD_IN_DEPTH> > phy0_ctl_lk0;
|
78 |
|
|
sc_out<sc_bv<CAD_IN_DEPTH> > phy0_cad_lk0[CAD_IN_WIDTH];
|
79 |
|
|
|
80 |
|
|
//sc_in< bool > transmit_clk0;
|
81 |
|
|
sc_in<sc_bv<CAD_OUT_DEPTH> > lk0_ctl_phy0;
|
82 |
|
|
sc_in<sc_bv<CAD_OUT_DEPTH> > lk0_cad_phy0[CAD_OUT_WIDTH];
|
83 |
|
|
sc_out<bool> phy0_consume_lk0;
|
84 |
|
|
|
85 |
|
|
sc_in<bool> lk0_disable_drivers_phy0;
|
86 |
|
|
sc_in<bool> lk0_disable_receivers_phy0;
|
87 |
|
|
|
88 |
|
|
//Link1 signals
|
89 |
|
|
//sc_out<bool > receive_clk1;
|
90 |
|
|
sc_out<bool> phy1_available_lk1;
|
91 |
|
|
sc_out<sc_bv<CAD_IN_DEPTH> > phy1_ctl_lk1;
|
92 |
|
|
sc_out<sc_bv<CAD_IN_DEPTH> > phy1_cad_lk1[CAD_IN_WIDTH];
|
93 |
|
|
|
94 |
|
|
//sc_in< bool > transmit_clk0;
|
95 |
|
|
sc_in<sc_bv<CAD_OUT_DEPTH> > lk1_ctl_phy1;
|
96 |
|
|
sc_in<sc_bv<CAD_OUT_DEPTH> > lk1_cad_phy1[CAD_OUT_WIDTH];
|
97 |
|
|
sc_out<bool> phy1_consume_lk1;
|
98 |
|
|
|
99 |
|
|
sc_in<bool> lk1_disable_drivers_phy1;
|
100 |
|
|
sc_in<bool> lk1_disable_receivers_phy1;
|
101 |
|
|
|
102 |
|
|
/////////////////////////////////////////////////////
|
103 |
|
|
// Interface to UserInterface memory - synchronous
|
104 |
|
|
/////////////////////////////////////////////////////
|
105 |
|
|
|
106 |
|
|
sc_in<bool> ui_memory_write0;
|
107 |
|
|
sc_in<bool> ui_memory_write1;//20
|
108 |
|
|
sc_in<sc_bv<USER_MEMORY_ADDRESS_WIDTH> > ui_memory_write_address;
|
109 |
|
|
sc_in<sc_bv<32> > ui_memory_write_data;
|
110 |
|
|
|
111 |
|
|
sc_in<sc_bv<USER_MEMORY_ADDRESS_WIDTH> > ui_memory_read_address0;
|
112 |
|
|
sc_in<sc_bv<USER_MEMORY_ADDRESS_WIDTH> > ui_memory_read_address1;
|
113 |
|
|
sc_out<sc_bv<32> > ui_memory_read_data0;
|
114 |
|
|
sc_out<sc_bv<32> > ui_memory_read_data1;
|
115 |
|
|
|
116 |
|
|
#ifdef RETRY_MODE_ENABLED
|
117 |
|
|
//////////////////////////////////////////
|
118 |
|
|
// Memory interface flowcontrol0- synchronous
|
119 |
|
|
/////////////////////////////////////////
|
120 |
|
|
sc_in<bool> history_memory_write0;
|
121 |
|
|
sc_in<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > history_memory_write_address0;
|
122 |
|
|
sc_in<sc_bv<32> > history_memory_write_data0;
|
123 |
|
|
sc_in<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > history_memory_read_address0;//30
|
124 |
|
|
sc_out<sc_bv<32> > history_memory_output0;
|
125 |
|
|
|
126 |
|
|
//////////////////////////////////////////
|
127 |
|
|
// Memory interface flowcontrol1- synchronous
|
128 |
|
|
/////////////////////////////////////////
|
129 |
|
|
sc_in<bool> history_memory_write1;
|
130 |
|
|
sc_in<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > history_memory_write_address1;
|
131 |
|
|
sc_in<sc_bv<32> > history_memory_write_data1;
|
132 |
|
|
sc_in<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > history_memory_read_address1;
|
133 |
|
|
sc_out<sc_bv<32> > history_memory_output1;
|
134 |
|
|
|
135 |
|
|
#endif
|
136 |
|
|
|
137 |
|
|
////////////////////////////////////
|
138 |
|
|
// Memory interface databuffer0 - synchronous
|
139 |
|
|
////////////////////////////////////
|
140 |
|
|
|
141 |
|
|
sc_in<bool> memory_write0;
|
142 |
|
|
sc_in<sc_uint<2> > memory_write_address_vc0;
|
143 |
|
|
sc_in<sc_uint<BUFFERS_ADDRESS_WIDTH> > memory_write_address_buffer0;
|
144 |
|
|
sc_in<sc_uint<4> > memory_write_address_pos0;//40
|
145 |
|
|
sc_in<sc_bv<32> > memory_write_data0;
|
146 |
|
|
|
147 |
|
|
sc_in<sc_uint<2> > memory_read_address_vc0[2];
|
148 |
|
|
sc_in<sc_uint<BUFFERS_ADDRESS_WIDTH> >memory_read_address_buffer0[2];
|
149 |
|
|
sc_in<sc_uint<4> > memory_read_address_pos0[2];//50
|
150 |
|
|
|
151 |
|
|
sc_out<sc_bv<32> > memory_output0[2];
|
152 |
|
|
|
153 |
|
|
//////////////////////////////////////
|
154 |
|
|
// Memory interface databuffer1 - synchronous
|
155 |
|
|
////////////////////////////////////
|
156 |
|
|
|
157 |
|
|
sc_in<bool> memory_write1;
|
158 |
|
|
sc_in<sc_uint<2> > memory_write_address_vc1;
|
159 |
|
|
sc_in<sc_uint<BUFFERS_ADDRESS_WIDTH> > memory_write_address_buffer1;
|
160 |
|
|
sc_in<sc_uint<4> > memory_write_address_pos1;
|
161 |
|
|
sc_in<sc_bv<32> > memory_write_data1;
|
162 |
|
|
|
163 |
|
|
sc_in<sc_uint<2> > memory_read_address_vc1[2];
|
164 |
|
|
sc_in<sc_uint<BUFFERS_ADDRESS_WIDTH> >memory_read_address_buffer1[2];
|
165 |
|
|
sc_in<sc_uint<4> > memory_read_address_pos1[2];
|
166 |
|
|
|
167 |
|
|
sc_out<sc_bv<32> > memory_output1[2];
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
///////////////////////////////////////
|
171 |
|
|
// Interface to command memory 0
|
172 |
|
|
///////////////////////////////////////
|
173 |
|
|
sc_in<sc_bv<CMD_BUFFER_MEM_WIDTH> > ro0_command_packet_wr_data;
|
174 |
|
|
sc_in<bool > ro0_command_packet_write;
|
175 |
|
|
sc_in<sc_uint<LOG2_NB_OF_BUFFERS+2> > ro0_command_packet_wr_addr;
|
176 |
|
|
sc_in<sc_uint<LOG2_NB_OF_BUFFERS+2> > ro0_command_packet_rd_addr[2];
|
177 |
|
|
sc_out<sc_bv<CMD_BUFFER_MEM_WIDTH> > command_packet_rd_data_ro0[2];
|
178 |
|
|
|
179 |
|
|
///////////////////////////////////////
|
180 |
|
|
// Interface to command memory 1
|
181 |
|
|
///////////////////////////////////////
|
182 |
|
|
sc_in<sc_bv<CMD_BUFFER_MEM_WIDTH> > ro1_command_packet_wr_data;
|
183 |
|
|
sc_in<bool > ro1_command_packet_write;
|
184 |
|
|
sc_in<sc_uint<LOG2_NB_OF_BUFFERS+2> > ro1_command_packet_wr_addr;
|
185 |
|
|
sc_in<sc_uint<LOG2_NB_OF_BUFFERS+2> > ro1_command_packet_rd_addr[2];
|
186 |
|
|
sc_out<sc_bv<CMD_BUFFER_MEM_WIDTH> > command_packet_rd_data_ro1[2];
|
187 |
|
|
|
188 |
|
|
//******************************************
|
189 |
|
|
// Signals to User
|
190 |
|
|
//******************************************
|
191 |
|
|
//------------------------------------------
|
192 |
|
|
// Signals to send received packets to User
|
193 |
|
|
//------------------------------------------
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
/**The actual control/data packet to the user*/
|
197 |
|
|
sc_in<sc_bv<64> > ui_packet_usr;
|
198 |
|
|
|
199 |
|
|
/**The virtual channel of the ctl/data packet*/
|
200 |
|
|
sc_in<VirtualChannel> ui_vc_usr;
|
201 |
|
|
|
202 |
|
|
/**The side from which came the packet*/
|
203 |
|
|
sc_in< bool > ui_side_usr;
|
204 |
|
|
|
205 |
|
|
/**If the packet is a direct_route packet - only valid for
|
206 |
|
|
requests (posted and non-posted) */
|
207 |
|
|
sc_in<bool> ui_directroute_usr;
|
208 |
|
|
|
209 |
|
|
/**If this is the last part of the packet*/
|
210 |
|
|
sc_in< bool > ui_eop_usr;
|
211 |
|
|
|
212 |
|
|
/**If there is another packet available*/
|
213 |
|
|
sc_in< bool > ui_available_usr;
|
214 |
|
|
|
215 |
|
|
/**If what is read is 64 bits or 32 bits*/
|
216 |
|
|
sc_in< bool > ui_output_64bits_usr;
|
217 |
|
|
|
218 |
|
|
/**To allow the user to consume the packets*/
|
219 |
|
|
sc_out< bool > usr_consume_ui;
|
220 |
|
|
|
221 |
|
|
|
222 |
|
|
//------------------------------------------
|
223 |
|
|
// Signals to allow the User to send packets
|
224 |
|
|
//------------------------------------------
|
225 |
|
|
|
226 |
|
|
/**The actual control/data packet from the user*/
|
227 |
|
|
sc_out<sc_bv<64> > usr_packet_ui;
|
228 |
|
|
|
229 |
|
|
/**If there is another packet available*/
|
230 |
|
|
sc_out< bool > usr_available_ui;
|
231 |
|
|
|
232 |
|
|
/**
|
233 |
|
|
The side to send the packet if it is a response
|
234 |
|
|
This bit is ignored if the packet is not a response
|
235 |
|
|
since the side to send a request is determined automatically
|
236 |
|
|
taking in acount DirectRoute functionnality.
|
237 |
|
|
*/
|
238 |
|
|
sc_out< bool > usr_side_ui;
|
239 |
|
|
|
240 |
|
|
|
241 |
|
|
/**Which what type of ctl packets can be sent to side0*/
|
242 |
|
|
sc_in<sc_bv<6> > ui_freevc0_usr;
|
243 |
|
|
/**Which what type of ctl packets can be sent to side0*/
|
244 |
|
|
sc_in<sc_bv<6> > ui_freevc1_usr;
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
//------------------------------------------
|
248 |
|
|
// Signals to affect CSR
|
249 |
|
|
//------------------------------------------
|
250 |
|
|
sc_out<bool> usr_receivedResponseError_csr;
|
251 |
|
|
|
252 |
|
|
//@}
|
253 |
|
|
|
254 |
|
|
/////////////////////////////////////////
|
255 |
|
|
// Methods
|
256 |
|
|
/////////////////////////////////////////
|
257 |
|
|
|
258 |
|
|
///Physical layer for the side 0
|
259 |
|
|
PhysicalLayer * physicalLayer0;
|
260 |
|
|
///Logical layer for the side 0
|
261 |
|
|
LogicalLayer * logicalLayer0;
|
262 |
|
|
///Physical layer for the side 1
|
263 |
|
|
PhysicalLayer * physicalLayer1;
|
264 |
|
|
///Logical layer for the side 1
|
265 |
|
|
LogicalLayer * logicalLayer1;
|
266 |
|
|
///Interface layer for the HT user interface
|
267 |
|
|
InterfaceLayer * interfaceLayer;
|
268 |
|
|
|
269 |
|
|
///Handles read and write to the design's memories
|
270 |
|
|
void manage_memories();
|
271 |
|
|
///Main testbench control process
|
272 |
|
|
void run();
|
273 |
|
|
|
274 |
|
|
sc_signal<bool> resetx_buf;
|
275 |
|
|
sc_signal<bool> pwrok_buf;
|
276 |
|
|
sc_signal<bool> ldtstopx_buf;
|
277 |
|
|
sc_signal<bool> usr_consume_ui_buf;
|
278 |
|
|
sc_signal<sc_bv<64> > usr_packet_ui_buf;
|
279 |
|
|
sc_signal<bool> usr_available_ui_buf;
|
280 |
|
|
sc_signal<bool> usr_side_ui_buf;
|
281 |
|
|
sc_signal<bool> usr_receivedResponseError_csr_buf;
|
282 |
|
|
|
283 |
|
|
sc_signal<bool> phy0_available_lk0_buf;
|
284 |
|
|
sc_signal<sc_bv<CAD_IN_DEPTH> > phy0_ctl_lk0_buf;
|
285 |
|
|
sc_signal<sc_bv<CAD_IN_DEPTH> > phy0_cad_lk0_buf[CAD_IN_WIDTH];
|
286 |
|
|
sc_signal<bool> phy0_consume_lk0_buf;
|
287 |
|
|
|
288 |
|
|
sc_signal<bool> phy1_available_lk1_buf;
|
289 |
|
|
sc_signal<sc_bv<CAD_IN_DEPTH> > phy1_ctl_lk1_buf;
|
290 |
|
|
sc_signal<sc_bv<CAD_IN_DEPTH> > phy1_cad_lk1_buf[CAD_IN_WIDTH];
|
291 |
|
|
sc_signal<bool> phy1_consume_lk1_buf;
|
292 |
|
|
|
293 |
|
|
void drive_async_outputs();
|
294 |
|
|
|
295 |
|
|
///SystemC macro
|
296 |
|
|
SC_HAS_PROCESS(vc_ht_tunnel_l1_tb);
|
297 |
|
|
|
298 |
|
|
///Constructor
|
299 |
|
|
vc_ht_tunnel_l1_tb(sc_module_name name);
|
300 |
|
|
//Destructor
|
301 |
|
|
virtual ~vc_ht_tunnel_l1_tb();
|
302 |
|
|
|
303 |
|
|
///Communication to HT Logical Interface, see LogicalLayerInterface
|
304 |
|
|
virtual void receivedHtPacketEvent(const ControlPacket * packet,
|
305 |
13 |
acastong |
const int * data,const LogicalLayer* origin);
|
306 |
2 |
acastong |
///Communication to HT Logical Interface, see LogicalLayerInterface
|
307 |
|
|
virtual void crcErrorDetected();
|
308 |
|
|
|
309 |
|
|
///Communication to HT Interface Layer, see InterfaceLayerEventHandler
|
310 |
|
|
virtual void receivedInterfacePacketEvent(const ControlPacket * packet,const int * data,
|
311 |
|
|
bool directRoute,bool side,InterfaceLayer* origin);
|
312 |
|
|
|
313 |
|
|
///A count of packets received from side 0
|
314 |
|
|
int count_side0;
|
315 |
|
|
///A count of packets received from side 1
|
316 |
|
|
int count_side1;
|
317 |
|
|
///A count of packets received from the interface
|
318 |
|
|
int count_interface;
|
319 |
|
|
///If a packet has been received from the interface
|
320 |
|
|
bool received_side0;
|
321 |
|
|
|
322 |
|
|
///User interface memory side 0
|
323 |
|
|
int ui_memory0[USER_MEMORY_SIZE];
|
324 |
|
|
///User interface memory side 1
|
325 |
|
|
int ui_memory1[USER_MEMORY_SIZE];
|
326 |
|
|
|
327 |
|
|
///History memory side 0
|
328 |
|
|
int history_memory0[HISTORY_MEMORY_SIZE];
|
329 |
|
|
///History memory side 1
|
330 |
|
|
int history_memory1[HISTORY_MEMORY_SIZE];
|
331 |
|
|
|
332 |
|
|
///Databuffer memory side 0
|
333 |
|
|
int databuffer_memory0[3][DATABUFFER_NB_BUFFERS][16];
|
334 |
|
|
///Databuffer memory side 1
|
335 |
|
|
int databuffer_memory1[3][DATABUFFER_NB_BUFFERS][16];
|
336 |
|
|
|
337 |
|
|
|
338 |
|
|
///Command memory side 0
|
339 |
|
|
sc_bv<CMD_BUFFER_MEM_WIDTH> command_memory0[4*NB_OF_BUFFERS];
|
340 |
|
|
///Command memory side 1
|
341 |
|
|
sc_bv<CMD_BUFFER_MEM_WIDTH> command_memory1[4*NB_OF_BUFFERS];
|
342 |
|
|
};
|
343 |
|
|
|
344 |
|
|
#endif
|
345 |
|
|
|