1 |
25 |
sfielding |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// usbHostSlaveAvalonWrap.v ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This file is part of the usbhostslave opencores effort.
|
6 |
|
|
//// <http://www.opencores.org/cores//> ////
|
7 |
|
|
//// ////
|
8 |
|
|
//// Module Description: ////
|
9 |
|
|
//// Top level module wrapper. Enable connection to Altera Avalon bus
|
10 |
|
|
//// ////
|
11 |
|
|
//// To Do: ////
|
12 |
|
|
////
|
13 |
|
|
//// ////
|
14 |
|
|
//// Author(s): ////
|
15 |
|
|
//// - Steve Fielding, sfielding@base2designs.com ////
|
16 |
|
|
//// ////
|
17 |
|
|
//////////////////////////////////////////////////////////////////////
|
18 |
|
|
//// ////
|
19 |
|
|
//// Copyright (C) 2004 Steve Fielding and OPENCORES.ORG ////
|
20 |
|
|
//// ////
|
21 |
|
|
//// This source file may be used and distributed without ////
|
22 |
|
|
//// restriction provided that this copyright statement is not ////
|
23 |
|
|
//// removed from the file and that any derivative work contains ////
|
24 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
25 |
|
|
//// ////
|
26 |
|
|
//// This source file is free software; you can redistribute it ////
|
27 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
28 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
29 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
30 |
|
|
//// later version. ////
|
31 |
|
|
//// ////
|
32 |
|
|
//// This source is distributed in the hope that it will be ////
|
33 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
34 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
35 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
36 |
|
|
//// details. ////
|
37 |
|
|
//// ////
|
38 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
39 |
|
|
//// Public License along with this source; if not, download it ////
|
40 |
|
|
//// from <http://www.opencores.org/lgpl.shtml> ////
|
41 |
|
|
//// ////
|
42 |
|
|
//////////////////////////////////////////////////////////////////////
|
43 |
|
|
//
|
44 |
|
|
`include "timescale.v"
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
module usbHostSlaveAvalonWrap(
|
48 |
|
|
clk,
|
49 |
|
|
reset,
|
50 |
|
|
address,
|
51 |
|
|
writedata,
|
52 |
|
|
readdata,
|
53 |
|
|
write,
|
54 |
|
|
read,
|
55 |
|
|
waitrequest,
|
56 |
|
|
chipselect,
|
57 |
|
|
irq,
|
58 |
|
|
usbClk,
|
59 |
|
|
USBWireVPI,
|
60 |
|
|
USBWireVMI,
|
61 |
|
|
USBWireDataInTick,
|
62 |
|
|
USBWireVPO,
|
63 |
|
|
USBWireVMO,
|
64 |
|
|
USBWireDataOutTick,
|
65 |
|
|
USBWireOutEn_n,
|
66 |
|
|
USBFullSpeed
|
67 |
|
|
);
|
68 |
|
|
|
69 |
|
|
input clk;
|
70 |
|
|
input reset;
|
71 |
|
|
input [7:0] address;
|
72 |
|
|
input [7:0] writedata;
|
73 |
|
|
output [7:0] readdata;
|
74 |
|
|
input write;
|
75 |
|
|
input read;
|
76 |
|
|
output waitrequest;
|
77 |
|
|
input chipselect;
|
78 |
|
|
output irq;
|
79 |
|
|
input usbClk;
|
80 |
|
|
input USBWireVPI /* synthesis useioff=1 */;
|
81 |
|
|
input USBWireVMI /* synthesis useioff=1 */;
|
82 |
|
|
output USBWireVPO /* synthesis useioff=1 */;
|
83 |
|
|
output USBWireVMO /* synthesis useioff=1 */;
|
84 |
|
|
output USBWireDataOutTick /* synthesis useioff=1 */;
|
85 |
|
|
output USBWireDataInTick /* synthesis useioff=1 */;
|
86 |
|
|
output USBWireOutEn_n /* synthesis useioff=1 */;
|
87 |
|
|
output USBFullSpeed /* synthesis useioff=1 */;
|
88 |
|
|
|
89 |
|
|
wire clk;
|
90 |
|
|
wire reset;
|
91 |
|
|
wire [7:0] address;
|
92 |
|
|
wire [7:0] writedata;
|
93 |
|
|
wire [7:0] readdata;
|
94 |
|
|
wire write;
|
95 |
|
|
wire read;
|
96 |
|
|
wire waitrequest;
|
97 |
|
|
wire chipselect;
|
98 |
|
|
wire irq;
|
99 |
|
|
wire usbClk;
|
100 |
|
|
wire USBWireVPI;
|
101 |
|
|
wire USBWireVMI;
|
102 |
|
|
wire USBWireVPO;
|
103 |
|
|
wire USBWireVMO;
|
104 |
|
|
wire USBWireDataOutTick;
|
105 |
|
|
wire USBWireDataInTick;
|
106 |
|
|
wire USBWireOutEn_n;
|
107 |
|
|
wire USBFullSpeed;
|
108 |
|
|
|
109 |
|
|
//internal wiring
|
110 |
|
|
wire strobe_i;
|
111 |
|
|
wire ack_o;
|
112 |
|
|
wire hostSOFSentIntOut;
|
113 |
|
|
wire hostConnEventIntOut;
|
114 |
|
|
wire hostResumeIntOut;
|
115 |
|
|
wire hostTransDoneIntOut;
|
116 |
|
|
wire slaveSOFRxedIntOut;
|
117 |
|
|
wire slaveResetEventIntOut;
|
118 |
|
|
wire slaveResumeIntOut;
|
119 |
|
|
wire slaveTransDoneIntOut;
|
120 |
|
|
wire slaveNAKSentIntOut;
|
121 |
|
|
wire USBWireCtrlOut;
|
122 |
|
|
wire [1:0] USBWireDataIn;
|
123 |
|
|
wire [1:0] USBWireDataOut;
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
assign irq = hostSOFSentIntOut | hostConnEventIntOut |
|
127 |
|
|
hostResumeIntOut | hostTransDoneIntOut |
|
128 |
|
|
slaveSOFRxedIntOut | slaveResetEventIntOut |
|
129 |
|
|
slaveResumeIntOut | slaveTransDoneIntOut |
|
130 |
|
|
slaveNAKSentIntOut;
|
131 |
|
|
|
132 |
|
|
assign strobe_i = chipselect & ( read | write);
|
133 |
|
|
assign waitrequest = ~ack_o;
|
134 |
|
|
|
135 |
|
|
assign USBWireOutEn_n = ~USBWireCtrlOut;
|
136 |
|
|
|
137 |
|
|
assign USBWireDataIn = {USBWireVPI, USBWireVMI};
|
138 |
|
|
assign {USBWireVPO, USBWireVMO} = USBWireDataOut;
|
139 |
|
|
|
140 |
|
|
//Parameters declaration:
|
141 |
|
|
defparam usbHostSlaveInst.HOST_FIFO_DEPTH = 64;
|
142 |
|
|
parameter HOST_FIFO_DEPTH = 64;
|
143 |
|
|
defparam usbHostSlaveInst.HOST_FIFO_ADDR_WIDTH = 6;
|
144 |
|
|
parameter HOST_FIFO_ADDR_WIDTH = 6;
|
145 |
|
|
defparam usbHostSlaveInst.EP0_FIFO_DEPTH = 64;
|
146 |
|
|
parameter EP0_FIFO_DEPTH = 64;
|
147 |
|
|
defparam usbHostSlaveInst.EP0_FIFO_ADDR_WIDTH = 6;
|
148 |
|
|
parameter EP0_FIFO_ADDR_WIDTH = 6;
|
149 |
|
|
defparam usbHostSlaveInst.EP1_FIFO_DEPTH = 64;
|
150 |
|
|
parameter EP1_FIFO_DEPTH = 64;
|
151 |
|
|
defparam usbHostSlaveInst.EP1_FIFO_ADDR_WIDTH = 6;
|
152 |
|
|
parameter EP1_FIFO_ADDR_WIDTH = 6;
|
153 |
|
|
defparam usbHostSlaveInst.EP2_FIFO_DEPTH = 64;
|
154 |
|
|
parameter EP2_FIFO_DEPTH = 64;
|
155 |
|
|
defparam usbHostSlaveInst.EP2_FIFO_ADDR_WIDTH = 6;
|
156 |
|
|
parameter EP2_FIFO_ADDR_WIDTH = 6;
|
157 |
|
|
defparam usbHostSlaveInst.EP3_FIFO_DEPTH = 64;
|
158 |
|
|
parameter EP3_FIFO_DEPTH = 64;
|
159 |
|
|
defparam usbHostSlaveInst.EP3_FIFO_ADDR_WIDTH = 6;
|
160 |
|
|
parameter EP3_FIFO_ADDR_WIDTH = 6;
|
161 |
|
|
usbHostSlave usbHostSlaveInst (
|
162 |
|
|
.clk_i(clk),
|
163 |
|
|
.rst_i(reset),
|
164 |
|
|
.address_i(address),
|
165 |
|
|
.data_i(writedata),
|
166 |
|
|
.data_o(readdata),
|
167 |
|
|
.we_i(write),
|
168 |
|
|
.strobe_i(strobe_i),
|
169 |
|
|
.ack_o(ack_o),
|
170 |
|
|
.usbClk(usbClk),
|
171 |
|
|
.hostSOFSentIntOut(hostSOFSentIntOut),
|
172 |
|
|
.hostConnEventIntOut(hostConnEventIntOut),
|
173 |
|
|
.hostResumeIntOut(hostResumeIntOut),
|
174 |
|
|
.hostTransDoneIntOut(hostTransDoneIntOut),
|
175 |
|
|
.slaveSOFRxedIntOut(slaveSOFRxedIntOut),
|
176 |
|
|
.slaveResetEventIntOut(slaveResetEventIntOut),
|
177 |
|
|
.slaveResumeIntOut(slaveResumeIntOut),
|
178 |
|
|
.slaveTransDoneIntOut(slaveTransDoneIntOut),
|
179 |
|
|
.slaveNAKSentIntOut(slaveNAKSentIntOut),
|
180 |
|
|
.USBWireDataIn(USBWireDataIn),
|
181 |
|
|
.USBWireDataInTick(USBWireDataInTick),
|
182 |
|
|
.USBWireDataOut(USBWireDataOut),
|
183 |
|
|
.USBWireDataOutTick(USBWireDataOutTick),
|
184 |
|
|
.USBWireCtrlOut(USBWireCtrlOut),
|
185 |
|
|
.USBFullSpeed(USBFullSpeed));
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
endmodule
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
|