1 |
2 |
acastong |
//reordering_l2_tb.h
|
2 |
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
3 |
|
|
* Version: MPL 1.1
|
4 |
|
|
*
|
5 |
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
6 |
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
7 |
|
|
* the License. You may obtain a copy of the License at
|
8 |
|
|
* http://www.mozilla.org/MPL/
|
9 |
|
|
*
|
10 |
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
11 |
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
12 |
|
|
* for the specific language governing rights and limitations under the
|
13 |
|
|
* License.
|
14 |
|
|
*
|
15 |
|
|
* The Original Code is HyperTransport Tunnel IP Core.
|
16 |
|
|
*
|
17 |
|
|
* The Initial Developer of the Original Code is
|
18 |
|
|
* Ecole Polytechnique de Montreal.
|
19 |
|
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
20 |
|
|
* the Initial Developer. All Rights Reserved.
|
21 |
|
|
*
|
22 |
|
|
* Contributor(s):
|
23 |
|
|
* Ami Castonguay <acastong@grm.polymtl.ca>
|
24 |
|
|
*
|
25 |
|
|
* Alternatively, the contents of this file may be used under the terms
|
26 |
|
|
* of the Polytechnique HyperTransport Tunnel IP Core Source Code License
|
27 |
|
|
* (the "PHTICSCL License", see the file PHTICSCL.txt), in which case the
|
28 |
|
|
* provisions of PHTICSCL License are applicable instead of those
|
29 |
|
|
* above. If you wish to allow use of your version of this file only
|
30 |
|
|
* under the terms of the PHTICSCL License and not to allow others to use
|
31 |
|
|
* your version of this file under the MPL, indicate your decision by
|
32 |
|
|
* deleting the provisions above and replace them with the notice and
|
33 |
|
|
* other provisions required by the PHTICSCL License. If you do not delete
|
34 |
|
|
* the provisions above, a recipient may use your version of this file
|
35 |
|
|
* under either the MPL or the PHTICSCL License."
|
36 |
|
|
*
|
37 |
|
|
* ***** END LICENSE BLOCK ***** */
|
38 |
|
|
#ifndef REORDERING_L2_TB_H
|
39 |
|
|
#define REORDERING_L2_TB_H
|
40 |
|
|
|
41 |
|
|
#include "../../rtl/systemc/core_synth/synth_datatypes.h"
|
42 |
|
|
#include <deque>
|
43 |
|
|
|
44 |
|
|
///Testbench for reordering_l2 module
|
45 |
|
|
class reordering_l2_tb : public sc_module{
|
46 |
|
|
//Structure containing all necessary information about a packet sent to reordering
|
47 |
|
|
/**
|
48 |
|
|
A packet might be for both accepted and forward (broadcast packet).
|
49 |
|
|
A packet for the CSR will have both the csr and accepted set to true
|
50 |
|
|
*/
|
51 |
|
|
struct ReorderTBPacket{
|
52 |
|
|
syn_ControlPacketComplete pkt;//The packet that was sent
|
53 |
|
|
VirtualChannel vc;//It's VirtualChannel
|
54 |
|
|
bool accepted;//If it is for accepted destination
|
55 |
|
|
bool forward;//If it is for forward destination
|
56 |
|
|
bool csr;//If it is for csr destination
|
57 |
|
|
};
|
58 |
|
|
|
59 |
|
|
///The different type of posted packet that can be requested
|
60 |
|
|
enum PostedType{
|
61 |
|
|
POSTED_ANY,
|
62 |
|
|
POSTED_ACCEPTED,
|
63 |
|
|
POSTED_FORWARD
|
64 |
|
|
};
|
65 |
|
|
|
66 |
|
|
///The different type of non-posted packet that can be requested
|
67 |
|
|
enum NPostedType{
|
68 |
|
|
NPOSTED_ANY,
|
69 |
|
|
NPOSTED_ACCEPTED,
|
70 |
|
|
NPOSTED_FORWARD
|
71 |
|
|
};
|
72 |
|
|
|
73 |
|
|
///The different type of response packet that can be requested
|
74 |
|
|
enum ResponseType{
|
75 |
|
|
RESPONSE_ANY,
|
76 |
|
|
RESPONSE_ACCEPTED,
|
77 |
|
|
RESPONSE_FORWARD
|
78 |
|
|
};
|
79 |
|
|
|
80 |
|
|
///The different type of destination and type of paccket chain posted packet can go
|
81 |
|
|
enum PostedDestination{
|
82 |
|
|
POSTED_DESTINATION_CSR = 0,
|
83 |
|
|
POSTED_DESTINATION_USER = 1,
|
84 |
|
|
POSTED_DESTINATION_FORWARD = 2,
|
85 |
|
|
POSTED_DESTINATION_USER_DEVICE_MSG = 3
|
86 |
|
|
};
|
87 |
|
|
|
88 |
|
|
public:
|
89 |
|
|
|
90 |
|
|
///clk signal
|
91 |
|
|
sc_in<bool> clk;
|
92 |
|
|
|
93 |
|
|
/// Reset signal
|
94 |
|
|
sc_out<bool> resetx;
|
95 |
|
|
/// Packet sent to CSR module
|
96 |
|
|
sc_in<syn_ControlPacketComplete> ro_packet_csr;
|
97 |
|
|
|
98 |
|
|
/// Packet sent to User module
|
99 |
|
|
sc_in<syn_ControlPacketComplete> ro_packet_ui;
|
100 |
|
|
/// Packet sent to FC module
|
101 |
|
|
sc_in<syn_ControlPacketComplete> ro_packet_fwd;
|
102 |
|
|
|
103 |
|
|
/// Indicates if a packet is available on the RO_ControlPacketComplete_CSR port
|
104 |
|
|
sc_in<bool> ro_available_csr;
|
105 |
|
|
/// Indicates if a packet is available on the RO_ControlPacketComplete_User port
|
106 |
|
|
sc_in<bool> ro_available_ui;
|
107 |
|
|
/// Indicates if a packet is available on the RO_ControlPacketComplete_FC port
|
108 |
|
|
sc_in<bool> ro_available_fwd;
|
109 |
|
|
|
110 |
|
|
/// Acknowledge signal from the CSR module
|
111 |
|
|
sc_out<bool> csr_ack_ro;
|
112 |
|
|
/// Acknowledge signal from the User module
|
113 |
|
|
sc_out<bool> ui_ack_ro;
|
114 |
|
|
/// Acknowledge signal from the FC module
|
115 |
|
|
/** fwd_ack_ro and eh_ack_ro do the same thing*/
|
116 |
|
|
sc_out<bool> fwd_ack_ro;
|
117 |
|
|
|
118 |
|
|
/// Acknowledge signal from the Error Handler module
|
119 |
|
|
sc_out<bool> eh_ack_ro;
|
120 |
|
|
|
121 |
|
|
/// Indicates that a NOP was sent
|
122 |
|
|
sc_out<bool> fc_nop_sent;
|
123 |
|
|
|
124 |
|
|
/// New packet from Command Decode
|
125 |
|
|
sc_out<syn_ControlPacketComplete> cd_packet_ro;
|
126 |
|
|
|
127 |
|
|
/// Indicates if a packet is available on the CD_ControlPacketComplete_RO port
|
128 |
|
|
sc_out<bool> cd_available_ro;
|
129 |
|
|
|
130 |
|
|
/**If the cd is currently receiving data. This is used to know if a packet
|
131 |
|
|
that has associated data can be sent*/
|
132 |
|
|
sc_out<bool> cd_data_pending_ro;
|
133 |
|
|
|
134 |
|
|
/**Where the cd is storing data. This is used to know if a packet
|
135 |
|
|
that has associated data can be sent*/
|
136 |
|
|
sc_out<sc_uint<BUFFERS_ADDRESS_WIDTH> > cd_data_pending_addr_ro;
|
137 |
|
|
|
138 |
|
|
/// UnitID of the current module
|
139 |
|
|
sc_out<sc_bv<5> > csr_unit_id;
|
140 |
|
|
|
141 |
|
|
/// Address Range reserved for the module.
|
142 |
|
|
sc_out<sc_bv<40> > csr_bar[NbRegsBars];
|
143 |
|
|
|
144 |
|
|
///If we accept writes or reads to the memory space
|
145 |
|
|
sc_out<bool> csr_memory_space_enable;
|
146 |
|
|
|
147 |
|
|
///If we accept writes or reads to the io space
|
148 |
|
|
sc_out<bool> csr_io_space_enable;
|
149 |
|
|
|
150 |
|
|
/** Indicates which unitID enables DirectRoute*/
|
151 |
|
|
sc_out<sc_bv<32> > csr_direct_route_enable;
|
152 |
|
|
|
153 |
|
|
/// Indicates the clumping configuration
|
154 |
|
|
sc_out<sc_bv<5> > clumped_unit_id[32];
|
155 |
|
|
|
156 |
|
|
///If the link is currently sync flooding
|
157 |
|
|
sc_out<bool> csr_sync;
|
158 |
|
|
|
159 |
|
|
#ifdef ENABLE_REORDERING
|
160 |
|
|
/// this flag disables the reordering.
|
161 |
|
|
/**See chapter 7.5.10.6 of hyperTransport specs 1.10*/
|
162 |
|
|
sc_out<bool> csr_unitid_reorder_disable;
|
163 |
|
|
#endif
|
164 |
|
|
/**Indicates whether the VC is upstream(=true) or downstream(=false)*/
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
/// Contains information about the Command buffers of the upper module.
|
168 |
|
|
/**A set bit indicates:
|
169 |
|
|
bit 5 = There is space in the PC VC
|
170 |
|
|
bit 4 = There is space in the PC data VC
|
171 |
|
|
bit 3 = There is space in the NPC VC
|
172 |
|
|
bit 2 = There is space in the NPC data VC
|
173 |
|
|
bit 1 = There is space in the R VC
|
174 |
|
|
bit 0 = There is space in the R data VC
|
175 |
|
|
A command packet cannot be sent if there is room in both data and command
|
176 |
|
|
buffers of the upper module*/
|
177 |
|
|
sc_out<sc_bv <6> > fwd_next_node_buffer_status_ro;
|
178 |
|
|
///Buffers to advertise as free when a nop is sent
|
179 |
|
|
/** [5,4]: nonposted; [3,2]: response. [1,0]: posted;*/
|
180 |
|
|
sc_in<sc_bv <6> > ro_buffer_cnt_fc;
|
181 |
|
|
/// Asks to send a NOP
|
182 |
|
|
sc_in<bool> ro_nop_req_fc;
|
183 |
|
|
///More packets than can be stored are received
|
184 |
|
|
sc_in<bool> ro_overflow_csr;
|
185 |
|
|
|
186 |
|
|
#ifdef RETRY_MODE_ENABLED
|
187 |
|
|
/// If the RX link is connected
|
188 |
|
|
sc_out< bool > lk_rx_connected;
|
189 |
|
|
///If retry mode is active
|
190 |
|
|
sc_out< bool > csr_retry;
|
191 |
|
|
#endif
|
192 |
|
|
|
193 |
|
|
///////////////////////////////////////
|
194 |
|
|
// Interface to memory
|
195 |
|
|
///////////////////////////////////////
|
196 |
|
|
sc_in<sc_bv<CMD_BUFFER_MEM_WIDTH> > ro_command_packet_wr_data;
|
197 |
|
|
sc_in<bool > ro_command_packet_write;
|
198 |
|
|
sc_in<sc_uint<LOG2_NB_OF_BUFFERS+2> > ro_command_packet_wr_addr;
|
199 |
|
|
sc_in<sc_uint<LOG2_NB_OF_BUFFERS+2> > ro_command_packet_rd_addr[2];
|
200 |
|
|
sc_out<sc_bv<CMD_BUFFER_MEM_WIDTH> > command_packet_rd_data_ro[2];
|
201 |
|
|
|
202 |
|
|
///Command memory
|
203 |
|
|
sc_bv<CMD_BUFFER_MEM_WIDTH> command_memory[4*NB_OF_BUFFERS];
|
204 |
|
|
|
205 |
|
|
/** @see ::consume_data()
|
206 |
|
|
*/
|
207 |
|
|
//@{
|
208 |
|
|
///Read packet to configuration space registers if available
|
209 |
|
|
sc_signal<bool> read_csr;
|
210 |
|
|
///Read packet to forward if available
|
211 |
|
|
sc_signal<bool> read_fwd;
|
212 |
|
|
///Read packet to user interface if available
|
213 |
|
|
sc_signal<bool> read_ui;
|
214 |
|
|
//@}
|
215 |
|
|
|
216 |
|
|
///Queue of packets sent in the reordering
|
217 |
|
|
std::deque<ReorderTBPacket> packet_sent;
|
218 |
|
|
///If the packets currently being sent to the reordering are part of a chain
|
219 |
|
|
bool curently_sending_chain;
|
220 |
|
|
///The destination the chain is going so that following packets to the same way
|
221 |
|
|
PostedDestination chain_destination;
|
222 |
|
|
|
223 |
|
|
///SystemC Macro
|
224 |
|
|
SC_HAS_PROCESS(reordering_l2_tb);
|
225 |
|
|
///Constructor
|
226 |
|
|
reordering_l2_tb(sc_module_name name);
|
227 |
|
|
|
228 |
|
|
///Main testbench control thread
|
229 |
|
|
void simulate();
|
230 |
|
|
/** The testbench is synchronous, so there is no way to know if during the
|
231 |
|
|
next cycle there will be data available from the reordering. Different
|
232 |
|
|
read signals(::read_csr,::read_fwd,::read_ui) can be read synchronously and
|
233 |
|
|
this process will read from the destination if there is data available.
|
234 |
|
|
*/
|
235 |
|
|
void consume_data();
|
236 |
|
|
|
237 |
|
|
void manage_memories();
|
238 |
|
|
|
239 |
|
|
/** @description Generate an random address that is not part of the
|
240 |
|
|
BAR addresses.
|
241 |
|
|
@param addr The generated address returned by address
|
242 |
|
|
*/
|
243 |
|
|
void generate_random_not_bar_address(sc_bv<40> &addr);
|
244 |
|
|
|
245 |
|
|
/** @description Generate an random posted packet going to the
|
246 |
|
|
specified destination
|
247 |
|
|
@param tb_pkt The generated packet and associated informations
|
248 |
|
|
returned by address
|
249 |
|
|
@param posted_type The destination where the packet should go
|
250 |
|
|
*/
|
251 |
|
|
void generate_random_posted_pkt(ReorderTBPacket &tb_pkt,
|
252 |
|
|
PostedType posted_type);
|
253 |
|
|
/** @description Generate an random posted packet going to the
|
254 |
|
|
accepted destination
|
255 |
|
|
@param pkt The generated packet returned by address
|
256 |
|
|
@param chain If the packet is part of a chain
|
257 |
|
|
*/
|
258 |
|
|
bool generate_random_accepted_posted_pkt(sc_bv<64> &pkt,
|
259 |
|
|
bool chain);
|
260 |
|
|
|
261 |
|
|
/** @description Generate an random posted packet going to the
|
262 |
|
|
forward destination
|
263 |
|
|
@param pkt The generated packet returned by address
|
264 |
|
|
@param chain If the packet is part of a chain
|
265 |
|
|
*/
|
266 |
|
|
void generate_random_forward_posted_pkt(sc_bv<64> &pkt, bool chain);
|
267 |
|
|
|
268 |
|
|
/** @description Generate an random broadcast packet
|
269 |
|
|
@param tb_pkt The generated packet returned by address
|
270 |
|
|
*/
|
271 |
|
|
void generate_random_broadcast_posted_pkt(sc_bv<64> &tb_pkt);
|
272 |
|
|
|
273 |
|
|
/** @description Generate an random 64-bit vector
|
274 |
|
|
@param pkt The generated vector returned by address
|
275 |
|
|
*/
|
276 |
|
|
void generate_random_64b_vector(sc_bv<64> &pkt);
|
277 |
|
|
|
278 |
|
|
/** @description Generate an random non posted packet going to the
|
279 |
|
|
specified destination
|
280 |
|
|
@param tb_pkt The generated packet and associated informations
|
281 |
|
|
returned by address
|
282 |
|
|
@param nposted_type The destination where the packet should go
|
283 |
|
|
*/
|
284 |
|
|
void generate_random_nposted_pkt(ReorderTBPacket &tb_pkt,
|
285 |
|
|
NPostedType nposted_type);
|
286 |
|
|
|
287 |
|
|
/** @description Generate an random non posted packet going to the
|
288 |
|
|
accepted destination
|
289 |
|
|
@param pkt The generated packet returned by address
|
290 |
|
|
*/
|
291 |
|
|
bool generate_random_accepted_nposted_pkt(sc_bv<64> &pkt);
|
292 |
|
|
|
293 |
|
|
/** @description Generate an random non posted packet going to the
|
294 |
|
|
forward destination
|
295 |
|
|
@param pkt The generated packet returned by address
|
296 |
|
|
*/
|
297 |
|
|
void generate_random_forward_nposted_pkt(sc_bv<64> &pkt);
|
298 |
|
|
|
299 |
|
|
/** @description Generate an random response packet going to the
|
300 |
|
|
specified destination
|
301 |
|
|
@param tb_pkt The generated packet and associated informations
|
302 |
|
|
returned by address
|
303 |
|
|
@param response_type The destination where the packet should go
|
304 |
|
|
*/
|
305 |
|
|
void generate_random_response_pkt(ReorderTBPacket &tb_pkt,
|
306 |
|
|
ResponseType response_type);
|
307 |
|
|
|
308 |
|
|
/** @description Generate an random response packet going to the
|
309 |
|
|
accepted destination
|
310 |
|
|
@param pkt The generated packet returned by address
|
311 |
|
|
*/
|
312 |
|
|
void generate_random_accepted_response_pkt(sc_bv<64> &pkt);
|
313 |
|
|
|
314 |
|
|
/** @description Generate an random response packet going to the
|
315 |
|
|
forward destination
|
316 |
|
|
@param pkt The generated packet returned by address
|
317 |
|
|
*/
|
318 |
|
|
void generate_random_forward_response_pkt(sc_bv<64> &pkt);
|
319 |
|
|
};
|
320 |
|
|
|
321 |
|
|
#endif
|
322 |
|
|
|