Hi,
in my introduction (
http://forum.6502.org/viewtopic.php?f=1&t=1935&start=180) I mentioned the IDE Interface I have built into my 6502 Computer and as it seams the subject of HDD interface in general is of larger interest. So I decided to elaborate a bit about my solutions.
First why an IDE Interface? At the time I was building my IDE Interfaces you could get a small IDE Harddisc for free. Mostly because many people were upgrading their computers and what was left was a small IDE Harddisc. I had already a SCSI Card for my Apple II and even built a SCSI interface for my homebrew 6502 computer. But I had only one SCSI Disk left. No backup! So I decided to build my own IDE interface. There are quite few examples in the internet and one is even commercially available (CFFA 3000). Today of course it is very hard to get a IDE Harddrive, but there's something even better than a IDE Harddrive that works perfectly with IDE Interfaces and thats a CF-Card (Compact Flash). The interfaces are all simple polling interfaces.
So let me start the presentation with the simplest IDE Interface I have built.
Attachment:
File comment: IDE Interface Schematic for a normal Apple II
AppleIIe-IDE-Interface.pdf [388.04 KiB]
Downloaded 570 times
This is an Apple II compatible interface that includes the decoding logic required in a Apple Slot and contains the ROM (an EEPROM Xicor X2864) and a scratchpad RAM (HM6116) with the appropriate logic for the Slot-ROM and the C8-ROM space. The logic for the ROM/RAM selection is burned into a GAL16V8 (AIIEIDE2) and is not required when interfacing with a generic 6502 system.
The interface itself only requires the GAL16V8 named AIIEIDE1.
Code:
GAL16V8
AIIEIDE1
/DEV A0 A1 A2 A3 PHI0 /DDEV nc nc GND
RW /OEW /OER ENW ENR /CS1 /CS0 /IOW /IOR VCC
;
; Generate the signals for the IO Registers which are
; C0x8 .. C0xF Normal Access to the ATA Registers
; C0x0 Write only access to the ATA Data Register
; C0x7 Read back of the High-Byte Register
; C0x6 Read Write Access to the Alternate Status/Control Register
; C0x1 Read Write Access to the High-Byte of IDE Bus Data
;
IOR = DDEV * /A3 * A2 * A1 * /A0 * RW ; C0x6
+ DDEV * A3 * RW ; C0x8..F
IOW = DDEV * DEV * /A3 * /A2 * /A1 * /A0 * /RW ; C0x0
+ DDEV * DEV * /A3 * A2 * A1 * /A0 * /RW ; C0x6
+ DDEV * DEV * A3 * /RW ; C0x8..F
CS1 = DEV * /A3 * A2 * A1 * /A0 ; C0x6
CS0 = DEV * /A3 * /A2 * /A1 * /A0 * /RW ; C0x0
+ DEV * A3 ; C0x8..F
ENR = DEV * /A3 * A2 * A1 * /A0 * RW ; C0x6
+ DEV * /A3 * A2 * A1 * A0 * RW ; C0X7
+ DEV * A3 * RW ; C0x8..F
ENW = DEV * /A3 * /A2 * /A1 * A0 * /RW ; C0x1
OER = DEV * /A3 * /A2 * /A1 * A0 * RW ; C0x1
+ DEV * /A3 * A2 * A1 * A0 * RW ; C0x7
OEW = DDEV * /A3 * /A2 * /A1 * /A0 * /RW ; C0x0
+ DDEV * /A3 * A2 * A1 * /A0 * /RW ; C0x6
+ DDEV * /A3 * A2 * A1 * A0 * RW ; C0x7
+ DDEV * A3 * /RW ; C0x8..F
DESCRIPTION
/*
IOR This is the ATA Interface IO Read Request Signal and is low only when
IO-Registers C0x8 .. C0xF and C0x6 are read accessed
IOW This is the ATA Interface IO Write Request Signal and is low when
IO-Registers C0x8 .. C0xF and C0x6 are write accessed or when C0x0 is
write accessed. Reading to C0x0 does not activate IOW. This is
to avoid additional read cycles when writing to the ATA Dataregister
this is required as the 6502 processor always reads the location
before writing to it and some IDE Interfaces count the number of
access rather than the number of write access when transferring a
block of data from the Host to the Device.
CS0 This is the standard CS0 Select Signal of ATA Interface and is used to
access the packet interface registers. This signal is asserted during
write access to C0x0 and during any reference to C0x8 .. C0xF.
CS1 This is the standard CS1 Select Signal of ATA Interface and is used to
access the alternate status or control register. This signal is
asserted during access of addresses C0x8 .. C0xF.
OER Output Enable of the Read High-Data Register. This is enabled when
reading locations C0x1 and C0x7. When reading C0x7 the current value
of the data high-byte register of the IDE interface is read back.
When reading C0x1 the last value of high-byte read from the IDE bus
is returned. Note that accessing C0x7 destroys the last value read
from the IDE bus and is only used for debugging purpose.
OEW Output Enable of the High-Byte Data Register to the ATA Device.
This signal is asserted with every write access of the IDE bus.
The high-byte data register must be set previously by writing the
appropriate value to C0x1. This signal is also asserted when reading
location C0x7 in order for the Read High-Data Register to read the
current Write High-Data Register value for debugging purposes.
ENR Enable Read High-Data Register Latch. Activated on each read cycle
to the ATA Registers and when reading location C0x7 to fetch the
previously store value of the high-byte data register.
ENW Enable Write High-Data Register Latch. This is only asserted when
writing to location C0x1 to set the high-byte data value which then
is used on every write cycle to the IDE bus.
*/
END
This interface is only suited for slow 6502 based computers as the ATA Register Cycle length is equal to the High-Phase of PHI. On the other hand it only requires generic TTL ICs. Although the IDE interface is a 16-bit interface it makes use of 16-bit transfers only during the data transfer. Command and Status are sent and retrieved using 8-bits only.
Attachment:
File comment: Source Listing of IDE Driver Code
IDEDriverv30-n.txt [54.32 KiB]
Downloaded 299 times
I have attached the source listing. To understand the code you need to know the following.
The code starts with code that writes the code into the EEPROM.
The code in Slot-ROM is not position independent. Normally you should avoid that in Apple Interfaces. But it worked for me
The driver expects a FAT-16 partition but does not read/write individual files. It only tries to find PRODOS diskimages. These images must be contiguous, in the root directory and have the extension .HVD. Also they must not have a header (like .2img diskimages). So a PRODOS block can be mapped one-to-one to a 512byte block in the diskimage by just adding the offset of the file on the FAT-16 volume.
I have also built a IDE interface that works with faster 6502 (up to 6MHz). If there is interest I can post this information as well.
Peter