1 |
2 |
acastong |
//main.cpp - Data buffer testbench
|
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 |
|
|
|
39 |
|
|
#include "../../rtl/systemc/core_synth/synth_datatypes.h"
|
40 |
|
|
#include "../../rtl/systemc/core_synth/constants.h"
|
41 |
|
|
|
42 |
|
|
#include "../../rtl/systemc/databuffer_l2/databuffer_l2.h"
|
43 |
|
|
#include "databuffer_l2_tb.h"
|
44 |
|
|
|
45 |
|
|
#include <iostream>
|
46 |
|
|
#include <string>
|
47 |
|
|
#include <sstream>
|
48 |
|
|
#include <iomanip>
|
49 |
|
|
|
50 |
|
|
using namespace std;
|
51 |
|
|
|
52 |
|
|
int sc_main( int argc, char* argv[] ){
|
53 |
|
|
//The Design Under Test
|
54 |
|
|
databuffer_l2* dut = new databuffer_l2("databuffer_l2");
|
55 |
|
|
//The TestBench
|
56 |
|
|
databuffer_l2_tb* tb = new databuffer_l2_tb("link_l2_tb");
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
//Signals used to link the design to the testbench
|
60 |
|
|
sc_clock clk("clk", 1); // system clk
|
61 |
|
|
|
62 |
|
|
sc_signal< bool > resetx;
|
63 |
|
|
sc_signal< bool > ldtstopx;
|
64 |
|
|
sc_signal< sc_bv<32> > cd_data_db;
|
65 |
|
|
sc_signal< sc_uint<4> > cd_datalen_db;
|
66 |
|
|
sc_signal< VirtualChannel > cd_vctype_db;
|
67 |
|
|
sc_signal< bool > cd_write_db;
|
68 |
|
|
sc_signal< bool > cd_getaddr_db;
|
69 |
|
|
#ifdef RETRY_MODE_ENABLED
|
70 |
|
|
sc_signal< bool > cd_drop_db;
|
71 |
|
|
sc_signal< bool > lk_initiate_retry_disconnect;
|
72 |
|
|
sc_signal< bool > cd_initiate_retry_disconnect;
|
73 |
|
|
sc_signal< bool > csr_retry;
|
74 |
|
|
#endif
|
75 |
|
|
sc_signal< sc_uint<BUFFERS_ADDRESS_WIDTH> > db_address_cd;
|
76 |
|
|
sc_signal< sc_uint<BUFFERS_ADDRESS_WIDTH> > eh_address_db;
|
77 |
|
|
sc_signal< VirtualChannel > eh_vctype_db;
|
78 |
|
|
sc_signal< bool > eh_erase_db;
|
79 |
|
|
sc_signal< sc_uint<BUFFERS_ADDRESS_WIDTH> > csr_address_db;
|
80 |
|
|
sc_signal< bool > csr_read_db;
|
81 |
|
|
sc_signal< VirtualChannel > csr_vctype_db;
|
82 |
|
|
sc_signal< sc_uint<BUFFERS_ADDRESS_WIDTH> > ui_address_db;
|
83 |
|
|
sc_signal< bool > ui_read_db;
|
84 |
|
|
sc_signal< VirtualChannel > ui_vctype_db;
|
85 |
|
|
sc_signal< sc_bv<32> > db_data_accepted;
|
86 |
|
|
sc_signal< bool > csr_erase_db;
|
87 |
|
|
sc_signal< bool > ui_erase_db;
|
88 |
|
|
sc_signal< sc_uint<BUFFERS_ADDRESS_WIDTH> > fwd_address_db;
|
89 |
|
|
sc_signal< bool > fwd_read_db;
|
90 |
|
|
sc_signal< VirtualChannel > fwd_vctype_db;
|
91 |
|
|
sc_signal< sc_bv<32> > db_data_fwd;
|
92 |
|
|
sc_signal< bool > fwd_erase_db;
|
93 |
|
|
sc_signal< bool > fc_nop_sent;
|
94 |
|
|
sc_signal< sc_bv<6> > db_buffer_cnt_fc;
|
95 |
|
|
sc_signal< bool > db_nop_req_fc;
|
96 |
|
|
sc_signal< bool > db_overflow_csr;
|
97 |
|
|
sc_signal<bool> ui_grant_csr_access_db;
|
98 |
|
|
|
99 |
|
|
////////////////////////////////////
|
100 |
|
|
//Interface to memory - synchronous
|
101 |
|
|
////////////////////////////////////
|
102 |
|
|
|
103 |
|
|
sc_signal<bool> memory_write;
|
104 |
|
|
sc_signal<sc_uint<2> > memory_write_address_vc;
|
105 |
|
|
sc_signal<sc_uint<BUFFERS_ADDRESS_WIDTH> > memory_write_address_buffer;
|
106 |
|
|
sc_signal<sc_uint<4> > memory_write_address_pos;
|
107 |
|
|
sc_signal<sc_bv<32> > memory_write_data;
|
108 |
|
|
|
109 |
|
|
sc_signal<sc_uint<2> > memory_read_address_vc[2];
|
110 |
|
|
sc_signal<sc_uint<BUFFERS_ADDRESS_WIDTH> >memory_read_address_buffer[2];
|
111 |
|
|
sc_signal<sc_uint<4> > memory_read_address_pos[2];
|
112 |
|
|
|
113 |
|
|
sc_signal<sc_bv<32> > memory_output[2];
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
sc_signal<bool> error;
|
117 |
|
|
|
118 |
|
|
//Connect the design
|
119 |
|
|
dut->clk(clk);
|
120 |
|
|
|
121 |
|
|
dut->resetx(resetx);
|
122 |
|
|
dut->ldtstopx(ldtstopx);
|
123 |
|
|
dut->cd_data_db(cd_data_db);
|
124 |
|
|
dut->cd_datalen_db(cd_datalen_db);
|
125 |
|
|
dut->cd_vctype_db(cd_vctype_db);
|
126 |
|
|
dut->cd_write_db(cd_write_db);
|
127 |
|
|
dut->cd_getaddr_db(cd_getaddr_db);
|
128 |
|
|
#ifdef RETRY_MODE_ENABLED
|
129 |
|
|
dut->cd_drop_db(cd_drop_db);
|
130 |
|
|
dut->lk_initiate_retry_disconnect(lk_initiate_retry_disconnect);
|
131 |
|
|
dut->cd_initiate_retry_disconnect(cd_initiate_retry_disconnect);
|
132 |
|
|
dut->csr_retry(csr_retry);
|
133 |
|
|
#endif
|
134 |
|
|
dut->db_address_cd(db_address_cd);
|
135 |
|
|
dut->eh_address_db(eh_address_db);
|
136 |
|
|
dut->eh_vctype_db(eh_vctype_db);
|
137 |
|
|
dut->eh_erase_db(eh_erase_db);
|
138 |
|
|
dut->csr_address_db(csr_address_db);
|
139 |
|
|
dut->csr_read_db(csr_read_db);
|
140 |
|
|
dut->csr_vctype_db(csr_vctype_db);
|
141 |
|
|
dut->ui_address_db(ui_address_db);
|
142 |
|
|
dut->ui_read_db(ui_read_db);
|
143 |
|
|
dut->ui_vctype_db(ui_vctype_db);
|
144 |
|
|
dut->db_data_accepted(db_data_accepted);
|
145 |
|
|
dut->csr_erase_db(csr_erase_db);
|
146 |
|
|
dut->ui_erase_db(ui_erase_db);
|
147 |
|
|
dut->fwd_address_db(fwd_address_db);
|
148 |
|
|
dut->fwd_read_db(fwd_read_db);
|
149 |
|
|
dut->fwd_vctype_db(fwd_vctype_db);
|
150 |
|
|
dut->db_data_fwd(db_data_fwd);
|
151 |
|
|
dut->fwd_erase_db(fwd_erase_db);
|
152 |
|
|
dut->fc_nop_sent(fc_nop_sent);
|
153 |
|
|
dut->db_buffer_cnt_fc(db_buffer_cnt_fc);
|
154 |
|
|
dut->db_nop_req_fc(db_nop_req_fc);
|
155 |
|
|
dut->db_overflow_csr(db_overflow_csr);
|
156 |
|
|
dut->ui_grant_csr_access_db(ui_grant_csr_access_db);
|
157 |
|
|
|
158 |
|
|
////////////////////////////////////
|
159 |
|
|
//Interface to memory - synchronous
|
160 |
|
|
////////////////////////////////////
|
161 |
|
|
|
162 |
|
|
dut->memory_write(memory_write);
|
163 |
|
|
dut->memory_write_address_vc(memory_write_address_vc);
|
164 |
|
|
dut->memory_write_address_buffer(memory_write_address_buffer);
|
165 |
|
|
dut->memory_write_address_pos(memory_write_address_pos);
|
166 |
|
|
dut->memory_write_data(memory_write_data);
|
167 |
|
|
|
168 |
|
|
for(int n = 0; n < 2; n++){
|
169 |
|
|
dut->memory_read_address_vc[n](memory_read_address_vc[n]);
|
170 |
|
|
dut->memory_read_address_buffer[n](memory_read_address_buffer[n]);
|
171 |
|
|
dut->memory_read_address_pos[n](memory_read_address_pos[n]);
|
172 |
|
|
|
173 |
|
|
dut->memory_output[n](memory_output[n]);
|
174 |
|
|
}
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
//Connect the testbench
|
178 |
|
|
tb->clk(clk);
|
179 |
|
|
|
180 |
|
|
tb->resetx(resetx);
|
181 |
|
|
tb->ldtstopx(ldtstopx);
|
182 |
|
|
tb->cd_data_db(cd_data_db);
|
183 |
|
|
tb->cd_datalen_db(cd_datalen_db);
|
184 |
|
|
tb->cd_vctype_db(cd_vctype_db);
|
185 |
|
|
tb->cd_write_db(cd_write_db);
|
186 |
|
|
tb->cd_getaddr_db(cd_getaddr_db);
|
187 |
|
|
#ifdef RETRY_MODE_ENABLED
|
188 |
|
|
tb->cd_drop_db(cd_drop_db);
|
189 |
|
|
tb->lk_initiate_retry_disconnect(lk_initiate_retry_disconnect);
|
190 |
|
|
tb->cd_initiate_retry_disconnect(cd_initiate_retry_disconnect);
|
191 |
|
|
tb->csr_retry(csr_retry);
|
192 |
|
|
#endif
|
193 |
|
|
tb->db_address_cd(db_address_cd);
|
194 |
|
|
tb->eh_address_db(eh_address_db);
|
195 |
|
|
tb->eh_vctype_db(eh_vctype_db);
|
196 |
|
|
tb->eh_erase_db(eh_erase_db);
|
197 |
|
|
tb->csr_address_db(csr_address_db);
|
198 |
|
|
tb->csr_read_db(csr_read_db);
|
199 |
|
|
tb->csr_vctype_db(csr_vctype_db);
|
200 |
|
|
tb->ui_address_db(ui_address_db);
|
201 |
|
|
tb->ui_read_db(ui_read_db);
|
202 |
|
|
tb->ui_vctype_db(ui_vctype_db);
|
203 |
|
|
tb->db_data_accepted(db_data_accepted);
|
204 |
|
|
tb->csr_erase_db(csr_erase_db);
|
205 |
|
|
tb->ui_erase_db(ui_erase_db);
|
206 |
|
|
tb->fwd_address_db(fwd_address_db);
|
207 |
|
|
tb->fwd_read_db(fwd_read_db);
|
208 |
|
|
tb->fwd_vctype_db(fwd_vctype_db);
|
209 |
|
|
tb->db_data_fwd(db_data_fwd);
|
210 |
|
|
tb->fwd_erase_db(fwd_erase_db);
|
211 |
|
|
tb->fc_nop_sent(fc_nop_sent);
|
212 |
|
|
tb->db_buffer_cnt_fc(db_buffer_cnt_fc);
|
213 |
|
|
tb->db_nop_req_fc(db_nop_req_fc);
|
214 |
|
|
tb->db_overflow_csr(db_overflow_csr);
|
215 |
|
|
tb->ui_grant_csr_access_db(ui_grant_csr_access_db);
|
216 |
|
|
|
217 |
|
|
////////////////////////////////////
|
218 |
|
|
//Interface to memory - synchronous
|
219 |
|
|
////////////////////////////////////
|
220 |
|
|
|
221 |
|
|
tb->memory_write(memory_write);
|
222 |
|
|
tb->memory_write_address_vc(memory_write_address_vc);
|
223 |
|
|
tb->memory_write_address_buffer(memory_write_address_buffer);
|
224 |
|
|
tb->memory_write_address_pos(memory_write_address_pos);
|
225 |
|
|
tb->memory_write_data(memory_write_data);
|
226 |
|
|
|
227 |
|
|
for(int n = 0; n < 2; n++){
|
228 |
|
|
tb->memory_read_address_vc[n](memory_read_address_vc[n]);
|
229 |
|
|
tb->memory_read_address_buffer[n](memory_read_address_buffer[n]);
|
230 |
|
|
tb->memory_read_address_pos[n](memory_read_address_pos[n]);
|
231 |
|
|
|
232 |
|
|
tb->memory_output[n](memory_output[n]);
|
233 |
|
|
}
|
234 |
|
|
|
235 |
|
|
tb->error(error);
|
236 |
|
|
|
237 |
|
|
//Trace signals
|
238 |
|
|
sc_trace_file *tf = sc_create_vcd_trace_file("sim_databuffer_l2");
|
239 |
|
|
|
240 |
|
|
sc_trace(tf,clk,"clk");
|
241 |
|
|
sc_trace(tf,resetx,"resetx");
|
242 |
|
|
sc_trace(tf,ldtstopx,"ldtstopx");
|
243 |
|
|
sc_trace(tf,cd_data_db,"cd_data_db");
|
244 |
|
|
sc_trace(tf,cd_datalen_db,"cd_datalen_db");
|
245 |
|
|
sc_trace(tf,tb->cd_vctype_db_trace,"cd_vctype_db");
|
246 |
|
|
sc_trace(tf,cd_write_db,"cd_write_db");
|
247 |
|
|
sc_trace(tf,cd_getaddr_db,"cd_getaddr_db");
|
248 |
|
|
#ifdef RETRY_MODE_ENABLED
|
249 |
|
|
sc_trace(tf,cd_drop_db,"cd_drop_db");
|
250 |
|
|
sc_trace(tf,lk_initiate_retry_disconnect,"lk_initiate_retry_disconnect");
|
251 |
|
|
sc_trace(tf,cd_initiate_retry_disconnect,"cd_initiate_retry_disconnect");
|
252 |
|
|
sc_trace(tf,csr_retry,"csr_retry");
|
253 |
|
|
#endif
|
254 |
|
|
sc_trace(tf,db_address_cd,"db_address_cd");
|
255 |
|
|
sc_trace(tf,eh_address_db,"eh_address_db");
|
256 |
|
|
sc_trace(tf,tb->eh_vctype_db_trace,"eh_vctype_db");
|
257 |
|
|
sc_trace(tf,eh_erase_db,"eh_erase_db");
|
258 |
|
|
sc_trace(tf,csr_address_db,"csr_address_db");
|
259 |
|
|
sc_trace(tf,csr_read_db,"csr_read_db");
|
260 |
|
|
sc_trace(tf,tb->csr_vctype_db_trace,"csr_vctype_db");
|
261 |
|
|
sc_trace(tf,ui_address_db,"ui_address_db");
|
262 |
|
|
sc_trace(tf,ui_read_db,"ui_read_db");
|
263 |
|
|
sc_trace(tf,tb->ui_vctype_db_trace,"ui_vctype_db");
|
264 |
|
|
sc_trace(tf,db_data_accepted,"db_data_accepted");
|
265 |
|
|
sc_trace(tf,csr_erase_db,"csr_erase_db");
|
266 |
|
|
sc_trace(tf,ui_erase_db,"ui_erase_db");
|
267 |
|
|
sc_trace(tf,fwd_address_db,"fwd_address_db");
|
268 |
|
|
sc_trace(tf,fwd_read_db,"fwd_read_db");
|
269 |
|
|
sc_trace(tf,tb->fwd_vctype_db_trace,"fwd_vctype_db");
|
270 |
|
|
sc_trace(tf,db_data_fwd,"db_data_fwd");
|
271 |
|
|
sc_trace(tf,fwd_erase_db,"fwd_erase_db");
|
272 |
|
|
sc_trace(tf,fc_nop_sent,"fc_nop_sent");
|
273 |
|
|
sc_trace(tf,db_buffer_cnt_fc,"db_buffer_cnt_fc");
|
274 |
|
|
sc_trace(tf,db_nop_req_fc,"db_nop_req_fc");
|
275 |
|
|
sc_trace(tf,db_overflow_csr,"db_overflow_csr");
|
276 |
|
|
sc_trace(tf,ui_grant_csr_access_db,"ui_grant_csr_access_db");
|
277 |
|
|
|
278 |
|
|
////////////////////////////////////
|
279 |
|
|
//Interface to memory - synchronous
|
280 |
|
|
////////////////////////////////////
|
281 |
|
|
|
282 |
|
|
sc_trace(tf,memory_write,"memory_write");
|
283 |
|
|
sc_trace(tf,memory_write_address_vc,"memory_write_address_vc");
|
284 |
|
|
sc_trace(tf,memory_write_address_buffer,"memory_write_address_buffer");
|
285 |
|
|
sc_trace(tf,memory_write_address_pos,"memory_write_address_pos");
|
286 |
|
|
sc_trace(tf,memory_write_data,"memory_write_data");
|
287 |
|
|
|
288 |
|
|
for(int n = 0; n < 2; n++){
|
289 |
|
|
|
290 |
|
|
std::ostringstream s;
|
291 |
|
|
s << "memory_read_address_vc(" << n << ')';
|
292 |
|
|
sc_trace(tf,memory_read_address_vc[n],s.str().c_str());
|
293 |
|
|
|
294 |
|
|
std::ostringstream s2;
|
295 |
|
|
s2 << "memory_read_address_buffer(" << n << ')';
|
296 |
|
|
sc_trace(tf,memory_read_address_buffer[n],s2.str().c_str());
|
297 |
|
|
|
298 |
|
|
std::ostringstream s3;
|
299 |
|
|
s3 << "memory_read_address_pos(" << n << ')';
|
300 |
|
|
sc_trace(tf,memory_read_address_pos[n],s3.str().c_str());
|
301 |
|
|
|
302 |
|
|
std::ostringstream s4;
|
303 |
|
|
s4 << "memory_output(" << n << ')';
|
304 |
|
|
sc_trace(tf,memory_output[n],s4.str().c_str());
|
305 |
|
|
}
|
306 |
|
|
|
307 |
|
|
sc_trace(tf,error,"ERROR");
|
308 |
|
|
sc_trace(tf,dut->bufferCount[0],"DB.bufferCount(0)");
|
309 |
|
|
sc_trace(tf,dut->bufferCount[1],"DB.bufferCount(1)");
|
310 |
|
|
sc_trace(tf,dut->bufferCount[2],"DB.bufferCount(2)");
|
311 |
|
|
sc_trace(tf,dut->freeBuffers[0],"DB.freeBuffers(0)");
|
312 |
|
|
sc_trace(tf,dut->freeBuffers[1],"DB.freeBuffers(1)");
|
313 |
|
|
sc_trace(tf,dut->freeBuffers[2],"DB.freeBuffers(2)");
|
314 |
|
|
|
315 |
|
|
//------------------------------------------
|
316 |
|
|
// Start simulation
|
317 |
|
|
//------------------------------------------
|
318 |
|
|
cout << "Begin simulation" << endl;
|
319 |
|
|
sc_start(500);
|
320 |
|
|
|
321 |
|
|
sc_close_vcd_trace_file(tf);
|
322 |
|
|
cout << "End simulation" << endl;
|
323 |
|
|
|
324 |
|
|
delete dut;
|
325 |
|
|
delete tb;
|
326 |
|
|
return 0;
|
327 |
|
|
}
|
328 |
|
|
|