Professional Documents
Culture Documents
PROJECT
By
ARSIWALA MURTAZA A
DIPESH NEBHNANI
KOLI SWAPNIL P
University of Mumbai
April, 2008
Acknowledgement
ii
Abstract
The project is being done for the BARC Branch of Tata Institute of
Fundamental Research (TIFR). A PCI card designed by the TIFR team,
houses an FPGA (XCS2S200 Package PQ208) which acts as a
controller. The project objective is to program the FPGA using VHDL
so that it emulates the PCI controller and ensure basic data transfer to
and from the card. This would set up the card for further applications
ranging from Data Acquisition to Data Processing.
iii
Contents
1) Introduction.....................................................................1
2) Review of
Literature........................................................................5
3) Introduction to
LogiCores........................................................................8
4) The PCI
core...............................................................................15
5) User
Application.....................................................................34
6) Design
Verification....................................................................48
7) Downloading and
Testing the
core...............................................................................58
8) Application.....................................................................69
iv
9) Further
Work.............................................................................70
10) Conclusion....................................................................72
11) References.................................................................... 73
12) Appendix........................................................................74
v
Chapter 1
Introduction
1
A 32 bit PCI bus supports a peak data transfer rate of
132Mbytes/second as opposed to a maximum of 12 Mbits/sec
which the USB supports.
Both these protocols are not processor specific. This means that
the same hardware can be used on any platform which supports
the PCI or USB interface.
2
the main project. After the core is customized to meet the desired
specification, a User Application which would enable us to perform
basic read and write operations from the card has to be written. A
User Application is a concomitant with the PCI Logicore, and is
written by the designer to describe the device function. Thus the core
ensures that the PCI protocol is maintained, while the User
Application defined the card function. A functional schematic of the
PCI card is shown below:
A successful attempt at data transfer from and into the card would
mean that the primary purpose of the project has been achieved, i.e.,
to set up the card for further applications. These applications could
range from a basic data collecting unit to a very complex data
processing device.
The project is very significant from the standpoint of data
acquisitions. After ensuring that basic operations can be performed,
an on chip Analog to Digital Converter (ADC) can be utilized to
monitor analog voltages at desired nodes. A User Application which
makes a log of this data can be written and the data can be made
available to a desktop computer on demand where it can be displayed
graphically. Thus, data can be monitored from the comfort of a
desktop PC.
PCI based DAQs available commercially, perform a similar function.
However an important distinction between the designed card and the
Application Specific devices which are readily available is that
reconfigurable hardware is being used in the former. The functionality
of the device can be changed as fast as a program can be written for it
3
in HDL. Thus the same card can be used as a simple data collecting
device or a highly complex computing unit which processes the data
on board and uses the desktop only as a display device.
4
Chapter 2
Review of Literature
The feature that has revolutionized computers in the last decade and a
half is the plug and play capability of its peripherals. Right from
devices like graphic cards, Random Access memory and secondary
storage devices to Hot plug and play devices like Flash drives and
basic I/O devices like keyboards and mouse, they have made
interacting with and using computers a lot easier for the average
individual. Data transfer protocols like the SCSI (Small Computer
System Interface), USB (Universal Serial Bus), PCI (Peripheral
Component Interconnect) and more recently SATA (Serial ATA) have
aided fast data transfer speeds for these plug and play devices.
Hence, any exposure to these protocols, especially a chance to work
on developing such a device as our final year project would have been
welcome.
Thus, when Mr. Sunil Kulkarni, our external guide, asked us to work
on a project related to the PCI protocol, we readily accepted. Since
none of us had any experience with the subject at hand we had to
study various books and refer to umpteen manuals in order to get a
thorough understanding of the task at hand. This is how we went about
with it:
Our first task was to get ourselves acquainted with the PCI protocol.
For this we referred– The PCI Architecture by Tom Shanley and
Don Anderson.
The book begins by introducing the PCI specifications in light of its
advantages over other protocols. It gave us a firm grounding in how
the protocol works, important concepts like Targets and Initiators
(elementary concepts required to understand the project) and basic
signals that would be useful from an implementation point of view.
The project deals mainly with software, to be more precise, the PCI
LogiCORE. The Logicore (details in the proceeding chapters), is a
software code in one of the HDL languages which the user can utilize
in his project by instantiation. The core requires licences which can
5
be obtained from the Xilinx website. Our success depended on how
well we got acquainted with the core. For this, we had to refer to the
PCI Logicore Manual obtained from the Xilinx online help. This
manual describes in detail the following:
1) PCI and user interface signals (the signals that would be
utilized by the user of the core).
6
synthesizable code, and how a behavioural description is transformed
into an RTL schematic and how this is mapped onto an FPGA.
The proceeding chapters deal with the software core, the PCI core and
how this core is configured. Then we move on to the main User
Application Design.
7
Chapter 3
Introduction to Logicores
8
the ISE development environment, the CORE Generator system
streamlines your design process and makes utilization of the core
easier.
Key Features:
1) Included with all versions of ISE Foundation as well as ISE
WebPACK software.
2) Search for IP by keyword, or sort the IP listings alphabetically, or
by function type.
3) Easy access to detailed information on each core (data sheets, user
guides, release notes, licensing status, enhancement listings for new
versions).
4) Regular updates keep you up to date with new features,
enhancements and architecture support.
5) Includes Memory Editor tool to allow you to specify memory
initialization values for CORE Generator based memory cores.
When a core is generated, several files are created. Similarly the core
requires several files as input, for generation. Here is a brief
description of all these files.
CGP File
The CGP file is the CORE Generator project file. The file stores user-
specified project settings.
CORE Generator Input Files
CGF File
As a log file, the CGF file is used in the Memory Editor to record the
user-specified inputs that are used to generate the COE files for a
memory. As a specification file, a CGF file can be used to define the
data contents of COE files for memory blocks.
COE File
An ASCII input coefficient file used when multiple data values must
be specified for a core, usually as an array.
XAW File
9
A binary file that holds the configuration settings for an Architecture
Wizard core. The XAW file is used as an input file when an
Architecture Wizard core is recustomized. The XAW file is also an
output file written out by the CORE Generator when an Architecture
Wizard core is generated.
XCO File
CORE Generator input file containing the parameters used to generate
a core. The XCO file is used as an input file when a core is
recustomized or regenerated. The XCO file is also an output file
generated by the CORE Generator.
10
MIF File
Memory Initialization File which is automatically generated by the
CORE Generator System for some CORE Generator modules when an
HDL simulation flow is specified. A MIF data file is used to support
HDL functional simulation of modules which use arrays of values.
Examples include memories, FIR filters, and bit correlators.
NDF File
An optional output file produced for cores that generate NGC files.
The NDF files allow third party synthesis tools to infer resource
utilization and timing from the NGC files associated with these new
cores.
NGC File
A binary Xilinx implementation netlist. The logic implementation of
certain CORE Generator IP is described by a combination of a top
level EDN file plus one or more NGC files.
Readme File
The Readme file, which is named generated_core_name_readme.txt,
lists the output files produced when a core is generated and describes
each file.
SYM File
Schematic symbol file used to instantiate a generated core into the
ISE Schematic Editor.
UCF File
Xilinx UCF (User Constraints File). The file is a UCF template
containing constraints generated when a core is elaborated. The
constraints in the file are cut and pasted into the UCF file of an ISE
project. All Architecture Wizard cores, and some other IP cores,
generate UCF files.
VHD File
VHDL wrapper file, which is used to support VHDL functional
simulation of a core. The VHD wrapper passes customized parameters
to the generic core simulation model.
11
VHO File
VHDL template file. The components in this file can be used to
instantiate a core.
XAW File
As an output file, the XAW file is a binary file that holds the
configuration settings for an Architecture Wizard core. The CORE
Generator generates an XAW file in the project directory for each
Architecture Wizard core that it creates.
XCO File
As an output file, the XCO file stores the project and core parameter
settings used to generate a particular core. The CORE Generator
generates an XCO file in the project directory for each IP core that it
creates.
XSF File
A Xilinx Netlist Format port list file used by the Mentor Graphics
tools to create a symbol representing the core.
From among the files described above, the user actually deals with
only a few. That is to say, only a few file are required to link a core o
the main project.
The procedure for linking a core to the main project is as shown
below:
Generation:
Core Generator can be accessed by the following path: Start
Menu=>Programs=>Xilinx 9.2i =>Accessories=>Core Generator.
Select a device from the left panel of the Core Generator window:
12
The above window pops up when you select the device: Adder
Subtractor. It allows you to configure the device and make
adjustments to parameters such as function (Adder, Subtractor, Both),
Port Width, Data Types and Radix.
After clicking on generate, a readme file, enumerating the various
generated files and their paths and function pops up.
The next step would be to link the core with the main project.
To do this, the .vhd (Wrapper file) is first added to the project by
right clicking the project in the Sources panel and selecting the “Add
copy of Source” option from the list. Navigate to the Core Generator
project folder and select the wrapper file.
After this, instantiate the core into the parent design by following
these steps.
13
To instantiate a core in a VHDL design
1. Copy the component declaration and the instantiation from the
core’s instantiation template (VHO file) into the appropriate
areas of the parent design.
14
Chapter 4
The PCI Core (Configuration, Components and Instantiation)
The PCI logicore simulates the PCI protocol replete with the rigid
timing specifications. This chapter deals with an overview of the core,
generation and configuration, and the procedure for using this core in
our project.
General Description
The Initiator/Target core for PCI is a pre-implemented and fully
tested module for Xilinx FPGAs. The pinout for each device and the
relative placement of the internal logic are predefined. Critical paths
are controlled by constraints and guide files to ensure predictable
timing. This significantly reduces engineering time required to
implement the PCI portion of your design. Resources can instead be
focused on the unique user application logic in the FPGA and on the
system-level design. As a result, Xilinx products for PCI minimize
your product development time. The core meets the setup, hold, and
clock-to-timing requirements as defined in the PCI specification. The
interface is verified through extensive simulation. Other FPGA
resources that can be used in conjunction with the core to enable
efficient implementation of a PCI system include:
•Block SelectRAM™ memory. Blocks of on-chip ultra-fast RAM with
synchronous write and dual-port RAM capabilities. Used in PCI
designs to implement FIFOs.
•SelectRAM memory. Distributed on-chip ultra-fast RAM with
synchronous write option and dual-port RAM capabilities. Used in PCI
designs to implement FIFOs.
•Internal three-state bus capability for data multiplexing. The
interface is carefully optimized for best possible performance and
utilization in Xilinx FPGA devices.
Functional Description
The Figure illustrates the major functional blocks generated when a
PCI core is generated using Core Generator:
15
Figure Courtesy Xilinx
16
Table Courtesy Xilinx
Note : The shaded areas are not implemented and return zero.
Parity Generator/Checker
17
This block generates and checks even parity across the AD bus, the
CBE# lines, and parity signals. It also reports data parity errors via
PERR# and address parity errors via SERR#.
This block controls core target functions. The target control logic
uses one-hot encoding for maximum performance.
Core Configuration
Burst Transfer
The PCI bus derives its performance from its ability to support burst
transfers. Performance of any PCI application depends largely on the
size of the burst transfer. Buffers to support PCI burst transfer can
efficiently be implemented using on-chip RAM resources.
18
Open the Core Generator tool by going through following path:
1) Enter the name of the project and select the location. For our
project it is: C:\Xilinx9.2i\bin\nt\coregen.
coregen is the name of the Project. All the cores generated in this
project will be stored in this location.
19
3) Now click the ‘View by Name’ tab in the left panel and select the
‘LogiCORE 32-bit Initiator/Target for PCI (Spartan only)’ IP.
4) In the right panel, select the ‘customize’ link. This would cause
the following configuration window to pop up:
20
5) The above screenshot shows the first 16 d-words of the
Configuration space. Here, we can make changes to few of the
configuration registers.
6) Here, not for any particular reason, we have made changes only to
the Base Address Registers. We have used only BAR0 to acquire a
16 bit memory. We set the BAR0 in the following manner.
21
7) After clicking ‘OK’, we click on Generate. A readme file with the
terms of use pops up.
Components:
The PCI core can be roughly divided into three components. These
are the pcim_lc (Wrapper file), userapp (the User Application) and
the cfg module (Configuration Module). These components are
22
linked to a parent source “ pcim_top.vhd”. They are instantiated
into the pcim_top.vhd source. Let us first take a look at these
components individually
The PCI core converts the PCI Bus signals into Local Bus
signals which can be used by the user to interface his
application to the PCI core.
23
A schematic diagram, showing the Core (wrapper file) and the
User Application along with the signals and their brief
descriptions is given in Appendix 1.
Constraints File
24
We now move on to actual project development. Before we
actually start work with Project Navigator, we need to copy
certain files into the coregen directory
Initial Steps
Device: 2S200-PQ208-5C
2) Go to File>New Project
25
A New Project Wizard pops up. Enter the name of the project
(data_core in our case) and select the Top-Level Source Type
as HDL.
<Install Path\vhdl\src\xpci\pcim_lc.vhd
<Install Path\vhdl\src\xpci\userapp.vhd
26
<Install Path\vhdl\src\xpci\cfg.vhd
<Install Path\vhdl\src\ucf\2s200pq208_32_33.ucf
8) The above steps include all the files that are required for
starting with the project.
27
The Class Code identifies the general function of a device.
The value, as provided in the default configuration,
identifies the device as a generic co-processor function.
28
By default, the Subsystem Vendor ID and Subsystem ID are
set at design time and part of the resulting interface netlist.
29
// Max_Lat
// Min_Gnt
Interrupt Enable
// Interrupt Enable
Capabilities List
30
assign CFG[116] = `DISABLE ;
Interrupt Acknowledge
// Interrupt Acknowledge
Reserved Settings
31
The PCI interface supports up to three BARs (Base Address
Registers). The designer is free to use any BAR desired.
Each BAR has several attributes. These attributes define:
32
We have already made the settings for the BAR0 using the
GUI in Core Generator.
33
The following is the code in the Configuration file:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_arith.all;
entity cfg is
port (
);
end cfg;
34
constant NOFETCH : bit := '0' ;
35
constant SIZE256K : bit_vector(31 downto 0) :=
X"fffc0000" ;
begin
--------------------------------------------------------------
--------------------------------------------------------------
36
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
-- BAR0
-- BAR1
37
-- BAR2
--------------------------------------------------------------
--------------------------------------------------------------
-------------------------------------------------------------
-------------------------------------------------------------
-- Interrupt Enable
-------------------------------------------------------------
38
-------------------------------------------------------------
-- Interrupt Acknowledge
-------------------------------------------------------------
-------------------------------------------------------------
-- Obsolete
-- Obsolete
-- Obsolete
-- Enable 66 MHz
39
cfg_int(244) <= DISABLE ;
-- Do Not Modify
end rtl;
Now that the PCI core has been configured, we can move on
to designing the User Application. The next Chapter deals
with design of the User Application.
40
Chapter 5
User Application
The User Application is a file where the user, i.e., the card
manufacturer is allowed to write the functionality of the device in
HDL.
In the previous chapter, we have defined the different components of
the PCI core, namely the PCI core (Wrapper files + NGD files), the
Configuration Module and the user application.
The first two components define the PCI protocol, take care of the
timing specifications and convert the incoming PCI Bus signals into
User Interface signals. Some of these signals are registered versions
of the PCI Bus Signals (eg : FRAMEQ_N is a registered signal for
FRAME_IO which is a PCI Bus signal) whereas others are signals
which allow us to use the User Application as a Black Box entity.
41
The PCI logic core is designed in such a manner that one can write an
application for the PCI card with elementary knowledge of the PCI
signals. Certain User Interface signals, which are derived from the
PCI Bus signals, inform the designer about when to read or write data
to the User Interface Bus. Also, the user manuals clearly define what
acknowledge signals to send before or after data transfer and what
signals to monitor for checking errors. Thus, the programmer needs to
only focus on the actual problem at hand, i.e., the function of the PCI
card. The protocol is taken care of by the core.
Since designing the User Application can be thought of as an
independent task (independent of the PCI protocol), we will treat our
design as a problem statement and utilize the User Interface Signals in
our design.
Problem Statement:
Our Primary purpose is to make the core functional.
It is essential that when the PCI card is inserted into the slot, it is
detected, the requested memory space is allotted to it and we are able
to perform the basic read and write operations to and from the card. It
is only then that the core can be utilized to its full potential.
Thus our primary goal and the most important aspect of this project is
to make sure that a basic user application can be implemented. Thus
our User Application should be capable of accepting a 16 bit data
from the core when data is written to the card, and make data
available to the core when data is read from the card.
We will split the User Application design in two parts:
1) Designing the User Application
42
A very important note
Since our device will not initiate any operations on the PCI bus, in
PCI terminology our device is a target. The core is designed in such a
manner that the Initiator and Target state machines are separate.
Thus when designing a Target Only design, we do not use the signals
that deal with Initiator functions.
Before we move on, we will first list the Interface signals associated
with the Target State Machine.
Basic Target Interface Signals
For basic transfers, a subset of the target interface signals is used. An
example of a basic target design using the reduced subset is presented
later in this chapter.
BASE_HIT[7:0]: Input indicates that one of the base address registers
recognizes that it is the target of a current transaction. This is the
first indicator to the user application that a target transaction is about
to begin.
ADIO[31:0]: Bidirectional bus provides the means for data and
address transfer to and from the core interface.
ADDR[31:0]: Input is a registered version of the PCI address
provided by the core interface. It becomes valid in the cycle after
ADDR_VLD is asserted, and remains valid through the entire
transaction. S_WRDN: Input indicates the direction of data transfer
for the current target transaction. Logic high indicates that the user
application is sinking data (such as target write). It is valid during the
cycle BASE_HIT is asserted and is held through the entire transaction.
S_CBE[3:0]: A registered version of the CBE_IO lines, and is delayed
by one cycle. It indicates the PCI command and byte enables during a
target transaction. This signal is used primarily for byte enable
information, as the command is decoded and latched in PCI_CMD
during the address phase of the transaction.
PCI_CMD[15:0]: Input is a decoded and latched version of the PCI
command for the current bus transaction.
43
S_DATA_VLD: Input has two interpretations depending on the
direction of data transfer. When the user application is sinking data
(target writes), S_DATA_VLD indicates that the user application
should capture valid data from the ADIO bus. When the user
application is sourcing data (target reads), S_DATA_VLD indicates
that a data phase has completed on the PCI Bus.
S_DATA: Input indicates that the target state machine is in the data
transfer state.
44
data phase of a transaction. Together with S_TERM, it is also used to
signal different types of target termination. It is important to note
that the user application is prohibited from using S_READY to insert
wait states after the first data phase.
S_TERM: Output from the user application indicates that data transfer
should cease. It is also used with S_READY to signal different types
of target termination.
S_ABORT: Output from the user application indicates that a serious
(fatal) error condition has occurred and that the current transaction
must stop.
The following signals are output by the target state machine in the
core interface.
IDLE: Input indicates that the target state machine is in the idle state
and that there is no activity on the PCI Bus.
B_BUSY: Input indicates that the target state machine has recognized
the beginning of a PCI Bus transaction. The target state machine will
change to the S_DATA state if it determines that it is the target of the
transaction.
S_DATA: Input indicates that the target state machine is in the data
transfer state.
BACKOFF: Input indicates that the target state machine is waiting for
a transaction to complete because the user application has asserted
S_TERM.
Now we will move onto the first part of the design process and drive
unused signals to benign values:
Conceptually, creating a target-only design is as simple as driving all
initiator control signals to a benign (de-asserted) state. In addition,
the user application should be designed without making use of any
initiator status or state outputs from the core interface.
However, connecting all unused control signals to logic high or logic
low may have unwanted side-effects—the map program may optimize
these signals away during the implementation step, which in itself is
45
not problematic, but the guide files, which are required to guarantee
timing in some designs, fail to work properly if certain signals are
optimized away.
The solution to this problem is to drive the initiator control signals
from the output of flip-flops. The following shows an example of this
solution:
always @(posedge CLK or posedge RST)
begin : cannot_be_optimized
if (RST) FAKE_LOGIC_0 = 1’b1;
else FAKE_LOGIC_0 = 1’b0;
end
The Table lists the initiator control signals that must be tied off and the appropriate
benign values. The table also identifies which signals must be driven from a flip-flop.
Some signals are present only in 64-bit implementations of the interface.
REQUEST 0 No
REQUESTHOLD 0 No
COMPLETE 1 Yes
M_WRDN 0 Yes
M_READY 1 Yes
CCFG_SELF 0 No
REQUEST64 0 No
46
For our User Application we will use a mode of Disconnection in
which the User Application will always be ready to transfer data and
will disconnect after one data phase.
always @(posedge CLK or posedge RST)
begin : cannot_be_optimized_a
if (RST) S_READY = 1’b0;
else S_READY = 1’b1;
end
always @(posedge CLK or posedge RST)
begin : cannot_be_optimized_b
if (RST) S_TERM = 1’b0;
else S_TERM = 1’b1;
end
Now, we will actually design the Application and derive signals that
would enable data transfer.
47
else
begin
if (BASE_HIT[x])
begin
BAR_x_RD = !S_WRDN & OPTIONAL;
BAR_x_WR = S_WRDN & OPTIONAL;
end
else if (!S_DATA)
begin
BAR_x_RD = 1'b0;
BAR_x_WR = 1'b0;
end
end
end
The last clause in the decoding block holds the decode asserted
throughout the entire data transfer state. Again, BASE_HIT[x] is only
active for a single clock cycle at the start of the transaction.
Effectively, the code above describes a synchronous set/reset flip-flop
with set dominant.
Target Writes
During a target write operation, data is captured from the ADIO bus to
a data register in the user application by asserting the LOAD input.
The first step is to generate the BAR _WR signal. The critical gating
signal is S_DATA_VLD. It is the final signal required to qualify the
write operation. Consequently, the other signals can be decoded
earlier and gated with S_DATA_VLD. The assignment for the load
input of the register would then be:
assign LOAD = BAR _WR & S_DATA_VLD;
Decoding BAR_WR and registering it before the assertion of
S_DATA_VLD allows more time for routing and reduces the number of
logic levels from the critical input, S_DATA_VLD.
48
The Write Timing Diagrams are shown below:
Target Reads
During a target read operation, data from the user application is
driven onto the ADIO bus. To do this, the user application must assert
the OE for the desired register. The first step is to generate the BAR
_RD signal on decoding target transactions. The assignment for the
output enable would then be:
assign OE = BAR _RD & S_DATA;
The Read Timing Diagrams are shown below:
49
Thus we have two derived signals, LOAD and OE, which are used by
the application to act as enables for storing and recovering data from
the Register buffer.
Design of the Register Buffer.
The Application requires a Register which latches the contents of the
ADIO Bus when LOAD is activated and outputs the stored value onto
the ADIO Bus when OE is activated.
Now this is a relatively simple design. However one must take one
precaution when dealing with the design. The implementation of the
tri-state logic should be immaculate. When none of the above signals
are activated, the output of the register should be tri-stated. In order
to implement this effectively, we use two cores to implement the
structure. These two cores are Bit Slice BUFE (Data Buffer) and Bit
50
Slice BUFT (Data Latch). This device works exactly as per our
requirement. In order to instantiate this core in our User Application,
refer “Introduction to Logicores”.
Note: Make sure that the VHD, NGC, XCO, MIF and TCL files are
copied from the <Install Path to the working project folder.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity userapp is
port (-- Interface to PCI Logicore.
FRAMEQ_N : in std_logic;
TRDYQ_N : in std_logic;
IRDYQ_N : in std_logic;
STOPQ_N : in std_logic;
DEVSELQ_N : in std_logic;
CFG_VLD : in std_logic;
CFG_HIT : in std_logic;
C_TERM : out std_logic;
C_READY : out std_logic;
ADDR_VLD : in std_logic;
BASE_HIT : in std_logic_vector( 7 downto 0);
51
REQUESTHOLD : out std_logic;
COMPLETE : out std_logic;
TIME_OUT : in std_logic;
CFG_SELF : out std_logic;
M_DATA : in std_logic;
DR_BUS : in std_logic;
I_IDLE : in std_logic;
M_ADDR_N : in std_logic;
IDLE : in std_logic;
B_BUSY : in std_logic;
S_DATA : in std_logic;
BACKOFF : in std_logic;
RST : in std_logic;
CLK : in std_logic
);
end userapp;
COMPONENT DATA_GATE
PORT(
OE : IN std_logic;
I : IN std_logic_vector(31 downto 0);
O : OUT std_logic_vector(31 downto 0)
);
END COMPONENT;
52
COMPONENT DATA_LATCH
PORT(
D : IN std_logic_vector(31 downto 0);
G : IN std_logic;
Q : OUT std_logic_vector(31 downto 0)
);
END COMPONENT;
begin
-- Add user application here.
REQUEST <='0';
REQUESTHOLD <= '0';
CFG_SELF <= '0';
KEEPOUT <= '0';
C_READY <= '1';
53
C_TERM <= '1';
process(RST,CLK)
begin
if(clk' event and clk='1') then
if(RST='1') then
COMPLETE <= '0';
M_WRDN <= '1';
M_READY <= '0';
M_CBE <= "1001";
S_READY <= '0';
S_TERM <= '0';
S_ABORT <= '1';
INTR_N <= '0';
SUB_DATA <= "11111111111111111111111111111111";
else
COMPLETE <= '1';
M_WRDN <= '0';
M_READY <= '1';
M_CBE <= "0110";
S_READY <= '1';
S_TERM <= '1';
S_ABORT <= '0';
INTR_N <= '1';
SUB_DATA <= "00000000000000000000000000000000";
end if;
end if;
end process;
end rtl;
54
Chapter 6
Design Verification
Design Flow:
A schematic illustrating the design flow for an FPGA is as shown:
Synthesis:
After design entry and optional simulation, you run synthesis. In the
Sources tab, select Synthesis/Implementation from the Design View
55
drop-down list, and select the pcim_top module . In the Processes
tab, double-click Synthesize.
The ISE software includes Xilinx Synthesis Technology (XST), which
synthesizes VHDL, Verilog, or mixed language designs to create
Xilinx-specific netlist files known as NGC files. Unlike output from
other vendors, which consists of an EDIF file with an associated NCF
file, NGC files contain both logical design data and constraints. XST
places the NGC file in your project directory and the file is accepted
as input to the Translate (NGDBuild) step of the Implement Design
process. To specify XST as your synthesis tool, you must set the
Synthesis Tool Project Property to XST, as described in Changing
Project, Source, and Snapshot Properties.
Note : You can set the Synthesis Tool to XST or to a partner synthesis
tool.
XST Design Flow Overview
The following figure shows the flow of files through the XST
software.
56
Verilog: IEEE 1364-1995, IEEE 1364-2001
Xilinx constraints file in which you can specify synthesis, timing, and
specific implementation constraints that can be propagated to the NGC
file.
Core files
These files can be in either NGC or EDIF format. XST does not
modify cores. It uses them to inform area and timing optimization.
In addition to NGC files, XST also generates the following files as
output:
Synthesis Report
This report contains the results from the synthesis run, including area
and timing estimation.
RTL schematic
57
discover design issues early in the design process. For details, see
Viewing a Technology Schematic - XST .
Note When the design is run in Incremental Synthesis mode, XST
generates multiple NGC and NGR files, which each represent a single
user design partition.
HDL Parsing
During HDL parsing, XST checks whether your HDL code is correct
and reports any syntax errors.
HDL Synthesis
During HDL synthesis, XST analyzes the HDL code and attempts to
infer specific design building blocks or macros (such as MUXes,
RAMs, adders, and subtracters) for which it can create efficient
technology implementations. To reduce the amount of inferred macros,
XST performs a resource sharing check. This usually leads to a
reduction of the area as well as an increase in the clock frequency.
58
Finite state machine (FSM) recognition is also part of the HDL
synthesis step. XST recognizes FSMs independent of the modeling
style used. To create the most efficient implementation, XST uses the
target optimization goal, whether area or speed, to determine which of
several FSM encoding algorithms to use.
You can control the HDL synthesis step using constraints. You can
enter constraints using any of the following methods:
HDL source file
HDL Options
Default property values are used for the Synthesize process, unless
you modify them.
Low Level Optimization
During low level optimization, XST transforms inferred macros and
general glue logic into a technology-specific implementation. The
flows for FPGAs and CPLDs differ significantly at this stage as
follows:
FPGA Flow
59
The FPGA flow is timing-driven and can be controlled using
constraints, such as PERIOD and OFFSET. During low level
optimization, XST infers specific components, such as the following:
Carry logic (MUXCY, XORCY, MULT_AND)
60
b<=s;
4) The XST tool might also report warnings of constructs that have
the possibility of generating mismatches between RTL
simulation results and output netlist simulation results.
Design Implementation:
After synthesis, you run design implementation, which comprises the
following steps:
61
Translate
62
The Translate process merges all of the input netlists and design
constraints and outputs a Xilinx native generic database (NGD) file,
which describes the logical design reduced to Xilinx primitives.
Map
The Map process maps the logic defined by an NGD file into FPGA
elements, such as CLBs and IOBs. The output design is a native
circuit description (NCD) file that physically represents the design
mapped to the components in the Xilinx FPGA.
Place and Route
The Place and Route process takes a mapped NCD file, places and
routes the design, and produces an NCD file that is used as input for
bitstream generation
63
process, a BIT or ISC file, to create a PROM, ACE or JTAG file that
can be downloaded into the FPGA's memory cells. This process opens
iMPACT, and in iMPACT you can create a PROM, System ACE, SVF,
XSVF or STAPL file.
This process is explained in some detail in the next chapter. In
addition, the next chapter also explains how the PCI card is to be
tested using Win Driver.
64
Chapter 7
Downloading & testing the Core
Model DLC7
Power 5V,0.2A
Serial JG -041031
One end of this cable in connected to the parallel port of the computer
(or laptop) and the other end of this cable has 6 pin viz. VCC, GND,
TCLK, TDO, TCI & TDS which are connected to the respective PROM
pins on the PCI card. The PROM xcf02s is being in the programmed in
the JTAG boundary scanning mode. The PROM operates at 3.3V which
will be provided by the external power supply. Proper care has to be
taken while connecting the PCI card as a single mistake may lead to
serious consequences.
65
2) Once the proper connections have been made click on Generate
programming file in the processes tab to generate the
programming file. This programming file will have the .bit
format.
66
4) After selecting the Next option a new window appears. In this
window, write the desired name & the desired location of the
PROM file for example select the file name as trans1104 . Click
on Next option.
5) Now the next window appears. From the drop down menu select
the type of the Xilinx PROM for example select the xcf02s then
click on ADD option. Finally, press the FINISH option.
7) Now, select the desired file which will add another device to the
PROM device like in our case the name of the file is
67
pcim_top.bit. A new dialog box prompts by asking whether the
user wants to add another file to the data stream. Click on the
‘NO’ option.
68
10) A new dialog box appears asking the name of the file
which has to be burnt into the Xilinx PROM. The PROM files
are generated in the .mcs format like for example the file name
is trans1104.mcs.
11) Right click the mouse and select the Program option. A
dialog box appears with the heading programming properties
basically allowing the user to select the properties. Select the
erase before programming option in this box and then simply
press ok option.
69
A process dialog box appears indicating the progress of transfer
and within a few seconds a message will appear saying Program
succeeded. Thus, indicating that the PROM device has been
programmed and also the Xilinx FPGA will be programmed with
the help of the Xilinx PROM.
70
The above process explains the user in which the core is downloaded
into the Xilinx FPGA with the help of Xilinx PROM device.
The next step is the testing of the card. The card is tested with the
help of a software called WINDRIVER. WinDriver is a multi-utility
software which is basically used to create custom device drivers as
well to test and debug the hardware. It is a software used by hardware
developers as well as software developers to test the new hardware &
to generate the device driver code to drive the hardware.
Features of WinDriver-
1) Immediate Hardware Access
Test your hardware through a graphical user-mode application,
without having to write a single line of code.
3) Field-proven quality
WinDriver's technology enables you to concentrate on your core
business and successfully create first-rate drivers without
having to invest redundant resources in driver development from
scratch.
4) Debugging
Included graphical Debug Monitor to monitor kernel level
activity throughout the driver development process.
71
Embedded / Server 2003, Vista, Windows CE / Mobile, Linux,
Solaris and VxWorks.
7) FPGA Access
Access, control and program FPGA chips via the PCI bus.
Enhanced support for FPGA vendors including Altera and Xilinx
is included.
1) Set up-
Plug the PCI card into your PCI slot of your computer & install
WinDriver software.
Now, once the new dialog box appears select New host
driver project.
The driver wizard will show all the Plug and Play cards in
your machine.
72
3) Install the .INF file for your plug and play device-
73
Click Next in the INF generation dialogue in order
to generate the INF file and install it (if selected).
When the INF file installation completes, select and
open your device from the list described in step 2
above.
74
5) Testing your Hardware-
Read and write to the I/O ports, memory space and your
defined registers.
Select the area where the user want to write data i.e. I/O
or memory.
75
Select the required BAR.
To read data from the BAR click on Read. The same data
will appear in the information panel window.
After the testing of the hardware has been done generate the code with
the help of the Generate code toolbar icon. The user needs to select
the programming language & the developing environment in which he
would like to generate his files. Also, the user needs to indicate
whether he wishes to handle Plug-and-Play and power management
events from within the driver code and whether he wishes to generate
Kernel PlugIn code. Finally, click on ‘ OK’ the required code would be
generated.
76
Chapter 8
Applications
The last chapter describes the method for testing the PCI card using
Win Drivers. Since basic data transfer is possible without distortion,
the card is functional. At TIFR, this card will be used for Data
Acquisition in one of the many processes for electron acceleration
measurement. This would entail monitoring of AC or DC voltages at
certain points of a Beam Profile Monitor. The PCI card contains a
vacant slot where ADC 805 can be mounted. A User Application can
be written such that it facilitates data transfer from the ADC to the
PCI Bus.
Apart from this, if the User Application is built upon, there are
illimitable applications to which the card can be put. Some of these
are:
Embedded applications in networking, industrial, and
telecommunication systems.
77
Add-in boards for PCI such as frame buffers, network adapters,
and data acquisition boards.
The last application really defines the crux of the project. Once the
core is correctly configured and set up for use, the card can be used
for virtually any application under the sun. This as long as any HDL
is capable of describing the function and has libraries powerful
enough to synthesize and translate the design.
Chapter 9
Further Work
The major achievement of this project has been the ability to read and
write from the PCI card. Before a complete Data Acquisition System
can be designed, two important designs need to be implemented.
1) A Memory Block (RAM) for RAM
78
Transfer data from an external port (connected to an
ADC) to a storage element (RAM).
79
Chapter 10
Conclusion
80
components like FPGAs and CPLDs have become indispensable while
designing hardware and custom solutions.
This project aims to utilize the FPGA’s reconfigurable property so
that a PCI card with customized functions can be designed. Here an
FPGA is used as the controlling element. The reason for doing this is
that an FPGA can be reprogrammed easily. Once the card functions
satisfactorily, it can be reprogrammed to implement any function. This
ability, coupled with the extremely high data transfer speeds afforded
by the PCI interface means that such system can be used for myriad
applications, the most basic being Data Acquisition Systems, where
this card will eventually find application.
Chapter 11
References
81
2) VHDL Programming by Example by Douglas L. Perry
http://china.xilinx.com/support/documentation/ip_documentation/
pci_ug159.pdf
http://go.6to23.com/zhangzhenyan/product/xc2s50/spartan_II.pdf
82
You can assign input and output signals to package pins in your
design using the Assign Package Pins process. This process launches
the Pinout and Area Constraints Editor (PACE) for Spartan II-targeted
designs. Using the editor, you can then assign I/O locations, specify
I/O banks, specify I/O standards, prohibit I/O locations, and create
legal pin assignments using the built-in design rule checks (DRC).
To Assign Package Pins
1) In the Sources tab, select Synthesis/Implementation from the
drop-down list.
6) You can assign I/O package pins for your design in the UCF in
PACE.
83
Since our FPGA is already connected in circuit on the PCI card, we
have used the following pin-out diagram and table as references while
assigning the pin locations.
To assign a location, say for AD0, first look it up in the table, get the
physical pin number and from the pin-out get the PCI pin number
(P60).
84
Add-in card
connector reference
85
FPGA Pinout
86