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 4

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

Line No. Rev Author Line
1 4 antanguay
// $Id: sc_main.cpp,v 1.2 2008-06-01 00:09:10 antanguay Exp $ -*- SystemC -*-
2
// 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
#include "SpTraceVcd.h"
53
 
54
#include "crc.h"
55
 
56
#include "Vxge_mac.h"           // Top level header, generated from verilog
57
 
58
#include "sc_testbench.h"
59
#include "sc_testcases.h"
60
 
61
 
62
int sc_main(int argc, char* argv[]) {
63
 
64
    chksum_crc32gentab();
65
 
66
    Verilated::randReset(2);
67
    Verilated::debug(0); // We compiled with it on for testing, turn it back off
68
 
69
    // General logfile
70
    ios::sync_with_stdio();
71
 
72
    cout << ("Defining Clocks\n");
73
 
74
    sc_clock clk_156m25 ("clk_156m25", 10, 0.5, 3, true);
75
    sc_clock clk_wb ("clk_wb", 29, 0.5, 3, true);
76
    sc_clock clk_xgmii ("clk_xgmii", 10, 0.5, 3, true);
77
 
78
    sc_signal<bool> pkt_rx_ren;
79
    sc_signal<sc_bv<64> > pkt_tx_data;
80
    sc_signal<unsigned int> pkt_tx_eop;
81
    sc_signal<bool> pkt_tx_sop;
82
    sc_signal<bool> pkt_tx_val;
83
    sc_signal<bool> reset_156m25_n;
84
    sc_signal<bool> reset_xgmii_n;
85
    sc_signal<unsigned int> wb_adr_i;
86
    sc_signal<bool> wb_cyc_i;
87
    sc_signal<unsigned int > wb_dat_i;
88
    sc_signal<bool> wb_rst_i;
89
    sc_signal<bool> wb_stb_i;
90
    sc_signal<bool> wb_we_i;
91
    sc_signal<unsigned int> xgmii_rxc;
92
    sc_signal<sc_bv<64> > xgmii_rxd;
93
 
94
    sc_signal<bool> pkt_rx_avail;
95
    sc_signal<sc_bv<64> > pkt_rx_data;
96
    sc_signal<unsigned int> pkt_rx_eop;
97
    sc_signal<bool> pkt_rx_sop;
98
    sc_signal<bool> pkt_rx_val;
99
    sc_signal<bool> pkt_rx_err;
100
    sc_signal<bool> pkt_tx_full;
101
    sc_signal<bool> wb_ack_o;
102
    sc_signal<unsigned int> wb_dat_o;
103
    sc_signal<bool> wb_int_o;
104
    sc_signal<unsigned int> xgmii_txc;
105
    sc_signal<sc_bv<64> > xgmii_txd;
106
 
107
    //==========
108
    // Part under test
109
 
110
    Vxge_mac* top = new Vxge_mac("top");
111
 
112
    top->clk_156m25 (clk_156m25);
113
    top->clk_xgmii_rx (clk_xgmii);
114
    top->clk_xgmii_tx (clk_xgmii);
115
 
116
    top->pkt_rx_ren (pkt_rx_ren);
117
    top->pkt_tx_data (pkt_tx_data);
118
    top->pkt_tx_eop (pkt_tx_eop);
119
    top->pkt_tx_sop (pkt_tx_sop);
120
    top->pkt_tx_val (pkt_tx_val);
121
    top->reset_156m25_n (reset_156m25_n);
122
    top->reset_xgmii_rx_n (reset_xgmii_n);
123
    top->reset_xgmii_tx_n (reset_xgmii_n);
124
    top->wb_adr_i (wb_adr_i);
125
    top->wb_clk_i (clk_wb);
126
    top->wb_cyc_i (wb_cyc_i);
127
    top->wb_dat_i (wb_dat_i);
128
    top->wb_rst_i (wb_rst_i);
129
    top->wb_stb_i (wb_stb_i);
130
    top->wb_we_i (wb_we_i);
131
    top->xgmii_rxc (xgmii_rxc);
132
    top->xgmii_rxd (xgmii_rxd);
133
 
134
    top->pkt_rx_avail (pkt_rx_avail);
135
    top->pkt_rx_data (pkt_rx_data);
136
    top->pkt_rx_eop (pkt_rx_eop);
137
    top->pkt_rx_err (pkt_rx_err);
138
    top->pkt_rx_sop (pkt_rx_sop);
139
    top->pkt_rx_val (pkt_rx_val);
140
    top->pkt_tx_full (pkt_tx_full);
141
    top->wb_ack_o (wb_ack_o);
142
    top->wb_dat_o (wb_dat_o);
143
    top->wb_int_o (wb_int_o);
144
    top->xgmii_txc (xgmii_txc);
145
    top->xgmii_txd (xgmii_txd);
146
 
147
    //==========
148
    // Testbench
149
 
150
    testbench* tb = new testbench("tb");
151
 
152
    tb->clk_156m25 (clk_156m25);
153
    tb->clk_xgmii (clk_xgmii);
154
    tb->wb_clk_i (clk_wb);
155
 
156
    tb->reset_156m25_n (reset_156m25_n);
157
    tb->reset_xgmii_n (reset_xgmii_n);
158
    tb->wb_rst_i (wb_rst_i);
159
 
160
    tb->wb_ack_o (wb_ack_o);
161
    tb->wb_dat_o (wb_dat_o);
162
    tb->wb_int_o (wb_int_o);
163
 
164
    tb->wb_adr_i (wb_adr_i);
165
    tb->wb_cyc_i (wb_cyc_i);
166
    tb->wb_dat_i (wb_dat_i);
167
    tb->wb_stb_i (wb_stb_i);
168
    tb->wb_we_i (wb_we_i);
169
 
170
    tb->xgmii_rxc (xgmii_rxc);
171
    tb->xgmii_rxd (xgmii_rxd);
172
 
173
    tb->xgmii_txc (xgmii_txc);
174
    tb->xgmii_txd (xgmii_txd);
175
 
176
    tb->pkt_tx_data (pkt_tx_data);
177
    tb->pkt_tx_eop (pkt_tx_eop);
178
    tb->pkt_tx_sop (pkt_tx_sop);
179
    tb->pkt_tx_val (pkt_tx_val);
180
 
181
    tb->pkt_tx_full (pkt_tx_full);
182
 
183
    tb->pkt_rx_avail (pkt_rx_avail);
184
    tb->pkt_rx_data (pkt_rx_data);
185
    tb->pkt_rx_eop (pkt_rx_eop);
186
    tb->pkt_rx_err (pkt_rx_err);
187
    tb->pkt_rx_sop (pkt_rx_sop);
188
    tb->pkt_rx_val (pkt_rx_val);
189
 
190
    tb->pkt_rx_ren (pkt_rx_ren);
191
 
192
    //==========
193
    // Testcases
194
    testcases* tc = new testcases("tc");
195
 
196
    tc->connect_testbench(tb);
197
 
198
 
199
#if WAVES
200
    // Before any evaluation, need to know to calculate those signals only used for tracing
201
    Verilated::traceEverOn(true);
202
#endif
203
 
204
    // You must do one evaluation before enabling waves, in order to allow
205
    // SystemC to interconnect everything for testing.
206
    cout <<("Test initialization...\n");
207
 
208
    sc_start(1);
209
 
210
    reset_156m25_n = 0;
211
    wb_rst_i = 1;
212
    reset_xgmii_n = 0;
213
 
214
    sc_start(1);
215
 
216
#if WAVES
217
    cout << "Enabling waves...\n";
218
    SpTraceFile* tfp = new SpTraceFile;
219
    top->trace (tfp, 99);
220
    tfp->open ("vl_dump.vcd");
221
#endif
222
 
223
    //==========
224
    // Start of Test
225
 
226
    cout <<("Test beginning...\n");
227
 
228
    reset_156m25_n = 0;
229
    wb_rst_i = 1;
230
    reset_xgmii_n = 0;
231
 
232
    while (!tc->done) {
233
 
234
#if WAVES
235
        tfp->flush();
236
#endif
237
        if (VL_TIME_Q() > 10) {
238
            reset_156m25_n = 1;
239
            wb_rst_i = 0;
240
            reset_xgmii_n = 1;
241
        }
242
 
243
        sc_start(1);
244
    }
245
 
246
    top->final();
247
 
248
#if WAVES
249
    tfp->close();
250
#endif
251
 
252
    cout << "*-* All Finished *-*\n";
253
 
254
    return(0);
255
}
256
 
257
 

powered by: WebSVN 2.1.0

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