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

Subversion Repositories usb11

[/] [usb11/] [trunk/] [rtl/] [systemc/] [usb_dma.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 IDMA Engine                                            ////
4
////                                                             ////
5
////  SystemC Version: usb_dma.h                                 ////
6
////  Author: Alfredo Luiz Foltran Fialho                        ////
7
////          alfoltran@ig.com.br                                ////
8
////                                                             ////
9
////                                                             ////
10
/////////////////////////////////////////////////////////////////////
11
////                                                             ////
12
//// Verilog Version: usb1_idma.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
#ifndef USB_DMA_H
39
#define USB_DMA_H
40
 
41
#include "usb_defines.h"
42
#include "usb_fifo2.h"
43
 
44
SC_MODULE(usb_dma) {
45
 
46
  public:
47
 
48
        sc_in<bool>             clk;
49
        sc_in<bool>             rst;
50
 
51
        // PA/PD Interface
52
        sc_in<bool>                     rx_data_valid;
53
        sc_in<bool>                     rx_data_done;
54
        sc_out<bool>            send_data;
55
        sc_in<bool>                     rd_next;
56
        sc_in<bool>                     tx_valid;
57
        sc_in<sc_uint<8> >      tx_data_st_i;
58
        sc_out<sc_uint<8> >     tx_data_st_o;
59
 
60
        // PE Interface
61
        sc_in<bool>                     tx_dma_en;
62
        sc_in<bool>                     rx_dma_en;
63
        sc_out<bool>            idma_done;              // DMA is done
64
        sc_in<sc_uint<4> >      ep_sel;
65
 
66
        // Register File Manager Interface
67
        sc_in<sc_uint<9> >      size;                   // Max PL size in bytes
68
        sc_out<sc_uint<8> >     rx_cnt;
69
        sc_out<bool>            rx_done;
70
        sc_out<bool>            tx_busy;
71
 
72
        // Memory Arbiter Interface
73
        sc_out<bool>            mwe;                    // Memory Write Enable
74
        sc_out<bool>            mre;                    // Memory Read Enable
75
        sc_in<bool>                     ep_empty;
76
        sc_out<bool>            ep_empty_int;
77
        sc_in<bool>                     ep_full;
78
 
79
        // Local Signals
80
        sc_signal<bool>                 tx_dma_en_r;
81
        sc_signal<sc_uint<9> >  sizd_c; // Internal Size Counter
82
        sc_signal<bool>                 adr_incw;
83
        sc_signal<bool>                 adr_incb;
84
        sc_signal<bool>                 siz_dec;
85
        sc_signal<bool>                 mwe_r;
86
        sc_signal<bool>                 sizd_is_zero;   // Indicates when all bytes have been transferred
87
        sc_signal<bool>                 sizd_is_zero_d;
88
        sc_signal<bool>                 rx_data_done_r;
89
        sc_signal<bool>                 rx_data_valid_r;
90
        sc_signal<bool>                 ff_re, ff_full, ff_empty;
91
        sc_signal<bool>                 ff_we, ff_we1;
92
        sc_signal<bool>                 tx_dma_en_r1;
93
        sc_signal<bool>                 tx_dma_en_r2;
94
        sc_signal<bool>                 tx_dma_en_r3;
95
        sc_signal<bool>                 send_data_r;
96
        sc_signal<bool>                 ff_clr;
97
        sc_signal<sc_uint<8> >  rx_cnt_r;
98
        sc_signal<bool>                 ep_empty_r;
99
        sc_signal<bool>                 ep_full_int;
100
        sc_signal<bool>                 tx_valid_r;
101
        sc_signal<bool>                 tx_valid_e;
102
 
103
        usb_fifo2               *i_ff2;                 // IDMA fast prefetch FIFO
104
 
105
        // Empty/Full Logic Functions
106
        void empty_int_up(void);
107
        void full_int_up(void);
108
 
109
        // FIFO Interface Functions
110
        void mwe_up1(void);
111
        void mwe_up2(void);
112
 
113
        // Misc Logic Functions
114
        void data_valid_up(void);
115
        void data_done_up(void);
116
 
117
        // TX DMA Enable Functions
118
        void tx_dma_en_up1(void);
119
        void tx_dma_en_up2(void);
120
        void tx_dma_en_up3(void);
121
 
122
        // DMA Done Indicator Function
123
        void idma_done_up(void);
124
 
125
        // RX DMA Done Indicator Functions
126
        void rx_cnt_up1(void);
127
        void rx_cnt_up2(void);
128
        void rx_done_up(void);
129
 
130
        // TX DMA Done Indicator Functions
131
        void sizd_cnt_up(void);
132
        void is_zero_up1(void);
133
        void is_zero_up2(void);
134
        void siz_dec_up(void);
135
 
136
        // TX DMA Logic Functions
137
        void tx_busy_up(void);
138
        void tx_valid_up1(void);
139
        void tx_valid_up2(void);
140
        void empty_up(void);
141
        void send_data_up1(void);
142
        void send_data_up2(void);
143
        void mre_up(void);
144
        void ff_we_up1(void);
145
        void ff_we_up2(void);
146
        void ff_re_up(void);
147
        void ff_clr_up(void);
148
 
149
        // Destructor
150
//      ~usb_dma(void);
151
 
152
        SC_CTOR(usb_dma) {
153
                SC_METHOD(empty_int_up);
154
                sensitive << ep_empty;
155
                SC_METHOD(full_int_up);
156
                sensitive << ep_full;
157
 
158
                SC_METHOD(mwe_up1);
159
                sensitive << clk.pos();
160
                SC_METHOD(mwe_up2);
161
                sensitive << mwe_r << ep_full_int;
162
 
163
                SC_METHOD(data_valid_up);
164
                sensitive << clk.pos();
165
                SC_METHOD(data_done_up);
166
                sensitive << clk.pos();
167
 
168
                SC_METHOD(tx_dma_en_up1);
169
                sensitive << clk.pos();
170
                SC_METHOD(tx_dma_en_up2);
171
                sensitive << clk.pos();
172
                SC_METHOD(tx_dma_en_up3);
173
                sensitive << clk.pos();
174
 
175
                SC_METHOD(idma_done_up);
176
                sensitive << clk.pos();
177
 
178
                SC_METHOD(rx_cnt_up1);
179
                sensitive << clk.pos() << rst.neg();
180
                SC_METHOD(rx_cnt_up2);
181
                sensitive << clk.pos() << rst.neg();
182
                SC_METHOD(rx_done_up);
183
                sensitive << rx_data_done_r;
184
 
185
                SC_METHOD(sizd_cnt_up);
186
                sensitive << clk.pos() << rst.neg();
187
                SC_METHOD(is_zero_up1);
188
                sensitive << sizd_c;
189
                SC_METHOD(is_zero_up2);
190
                sensitive << clk.pos();
191
                SC_METHOD(siz_dec_up);
192
                sensitive << tx_dma_en_r << tx_dma_en_r1 << rd_next << sizd_is_zero_d;
193
 
194
                SC_METHOD(tx_busy_up);
195
                sensitive << send_data << tx_dma_en_r << tx_dma_en;
196
                SC_METHOD(tx_valid_up1);
197
                sensitive << clk.pos();
198
                SC_METHOD(tx_valid_up2);
199
                sensitive << tx_valid_r << tx_valid;
200
                SC_METHOD(empty_up);
201
                sensitive << clk.pos() << rst.neg();
202
                SC_METHOD(send_data_up1);
203
                sensitive << clk.pos() << rst.neg();
204
                SC_METHOD(send_data_up2);
205
                sensitive << send_data_r << ep_empty_r << sizd_is_zero << size << tx_dma_en_r1;
206
                SC_METHOD(mre_up);
207
                sensitive << tx_dma_en_r1 << tx_dma_en_r << rd_next << sizd_is_zero_d << ep_empty_int << send_data;
208
                SC_METHOD(ff_we_up1);
209
                sensitive << clk.pos();
210
                SC_METHOD(ff_we_up2);
211
                sensitive << clk.pos();
212
                SC_METHOD(ff_re_up);
213
                sensitive << rd_next;
214
                SC_METHOD(ff_clr_up);
215
                sensitive << tx_valid;
216
 
217
                // IDMA FIFO Instantiation and Binding
218
                i_ff2 = new usb_fifo2("FIFO2");
219
                i_ff2->clk(clk);
220
                i_ff2->rst(rst);
221
                i_ff2->clr(ff_clr);
222
                i_ff2->din(tx_data_st_i);
223
                i_ff2->we(ff_we);
224
                i_ff2->dout(tx_data_st_o);
225
                i_ff2->re(ff_re);
226
        }
227
 
228
};
229
 
230
#endif
231
 

powered by: WebSVN 2.1.0

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