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

Subversion Repositories ata

[/] [ata/] [trunk/] [rtl/] [verilog/] [ocidec-1/] [atahost_controller.v] - Blame information for rev 23

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 22 rherveille
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3 23 rherveille
////  OCIDEC-1 ATA/ATAPI-5 Host Controller                       ////
4
////  PIO Controller                                             ////
5 22 rherveille
////                                                             ////
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 15 rherveille
 
36 22 rherveille
//  CVS Log
37 15 rherveille
//
38 23 rherveille
//  $Id: atahost_controller.v,v 1.3 2002-02-18 14:25:43 rherveille Exp $
39 22 rherveille
//
40 23 rherveille
//  $Date: 2002-02-18 14:25:43 $
41
//  $Revision: 1.3 $
42 22 rherveille
//  $Author: rherveille $
43
//  $Locker:  $
44
//  $State: Exp $
45
//
46
// Change History:
47
//               rev.: 1.0  june  28th, 2001. Initial Verilog release
48
//               rev.: 1.1  July   3rd, 2001. Rewrote "IORDY" and "INTRQ" capture section.
49
//               rev.: 1.2  July   9th, 2001. Added "timescale". Undid "IORDY & INTRQ" rewrite.
50
//               rev.: 1.3  July  11th, 2001. Changed PIOreq & PIOack generation (made them synchronous). 
51
//               rev.: 1.4  July  26th, 2001. Fixed non-blocking assignments.
52
//
53
//               $Log: not supported by cvs2svn $
54 23 rherveille
//               Revision 1.2  2002/02/16 10:42:17  rherveille
55
//               Added disclaimer
56
//               Added CVS information
57
//               Changed core for new internal counter libraries (synthesis fixes).
58 22 rherveille
//
59
//
60 23 rherveille
//
61 15 rherveille
 
62
`include "timescale.v"
63
 
64
module atahost_controller (clk, nReset, rst, irq, IDEctrl_rst, IDEctrl_IDEen,
65
                        PIO_cmdport_T1, PIO_cmdport_T2, PIO_cmdport_T4, PIO_cmdport_Teoc, PIO_cmdport_IORDYen,
66
                        PIOreq, PIOack, PIOa, PIOd, PIOq, PIOwe,
67
                        RESETn, DDi, DDo, DDoe, DA, CS0n, CS1n, DIORn, DIOWn, IORDY, INTRQ);
68
        //
69
        // parameter declarations
70
        //
71
        parameter TWIDTH = 8;              // counter width
72
        // PIO mode 0 timing settings @100MHz master clock
73
        parameter PIO_mode0_T1   = 6;      // 70ns
74
        parameter PIO_mode0_T2   = 28;     // 290ns
75
        parameter PIO_mode0_T4   = 2;      // 30ns
76
        parameter PIO_mode0_Teoc = 23;     // 240ns ==> T0 - T1 - T2 = 600 - 70 - 290 = 240
77
        //
78
        // inputs & outputs
79
        //
80
        input  clk; //master clock
81
        input  nReset; // asynchronous active low reset
82
        input  rst; // synchronous active high reset
83
 
84
        output irq; // interrupt request signal
85
        reg irq;
86
 
87
        // control bits
88
        input  IDEctrl_rst;
89
        input  IDEctrl_IDEen;
90
 
91
        // PIO timing registers
92
        input  [7:0] PIO_cmdport_T1;
93
        input  [7:0] PIO_cmdport_T2;
94
        input  [7:0] PIO_cmdport_T4;
95
        input  [7:0] PIO_cmdport_Teoc;
96
        input        PIO_cmdport_IORDYen;
97
 
98
        // PIO control signals
99
        input         PIOreq; // PIO transfer request
100
        output        PIOack; // PIO transfer ended
101
        input  [ 3:0] PIOa;   // PIO address
102
        input  [15:0] PIOd;   // PIO data in
103
        output [15:0] PIOq;   // PIO data out
104
        input         PIOwe;  // PIO direction  bit. 1'b1==write, 1'b0==read
105
 
106
        reg [15:0] PIOq;
107
        reg PIOack;
108
 
109
        // ATA signals
110
        output        RESETn;
111
        input  [15:0] DDi;
112
        output [15:0] DDo;
113
        output        DDoe;
114
        output [ 2:0] DA;
115
        output        CS0n;
116
        output        CS1n;
117
        output        DIORn;
118
        output        DIOWn;
119
        input         IORDY;
120
        input         INTRQ;
121
 
122
        reg        RESETn;
123
        reg [15:0] DDo;
124
        reg        DDoe;
125
        reg [ 2:0] DA;
126
        reg        CS0n;
127
        reg        CS1n;
128
        reg        DIORn;
129
        reg        DIOWn;
130
 
131
        //
132
        // Variable declarations
133
        //
134
 
135
        reg dPIOreq;
136
        reg PIOgo;   // start PIO timing controller
137
        wire PIOdone; // PIO timing controller done
138
 
139
        // PIO signals
140
        wire PIOdior, PIOdiow;
141
        wire PIOoe;
142
 
143
        // Timing settings
144
        wire              dstrb;
145
        wire [TWIDTH-1:0] T1, T2, T4, Teoc;
146
        wire              IORDYen;
147
 
148
        // synchronized ATA inputs
149
        reg sIORDY;
150
 
151
        //
152
        // Module body
153
        //
154
 
155
 
156
        // synchronize incoming signals
157
        reg cIORDY;                               // capture IORDY
158
        reg cINTRQ;                               // capture INTRQ
159
 
160
        always@(posedge clk)
161
        begin : synch_incoming
162 23 rherveille
                cIORDY <= #1 IORDY;
163
                cINTRQ <= #1 INTRQ;
164 15 rherveille
 
165 23 rherveille
                sIORDY <= #1 cIORDY;
166
                irq    <= #1 cINTRQ;
167 15 rherveille
        end
168
 
169
        // generate ATA signals
170
        always@(posedge clk or negedge nReset)
171
                if (~nReset)
172
                        begin
173 23 rherveille
                                RESETn <= #1 1'b0;
174
                                DIORn  <= #1 1'b1;
175
                                DIOWn  <= #1 1'b1;
176
                                DA     <= #1 0;
177
                                CS0n      <= #1 1'b1;
178
                                CS1n      <= #1 1'b1;
179
                                DDo    <= #1 0;
180
                                DDoe   <= #1 1'b0;
181 15 rherveille
                        end
182
                else if (rst)
183
                        begin
184 23 rherveille
                                RESETn <= #1 1'b0;
185
                                DIORn  <= #1 1'b1;
186
                                DIOWn  <= #1 1'b1;
187
                                DA     <= #1 0;
188
                                CS0n      <= #1 1'b1;
189
                                CS1n      <= #1 1'b1;
190
                                DDo    <= #1 0;
191
                                DDoe   <= #1 1'b0;
192 15 rherveille
                        end
193
                else
194
                        begin
195 23 rherveille
                                RESETn <= #1 !IDEctrl_rst;
196
                                DA     <= #1 PIOa[2:0];
197
                                CS0n   <= #1 !( !PIOa[3] & PIOreq); // CS0 asserted when A(3) = '0'
198
                                CS1n   <= #1 !(  PIOa[3] & PIOreq); // CS1 asserted when A(3) = '1'
199 15 rherveille
 
200 23 rherveille
                                DDo    <= #1 PIOd;
201
                                DDoe   <= #1 PIOoe;
202
                                DIORn  <= #1 !PIOdior;
203
                                DIOWn  <= #1 !PIOdiow;
204 15 rherveille
                        end
205
 
206
 
207
        //
208
        //////////////////////////
209
        // PIO transfer control //
210
        //////////////////////////
211
        //
212
        // capture ATA data for PIO access
213
        always@(posedge clk)
214
                if (dstrb)
215 23 rherveille
                        PIOq <= #1 DDi;
216 15 rherveille
 
217
        // generate PIOgo signal
218
        always@(posedge clk)
219
        begin
220 23 rherveille
                dPIOreq <= #1 PIOreq & !PIOack;
221
                PIOgo   <= #1 (PIOreq & !dPIOreq) & IDEctrl_IDEen;
222 15 rherveille
        end
223
 
224
        // set Timing signals
225
        assign T1      = PIO_cmdport_T1;
226
        assign T2      = PIO_cmdport_T2;
227
        assign T4      = PIO_cmdport_T4;
228
        assign Teoc    = PIO_cmdport_Teoc;
229
        assign IORDYen = PIO_cmdport_IORDYen;
230
 
231
        // hookup timing controller
232
        atahost_pio_tctrl #(TWIDTH, PIO_mode0_T1, PIO_mode0_T2, PIO_mode0_T4, PIO_mode0_Teoc)
233 23 rherveille
                PIO_timing_controller (
234
                        .clk(clk),
235
                        .nReset(nReset),
236
                        .rst(rst),
237
                        .IORDY_en(IORDYen),
238
                        .T1(T1),
239
                        .T2(T2),
240
                        .T4(T4),
241
                        .Teoc(Teoc),
242
                        .go(PIOgo),
243
                        .we(PIOwe),
244
                        .oe(PIOoe),
245
                        .done(PIOdone),
246
                        .dstrb(dstrb),
247
                        .DIOR(PIOdior),
248
                        .DIOW(PIOdiow),
249
                        .IORDY(sIORDY)
250
                );
251 15 rherveille
 
252
        always@(posedge clk)
253 23 rherveille
                PIOack <= #1 PIOdone | (PIOreq & !IDEctrl_IDEen); // acknowledge when done or when IDE not enabled (discard request)
254 15 rherveille
 
255
endmodule

powered by: WebSVN 2.1.0

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