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

Subversion Repositories usb11

[/] [usb11/] [trunk/] [rtl/] [systemc/] [usb.h] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfoltran
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  USB 1.1                                                    ////
4
////  Endpoints Config and FIFOs Instantiation                   ////
5
////                                                             ////
6
////  SystemC Version: usb.h                                     ////
7
////  Author: Alfredo Luiz Foltran Fialho                        ////
8
////          alfoltran@ig.com.br                                ////
9
////                                                             ////
10
////                                                             ////
11
/////////////////////////////////////////////////////////////////////
12
////                                                             ////
13
//// Verilog Version: usb.v                                      ////
14
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
15
////                         www.asics.ws                        ////
16
////                         rudi@asics.ws                       ////
17
////                                                             ////
18
//// This source file may be used and distributed without        ////
19
//// restriction provided that this copyright statement is not   ////
20
//// removed from the file and that any derivative work contains ////
21
//// the original copyright notice and the associated disclaimer.////
22
////                                                             ////
23
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
24
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
25
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
26
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
27
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
28
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
29
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
30
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
31
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
32
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
33
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
34
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
35
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
36
////                                                             ////
37
/////////////////////////////////////////////////////////////////////
38
 
39
#ifndef USB_H
40
#define USB_H
41
 
42
#include "systemc.h"
43
#include "usb_defines.h"
44
#include "usb_core.h"
45
#include "usb_fifo512x8.h"
46
#include "usb_fifo128x8.h"
47
 
48
SC_MODULE(usb) {
49
 
50
  private:
51
 
52
        sc_signal<bool>                 vcc, gnd;
53
        sc_signal<sc_uint<8> >  gnd8;
54
        sc_signal<sc_uint<14> > cfg1, cfg2, cfg3, cfg4, cfg5, cfg6, cfg7;
55
        sc_signal<bool>                 ep1_we_nc, ep2_re_nc, ep3_we_nc, ep4_re_nc, ep5_we_nc, ep6_re_nc, ep7_we_nc, ep7_re_nc;
56
        sc_signal<sc_uint<8> >  ep1_dout_nc, ep3_dout_nc, ep5_dout_nc, ep7_dout_nc;
57
 
58
  public:
59
 
60
        sc_in<bool>                             clk_i;
61
        sc_in<bool>                             rst_i;
62
 
63
        // PHY Interface
64
        sc_out<bool>                    tx_dp, tx_dn, tx_oe;
65
        sc_in<bool>                             rx_dp, rx_dn, rx_d;
66
        sc_in<bool>                             phy_tx_mode;
67
 
68
        // Misc
69
        sc_out<bool>                    usb_rst;
70
 
71
        // Interrupts
72
        sc_out<bool>                    crc16_err;
73
 
74
        // Vendor Features
75
        sc_out<bool>                    v_set_int;
76
        sc_out<bool>                    v_set_feature;
77
        sc_out<sc_uint<16> >    wValue;
78
        sc_out<sc_uint<16> >    wIndex;
79
        sc_in<sc_uint<16> >             vendor_data;
80
 
81
        // USB Status
82
        sc_out<bool>                    usb_busy;
83
        sc_out<sc_uint<4> >             ep_sel;
84
 
85
        // Endpoint Interface
86
        // EP1
87
        sc_in<sc_uint<8> >              ep1_f_din;
88
        sc_in<bool>                             ep1_f_we;
89
        sc_out<bool>                    ep1_f_full;
90
 
91
        // EP2
92
        sc_out<sc_uint<8> >             ep2_f_dout;
93
        sc_in<bool>                             ep2_f_re;
94
        sc_out<bool>                    ep2_f_empty;
95
 
96
        // EP3
97
        sc_in<sc_uint<8> >              ep3_f_din;
98
        sc_in<bool>                             ep3_f_we;
99
        sc_out<bool>                    ep3_f_full;
100
 
101
        // EP4
102
        sc_out<sc_uint<8> >             ep4_f_dout;
103
        sc_in<bool>                             ep4_f_re;
104
        sc_out<bool>                    ep4_f_empty;
105
 
106
        // EP5
107
        sc_in<sc_uint<8> >              ep5_f_din;
108
        sc_in<bool>                             ep5_f_we;
109
        sc_out<bool>                    ep5_f_full;
110
 
111
        // EP6
112
        sc_out<sc_uint<8> >             ep6_f_dout;
113
        sc_in<bool>                             ep6_f_re;
114
        sc_out<bool>                    ep6_f_empty;
115
 
116
        // Local Signals
117
        // EP1
118
        sc_signal<sc_uint<8> >  ep1_us_din;
119
        sc_signal<bool>                 ep1_us_re;
120
        sc_signal<bool>                 ep1_us_empty;
121
 
122
        // EP2
123
        sc_signal<sc_uint<8> >  ep2_us_dout;
124
        sc_signal<bool>                 ep2_us_we;
125
        sc_signal<bool>                 ep2_us_full;
126
 
127
        // EP3
128
        sc_signal<sc_uint<8> >  ep3_us_din;
129
        sc_signal<bool>                 ep3_us_re;
130
        sc_signal<bool>                 ep3_us_empty;
131
 
132
        // EP4
133
        sc_signal<sc_uint<8> >  ep4_us_dout;
134
        sc_signal<bool>                 ep4_us_we;
135
        sc_signal<bool>                 ep4_us_full;
136
 
137
        // EP5
138
        sc_signal<sc_uint<8> >  ep5_us_din;
139
        sc_signal<bool>                 ep5_us_re;
140
        sc_signal<bool>                 ep5_us_empty;
141
 
142
        // EP6
143
        sc_signal<sc_uint<8> >  ep6_us_dout;
144
        sc_signal<bool>                 ep6_us_we;
145
        sc_signal<bool>                 ep6_us_full;
146
 
147
        usb_core                                *i_core;                        // CORE
148
        usb_fifo512x8                   *i_ff_ep1;                      // FIFO1
149
        usb_fifo512x8                   *i_ff_ep2;                      // FIFO2
150
        usb_fifo128x8                   *i_ff_ep3;                      // FIFO3
151
        usb_fifo128x8                   *i_ff_ep4;                      // FIFO4
152
        usb_fifo128x8                   *i_ff_ep5;                      // FIFO5
153
        usb_fifo128x8                   *i_ff_ep6;                      // FIFO6
154
/*
155
        // Destructor
156
        ~usb(void) {
157
                if (i_core)
158
                        delete i_core;
159
                if (i_ff_ep1)
160
                        delete i_ff_ep1;
161
                if (i_ff_ep2)
162
                        delete i_ff_ep2;
163
                if (i_ff_ep3)
164
                        delete i_ff_ep3;
165
                if (i_ff_ep4)
166
                        delete i_ff_ep4;
167
                if (i_ff_ep5)
168
                        delete i_ff_ep5;
169
                if (i_ff_ep6)
170
                        delete i_ff_ep6;
171
        }
172
*/
173
        SC_CTOR(usb) {
174
                vcc.write(true);
175
                gnd.write(false);
176
                gnd8.write(0);
177
 
178
                cfg1.write(ISO  | IN  | 256);
179
                cfg2.write(ISO  | OUT | 256);
180
                cfg3.write(BULK | IN  | 64);
181
                cfg4.write(BULK | OUT | 64);
182
                cfg5.write(INT  | IN  | 64);
183
                cfg6.write(INT  | OUT | 64);
184
                cfg7.write(0);
185
 
186
                // CORE Instantiation and Binding
187
                i_core = new usb_core("CORE");
188
                i_core->clk_i(clk_i);
189
                i_core->rst_i(rst_i);
190
                i_core->tx_dp(tx_dp);
191
                i_core->tx_dn(tx_dn);
192
                i_core->tx_oe(tx_oe);
193
                i_core->rx_dp(rx_dp);
194
                i_core->rx_dn(rx_dn);
195
                i_core->rx_d(rx_d);
196
                i_core->phy_tx_mode(vcc);
197
                i_core->usb_rst(usb_rst);
198
                i_core->crc16_err(crc16_err);
199
                i_core->v_set_int(v_set_int);
200
                i_core->v_set_feature(v_set_feature);
201
                i_core->wValue(wValue);
202
                i_core->wIndex(wIndex);
203
                i_core->vendor_data(vendor_data);
204
                i_core->usb_busy(usb_busy);
205
                i_core->ep_sel(ep_sel);
206
 
207
                // EP1 -> ISO IN 256
208
                i_core->ep1_cfg(cfg1);
209
                i_core->ep1_din(ep1_us_din);
210
                i_core->ep1_dout(ep1_dout_nc);
211
                i_core->ep1_we(ep1_we_nc);
212
                i_core->ep1_re(ep1_us_re);
213
                i_core->ep1_empty(ep1_us_empty);
214
                i_core->ep1_full(gnd);
215
 
216
                // EP2 -> ISO OUT 256
217
                i_core->ep2_cfg(cfg2);
218
                i_core->ep2_din(gnd8);
219
                i_core->ep2_dout(ep2_us_dout);
220
                i_core->ep2_we(ep2_us_we);
221
                i_core->ep2_re(ep2_re_nc);
222
                i_core->ep2_empty(gnd);
223
                i_core->ep2_full(ep2_us_full);
224
 
225
                // EP3 -> BULK IN 64
226
                i_core->ep3_cfg(cfg3);
227
                i_core->ep3_din(ep3_us_din);
228
                i_core->ep3_dout(ep3_dout_nc);
229
                i_core->ep3_we(ep3_we_nc);
230
                i_core->ep3_re(ep3_us_re);
231
                i_core->ep3_empty(ep3_us_empty);
232
                i_core->ep3_full(gnd);
233
 
234
                // EP4 -> BULK OUT 64
235
                i_core->ep4_cfg(cfg4);
236
                i_core->ep4_din(gnd8);
237
                i_core->ep4_dout(ep4_us_dout);
238
                i_core->ep4_we(ep4_us_we);
239
                i_core->ep4_re(ep4_re_nc);
240
                i_core->ep4_empty(gnd);
241
                i_core->ep4_full(ep4_us_full);
242
 
243
                // EP5 -> INT IN 64
244
                i_core->ep5_cfg(cfg5);
245
                i_core->ep5_din(ep5_us_din);
246
                i_core->ep5_dout(ep5_dout_nc);
247
                i_core->ep5_we(ep5_we_nc);
248
                i_core->ep5_re(ep5_us_re);
249
                i_core->ep5_empty(ep5_us_empty);
250
                i_core->ep5_full(gnd);
251
 
252
                // EP6 -> INT OUT 64
253
                i_core->ep6_cfg(cfg6);
254
                i_core->ep6_din(gnd8);
255
                i_core->ep6_dout(ep6_us_dout);
256
                i_core->ep6_we(ep6_us_we);
257
                i_core->ep6_re(ep6_re_nc);
258
                i_core->ep6_empty(gnd);
259
                i_core->ep6_full(ep6_us_full);
260
 
261
                // EP7 -> DEAD
262
                i_core->ep7_cfg(cfg7);
263
                i_core->ep7_din(gnd8);
264
                i_core->ep7_dout(ep7_dout_nc);
265
                i_core->ep7_we(ep7_we_nc);
266
                i_core->ep7_re(ep7_re_nc);
267
                i_core->ep7_empty(gnd);
268
                i_core->ep7_full(gnd);
269
 
270
                // FIFO1 Instantiation and Binding
271
                i_ff_ep1 = new usb_fifo512x8("FIFO1");
272
                i_ff_ep1->clk(clk_i);
273
                i_ff_ep1->rst(rst_i);
274
                i_ff_ep1->clr(gnd);
275
                i_ff_ep1->we(ep1_f_we);
276
                i_ff_ep1->din(ep1_f_din);
277
                i_ff_ep1->re(ep1_us_re);
278
                i_ff_ep1->dout(ep1_us_din);
279
                i_ff_ep1->empty(ep1_us_empty);
280
                i_ff_ep1->full(ep1_f_full);
281
 
282
                // FIFO2 Instantiation and Binding
283
                i_ff_ep2 = new usb_fifo512x8("FIFO2");
284
                i_ff_ep2->clk(clk_i);
285
                i_ff_ep2->rst(rst_i);
286
                i_ff_ep2->clr(gnd);
287
                i_ff_ep2->we(ep2_us_we);
288
                i_ff_ep2->din(ep2_us_dout);
289
                i_ff_ep2->re(ep2_f_re);
290
                i_ff_ep2->dout(ep2_f_dout);
291
                i_ff_ep2->empty(ep2_f_empty);
292
                i_ff_ep2->full(ep2_us_full);
293
 
294
                // FIFO3 Instantiation and Binding
295
                i_ff_ep3 = new usb_fifo128x8("FIFO3");
296
                i_ff_ep3->clk(clk_i);
297
                i_ff_ep3->rst(rst_i);
298
                i_ff_ep3->clr(gnd);
299
                i_ff_ep3->we(ep3_f_we);
300
                i_ff_ep3->din(ep3_f_din);
301
                i_ff_ep3->re(ep3_us_re);
302
                i_ff_ep3->dout(ep3_us_din);
303
                i_ff_ep3->empty(ep3_us_empty);
304
                i_ff_ep3->full(ep3_f_full);
305
 
306
                // FIFO4 Instantiation and Binding
307
                i_ff_ep4 = new usb_fifo128x8("FIFO4");
308
                i_ff_ep4->clk(clk_i);
309
                i_ff_ep4->rst(rst_i);
310
                i_ff_ep4->clr(gnd);
311
                i_ff_ep4->we(ep4_us_we);
312
                i_ff_ep4->din(ep4_us_dout);
313
                i_ff_ep4->re(ep4_f_re);
314
                i_ff_ep4->dout(ep4_f_dout);
315
                i_ff_ep4->empty(ep4_f_empty);
316
                i_ff_ep4->full(ep4_us_full);
317
 
318
                // FIFO5 Instantiation and Binding
319
                i_ff_ep5 = new usb_fifo128x8("FIFO5");
320
                i_ff_ep5->clk(clk_i);
321
                i_ff_ep5->rst(rst_i);
322
                i_ff_ep5->clr(gnd);
323
                i_ff_ep5->we(ep5_f_we);
324
                i_ff_ep5->din(ep5_f_din);
325
                i_ff_ep5->re(ep5_us_re);
326
                i_ff_ep5->dout(ep5_us_din);
327
                i_ff_ep5->empty(ep5_us_empty);
328
                i_ff_ep5->full(ep5_f_full);
329
 
330
                // FIFO6 Instantiation and Binding
331
                i_ff_ep6 = new usb_fifo128x8("FIFO6");
332
                i_ff_ep6->clk(clk_i);
333
                i_ff_ep6->rst(rst_i);
334
                i_ff_ep6->clr(gnd);
335
                i_ff_ep6->we(ep6_us_we);
336
                i_ff_ep6->din(ep6_us_dout);
337
                i_ff_ep6->re(ep6_f_re);
338
                i_ff_ep6->dout(ep6_f_dout);
339
                i_ff_ep6->empty(ep6_f_empty);
340
                i_ff_ep6->full(ep6_us_full);
341
 
342
        }
343
 
344
};
345
 
346
#endif
347
 

powered by: WebSVN 2.1.0

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