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

Subversion Repositories ht_tunnel

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

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_frame_rx_l3.h"
50
#include "link_frame_rx_l3_tb.h"
51
 
52
#include <iostream>
53
#include <string>
54
#include <sstream>
55
#include <iomanip>
56
 
57
using namespace std;
58
 
59
int sc_main( int argc, char* argv[] ){
60
 
61
 
62
        //The Design Under Test
63
        link_frame_rx_l3* dut = new link_frame_rx_l3("link_frame_rx_l3");
64
        //The TestBench
65
        link_frame_rx_l3_tb* tb = new link_frame_rx_l3_tb("link_frame_rx_l3_tb");
66
 
67
 
68
        //Signals used to link the design to the testbench
69
        sc_clock clk("clk", 1);  // system clk
70
        sc_signal<sc_bv<CAD_IN_DEPTH> > phy_ctl_lk;
71
        sc_signal<sc_bv<CAD_IN_DEPTH> > phy_cad_lk[CAD_IN_WIDTH];
72
        sc_signal<bool>                                 phy_available_lk;
73
        sc_signal<bool>                                         lk_disable_receivers_phy;
74
        sc_signal<sc_bv<32> >                           framed_cad;
75
        sc_signal<bool>                                         framed_lctl;
76
        sc_signal<bool >                                        framed_hctl;
77
        sc_signal<bool>                                         framed_data_available;
78
        sc_signal<bool>                                         lk_rx_connected;
79
        sc_signal<bool>                                 resetx;
80
        sc_signal<bool>                                 pwrok;
81
        sc_signal<bool>                                 ldtstopx;
82
        sc_signal<sc_bv<3> >    csr_rx_link_width_lk;
83
        sc_signal<bool >                csr_end_of_chain;
84
        sc_signal<bool >                csr_sync;
85
        sc_signal<bool >                csr_extended_ctl_timeout_lk;
86
        sc_signal<bool>         lk_update_link_width_csr;
87
        sc_signal<sc_bv<3> >    lk_sampled_link_width_csr;
88
        sc_signal<bool>         lk_update_link_failure_property_csr;
89
        sc_signal<bool>         lk_link_failure_csr;
90
        sc_signal<bool>                 ldtstop_disconnect_rx;
91
 
92
#ifdef RETRY_MODE_ENABLED
93
        sc_signal<bool>                 csr_retry;
94
        sc_signal<bool>         lk_initiate_retry_disconnect;
95
        sc_signal<bool>                 cd_initiate_retry_disconnect;
96
#endif
97
        sc_signal<bool>                 lk_protocol_error_csr;
98
        sc_signal<bool>                 rx_waiting_for_ctl_tx;
99
 
100
 
101
#ifndef INTERNAL_SHIFTER_ALIGNMENT
102
        sc_signal<bool > lk_deser_stall_phy;
103
        sc_signal<sc_uint<LOG2_CAD_IN_DEPTH> > lk_deser_stall_cycles_phy;
104
#endif
105
 
106
        //Connect the design
107
        dut->clk(clk);
108
        dut->phy_ctl_lk(phy_ctl_lk);
109
        for(int n = 0; n < CAD_IN_WIDTH; n++){
110
                dut->phy_cad_lk[n](phy_cad_lk[n]);
111
        }
112
        dut->phy_available_lk(phy_available_lk);
113
        dut->lk_disable_receivers_phy(lk_disable_receivers_phy);
114
        dut->framed_cad(framed_cad);
115
        dut->framed_lctl(framed_lctl);
116
        dut->framed_hctl(framed_hctl);
117
        dut->framed_data_available(framed_data_available);
118
        dut->lk_rx_connected(lk_rx_connected);
119
        dut->resetx(resetx);
120
        dut->pwrok(pwrok);
121
        dut->ldtstopx(ldtstopx);
122
        dut->csr_rx_link_width_lk(csr_rx_link_width_lk);
123
        dut->csr_end_of_chain(csr_end_of_chain);
124
        dut->csr_sync(csr_sync);
125
        dut->csr_extended_ctl_timeout_lk(csr_extended_ctl_timeout_lk);
126
        dut->lk_update_link_width_csr(lk_update_link_width_csr);
127
        dut->lk_sampled_link_width_csr(lk_sampled_link_width_csr);
128
        dut->lk_update_link_failure_property_csr(lk_update_link_failure_property_csr);
129
        dut->lk_link_failure_csr(lk_link_failure_csr);
130
        dut->ldtstop_disconnect_rx(ldtstop_disconnect_rx);
131
 
132
#ifdef RETRY_MODE_ENABLED
133
        dut->csr_retry(csr_retry);
134
        dut->lk_initiate_retry_disconnect(lk_initiate_retry_disconnect);
135
        dut->cd_initiate_retry_disconnect(cd_initiate_retry_disconnect);
136
#endif
137
 
138
        dut->lk_protocol_error_csr(lk_protocol_error_csr);
139
        dut->rx_waiting_for_ctl_tx(rx_waiting_for_ctl_tx);
140
 
141
#ifndef INTERNAL_SHIFTER_ALIGNMENT
142
        dut->lk_deser_stall_phy(lk_deser_stall_phy);
143
        dut->lk_deser_stall_cycles_phy(lk_deser_stall_cycles_phy);
144
#endif
145
 
146
        //Connect the testbench
147
        //Connect the design
148
        tb->clk(clk);
149
        tb->phy_ctl_lk(phy_ctl_lk);
150
        for(int n = 0; n < CAD_IN_WIDTH; n++){
151
                tb->phy_cad_lk[n](phy_cad_lk[n]);
152
        }
153
        tb->phy_available_lk(phy_available_lk);
154
        tb->lk_disable_receivers_phy(lk_disable_receivers_phy);
155
        tb->framed_cad(framed_cad);
156
        tb->framed_lctl(framed_lctl);
157
        tb->framed_hctl(framed_hctl);
158
        tb->framed_data_available(framed_data_available);
159
        tb->lk_rx_connected(lk_rx_connected);
160
        tb->resetx(resetx);
161
        tb->pwrok(pwrok);
162
        tb->ldtstopx(ldtstopx);
163
        tb->csr_rx_link_width_lk(csr_rx_link_width_lk);
164
        tb->csr_end_of_chain(csr_end_of_chain);
165
        tb->csr_sync(csr_sync);
166
        tb->csr_extended_ctl_timeout_lk(csr_extended_ctl_timeout_lk);
167
        tb->lk_update_link_width_csr(lk_update_link_width_csr);
168
        tb->lk_sampled_link_width_csr(lk_sampled_link_width_csr);
169
        tb->lk_update_link_failure_property_csr(lk_update_link_failure_property_csr);
170
        tb->lk_link_failure_csr(lk_link_failure_csr);
171
        tb->ldtstop_disconnect_rx(ldtstop_disconnect_rx);
172
 
173
#ifdef RETRY_MODE_ENABLED
174
        tb->csr_retry(csr_retry);
175
        tb->lk_initiate_retry_disconnect(lk_initiate_retry_disconnect);
176
        tb->cd_initiate_retry_disconnect(cd_initiate_retry_disconnect);
177
#endif
178
 
179
        tb->ctl_transition_error(lk_protocol_error_csr);
180
        tb->rx_waiting_for_ctl_tx(rx_waiting_for_ctl_tx);
181
 
182
#ifndef INTERNAL_SHIFTER_ALIGNMENT
183
        tb->lk_deser_stall_phy(lk_deser_stall_phy);
184
        tb->lk_deser_stall_cycles_phy(lk_deser_stall_cycles_phy);
185
#endif
186
 
187
        // tracing:
188
        // trace file creation
189
        sc_trace_file *tf = sc_create_vcd_trace_file("sim_link_frame_rx_l3");
190
        // External Signals
191
        sc_trace(tf, clk, "clk");
192
 
193
        sc_trace(tf, phy_ctl_lk,"phy_ctl_lk");
194
 
195
        for(int n = 0 ; n < CAD_IN_WIDTH; n++){
196
                std::ostringstream s;
197
                s << "phy_cad_lk(" << n << ')';
198
                sc_trace(tf, phy_cad_lk[n],s.str().c_str());
199
        }
200
 
201
        sc_trace(tf, phy_available_lk,"phy_available_lk");
202
        sc_trace(tf, lk_disable_receivers_phy,"lk_disable_receivers_phy");
203
 
204
        sc_trace(tf, framed_cad, "framed_cad");
205
        sc_trace(tf, framed_lctl, "framed_lctl");
206
        sc_trace(tf, framed_hctl, "framed_hctl");
207
        sc_trace(tf, framed_data_available, "framed_data_available");
208
        sc_trace(tf, lk_rx_connected,"lk_rx_connected");
209
        sc_trace(tf, resetx,"resetx");
210
        sc_trace(tf, pwrok,"pwrok");
211
        sc_trace(tf, ldtstopx,"ldtstopx");
212
 
213
        sc_trace(tf, csr_rx_link_width_lk,"csr_rx_link_width_lk");
214
        sc_trace(tf, csr_end_of_chain,"csr_end_of_chain");
215
        sc_trace(tf, csr_sync,"csr_sync");
216
        sc_trace(tf, csr_extended_ctl_timeout_lk,"csr_extended_ctl_timeout_lk");
217
        sc_trace(tf, lk_update_link_width_csr,"lk_update_link_width_csr");
218
        sc_trace(tf, lk_sampled_link_width_csr,"lk_sampled_link_width_csr");
219
        sc_trace(tf, lk_update_link_failure_property_csr,"lk_update_link_failure_property_csr");
220
        sc_trace(tf, lk_link_failure_csr,"lk_link_failure_csr");
221
        sc_trace(tf, ldtstop_disconnect_rx,"ldtstop_disconnect_rx");
222
 
223
#ifdef RETRY_MODE_ENABLED
224
        sc_trace(tf, csr_retry,"csr_retry");
225
        sc_trace(tf, lk_initiate_retry_disconnect,"lk_initiate_retry_disconnect");
226
        sc_trace(tf, cd_initiate_retry_disconnect,"cd_initiate_retry_disconnect");
227
#endif
228
 
229
        sc_trace(tf, lk_protocol_error_csr,"lk_protocol_error_csr");
230
        sc_trace(tf, rx_waiting_for_ctl_tx,"rx_waiting_for_ctl_tx");
231
 
232
        //sc_trace(tf, dut->debug_state,"debug_state");
233
        sc_trace(tf, dut->reordered_cad,"reordered_cad");
234
        sc_trace(tf, dut->reordered_data_ready,"reordered_data_ready");
235
        //sc_trace(tf, dut->calculated_frame_shift_div2,"calculated_frame_shift_div2");
236
        //sc_trace(tf, dut->frame_shift_div2,"frame_shift_div2");
237
        sc_trace(tf, dut->reordered_ctl,"reordered_ctl");
238
        sc_trace(tf, dut->detected_ctl_transition_error,"detected_ctl_transition_error");
239
 
240
        //------------------------------------------
241
        // Start simulation
242
        //------------------------------------------
243
        std::cout << "Debut de la simulation" << endl;
244
        sc_start(2248);
245
 
246
        sc_close_vcd_trace_file(tf);
247
        std::cout << "fin de la simulation" << endl;
248
 
249
        delete dut;
250
        delete tb;
251
        return 0;
252
}

powered by: WebSVN 2.1.0

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