fpga4fun.com - where FPGAs are fun.
Home
Welcome
Information


FPGA projects
Music box
Pong game
R/C servos
Text LCD module
Quadrature decoder
PWM and one-bit DAC
Debouncer
LED displays
Crossing clock domains
External contributions

FPGA interface projects
RS-232
JTAG
I2C
EPP
SPI
CNC steppers

FPGA advanced projects
Graphic LCD panel
Digital oscilloscope
10BASE-T interface
PCI interface
Spoc CPU core

Hands-on
A simple oscilloscope


FPGA introduction
What are FPGAs?
How FPGAs work
FPGA pins
Clocks and global lines
Download cables
Configuration
Learn more

FPGA software
Design software
Pin assignment
Design-entry/HDL
Simulation/HDL
Synthesis and P&R

FPGA electronic
SMD technology
Crystals and oscillators

HDL info
HDL tutorials
Verilog tips
VHDL tips

Quick-start guides
ISE
Quartus

Site
News
FPGA links
HDL tutorials
Forum


PCI plug-and-play

Now that reads and writes accesses are going through, what does it take for the PCI plug-and-play to work?



Our PCI card is not yet in the list...

Configuration space

Remember that PCI cards have three "spaces" where transactions (reads and writes) take place?
  1. Memory space
  2. IO space
  3. Configuration space
The configuration space is the heart of PCI plug-and-play. The OS (Windows, Linux...) reads there first to find if PCI cards are plugged-in, and their characteristics.

For simple boards, the configuration space consists of just 64 bytes. They important fields are:
OffsetNameFunctionNoteLength
0Vendor IDManufacturer number... allocated by the PCI-SIG2 bytes
2Device IDDevice number... allocated by the manufacturers themselves2 bytes
4CommandTurn on and off accesses to the PCI board... but configuration space accesses are always on2 bytes
16BAR0 (Base address register 0)Address at which the PCI board should respond... followed by BAR1 through BAR54 bytes each

By implementing the right values and registers at these locations, the OS can "find" the PCI card.

Configuration space transactions

Each PCI slots as a signal called IDSEL. The IDSEL signal is the only one that is not shared along the bus; each PCI slot has its own.
When a PCI card sees a configuration space transaction on the bus, and its own IDSEL is asserted, it knows it should respond.

parameter PCI_CBECD_CSRead = 4'b1010;   // configuration space read
parameter PCI_CBECD_CSWrite = 4'b1011;   // configuration space write

wire PCI_Targeted = PCI_TransactionStart & PCI_IDSEL & ((PCI_CBE==PCI_CBECD_CSRead) | (PCI_CBE==PCI_CBECD_CSWrite)) & (PCI_AD[1:0]==0);

After that, it can be a read or a write but it works the same way that memory or IO spaces do.

A few details: There are a few other details left out, like some bits of BAR0 are read-only...
Please refer to a PCI specification/book for the down-to-earth details.

Windows plug-and-play

Once these registers are implemented, the OS can discover the new hardware.




But the OS requires a driver before...




... it agrees to allocate the memory resource.


Links



>>> NEXT: PCI software driver for Windows >>>



This page was last updated on November 22 2005.