Professional Documents
Culture Documents
Compact Flash
Compact Flash
Core Overview
The CompactFlash Core with Avalon Interface (“the CompactFlash core”)
implements a method of communicating between a CompactFlash Storage Card in
True IDE Mode and an embedded system on an Altera FPGA. The core
implements the CompactFlash True IDE Mode timing and provides a direct
Avalon interface to the registers on the CompactFlash device.
The core provides a simple register-mapped Avalon slave interface that allows
Avalon master peripherals (such as a Nios II processor) to communicate with the
core simply by reading and writing control and data registers.
The CompactFlash core is SOPC Builder-ready and integrates easily into any
SOPC Builder- generated system.
Quick Reference
Functional Description
Figure X shows a block diagram of the CompactFlash core.
Altera FPGA
CompactFlash core
CompactFlash Slot
address
data ide
port Avalon-to-
CompactFlash
IRQ
Avalon
signals
connected
to on-chip
logic address cfctl
data ctl
port
IRQ
idectl
The CompactFlash core provides two active-high interrupt request (IRQ) outputs.
One interrupt signals the insertion or removal of a CompactFlash device; the
second passes the interrupt signal from the device on to the Avalon master.
CompactFlash Interface
The CompactFlash core maps the Avalon bus signals to the CompactFlash device
with the proper timing, allowing an Avalon master direct access to registers in the
device. More information can be found in the CF+ and CompactFlash
Specification.
ATA registers
IORD_ALTERA_AVALON_CF_IDE_DATA(ide_base)
IORD_ALTERA_AVALON_CF_IDE_ERROR(ide_base)
IORD_ALTERA_AVALON_CF_IDE_SECTOR_COUNT(ide_base)
IORD_ALTERA_AVALON_CF_IDE_SECTOR_NUMBER(ide_base)
IORD_ALTERA_AVALON_CF_IDE_CYLINDER_LOW(ide_base)
IORD_ALTERA_AVALON_CF_IDE_CYLINDER_HIGH(ide_base)
IORD_ALTERA_AVALON_CF_IDE_DEVICE_HEAD(ide_base)
IORD_ALTERA_AVALON_CF_IDE_STATUS(ide_base)
IORD_ALTERA_AVALON_CF_IDE_ALTERNATE_STATUS(ide_base)
IOWR_ALTERA_AVALON_CF_IDE_DATA(ide_base, data)
IOWR_ALTERA_AVALON_CF_IDE_FEATURES(ide_base, data)
IOWR_ALTERA_AVALON_CF_IDE_SECTOR_COUNT(ide_base, data)
IOWR_ALTERA_AVALON_CF_IDE_SECTOR_NUMBER(ide_base, data)
IOWR_ALTERA_AVALON_CF_IDE_CYLINDER_LOW(ide_base, data)
IOWR_ALTERA_AVALON_CF_IDE_CYLINDER_HIGH(ide_base, data)
IOWR_ALTERA_AVALON_CF_IDE_DEVICE_HEAD(ide_base, data)
IOWR_ALTERA_AVALON_CF_IDE_COMMAND(ide_base, data)
IOWR_ALTERA_AVALON_CF_IDE_DEVICE_CONTROL(ide_base, data)
Reading register:
IORD_ALTERA_AVALON_CF_CTL_STATUS(ctl_base)
Writing register:
IOWR_ALTERA_AVALON_CF_CTL_CONTROL(ctl_base, data)
bit definitions:
ALTERA_AVALON_CF_CTL_STATUS_PRESENT_MSK
ALTERA_AVALON_CF_CTL_STATUS_PRESENT_OFST
ALTERA_AVALON_CF_CTL_STATUS_IRQ_EN_MSK
ALTERA_AVALON_CF_CTL_STATUS_IRQ_EN_OFST
ALTERA_AVALON_CF_CTL_STATUS_POWER_MSK
ALTERA_AVALON_CF_CTL_STATUS_POWER_OFST
Controls power to the device. If asserted, the device will be powered up.
ALTERA_AVALON_CF_CTL_STATUS_RESET_MSK
ALTERA_AVALON_CF_CTL_STATUS_RESET_OFST
Bit definitions:
ALTERA_AVALON_CF_IDE_CTL_IRQ_EN_MSK
ALTERA_AVALON_CF_IDE_CTL_IRQ_EN_OFST
Examples:
IOWR_ALTERA_AVALON_CF_IDE_CTL(ctl_base,
ALTERA_AVALON_CF_IDE_CTL_IRQ_EN_MSK)
IOWR_ALTERA_AVALON_CF_IDE_CTL(ctl_base, 0)
Software Files
The CompactFlash core is accompanied by the following software files. These
files provide low-level access to the hardware. Application developers should not
modify these files.
• altera_avalon_cf_regs.h – This file defines the core’s register map,
providing symbolic constants to access the low-level hardware. The
symbols in this file are used only by device driver functions.
• altera_avalon_cf.h, altera_avalon_cf.c – These files implement the
CompactFlash core device driver for the HAL system library.
Register Map
The CompactFlash core has two separate slave ports, each with an associated
register map. The ide port exposes to the user, the IDE register set found on the
CompactFlash device. Table X lists these IDE registers. A detailed description
of the register contents and functions can be found in the CF+ and CompactFlash
Specification available from the CompactFlash Association.
CompactFlash Core ide Register Map
Off- Register Name
set Read Write
0 RD Data WR Data
1 Error Features
2 Sector Count Sector Count
3 Sector No. Sector No.
4 Cylinder Low Cylinder Low
5 Cylinder High Cylinder High
6 Select Card/Head Select Card/Head
7 Status Command
14 Alt Status Device Control
Table X shows the register map for the ctl slave port of the CompactFlash core.
cfctl Register
The cfctl register consists of individual bits, each controlling an aspect of the
CompactFlash core’s operation. The value in the cfctl register can be read at any
time.
idectl Register
The idectl register consists of individual bits, each controlling an aspect of the
interface to the CompactFlash device. The value in the idectl register can be read
at any time.
The ctl port generates an interrupt when the det bit of the cfctl register changes,
indicating a CompactFlash device has been inserted or removed. Reading from
the cfctl register clears the interrupt condition. Generation of this interrupt can be
enabled or disabled with the idet bit of the cfctl register.
The ide port also generates an interrupt. It passes on interrupts generated by the
CompactFlash device. Information on CompactFlash interrupts can be found in
the CF+ and CompactFlash Specification. Generation of this interrupt can be
enabled or disabled with the xxx bit of the idectl register.