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

Subversion Repositories usb11

[/] [usb11/] [trunk/] [bench/] [systemc/] [usb_8051_test.cpp] - Blame information for rev 15

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

Line No. Rev Author Line
1 2 alfoltran
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  USB 1.1 Top Level Test Bench                               ////
4
////                                                             ////
5
////  SystemC Version: usb_test.cpp                              ////
6
////  Author: Alfredo Luiz Foltran Fialho                        ////
7
////          alfoltran@ig.com.br                                ////
8
////                                                             ////
9
////                                                             ////
10
/////////////////////////////////////////////////////////////////////
11
////                                                             ////
12
//// Verilog Version: test_bench_top.v                           ////
13
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
14
////                         www.asics.ws                        ////
15
////                         rudi@asics.ws                       ////
16
////                                                             ////
17
//// This source file may be used and distributed without        ////
18
//// restriction provided that this copyright statement is not   ////
19
//// removed from the file and that any derivative work contains ////
20
//// the original copyright notice and the associated disclaimer.////
21
////                                                             ////
22
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
23
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
24
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
25
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
26
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
27
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
28
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
29
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
30
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
31
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
32
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
33
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
34
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
35
////                                                             ////
36
/////////////////////////////////////////////////////////////////////
37
 
38
#include "systemc.h"
39
#include "usb_phy.h"
40
#include "usb_top.h"
41
 
42
#define VCD_OUTPUT_ENABLE
43
//#define WIF_OUTPUT_ENABLE
44
 
45
SC_MODULE(test) {
46
        sc_in<bool>             clk, clk2;
47
        sc_out<bool>    rst;
48
 
49
        int i;
50
 
51
        void update(void) {
52
                rst.write(false);
53
                for (i = 0; i < 10; i++) wait(clk.posedge_event());
54
                rst.write(true);
55
                for (i = 0; i < 500; i++) wait(clk.posedge_event());
56
                sc_stop();
57
        }
58
 
59
        SC_CTOR(test) {
60
                SC_THREAD(update);
61
                sensitive_pos(clk);
62
        }
63
};
64
 
65
int sc_main(int argc, char *argv[]) {
66
 
67
        sc_set_time_resolution(1.0, SC_NS);
68
 
69
        sc_clock clk("clock", 20.84, SC_NS);
70
        sc_clock clk2("clock2", 20.84, SC_NS);
71
 
72
        sc_signal<bool> rst, vcc;
73
 
74
        sc_signal<bool> rx_dp1, rx_dn1, tx_dp1, tx_dn1;
75
        sc_signal<bool> tb_rx_valid, tb_rx_active, tb_rx_error;
76
        sc_signal<bool> tb_tx_valid, tb_tx_ready;
77
        sc_signal<sc_uint<8> > tb_rx_data, tb_tx_data;
78
 
79
        sc_signal<bool> rx_dp2, rx_dn2, tx_dp2, tx_dn2;
80
        sc_signal<sc_uint<8> >  ep_f_din;
81
        sc_signal_rv<8> ep_f_dout;
82
        sc_signal<sc_uint<8> > ep_f_adr;
83
        sc_signal<bool> cs, ep_f_re, ep_f_we, ep_f_empty, ep_f_full;
84
 
85
        sc_signal<bool> usb_rst_nc, txoe_nc;
86
        sc_signal<sc_uint<2> > line_nc;
87
 
88
        sc_signal<bool> rst_nc, tx_oe_nc, crc16_nc, int_nc, feature_nc, busy_nc;
89
        sc_signal<sc_uint<4> > sel_nc;
90
 
91
        usb_phy                 i_phy("HOST_PHY");
92
        usb_top                 i_top("USB_TOP");
93
        test                    i_test("TEST");
94
 
95
        i_phy.clk(clk);
96
        i_phy.rst(rst);
97
        i_phy.phy_tx_mode(vcc);
98
        i_phy.usb_rst(usb_rst_nc);
99
        i_phy.txdp(tx_dp1);
100
        i_phy.txdn(tx_dn1);
101
        i_phy.txoe(txoe_nc);
102
        i_phy.rxd(rx_dp1);
103
        i_phy.rxdp(rx_dp1);
104
        i_phy.rxdn(rx_dn1);
105
        i_phy.DataOut_i(tb_tx_data);
106
        i_phy.TxValid_i(tb_tx_valid);
107
        i_phy.TxReady_o(tb_tx_ready);
108
        i_phy.DataIn_o(tb_rx_data);
109
        i_phy.RxValid_o(tb_rx_valid);
110
        i_phy.RxActive_o(tb_rx_active);
111
        i_phy.RxError_o(tb_rx_error);
112
        i_phy.LineState_o(line_nc);
113
 
114
        i_top.clk_i(clk);
115
        i_top.rst_i(rst);
116
        i_top.tx_dp(tx_dp2);
117
        i_top.tx_dn(tx_dn2);
118
        i_top.tx_oe(tx_oe_nc);
119
        i_top.rx_dp(rx_dp2);
120
        i_top.rx_dn(rx_dn2);
121
        i_top.rx_d(rx_dp2);
122
        i_top.usb_rst(rst_nc);
123
        i_top.crc16_err(crc16_nc);
124
        i_top.v_set_int(int_nc);
125
        i_top.v_set_feature(feature_nc);
126
        i_top.usb_busy(busy_nc);
127
        i_top.ep_sel(sel_nc);
128
        i_top.adr(ep_f_adr);
129
        i_top.din(ep_f_din);
130
        i_top.dout(ep_f_dout);
131
        i_top.cs(cs);
132
        i_top.re(ep_f_re);
133
        i_top.we(ep_f_we);
134
        i_top.empty(ep_f_empty);
135
        i_top.full(ep_f_full);
136
 
137
        i_test.clk(clk);
138
        i_test.clk2(clk2);
139
        i_test.rst(rst);
140
 
141
        vcc.write(true);
142
 
143
#ifdef VCD_OUTPUT_ENABLE
144
        sc_trace_file *vcd_log = sc_create_vcd_trace_file("USB_TEST");
145
        sc_trace(vcd_log, clk, "Clock");
146
        sc_trace(vcd_log, rst, "Reset");
147
#endif
148
 
149
#ifdef WIF_OUTPUT_ENABLE
150
        sc_trace_file *wif_log = sc_create_wif_trace_file("USB_TEST");
151
        sc_trace(wif_log, clk, "Clock");
152
        sc_trace(wif_log, rst, "Reset");
153
#endif
154
 
155
        sc_start();
156
 
157
#ifdef VCD_OUTPUT_ENABLE
158
        sc_close_vcd_trace_file(vcd_log);
159
#endif
160
 
161
#ifdef WIF_OUTPUT_ENABLE
162
        sc_close_wif_trace_file(wif_log);
163
#endif
164
 
165
        return 0;
166
}
167
 

powered by: WebSVN 2.1.0

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