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

Subversion Repositories xge_mac

[/] [xge_mac/] [trunk/] [tbench/] [systemc/] [sc_main.cpp] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 antanguay
// $Id: sc_main.cpp,v 1.3 2008-06-07 02:59:55 antanguay Exp $ -*- SystemC -*-
2 4 antanguay
// DESCRIPTION: Verilator Example: Top level main for invoking SystemC model
3
//
4
// Copyright 2003-2008 by Wilson Snyder. This program is free software; you can
5
// redistribute it and/or modify it under the terms of either the GNU
6
// General Public License or the Perl Artistic License.
7
//====================================================================
8
 
9 2 antanguay
//////////////////////////////////////////////////////////////////////
10
////                                                              ////
11
////  File name "sc_main.cpp"                                     ////
12
////                                                              ////
13
////  This file is part of the "10GE MAC" project                 ////
14
////  http://www.opencores.org/cores/xge_mac/                     ////
15
////                                                              ////
16
////  Author(s):                                                  ////
17
////      - A. Tanguay (antanguay@opencores.org)                  ////
18
////                                                              ////
19
//////////////////////////////////////////////////////////////////////
20
////                                                              ////
21
//// Copyright (C) 2008 AUTHORS. All rights reserved.             ////
22
////                                                              ////
23
//// This source file may be used and distributed without         ////
24
//// restriction provided that this copyright statement is not    ////
25
//// removed from the file and that any derivative work contains  ////
26
//// the original copyright notice and the associated disclaimer. ////
27
////                                                              ////
28
//// This source file is free software; you can redistribute it   ////
29
//// and/or modify it under the terms of the GNU Lesser General   ////
30
//// Public License as published by the Free Software Foundation; ////
31
//// either version 2.1 of the License, or (at your option) any   ////
32
//// later version.                                               ////
33
////                                                              ////
34
//// This source is distributed in the hope that it will be       ////
35
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
36
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
37
//// PURPOSE.  See the GNU Lesser General Public License for more ////
38
//// details.                                                     ////
39
////                                                              ////
40
//// You should have received a copy of the GNU Lesser General    ////
41
//// Public License along with this source; if not, download it   ////
42
//// from http://www.opencores.org/lgpl.shtml                     ////
43
////                                                              ////
44
//////////////////////////////////////////////////////////////////////
45
 
46
#include <stdio.h>
47
#include <iostream>
48
#include <sys/times.h>
49
#include <sys/stat.h>
50
 
51
#include "systemc.h"            // SystemC global header
52 15 antanguay
//#include "SpTraceVcd.h"
53
#include "verilated_vcd_sc.h"  // Tracing
54 2 antanguay
 
55
#include "crc.h"
56
 
57
#include "Vxge_mac.h"           // Top level header, generated from verilog
58
 
59 19 antanguay
#include "sc_defines.h"
60
 
61 2 antanguay
#include "sc_testbench.h"
62
#include "sc_testcases.h"
63
 
64
 
65
int sc_main(int argc, char* argv[]) {
66
 
67
    chksum_crc32gentab();
68
 
69
    Verilated::randReset(2);
70
    Verilated::debug(0); // We compiled with it on for testing, turn it back off
71
 
72
    // General logfile
73
    ios::sync_with_stdio();
74
 
75
    cout << ("Defining Clocks\n");
76
 
77 17 antanguay
    sc_clock clk_156m25 ("clk_156m25", 10, SC_NS, 0.5);
78
    sc_clock clk_wb ("clk_wb", 29, SC_NS, 0.5);
79
    sc_clock clk_xgmii ("clk_xgmii", 10, SC_NS, 0.5);
80 2 antanguay
 
81
    sc_signal<bool> pkt_rx_ren;
82 19 antanguay
    sc_signal<vluint64_t > pkt_tx_data;
83 6 antanguay
    sc_signal<bool> pkt_tx_eop;
84
    sc_signal<unsigned int> pkt_tx_mod;
85 2 antanguay
    sc_signal<bool> pkt_tx_sop;
86
    sc_signal<bool> pkt_tx_val;
87
    sc_signal<bool> reset_156m25_n;
88
    sc_signal<bool> reset_xgmii_n;
89
    sc_signal<unsigned int> wb_adr_i;
90
    sc_signal<bool> wb_cyc_i;
91
    sc_signal<unsigned int > wb_dat_i;
92
    sc_signal<bool> wb_rst_i;
93
    sc_signal<bool> wb_stb_i;
94
    sc_signal<bool> wb_we_i;
95
    sc_signal<unsigned int> xgmii_rxc;
96 19 antanguay
    sc_signal<vluint64_t > xgmii_rxd;
97 2 antanguay
 
98
    sc_signal<bool> pkt_rx_avail;
99 19 antanguay
    sc_signal<vluint64_t > pkt_rx_data;
100 6 antanguay
    sc_signal<bool> pkt_rx_eop;
101
    sc_signal<unsigned int> pkt_rx_mod;
102 2 antanguay
    sc_signal<bool> pkt_rx_sop;
103
    sc_signal<bool> pkt_rx_val;
104
    sc_signal<bool> pkt_rx_err;
105
    sc_signal<bool> pkt_tx_full;
106
    sc_signal<bool> wb_ack_o;
107
    sc_signal<unsigned int> wb_dat_o;
108
    sc_signal<bool> wb_int_o;
109
    sc_signal<unsigned int> xgmii_txc;
110 19 antanguay
    sc_signal<vluint64_t > xgmii_txd;
111 2 antanguay
 
112
    //==========
113
    // Part under test
114
 
115
    Vxge_mac* top = new Vxge_mac("top");
116
 
117
    top->clk_156m25 (clk_156m25);
118
    top->clk_xgmii_rx (clk_xgmii);
119
    top->clk_xgmii_tx (clk_xgmii);
120
 
121
    top->pkt_rx_ren (pkt_rx_ren);
122
    top->pkt_tx_data (pkt_tx_data);
123
    top->pkt_tx_eop (pkt_tx_eop);
124 6 antanguay
    top->pkt_tx_mod (pkt_tx_mod);
125 2 antanguay
    top->pkt_tx_sop (pkt_tx_sop);
126
    top->pkt_tx_val (pkt_tx_val);
127
    top->reset_156m25_n (reset_156m25_n);
128
    top->reset_xgmii_rx_n (reset_xgmii_n);
129
    top->reset_xgmii_tx_n (reset_xgmii_n);
130
    top->wb_adr_i (wb_adr_i);
131
    top->wb_clk_i (clk_wb);
132
    top->wb_cyc_i (wb_cyc_i);
133
    top->wb_dat_i (wb_dat_i);
134
    top->wb_rst_i (wb_rst_i);
135
    top->wb_stb_i (wb_stb_i);
136
    top->wb_we_i (wb_we_i);
137
    top->xgmii_rxc (xgmii_rxc);
138
    top->xgmii_rxd (xgmii_rxd);
139
 
140
    top->pkt_rx_avail (pkt_rx_avail);
141
    top->pkt_rx_data (pkt_rx_data);
142
    top->pkt_rx_eop (pkt_rx_eop);
143 6 antanguay
    top->pkt_rx_mod (pkt_rx_mod);
144 2 antanguay
    top->pkt_rx_err (pkt_rx_err);
145
    top->pkt_rx_sop (pkt_rx_sop);
146
    top->pkt_rx_val (pkt_rx_val);
147
    top->pkt_tx_full (pkt_tx_full);
148
    top->wb_ack_o (wb_ack_o);
149
    top->wb_dat_o (wb_dat_o);
150
    top->wb_int_o (wb_int_o);
151
    top->xgmii_txc (xgmii_txc);
152
    top->xgmii_txd (xgmii_txd);
153
 
154
    //==========
155
    // Testbench
156
 
157
    testbench* tb = new testbench("tb");
158
 
159
    tb->clk_156m25 (clk_156m25);
160
    tb->clk_xgmii (clk_xgmii);
161
    tb->wb_clk_i (clk_wb);
162
 
163
    tb->reset_156m25_n (reset_156m25_n);
164
    tb->reset_xgmii_n (reset_xgmii_n);
165
    tb->wb_rst_i (wb_rst_i);
166
 
167
    tb->wb_ack_o (wb_ack_o);
168
    tb->wb_dat_o (wb_dat_o);
169
    tb->wb_int_o (wb_int_o);
170
 
171
    tb->wb_adr_i (wb_adr_i);
172
    tb->wb_cyc_i (wb_cyc_i);
173
    tb->wb_dat_i (wb_dat_i);
174
    tb->wb_stb_i (wb_stb_i);
175
    tb->wb_we_i (wb_we_i);
176
 
177
    tb->xgmii_rxc (xgmii_rxc);
178
    tb->xgmii_rxd (xgmii_rxd);
179
 
180
    tb->xgmii_txc (xgmii_txc);
181
    tb->xgmii_txd (xgmii_txd);
182
 
183
    tb->pkt_tx_data (pkt_tx_data);
184
    tb->pkt_tx_eop (pkt_tx_eop);
185 6 antanguay
    tb->pkt_tx_mod (pkt_tx_mod);
186 2 antanguay
    tb->pkt_tx_sop (pkt_tx_sop);
187
    tb->pkt_tx_val (pkt_tx_val);
188
 
189
    tb->pkt_tx_full (pkt_tx_full);
190
 
191
    tb->pkt_rx_avail (pkt_rx_avail);
192
    tb->pkt_rx_data (pkt_rx_data);
193
    tb->pkt_rx_eop (pkt_rx_eop);
194 6 antanguay
    tb->pkt_rx_mod (pkt_rx_mod);
195 2 antanguay
    tb->pkt_rx_err (pkt_rx_err);
196
    tb->pkt_rx_sop (pkt_rx_sop);
197
    tb->pkt_rx_val (pkt_rx_val);
198
 
199
    tb->pkt_rx_ren (pkt_rx_ren);
200
 
201
    //==========
202
    // Testcases
203
    testcases* tc = new testcases("tc");
204
 
205
    tc->connect_testbench(tb);
206
 
207
 
208
#if WAVES
209
    // Before any evaluation, need to know to calculate those signals only used for tracing
210
    Verilated::traceEverOn(true);
211
#endif
212
 
213
    // You must do one evaluation before enabling waves, in order to allow
214
    // SystemC to interconnect everything for testing.
215
    cout <<("Test initialization...\n");
216
 
217 17 antanguay
    sc_start(1, SC_NS);
218 2 antanguay
 
219
    reset_156m25_n = 0;
220
    wb_rst_i = 1;
221
    reset_xgmii_n = 0;
222
 
223 17 antanguay
    sc_start(1, SC_NS);
224 2 antanguay
 
225
#if WAVES
226
    cout << "Enabling waves...\n";
227 15 antanguay
    VerilatedVcdSc* tfp = new VerilatedVcdSc;
228 2 antanguay
    top->trace (tfp, 99);
229
    tfp->open ("vl_dump.vcd");
230
#endif
231
 
232
    //==========
233
    // Start of Test
234
 
235
    cout <<("Test beginning...\n");
236 15 antanguay
 
237 2 antanguay
    reset_156m25_n = 0;
238
    wb_rst_i = 1;
239
    reset_xgmii_n = 0;
240
 
241
    while (!tc->done) {
242
 
243
#if WAVES
244
        tfp->flush();
245
#endif
246
        if (VL_TIME_Q() > 10) {
247
            reset_156m25_n = 1;
248
            wb_rst_i = 0;
249
            reset_xgmii_n = 1;
250
        }
251
 
252 17 antanguay
        sc_start(1, SC_NS);
253 2 antanguay
    }
254
 
255
    top->final();
256
 
257
#if WAVES
258
    tfp->close();
259
#endif
260
 
261
    cout << "*-* All Finished *-*\n";
262 15 antanguay
 
263 2 antanguay
    return(0);
264
}

powered by: WebSVN 2.1.0

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