1 |
2 |
alfoltran |
/////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// USB 1.1 Top Module ////
|
4 |
|
|
//// Function Interface ////
|
5 |
|
|
//// ////
|
6 |
|
|
//// SystemC Version: usb_top.cpp ////
|
7 |
|
|
//// Author: Alfredo Luiz Foltran Fialho ////
|
8 |
|
|
//// alfoltran@ig.com.br ////
|
9 |
|
|
//// ////
|
10 |
|
|
//// ////
|
11 |
|
|
/////////////////////////////////////////////////////////////////////
|
12 |
|
|
//// ////
|
13 |
|
|
//// Verilog Version: usb_8051_if.v ////
|
14 |
|
|
//// Copyright (C) 2003 Alfredo Luiz Foltran Fialho ////
|
15 |
|
|
//// alfoltran@ig.com.br ////
|
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_top.h"
|
40 |
|
|
|
41 |
|
|
void usb_top::mux(void) {
|
42 |
|
|
sc_uint<9> sel;
|
43 |
|
|
|
44 |
|
|
dout.write("ZZZZZZZZ");
|
45 |
|
|
empty.write(false);
|
46 |
|
|
full.write(false);
|
47 |
|
|
ep1_f_we.write(false);
|
48 |
|
|
ep2_f_re.write(false);
|
49 |
|
|
ep3_f_we.write(false);
|
50 |
|
|
ep4_f_re.write(false);
|
51 |
|
|
ep5_f_we.write(false);
|
52 |
|
|
ep6_f_re.write(false);
|
53 |
|
|
|
54 |
|
|
sel = ((sc_uint<1>)cs.read(), (sc_uint<8>)adr.read());
|
55 |
|
|
|
56 |
|
|
switch (sel) {// synopsys full_case parallel_case
|
57 |
|
|
case 0: dout.write("00000000");
|
58 |
|
|
full.write(false);
|
59 |
|
|
empty.write(false);
|
60 |
|
|
break;
|
61 |
|
|
case 1: ep1_f_din.write(din.read());
|
62 |
|
|
ep1_f_we.write(we.read());
|
63 |
|
|
full.write(ep1_f_full.read());
|
64 |
|
|
break;
|
65 |
|
|
case 2: dout.write((sc_lv<8>)ep2_f_dout.read());
|
66 |
|
|
ep2_f_re.write(re.read());
|
67 |
|
|
empty.write(ep2_f_empty.read());
|
68 |
|
|
break;
|
69 |
|
|
case 3: ep3_f_din.write(din.read());
|
70 |
|
|
ep3_f_we.write(we.read());
|
71 |
|
|
full.write(ep3_f_full.read());
|
72 |
|
|
break;
|
73 |
|
|
case 4: dout.write((sc_lv<8>)ep4_f_dout.read());
|
74 |
|
|
ep4_f_re.write(re.read());
|
75 |
|
|
empty.write(ep4_f_empty.read());
|
76 |
|
|
break;
|
77 |
|
|
case 5: ep5_f_din.write(din.read());
|
78 |
|
|
ep5_f_we.write(we.read());
|
79 |
|
|
full.write(ep5_f_full.read());
|
80 |
|
|
break;
|
81 |
|
|
case 6: dout.write((sc_lv<8>)ep6_f_dout.read());
|
82 |
|
|
ep6_f_re.write(re.read());
|
83 |
|
|
empty.write(ep6_f_empty.read());
|
84 |
|
|
break;
|
85 |
|
|
case 8: dout.write("00000000");
|
86 |
|
|
full.write(false);
|
87 |
|
|
empty.write(false);
|
88 |
|
|
break;
|
89 |
|
|
case 16:dout.write((sc_lv<8>)wValue.read().range(7, 0));
|
90 |
|
|
break;
|
91 |
|
|
case 17:dout.write((sc_lv<8>)wValue.read().range(15, 8));
|
92 |
|
|
break;
|
93 |
|
|
case 18:dout.write((sc_lv<8>)wIndex.read().range(7, 0));
|
94 |
|
|
break;
|
95 |
|
|
case 19:dout.write((sc_lv<8>)wIndex.read().range(15, 8));
|
96 |
|
|
break;
|
97 |
|
|
case 20:vendor_data.write((vendor_data.read().range(15, 8), din.read()));
|
98 |
|
|
break;
|
99 |
|
|
case 21:vendor_data.write((din.read(), vendor_data.read().range(7, 0)));
|
100 |
|
|
break;
|
101 |
|
|
}
|
102 |
|
|
}
|
103 |
|
|
/*
|
104 |
|
|
usb_top::~usb_top(void) {
|
105 |
|
|
if (i_usb)
|
106 |
|
|
delete i_usb;
|
107 |
|
|
}
|
108 |
|
|
*/
|