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

Subversion Repositories xge_mac

[/] [xge_mac/] [tags/] [initial/] [tbench/] [systemc/] [sc_main.cpp] - Blame information for rev 2

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

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

powered by: WebSVN 2.1.0

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