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

Subversion Repositories usb11

[/] [usb11/] [trunk/] [rtl/] [systemc/] [usb_core.cpp] - 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
////  Function IP Core                                           ////
5
////                                                             ////
6
////  SystemC Version: usb_core.cpp                              ////
7
////  Author: Alfredo Luiz Foltran Fialho                        ////
8
////          alfoltran@ig.com.br                                ////
9
////                                                             ////
10
////                                                             ////
11
/////////////////////////////////////////////////////////////////////
12
////                                                             ////
13
//// Verilog Version: usb1_core.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
#include "systemc.h"
40
#include "usb_core.h"
41
 
42
void usb_core::rst_local_up(void) {
43
        rst_local.write(rst_i.read() && !usb_rst.read());
44
}
45
 
46
void usb_core::stat_up(void) {
47
        ep0_ctrl_stat.write(((sc_uint<1>)0, (sc_uint<1>)stat2.read(), (sc_uint<1>)stat1.read(), (sc_uint<1>)0));
48
}
49
 
50
void usb_core::frame_no_up(void) {
51
        frame_no.write(frm_nat.read().range(26, 16));
52
}
53
 
54
void usb_core::cfg_mux(void) {
55
        switch (ep_sel.read()) {// synopsys full_case parallel_case
56
                case 0:  cfg.write(ep0_size.read() | CTRL); break;
57
                case 1: cfg.write(ep1_cfg.read()); break;
58
                case 2: cfg.write(ep2_cfg.read()); break;
59
                case 3: cfg.write(ep3_cfg.read()); break;
60
                case 4: cfg.write(ep4_cfg.read()); break;
61
                case 5: cfg.write(ep5_cfg.read()); break;
62
                case 6: cfg.write(ep6_cfg.read()); break;
63
                case 7: cfg.write(ep7_cfg.read()); break;
64
        }
65
}
66
 
67
void usb_core::tx_data_mux(void) {
68
        switch (ep_sel.read()) {// synopsys full_case parallel_case
69
                case 0:  tx_data_st.write(ep0_dout.read()); break;
70
                case 1: tx_data_st.write(ep1_din.read()); break;
71
                case 2: tx_data_st.write(ep2_din.read()); break;
72
                case 3: tx_data_st.write(ep3_din.read()); break;
73
                case 4: tx_data_st.write(ep4_din.read()); break;
74
                case 5: tx_data_st.write(ep5_din.read()); break;
75
                case 6: tx_data_st.write(ep6_din.read()); break;
76
                case 7: tx_data_st.write(ep7_din.read()); break;
77
        }
78
}
79
 
80
void usb_core::ep_empty_mux(void) {
81
        switch (ep_sel.read()) {// synopsys full_case parallel_case
82
                case 0:  ep_empty.write(ep0_empty.read()); break;
83
                case 1: ep_empty.write(ep1_empty.read()); break;
84
                case 2: ep_empty.write(ep2_empty.read()); break;
85
                case 3: ep_empty.write(ep3_empty.read()); break;
86
                case 4: ep_empty.write(ep4_empty.read()); break;
87
                case 5: ep_empty.write(ep5_empty.read()); break;
88
                case 6: ep_empty.write(ep6_empty.read()); break;
89
                case 7: ep_empty.write(ep7_empty.read()); break;
90
        }
91
}
92
 
93
void usb_core::ep_full_mux(void) {
94
        switch (ep_sel.read()) {// synopsys full_case parallel_case
95
                case 0:  ep_full.write(ep0_full.read()); break;
96
                case 1: ep_full.write(ep1_full.read()); break;
97
                case 2: ep_full.write(ep2_full.read()); break;
98
                case 3: ep_full.write(ep3_full.read()); break;
99
                case 4: ep_full.write(ep4_full.read()); break;
100
                case 5: ep_full.write(ep5_full.read()); break;
101
                case 6: ep_full.write(ep6_full.read()); break;
102
                case 7: ep_full.write(ep7_full.read()); break;
103
        }
104
}
105
 
106
void usb_core::ep_dout_deco(void) {
107
        ep1_dout.write(rx_data_st.read());
108
        ep2_dout.write(rx_data_st.read());
109
        ep3_dout.write(rx_data_st.read());
110
        ep4_dout.write(rx_data_st.read());
111
        ep5_dout.write(rx_data_st.read());
112
        ep6_dout.write(rx_data_st.read());
113
        ep7_dout.write(rx_data_st.read());
114
}
115
 
116
void usb_core::ep_re_deco(void) {
117
        ep0_re.write(idma_re.read() && (ep_sel.read() == 0));
118
        ep1_re.write(idma_re.read() && (ep_sel.read() == 1) && !ep1_empty.read());
119
        ep2_re.write(idma_re.read() && (ep_sel.read() == 2) && !ep2_empty.read());
120
        ep3_re.write(idma_re.read() && (ep_sel.read() == 3) && !ep3_empty.read());
121
        ep4_re.write(idma_re.read() && (ep_sel.read() == 4) && !ep4_empty.read());
122
        ep5_re.write(idma_re.read() && (ep_sel.read() == 5) && !ep5_empty.read());
123
        ep6_re.write(idma_re.read() && (ep_sel.read() == 6) && !ep6_empty.read());
124
        ep7_re.write(idma_re.read() && (ep_sel.read() == 7) && !ep7_empty.read());
125
}
126
 
127
void usb_core::ep_we_deco(void) {
128
        ep0_we.write(idma_we.read() && (ep_sel.read() == 0));
129
        ep1_we.write(idma_we.read() && (ep_sel.read() == 1) && !ep1_full.read());
130
        ep2_we.write(idma_we.read() && (ep_sel.read() == 2) && !ep2_full.read());
131
        ep3_we.write(idma_we.read() && (ep_sel.read() == 3) && !ep3_full.read());
132
        ep4_we.write(idma_we.read() && (ep_sel.read() == 4) && !ep4_full.read());
133
        ep5_we.write(idma_we.read() && (ep_sel.read() == 5) && !ep5_full.read());
134
        ep6_we.write(idma_we.read() && (ep_sel.read() == 6) && !ep6_full.read());
135
        ep7_we.write(idma_we.read() && (ep_sel.read() == 7) && !ep7_full.read());
136
}
137
/*
138
usb_core::~usb_core(void) {
139
        if (i_phy)
140
                delete i_phy;
141
        if (i_sie)
142
                delete i_sie;
143
        if (i_ep0)
144
                delete i_ep0;
145
        if (i_rom)
146
                delete i_rom;
147
        if (i_ff_in)
148
                delete i_ff_in;
149
        if (i_ff_out)
150
                delete i_ff_out;
151
}
152
*/

powered by: WebSVN 2.1.0

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