OpenCores
URL https://opencores.org/ocsvn/ht_tunnel/ht_tunnel/trunk

Subversion Repositories ht_tunnel

[/] [ht_tunnel/] [tags/] [START/] [bench/] [link_l2/] [link_l2_tb/] [main.cpp] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 acastong
//main.cpp
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
//Main for link_frame_rx_l3 testbench
39
 
40
#ifndef SC_USER_DEFINED_MAX_NUMBER_OF_PROCESSES
41
#define SC_USER_DEFINED_MAX_NUMBER_OF_PROCESSES
42
#define SC_VC6_MAX_NUMBER_OF_PROCESSES 20
43
#endif
44
#include <systemc.h>
45
 
46
#include "../../../rtl/systemc/core_synth/synth_datatypes.h"
47
#include "../../../rtl/systemc/core_synth/constants.h"
48
 
49
#include "../../../rtl/systemc/link_l2/link_l2.h"
50
#include "../../../rtl/systemc/link_l2/link_frame_rx_l3.h"
51
#include "link_l2_tb.h"
52
 
53
#include <iostream>
54
#include <string>
55
#include <sstream>
56
#include <iomanip>
57
 
58
using namespace std;
59
 
60
int sc_main( int argc, char* argv[] ){
61
 
62
 
63
        //The Design Under Test
64
        link_l2* dut = new link_l2("link_l2");
65
        //The TestBench
66
        link_l2_tb* tb = new link_l2_tb("link_l2_tb");
67
 
68
 
69
        //Signals used to link the design to the testbench
70
        sc_clock clk("clk", 1);  // system clk
71
        sc_signal<bool>                 resetx;
72
        sc_signal<bool>                 pwrok;
73
        sc_signal<bool>                 ldtstopx;
74
 
75
        sc_signal<sc_bv<CAD_IN_DEPTH> >         phy_ctl_lk;
76
        sc_signal<sc_bv<CAD_IN_DEPTH> >         phy_cad_lk[CAD_IN_WIDTH];
77
        sc_signal<bool>                                         phy_available_lk;
78
 
79
        sc_signal<sc_bv<CAD_OUT_DEPTH> >        lk_ctl_phy;
80
        sc_signal<sc_bv<CAD_OUT_DEPTH> >        lk_cad_phy[CAD_OUT_WIDTH];
81
        sc_signal<bool>                                         phy_consume_lk;
82
 
83
        sc_signal<bool>                                 lk_disable_drivers_phy;
84
        sc_signal<bool>                                 lk_disable_receivers_phy;
85
 
86
        /**
87
                Data to be sent to the next link
88
                This data comes from the flow control
89
                @{
90
        */
91
        ///Dword to send
92
        sc_signal<sc_bv<32> >   fc_dword_lk;
93
        ///The LCTL value associated with the dword to send
94
        sc_signal<bool>                 fc_lctl_lk;
95
        ///The HCTL value associated with the dword to send
96
        sc_signal<bool>                 fc_hctl_lk;
97
        ///To consume the data from the flow control
98
        sc_signal<bool>         lk_consume_fc;
99
        ///@}
100
 
101
 
102
        //*******************************
103
        //      Signals from link
104
        //*******************************
105
 
106
        ///Bit vector output for command decoder 
107
        sc_signal< sc_bv<32> >          lk_dword_cd;
108
        ///Control bit
109
        sc_signal< bool >                       lk_hctl_cd;
110
        ///Control bit
111
        sc_signal< bool >                       lk_lctl_cd;
112
        ///FIFO is ready to be read from
113
        sc_signal< bool >                       lk_available_cd;
114
 
115
        /**
116
        Link widths
117
 
118
        000 8 bits
119
        100 2 bits
120
        101 4 bits
121
        111  Link physically not connected
122
        @{
123
        */
124
        ///The link width for the RX side
125
        sc_signal<sc_bv<3> >    csr_rx_link_width_lk;
126
        ///The link width for the TX side
127
        sc_signal<sc_bv<3> >    csr_tx_link_width_lk;
128
        ///@}
129
 
130
        //If the chain is being synched
131
        sc_signal<bool>                 csr_sync;
132
 
133
        ///If this link should be inactive because it is the end of chain
134
        sc_signal<bool>                 csr_end_of_chain;
135
 
136
        ///To update the link width registered in the CSR with the new value
137
        sc_signal<bool>         lk_update_link_width_csr;
138
        ///The link width that is being sampled
139
        sc_signal<sc_bv<3> >    lk_sampled_link_width_csr;
140
        ///A protocol error has been detected
141
        sc_signal<bool>         lk_protocol_error_csr;
142
 
143
 
144
        ///Force CRC errors to be generated
145
        sc_signal<bool>                 csr_crc_force_error_lk;
146
        ///To turn off the transmitter
147
        sc_signal<bool>                 csr_transmitter_off_lk;
148
        ///Hold CTL longer in the ini sequemce
149
        sc_signal<bool>                 csr_extented_ctl_lk;
150
        ///The timeout for CTL being low too long is extended
151
        sc_signal<bool>                 csr_extended_ctl_timeout_lk;
152
        ///If we are enabled to tristated the drivers when in ldtstop
153
        sc_signal<bool>                 csr_ldtstop_tristate_enable_lk;
154
 
155
        ///CRC error detected on link
156
        sc_signal<bool>         lk_crc_error_csr;
157
        ///Update the link failure flag in CSR with the lk_link_failure_csr signal
158
        sc_signal<bool>         lk_update_link_failure_property_csr;
159
 
160
#ifdef RETRY_MODE_ENABLED
161
        ///Start a retry sequence
162
        sc_signal<bool>         lk_initiate_retry_disconnect;
163
        ///Command decoder commands a retry disconnect
164
        sc_signal<bool>                 cd_initiate_retry_disconnect;
165
 
166
        ///The flow control asks us to disconnect the link
167
        sc_signal<bool>                 fc_disconnect_lk;
168
        ///If we are in the retry mode
169
        sc_signal<bool >                csr_retry;
170
#endif
171
        ///RX link is connected (identical to lk_initialization_complete_csr)
172
        sc_signal<bool>         lk_rx_connected;
173
        ///This signal should only be evaluated at lk_update_link_failure_property_csr
174
        sc_signal<bool>         lk_link_failure_csr;
175
 
176
        //A sync error has been detected
177
        // - Not used anymore, sync only detected through standard decode logic
178
        //sc_signal<bool>               lk_sync_detected_csr;
179
 
180
        ///Command decoder commands a ltdstop disconnect
181
        sc_signal<bool>                 cd_initiate_nonretry_disconnect_lk;
182
 
183
#ifndef INTERNAL_SHIFTER_ALIGNMENT
184
        sc_signal<bool > lk_deser_stall_phy;
185
        ///Number of bit times to stall deserializing incoming data when lk_deser_stall_phy is asserted
186
        sc_signal<sc_uint<LOG2_CAD_IN_DEPTH> > lk_deser_stall_cycles_phy;
187
#endif
188
 
189
        //Connect the design
190
        dut->clk(clk);
191
        dut->resetx(resetx);
192
        dut->pwrok(pwrok);
193
        dut->ldtstopx(ldtstopx);
194
        dut->phy_ctl_lk(phy_ctl_lk);
195
        for(int n = 0; n < CAD_IN_WIDTH; n++)
196
                dut->phy_cad_lk[n](phy_cad_lk[n]);
197
        dut->phy_available_lk(phy_available_lk);
198
        dut->lk_ctl_phy(lk_ctl_phy);
199
        for(int n = 0; n < CAD_OUT_WIDTH; n++)
200
                dut->lk_cad_phy[n](lk_cad_phy[n]);
201
        dut->phy_consume_lk(phy_consume_lk);
202
        dut->lk_disable_drivers_phy(lk_disable_drivers_phy);
203
        dut->lk_disable_receivers_phy(lk_disable_receivers_phy);
204
        dut->fc_dword_lk(fc_dword_lk);
205
        dut->fc_lctl_lk(fc_lctl_lk);
206
        dut->fc_hctl_lk(fc_hctl_lk);
207
        dut->lk_consume_fc(lk_consume_fc);
208
        dut->lk_dword_cd(lk_dword_cd);
209
        dut->lk_hctl_cd(lk_hctl_cd);
210
        dut->lk_lctl_cd(lk_lctl_cd);
211
        dut->lk_available_cd(lk_available_cd);
212
        dut->csr_rx_link_width_lk(csr_rx_link_width_lk);
213
        dut->csr_tx_link_width_lk(csr_tx_link_width_lk);
214
        dut->csr_sync(csr_sync);
215
        dut->csr_end_of_chain(csr_end_of_chain);
216
        dut->lk_update_link_width_csr(lk_update_link_width_csr);
217
        dut->lk_sampled_link_width_csr(lk_sampled_link_width_csr);
218
        dut->lk_protocol_error_csr(lk_protocol_error_csr);
219
        dut->csr_crc_force_error_lk(csr_crc_force_error_lk);
220
        dut->csr_transmitter_off_lk(csr_transmitter_off_lk);
221
        dut->csr_extented_ctl_lk(csr_extented_ctl_lk);
222
        dut->csr_extended_ctl_timeout_lk(csr_extended_ctl_timeout_lk);
223
        dut->csr_ldtstop_tristate_enable_lk(csr_ldtstop_tristate_enable_lk);
224
        dut->lk_crc_error_csr(lk_crc_error_csr);
225
        dut->lk_update_link_failure_property_csr(lk_update_link_failure_property_csr);
226
 
227
#ifdef RETRY_MODE_ENABLED
228
        dut->lk_initiate_retry_disconnect(lk_initiate_retry_disconnect);
229
        dut->cd_initiate_retry_disconnect(cd_initiate_retry_disconnect);
230
        dut->fc_disconnect_lk(fc_disconnect_lk);
231
        dut->csr_retry(csr_retry);
232
#endif
233
        dut->lk_rx_connected(lk_rx_connected);
234
        dut->lk_link_failure_csr(lk_link_failure_csr);
235
        dut->cd_initiate_nonretry_disconnect_lk(cd_initiate_nonretry_disconnect_lk);
236
 
237
#ifndef INTERNAL_SHIFTER_ALIGNMENT
238
        dut->lk_deser_stall_phy(lk_deser_stall_phy);
239
        dut->lk_deser_stall_cycles_phy(lk_deser_stall_cycles_phy);
240
#endif
241
        //Connect the testbench
242
        tb->clk(clk);
243
        tb->resetx(resetx);
244
        tb->pwrok(pwrok);
245
        tb->ldtstopx(ldtstopx);
246
        tb->phy_ctl_lk(phy_ctl_lk);
247
        for(int n = 0; n < CAD_IN_WIDTH; n++)
248
                tb->phy_cad_lk[n](phy_cad_lk[n]);
249
        tb->phy_available_lk(phy_available_lk);
250
        tb->lk_ctl_phy(lk_ctl_phy);
251
        for(int n = 0; n < CAD_OUT_WIDTH; n++)
252
                tb->lk_cad_phy[n](lk_cad_phy[n]);
253
        tb->phy_consume_lk(phy_consume_lk);
254
        tb->lk_disable_drivers_phy(lk_disable_drivers_phy);
255
        tb->lk_disable_receivers_phy(lk_disable_receivers_phy);
256
        tb->fc_dword_lk(fc_dword_lk);
257
        tb->fc_lctl_lk(fc_lctl_lk);
258
        tb->fc_hctl_lk(fc_hctl_lk);
259
        tb->lk_consume_fc(lk_consume_fc);
260
        tb->lk_dword_cd(lk_dword_cd);
261
        tb->lk_hctl_cd(lk_hctl_cd);
262
        tb->lk_lctl_cd(lk_lctl_cd);
263
        tb->lk_available_cd(lk_available_cd);
264
        tb->csr_rx_link_width_lk(csr_rx_link_width_lk);
265
        tb->csr_tx_link_width_lk(csr_tx_link_width_lk);
266
        tb->csr_sync(csr_sync);
267
        tb->csr_end_of_chain(csr_end_of_chain);
268
        tb->lk_update_link_width_csr(lk_update_link_width_csr);
269
        tb->lk_sampled_link_width_csr(lk_sampled_link_width_csr);
270
        tb->lk_protocol_error_csr(lk_protocol_error_csr);
271
        tb->csr_crc_force_error_lk(csr_crc_force_error_lk);
272
        tb->csr_transmitter_off_lk(csr_transmitter_off_lk);
273
        tb->csr_extented_ctl_lk(csr_extented_ctl_lk);
274
        tb->csr_extended_ctl_timeout_lk(csr_extended_ctl_timeout_lk);
275
        tb->csr_ldtstop_tristate_enable_lk(csr_ldtstop_tristate_enable_lk);
276
        tb->lk_crc_error_csr(lk_crc_error_csr);
277
        tb->lk_update_link_failure_property_csr(lk_update_link_failure_property_csr);
278
 
279
#ifdef RETRY_MODE_ENABLED
280
        tb->lk_initiate_retry_disconnect(lk_initiate_retry_disconnect);
281
        tb->cd_initiate_retry_disconnect(cd_initiate_retry_disconnect);
282
        tb->fc_disconnect_lk(fc_disconnect_lk);
283
        tb->csr_retry(csr_retry);
284
#endif
285
        tb->lk_rx_connected(lk_rx_connected);
286
        tb->lk_link_failure_csr(lk_link_failure_csr);
287
        tb->cd_initiate_nonretry_disconnect_lk(cd_initiate_nonretry_disconnect_lk);
288
 
289
#ifndef INTERNAL_SHIFTER_ALIGNMENT
290
        tb->lk_deser_stall_phy(lk_deser_stall_phy);
291
        tb->lk_deser_stall_cycles_phy(lk_deser_stall_cycles_phy);
292
#endif
293
        // tracing:
294
        // trace file creation
295
        sc_trace_file *tf = sc_create_vcd_trace_file("sim_link_l2");
296
        // External Signals
297
        sc_trace(tf, clk, "clk");
298
        sc_trace(tf,resetx,"resetx");
299
        sc_trace(tf,pwrok,"pwrok");
300
        sc_trace(tf,ldtstopx,"ldtstopx");
301
        sc_trace(tf,phy_ctl_lk,"phy_ctl_lk");
302
        for(int n = 0 ; n < CAD_IN_WIDTH; n++){
303
                std::ostringstream s;
304
                s << "phy_cad_lk(" << n << ')';
305
                sc_trace(tf, phy_cad_lk[n],s.str().c_str());
306
        }
307
        sc_trace(tf,phy_available_lk,"phy_available_lk");
308
        sc_trace(tf,lk_ctl_phy,"lk_ctl_phy");
309
        for(int n = 0 ; n < CAD_OUT_WIDTH; n++){
310
                std::ostringstream s;
311
                s << "lk_cad_phy(" << n << ')';
312
                sc_trace(tf,lk_cad_phy[n],s.str().c_str());
313
        }
314
        sc_trace(tf,phy_consume_lk,"phy_consume_lk");
315
        sc_trace(tf,lk_disable_drivers_phy,"lk_disable_drivers_phy");
316
        sc_trace(tf,lk_disable_receivers_phy,"lk_disable_receivers_phy");
317
        sc_trace(tf,fc_dword_lk,"fc_dword_lk");
318
        sc_trace(tf,fc_lctl_lk,"fc_lctl_lk");
319
        sc_trace(tf,fc_hctl_lk,"fc_hctl_lk");
320
        sc_trace(tf,lk_consume_fc,"lk_consume_fc");
321
        sc_trace(tf,lk_dword_cd,"lk_dword_cd");
322
        sc_trace(tf,lk_hctl_cd,"lk_hctl_cd");
323
        sc_trace(tf,lk_lctl_cd,"lk_lctl_cd");
324
        sc_trace(tf,lk_available_cd,"lk_available_cd");
325
        sc_trace(tf,csr_rx_link_width_lk,"csr_rx_link_width_lk");
326
        sc_trace(tf,csr_tx_link_width_lk,"csr_tx_link_width_lk");
327
        sc_trace(tf,csr_sync,"csr_sync");
328
        sc_trace(tf,csr_end_of_chain,"csr_end_of_chain");
329
        sc_trace(tf,lk_update_link_width_csr,"lk_update_link_width_csr");
330
        sc_trace(tf,lk_sampled_link_width_csr,"lk_sampled_link_width_csr");
331
        sc_trace(tf,lk_protocol_error_csr,"lk_protocol_error_csr");
332
        sc_trace(tf,csr_crc_force_error_lk,"csr_crc_force_error_lk");
333
        sc_trace(tf,csr_transmitter_off_lk,"csr_transmitter_off_lk");
334
        sc_trace(tf,csr_extented_ctl_lk,"csr_extented_ctl_lk");
335
        sc_trace(tf,csr_extended_ctl_timeout_lk,"csr_extended_ctl_timeout_lk");
336
        sc_trace(tf,csr_ldtstop_tristate_enable_lk,"csr_ldtstop_tristate_enable_lk");
337
        sc_trace(tf,lk_crc_error_csr,"lk_crc_error_csr");
338
        sc_trace(tf,lk_update_link_failure_property_csr,"lk_update_link_failure_property_csr");
339
 
340
#ifdef RETRY_MODE_ENABLED
341
        sc_trace(tf,lk_initiate_retry_disconnect,"lk_initiate_retry_disconnect");
342
        sc_trace(tf,cd_initiate_retry_disconnect,"cd_initiate_retry_disconnect");
343
        sc_trace(tf,fc_disconnect_lk,"fc_disconnect_lk");
344
        sc_trace(tf,csr_retry,"csr_retry");
345
#endif
346
        sc_trace(tf,lk_rx_connected,"lk_rx_connected");
347
        sc_trace(tf,lk_link_failure_csr,"lk_link_failure_csr");
348
        sc_trace(tf,cd_initiate_nonretry_disconnect_lk,"cd_initiate_nonretry_disconnect_lk");
349
 
350
 
351
 
352
        //------------------------------------------
353
        // Start simulation
354
        //------------------------------------------
355
        cout << "Debut de la simulation" << endl;
356
        sc_start(4500);
357
 
358
 
359
        sc_close_vcd_trace_file(tf);
360
        cout << "fin de la simulation" << endl;
361
 
362
        delete dut;
363
        delete tb;
364
        return 0;
365
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.