1 |
24 |
rherveille |
/////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// OpenCores ATA/ATAPI-5 Host Controller ////
|
4 |
|
|
//// ATA/ATAPI-5 PIO Controller (OCIDEC-2) Top Level ////
|
5 |
|
|
//// ////
|
6 |
|
|
//// Author: Richard Herveille ////
|
7 |
|
|
//// richard@asics.ws ////
|
8 |
|
|
//// www.asics.ws ////
|
9 |
|
|
//// ////
|
10 |
|
|
/////////////////////////////////////////////////////////////////////
|
11 |
|
|
//// ////
|
12 |
|
|
//// Copyright (C) 2001, 2002 Richard Herveille ////
|
13 |
|
|
//// richard@asics.ws ////
|
14 |
|
|
//// ////
|
15 |
|
|
//// This source file may be used and distributed without ////
|
16 |
|
|
//// restriction provided that this copyright statement is not ////
|
17 |
|
|
//// removed from the file and that any derivative work contains ////
|
18 |
|
|
//// the original copyright notice and the associated disclaimer.////
|
19 |
|
|
//// ////
|
20 |
|
|
//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY ////
|
21 |
|
|
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED ////
|
22 |
|
|
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ////
|
23 |
|
|
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR ////
|
24 |
|
|
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ////
|
25 |
|
|
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ////
|
26 |
|
|
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ////
|
27 |
|
|
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ////
|
28 |
|
|
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ////
|
29 |
|
|
//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ////
|
30 |
|
|
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ////
|
31 |
|
|
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ////
|
32 |
|
|
//// POSSIBILITY OF SUCH DAMAGE. ////
|
33 |
|
|
//// ////
|
34 |
|
|
/////////////////////////////////////////////////////////////////////
|
35 |
|
|
|
36 |
|
|
//
|
37 |
|
|
// CVS Log
|
38 |
|
|
//
|
39 |
|
|
// $Id: atahost_top.v,v 1.1 2002-02-18 14:26:46 rherveille Exp $
|
40 |
|
|
//
|
41 |
|
|
// $Date: 2002-02-18 14:26:46 $
|
42 |
|
|
// $Revision: 1.1 $
|
43 |
|
|
// $Author: rherveille $
|
44 |
|
|
// $Locker: $
|
45 |
|
|
// $State: Exp $
|
46 |
|
|
//
|
47 |
|
|
// Change History:
|
48 |
|
|
// $Log: not supported by cvs2svn $
|
49 |
|
|
//
|
50 |
|
|
|
51 |
|
|
//
|
52 |
|
|
// DeviceType: OCIDEC-2: OpenCores IDE Controller type2
|
53 |
|
|
// Features: PIO Compatible Timing, PIO Fast Timing 0/1
|
54 |
|
|
// DeviceID: 0x02
|
55 |
|
|
// RevNo : 0x00
|
56 |
|
|
//
|
57 |
|
|
|
58 |
|
|
//
|
59 |
|
|
// Host signals:
|
60 |
|
|
// Reset
|
61 |
|
|
// DIOR- read strobe. The falling edge enables data from device onto DD. The rising edge latches data at the host.
|
62 |
|
|
// DIOW- write strobe. The rising edge latches data from DD into the device.
|
63 |
|
|
// DA(2:0) 3bit binary coded adress
|
64 |
|
|
// CS0- select command block registers
|
65 |
|
|
// CS1- select control block registers
|
66 |
|
|
//
|
67 |
|
|
|
68 |
|
|
`include "timescale.v"
|
69 |
|
|
|
70 |
|
|
module atahost_top (wb_clk_i, arst_i, wb_rst_i, wb_cyc_i, wb_stb_i, wb_ack_o, wb_err_o,
|
71 |
|
|
wb_adr_i, wb_dat_i, wb_dat_o, wb_sel_i, wb_we_i, wb_inta_o,
|
72 |
|
|
resetn_pad_o, dd_pad_i, dd_pad_o, dd_padoe_o, da_pad_o, cs0n_pad_o,
|
73 |
|
|
cs1n_pad_o, diorn_pad_o, diown_pad_o, iordy_pad_i, intrq_pad_i);
|
74 |
|
|
//
|
75 |
|
|
// Parameter declarations
|
76 |
|
|
//
|
77 |
|
|
parameter ARST_LVL = 1'b0; // asynchronous reset level
|
78 |
|
|
|
79 |
|
|
parameter TWIDTH = 8; // counter width
|
80 |
|
|
// PIO mode 0 settings (@100MHz clock)
|
81 |
|
|
parameter PIO_mode0_T1 = 6; // 70ns
|
82 |
|
|
parameter PIO_mode0_T2 = 28; // 290ns
|
83 |
|
|
parameter PIO_mode0_T4 = 2; // 30ns
|
84 |
|
|
parameter PIO_mode0_Teoc = 23; // 240ns ==> T0 - T1 - T2 = 600 - 70 - 290 = 240
|
85 |
|
|
|
86 |
|
|
//
|
87 |
|
|
// inputs & outputs
|
88 |
|
|
//
|
89 |
|
|
|
90 |
|
|
// WISHBONE SYSCON signals
|
91 |
|
|
input wb_clk_i; // master clock in
|
92 |
|
|
input arst_i; // asynchronous reset
|
93 |
|
|
input wb_rst_i; // synchronous reset
|
94 |
|
|
|
95 |
|
|
// WISHBONE SLAVE signals
|
96 |
|
|
input wb_cyc_i; // valid bus cycle input
|
97 |
|
|
input wb_stb_i; // strobe/core select input
|
98 |
|
|
output wb_ack_o; // strobe acknowledge output
|
99 |
|
|
output wb_err_o; // error output
|
100 |
|
|
input [6:2] wb_adr_i; // A6 = '1' ATA devices selected
|
101 |
|
|
// A5 = '1' CS1- asserted, '0' CS0- asserted
|
102 |
|
|
// A4..A2 ATA address lines
|
103 |
|
|
// A6 = '0' ATA controller selected
|
104 |
|
|
input [31:0] wb_dat_i; // Databus in
|
105 |
|
|
output [31:0] wb_dat_o; // Databus out
|
106 |
|
|
input [ 3:0] wb_sel_i; // Byte select signals
|
107 |
|
|
input wb_we_i; // Write enable input
|
108 |
|
|
output wb_inta_o; // interrupt request signal
|
109 |
|
|
|
110 |
|
|
// ATA signals
|
111 |
|
|
output resetn_pad_o;
|
112 |
|
|
input [15:0] dd_pad_i;
|
113 |
|
|
output [15:0] dd_pad_o;
|
114 |
|
|
output dd_padoe_o;
|
115 |
|
|
output [ 2:0] da_pad_o;
|
116 |
|
|
output cs0n_pad_o;
|
117 |
|
|
output cs1n_pad_o;
|
118 |
|
|
|
119 |
|
|
output diorn_pad_o;
|
120 |
|
|
output diown_pad_o;
|
121 |
|
|
input iordy_pad_i;
|
122 |
|
|
input intrq_pad_i;
|
123 |
|
|
|
124 |
|
|
//
|
125 |
|
|
// constant declarations
|
126 |
|
|
//
|
127 |
|
|
parameter [3:0] DeviceId = 4'h2;
|
128 |
|
|
parameter [3:0] RevisionNo = 4'h0;
|
129 |
|
|
|
130 |
|
|
//
|
131 |
|
|
// Variable declarations
|
132 |
|
|
//
|
133 |
|
|
|
134 |
|
|
// registers
|
135 |
|
|
wire IDEctrl_IDEen, IDEctrl_rst;
|
136 |
|
|
wire IDEctrl_FATR0, IDEctrl_FATR1;
|
137 |
|
|
wire [ 7:0] PIO_cmdport_T1, PIO_cmdport_T2, PIO_cmdport_T4, PIO_cmdport_Teoc;
|
138 |
|
|
wire PIO_cmdport_IORDYen;
|
139 |
|
|
wire [ 7:0] PIO_dport0_T1, PIO_dport0_T2, PIO_dport0_T4, PIO_dport0_Teoc;
|
140 |
|
|
wire PIO_dport0_IORDYen;
|
141 |
|
|
wire [ 7:0] PIO_dport1_T1, PIO_dport1_T2, PIO_dport1_T4, PIO_dport1_Teoc;
|
142 |
|
|
wire PIO_dport1_IORDYen;
|
143 |
|
|
|
144 |
|
|
wire PIOack;
|
145 |
|
|
wire [15:0] PIOq;
|
146 |
|
|
|
147 |
|
|
wire irq; // ATA bus IRQ signal
|
148 |
|
|
|
149 |
|
|
|
150 |
|
|
/////////////////
|
151 |
|
|
// Module body //
|
152 |
|
|
/////////////////
|
153 |
|
|
|
154 |
|
|
// generate asynchronous reset level
|
155 |
|
|
// arst_signal is either a wire or a NOT-gate
|
156 |
|
|
wire arst_signal = arst_i ^ ARST_LVL;
|
157 |
|
|
|
158 |
|
|
//
|
159 |
|
|
// hookup wishbone slave
|
160 |
|
|
//
|
161 |
|
|
atahost_wb_slave #(DeviceId, RevisionNo, PIO_mode0_T1,
|
162 |
|
|
PIO_mode0_T2, PIO_mode0_T4, PIO_mode0_Teoc, 0, 0, 0)
|
163 |
|
|
u0 (
|
164 |
|
|
// WISHBONE SYSCON signals
|
165 |
|
|
.clk_i(wb_clk_i),
|
166 |
|
|
.arst_i(arst_signal),
|
167 |
|
|
.rst_i(wb_rst_i),
|
168 |
|
|
|
169 |
|
|
// WISHBONE SLAVE signals
|
170 |
|
|
.cyc_i(wb_cyc_i),
|
171 |
|
|
.stb_i(wb_stb_i),
|
172 |
|
|
.ack_o(wb_ack_o),
|
173 |
|
|
.rty_o(),
|
174 |
|
|
.err_o(wb_err_o),
|
175 |
|
|
.adr_i(wb_adr_i),
|
176 |
|
|
.dat_i(wb_dat_i),
|
177 |
|
|
.dat_o(wb_dat_o),
|
178 |
|
|
.sel_i(wb_sel_i),
|
179 |
|
|
.we_i(wb_we_i),
|
180 |
|
|
.inta_o(wb_inta_o),
|
181 |
|
|
|
182 |
|
|
// PIO control inputs
|
183 |
|
|
.PIOsel(PIOsel),
|
184 |
|
|
// PIOtip is only asserted during a PIO transfer (No shit! ;)
|
185 |
|
|
// Since it is impossible to read the status register and access the PIO registers at the same time
|
186 |
|
|
// this bit is useless (besides using-up resources)
|
187 |
|
|
.PIOtip(1'b0),
|
188 |
|
|
.PIOack(PIOack),
|
189 |
|
|
.PIOq(PIOq),
|
190 |
|
|
.PIOpp_full(1'b0), // OCIDEC-2 does not support PIO-write pingpong, negate signal
|
191 |
|
|
.irq(irq),
|
192 |
|
|
|
193 |
|
|
// DMA control inputs (negate all of them, OCIDEC-2 does not support DMA)
|
194 |
|
|
.DMAsel(),
|
195 |
|
|
.DMAtip(1'b0),
|
196 |
|
|
.DMAack(1'b0),
|
197 |
|
|
.DMARxEmpty(1'b0),
|
198 |
|
|
.DMATxFull(1'b0),
|
199 |
|
|
.DMA_dmarq(1'b0),
|
200 |
|
|
.DMAq(32'h0),
|
201 |
|
|
|
202 |
|
|
// outputs
|
203 |
|
|
// control register outputs
|
204 |
|
|
.IDEctrl_rst(IDEctrl_rst),
|
205 |
|
|
.IDEctrl_IDEen(IDEctrl_IDEen),
|
206 |
|
|
.IDEctrl_FATR0(IDEctrl_FATR0),
|
207 |
|
|
.IDEctrl_FATR1(IDEctrl_FATR1),
|
208 |
|
|
.IDEctrl_ppen(),
|
209 |
|
|
|
210 |
|
|
.DMActrl_DMAen(),
|
211 |
|
|
.DMActrl_dir(),
|
212 |
|
|
.DMActrl_BeLeC0(),
|
213 |
|
|
.DMActrl_BeLeC1(),
|
214 |
|
|
|
215 |
|
|
// CMD port timing registers
|
216 |
|
|
.PIO_cmdport_T1(PIO_cmdport_T1),
|
217 |
|
|
.PIO_cmdport_T2(PIO_cmdport_T2),
|
218 |
|
|
.PIO_cmdport_T4(PIO_cmdport_T4),
|
219 |
|
|
.PIO_cmdport_Teoc(PIO_cmdport_Teoc),
|
220 |
|
|
.PIO_cmdport_IORDYen(PIO_cmdport_IORDYen),
|
221 |
|
|
|
222 |
|
|
// data-port0 timing registers
|
223 |
|
|
.PIO_dport0_T1(PIO_dport0_T1),
|
224 |
|
|
.PIO_dport0_T2(PIO_dport0_T2),
|
225 |
|
|
.PIO_dport0_T4(PIO_dport0_T4),
|
226 |
|
|
.PIO_dport0_Teoc(PIO_dport0_Teoc),
|
227 |
|
|
.PIO_dport0_IORDYen(PIO_dport0_IORDYen),
|
228 |
|
|
|
229 |
|
|
// data-port1 timing registers
|
230 |
|
|
.PIO_dport1_T1(PIO_dport1_T1),
|
231 |
|
|
.PIO_dport1_T2(PIO_dport1_T2),
|
232 |
|
|
.PIO_dport1_T4(PIO_dport1_T4),
|
233 |
|
|
.PIO_dport1_Teoc(PIO_dport1_Teoc),
|
234 |
|
|
.PIO_dport1_IORDYen(PIO_dport1_IORDYen),
|
235 |
|
|
|
236 |
|
|
// DMA device0 timing registers
|
237 |
|
|
.DMA_dev0_Tm(),
|
238 |
|
|
.DMA_dev0_Td(),
|
239 |
|
|
.DMA_dev0_Teoc(),
|
240 |
|
|
|
241 |
|
|
// DMA device1 timing registers
|
242 |
|
|
.DMA_dev1_Tm(),
|
243 |
|
|
.DMA_dev1_Td(),
|
244 |
|
|
.DMA_dev1_Teoc()
|
245 |
|
|
);
|
246 |
|
|
|
247 |
|
|
|
248 |
|
|
//
|
249 |
|
|
// hookup controller section
|
250 |
|
|
//
|
251 |
|
|
atahost_controller #(TWIDTH, PIO_mode0_T1, PIO_mode0_T2, PIO_mode0_T4, PIO_mode0_Teoc)
|
252 |
|
|
u1 (
|
253 |
|
|
.clk(wb_clk_i),
|
254 |
|
|
.nReset(arst_signal),
|
255 |
|
|
.rst(wb_rst_i),
|
256 |
|
|
.irq(irq),
|
257 |
|
|
.IDEctrl_rst(IDEctrl_rst),
|
258 |
|
|
.IDEctrl_IDEen(IDEctrl_IDEen),
|
259 |
|
|
.IDEctrl_FATR0(IDEctrl_FATR0),
|
260 |
|
|
.IDEctrl_FATR1(IDEctrl_FATR1),
|
261 |
|
|
.cmdport_T1(PIO_cmdport_T1),
|
262 |
|
|
.cmdport_T2(PIO_cmdport_T2),
|
263 |
|
|
.cmdport_T4(PIO_cmdport_T4),
|
264 |
|
|
.cmdport_Teoc(PIO_cmdport_Teoc),
|
265 |
|
|
.cmdport_IORDYen(PIO_cmdport_IORDYen),
|
266 |
|
|
.dport0_T1(PIO_dport0_T1),
|
267 |
|
|
.dport0_T2(PIO_dport0_T2),
|
268 |
|
|
.dport0_T4(PIO_dport0_T4),
|
269 |
|
|
.dport0_Teoc(PIO_dport0_Teoc),
|
270 |
|
|
.dport0_IORDYen(PIO_dport0_IORDYen),
|
271 |
|
|
.dport1_T1(PIO_dport1_T1),
|
272 |
|
|
.dport1_T2(PIO_dport1_T2),
|
273 |
|
|
.dport1_T4(PIO_dport1_T4),
|
274 |
|
|
.dport1_Teoc(PIO_dport1_Teoc),
|
275 |
|
|
.dport1_IORDYen(PIO_dport1_IORDYen),
|
276 |
|
|
.PIOreq(PIOsel),
|
277 |
|
|
.PIOack(PIOack),
|
278 |
|
|
.PIOa(wb_adr_i[5:2]),
|
279 |
|
|
.PIOd(wb_dat_i[15:0]),
|
280 |
|
|
.PIOq(PIOq),
|
281 |
|
|
.PIOwe(wb_we_i),
|
282 |
|
|
.RESETn(resetn_pad_o),
|
283 |
|
|
.DDi(dd_pad_i),
|
284 |
|
|
.DDo(dd_pad_o),
|
285 |
|
|
.DDoe(dd_padoe_o),
|
286 |
|
|
.DA(da_pad_o),
|
287 |
|
|
.CS0n(cs0n_pad_o),
|
288 |
|
|
.CS1n(cs1n_pad_o),
|
289 |
|
|
.DIORn(diorn_pad_o),
|
290 |
|
|
.DIOWn(diown_pad_o),
|
291 |
|
|
.IORDY(iordy_pad_i),
|
292 |
|
|
.INTRQ(intrq_pad_i)
|
293 |
|
|
);
|
294 |
|
|
|
295 |
|
|
endmodule
|
296 |
|
|
|