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 18

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

powered by: WebSVN 2.1.0

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