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

Subversion Repositories usb11

[/] [usb11/] [trunk/] [rtl/] [systemc/] [usb_ocp.h] - 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 Module                                         ////
4
////  Function Interface                                         ////
5
////  OCP Interface                                              ////
6
////                                                             ////
7
////  SystemC Version: usb_ocp.h                                 ////
8
////  Author: Alfredo Luiz Foltran Fialho                        ////
9
////          alfoltran@ig.com.br                                ////
10
////                                                             ////
11
////                                                             ////
12
/////////////////////////////////////////////////////////////////////
13
////                                                             ////
14
//// Verilog Version: usb_ocp_if.v                               ////
15
//// Copyright (C) 2004      Alfredo Luiz Foltran Fialho         ////
16
////                         alfoltran@ig.com.br                 ////
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_OCP_H
40
#define USB_OCP_H
41
 
42
#include "usb.h"
43
 
44
// Command Encoding -> MCmd[2:0]
45
enum COMMAND {  OCP_IDLE = 0,
46
                                OCP_WR = 1,
47
                                OCP_RD = 2,
48
                                OCP_RDEX = 3,
49
                                // 100..110 -> Reserved,
50
                                OCP_BCST = 7};
51
 
52
// Response Encoding -> SResp[1:0]
53
enum RESPONSE { OCP_NULL = 0,
54
                                OCP_DVA = 1,
55
                                // 10 -> Reserved
56
                                OCP_ERR = 3};
57
 
58
SC_MODULE(usb_ocp) {
59
 
60
  private:
61
 
62
        sc_signal<bool> vcc;
63
        sc_signal<bool> usb_rst_nc;
64
 
65
  public:
66
 
67
        sc_in<bool>                     Clk;                                    // Basic Signal -> Clock signal
68
        sc_in<bool>                     Reset_n;                                // Sideband Signal -> Reset signal
69
 
70
        // PHY Interface
71
        sc_out<bool>            tx_dp, tx_dn, tx_oe;
72
        sc_in<bool>                     rx_dp, rx_dn, rx_d;
73
 
74
        // Sideband Interface
75
        sc_out<bool>            SInterrupt;                             // Interrupt
76
        sc_out<sc_uint<8> >     SFlag;                                  // Flags
77
        sc_out<bool>            SError;                                 // Error Indicator
78
 
79
        // Basic Interface
80
        sc_in<sc_uint<32> >     MAddr;
81
        sc_in<sc_uint<3> >      MCmd;
82
        sc_in<sc_uint<8> >      MData;
83
        sc_out<bool>            SCmdAccept;
84
        sc_out<sc_uint<8> >     SData;
85
        sc_out<sc_uint<2> >     SResp;
86
 
87
        // Local Signals
88
 
89
        sc_signal<bool>                 empty;
90
        sc_signal<bool>                 full;
91
 
92
        // Vendor Signals
93
        sc_signal<sc_uint<16> > wValue;
94
        sc_signal<sc_uint<16> > wIndex;
95
        sc_signal<sc_uint<16> > vendor_data;
96
 
97
        // SFlag Signals
98
        sc_signal<bool>                 SF_busy;
99
        sc_signal<sc_uint<4> >  SF_sel;
100
        sc_signal<bool>                 SF_feature;
101
 
102
        // Endpoint Interface
103
        // EP1
104
        sc_signal<sc_uint<8> >  ep1_f_din;
105
        sc_signal<bool>                 ep1_f_we;
106
        sc_signal<bool>                 ep1_f_full;
107
 
108
        // EP2
109
        sc_signal<sc_uint<8> >  ep2_f_dout;
110
        sc_signal<bool>                 ep2_f_re;
111
        sc_signal<bool>                 ep2_f_empty;
112
 
113
        // EP3
114
        sc_signal<sc_uint<8> >  ep3_f_din;
115
        sc_signal<bool>                 ep3_f_we;
116
        sc_signal<bool>                 ep3_f_full;
117
 
118
        // EP4
119
        sc_signal<sc_uint<8> >  ep4_f_dout;
120
        sc_signal<bool>                 ep4_f_re;
121
        sc_signal<bool>                 ep4_f_empty;
122
 
123
        // EP5
124
        sc_signal<sc_uint<8> >  ep5_f_din;
125
        sc_signal<bool>                 ep5_f_we;
126
        sc_signal<bool>                 ep5_f_full;
127
 
128
        // EP6
129
        sc_signal<sc_uint<8> >  ep6_f_dout;
130
        sc_signal<bool>                 ep6_f_re;
131
        sc_signal<bool>                 ep6_f_empty;
132
 
133
        usb                                             *i_usb;                 // USB
134
 
135
        // Mux Function
136
        void mux(void);
137
        void sflag_up(void);
138
        void sresp_up(void);
139
 
140
        // Destructor
141
//      ~usb_ocp(void);
142
 
143
        SC_CTOR(usb_ocp) {
144
                vcc.write(true);
145
 
146
                SC_METHOD(mux);
147
                sensitive << MAddr << MCmd << MData;
148
                sensitive << ep1_f_full << ep2_f_dout << ep2_f_empty;
149
                sensitive << ep3_f_full << ep4_f_dout << ep4_f_empty;
150
                sensitive << ep5_f_full << ep6_f_dout << ep6_f_empty;
151
                sensitive << wValue << wIndex;
152
                SC_METHOD(sflag_up);
153
                sensitive << empty << full << SF_busy << SF_sel << SF_feature;
154
                SC_METHOD(sresp_up);
155
                sensitive << Clk.pos();
156
 
157
                // USB Instantiation and Binding
158
                i_usb = new usb("USB");
159
                i_usb->clk_i(Clk);
160
                i_usb->rst_i(Reset_n);
161
                i_usb->tx_dp(tx_dp);
162
                i_usb->tx_dn(tx_dn);
163
                i_usb->tx_oe(tx_oe);
164
                i_usb->rx_dp(rx_dp);
165
                i_usb->rx_dn(rx_dn);
166
                i_usb->rx_d(rx_d);
167
                i_usb->phy_tx_mode(vcc);
168
                i_usb->usb_rst(usb_rst_nc);
169
                i_usb->crc16_err(SError);
170
                i_usb->v_set_int(SInterrupt);
171
                i_usb->v_set_feature(SF_feature);
172
                i_usb->wValue(wValue);
173
                i_usb->wIndex(wIndex);
174
                i_usb->vendor_data(vendor_data);
175
                i_usb->usb_busy(SF_busy);
176
                i_usb->ep_sel(SF_sel);
177
                i_usb->ep1_f_din(ep1_f_din);
178
                i_usb->ep1_f_we(ep1_f_we);
179
                i_usb->ep1_f_full(ep1_f_full);
180
                i_usb->ep2_f_dout(ep2_f_dout);
181
                i_usb->ep2_f_re(ep2_f_re);
182
                i_usb->ep2_f_empty(ep2_f_empty);
183
                i_usb->ep3_f_din(ep3_f_din);
184
                i_usb->ep3_f_we(ep3_f_we);
185
                i_usb->ep3_f_full(ep3_f_full);
186
                i_usb->ep4_f_dout(ep4_f_dout);
187
                i_usb->ep4_f_re(ep4_f_re);
188
                i_usb->ep4_f_empty(ep4_f_empty);
189
                i_usb->ep5_f_din(ep5_f_din);
190
                i_usb->ep5_f_we(ep5_f_we);
191
                i_usb->ep5_f_full(ep5_f_full);
192
                i_usb->ep6_f_dout(ep6_f_dout);
193
                i_usb->ep6_f_re(ep6_f_re);
194
                i_usb->ep6_f_empty(ep6_f_empty);
195
        }
196
 
197
};
198
 
199
#endif
200
 

powered by: WebSVN 2.1.0

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