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

Subversion Repositories usb11

[/] [usb11/] [trunk/] [rtl/] [systemc/] [usb_dma.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 IDMA Engine                                            ////
4
////                                                             ////
5
////  SystemC Version: usb_dma.cpp                               ////
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
#include "systemc.h"
39
#include "usb_dma.h"
40
 
41
void usb_dma::empty_int_up(void) {
42
        ep_empty_int.write(ep_empty.read());
43
}
44
 
45
void usb_dma::full_int_up(void) {
46
        ep_full_int.write(ep_full.read());
47
}
48
 
49
void usb_dma::mwe_up1(void) {
50
        mwe_r.write(rx_data_valid.read());
51
}
52
 
53
void usb_dma::mwe_up2(void) {
54
        mwe.write(mwe_r.read() && !ep_full_int.read());
55
}
56
 
57
void usb_dma::data_valid_up(void) {
58
        rx_data_valid_r.write(rx_data_valid.read());
59
}
60
 
61
void usb_dma::data_done_up(void) {
62
        rx_data_done_r.write(rx_data_done.read());
63
}
64
 
65
void usb_dma::tx_dma_en_up1(void) {
66
        tx_dma_en_r.write(tx_dma_en.read());
67
}
68
 
69
void usb_dma::tx_dma_en_up2(void) {
70
        tx_dma_en_r1.write(tx_dma_en_r.read());
71
}
72
 
73
void usb_dma::tx_dma_en_up3(void) {
74
        tx_dma_en_r2.write(tx_dma_en_r1.read());
75
}
76
 
77
void usb_dma::idma_done_up(void) {
78
        idma_done.write(rx_data_done_r.read() || sizd_is_zero_d.read() || ep_empty_int.read());
79
}
80
 
81
void usb_dma::rx_cnt_up1(void) {
82
        if (!rst.read())
83
                rx_cnt_r.write(0);
84
        else if (rx_data_done_r.read())
85
                rx_cnt_r.write(0);
86
        else if (rx_data_valid.read())
87
                rx_cnt_r.write(rx_cnt_r.read() + 1);
88
}
89
 
90
void usb_dma::rx_cnt_up2(void) {
91
        if (!rst.read())
92
                rx_cnt.write(0);
93
        else if (rx_data_done_r.read())
94
                rx_cnt.write(rx_cnt_r.read());
95
}
96
 
97
void usb_dma::rx_done_up(void) {
98
        rx_done.write(rx_data_done_r.read());
99
}
100
 
101
// Transmit Size Counter (counting backward from input size)
102
// For MAX packet size
103
void usb_dma::sizd_cnt_up(void) {
104
        if (!rst.read())
105
                sizd_c.write(511);
106
        else if (tx_dma_en.read())
107
                sizd_c.write(size.read());
108
        else if (siz_dec.read())
109
                sizd_c.write(sizd_c.read() - 1);
110
}
111
 
112
void usb_dma::is_zero_up1(void) {
113
        sizd_is_zero_d.write(sizd_c.read() == 0);
114
}
115
 
116
void usb_dma::is_zero_up2(void) {
117
        sizd_is_zero.write(sizd_is_zero_d.read());
118
}
119
 
120
void usb_dma::siz_dec_up(void) {
121
        siz_dec.write((tx_dma_en_r.read() || tx_dma_en_r1.read() || rd_next.read()) && !sizd_is_zero_d.read());
122
}
123
 
124
void usb_dma::tx_busy_up(void) {
125
        tx_busy.write(send_data.read() || tx_dma_en_r.read() || tx_dma_en.read());
126
}
127
 
128
void usb_dma::tx_valid_up1(void) {
129
        tx_valid_r.write(tx_valid.read());
130
}
131
 
132
void usb_dma::tx_valid_up2(void) {
133
        tx_valid_e.write(tx_valid_r.read() && !tx_valid.read());
134
}
135
 
136
// Since we are prefetching two entries in to our fast fifo, we
137
// need to know when exactly ep_empty was asserted, as we might
138
// only need 1 or 2 bytes. This is for ep_empty_r
139
void usb_dma::empty_up(void) {
140
        if (!rst.read())
141
                ep_empty_r.write(false);
142
        else if (!tx_valid.read())
143
                ep_empty_r.write(false);
144
        else if (tx_dma_en_r2.read())
145
                ep_empty_r.write(ep_empty_int.read());
146
}
147
 
148
void usb_dma::send_data_up1(void) {
149
        if (!rst.read())
150
                send_data_r.write(false);
151
        else if (tx_dma_en_r.read() && !ep_empty_int.read())
152
                send_data_r.write(true);
153
        else if (rd_next.read() && (sizd_is_zero_d.read() || (ep_empty_int.read() && !sizd_is_zero_d.read())))
154
                send_data_r.write(false);
155
}
156
 
157
void usb_dma::send_data_up2(void) {
158
        send_data.write((send_data_r.read() && !ep_empty_r.read() && !(sizd_is_zero.read() &&
159
                        (size.read() == 1))) || tx_dma_en_r1.read());
160
}
161
 
162
void usb_dma::mre_up(void) {
163
        mre.write((tx_dma_en_r1.read() || tx_dma_en_r.read() || rd_next.read()) &&
164
                        !sizd_is_zero_d.read() && !ep_empty_int.read() &&
165
                        (send_data.read() || tx_dma_en_r1.read() || tx_dma_en_r.read()));
166
}
167
 
168
void usb_dma::ff_we_up1(void) {
169
        ff_we1.write(mre.read());
170
}
171
 
172
void usb_dma::ff_we_up2(void) {
173
        ff_we.write(ff_we1.read());
174
}
175
 
176
void usb_dma::ff_re_up(void) {
177
        ff_re.write(rd_next.read());
178
}
179
 
180
void usb_dma::ff_clr_up(void) {
181
        ff_clr.write(!tx_valid.read());
182
}
183
/*
184
usb_dma::~usb_dma(void) {
185
        if (i_ff2)
186
                delete i_ff2;
187
}
188
*/

powered by: WebSVN 2.1.0

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