Sei sulla pagina 1di 6

IC DESIGN

The basics of constructing FPGA


By Gina R. Smith
CEO, Owner
Brown-Smith Research and
Development Laboratory Inc.

Over the last several years, the use


of FPGAs has greatly increased in
military and commercial prod-
ucts. They can be found in pri-
mary and secondary surveillance
radar, satellite communication,
automotive, manufacturing, and
many other types of products.
While the FPGA development
process is second nature to
embedded systems designers
experienced in implementing
digital designs on an FPGA, it
can be confusing and difficult for
the rest of us. Good communica-
tion is important when technical
leads, supervisors, managers, or
systems engineers interface with
FPGA designers.
The key to good communica-
tion is having an understanding
of the development process. A
solid understanding will help
you comprehend and extract
relevant information for status
reports, define schedule tasks,
and allocate appropriate re-
sources and time. There have
been many times when my
FPGA knowledge has allowed
me to detect and correct errors,
such as wrong part numbers or
misuse of terms and terminology
found in requirements and other
documents.
Regardless of your final prod-
uct, FPGA designers must follow
the same basic process. The Figure 1: The FPGA development process can be divided into four functions: design, synthesis, simulation and imple-
FPGA development stages are mentation.
design, simulation, synthesis,
and implementation, as shown Schematic capture prietary symbols make the design tation is easy to understand.
in Figure 1. The design pro- Schematic capture, the graphi- unrecognizable by competitors’ However, its major drawback is
cess involves converting the cal depiction of a digital design, FPGA development tools. The an increase in cost and time to
requirements into a format that shows the actual interconnec- proprietary nature of this type reproduce a design for different
represents the desired digital tion between each logic gate of design makes it vendor de- vendors due to the design’s pro-
function(s). Common design that produces the desired output pendent, and the entire design prietary nature.
formats are schematic capture, function(s). Many of these logic- process must be repeated if a
hardware description language gate symbols involve proprietary different vendor is used. HDL method
(HDL), or a combination of the information making them avail- Examples of schematic cap- Hardware description languages
two. While each method has its able to the designer only through ture tools are Viewlogic’s View- (HDLs) use code to represent
advantages and disadvantages, the specific vendor’s component Draw and HDL’s EASE. The main digital functions. “Firmware” often
HDLs generally offer the great- library. Schematic capture de- advantage of schematic capture refers to the resulting HDL code.
est design flexibility. signs that mainly consist of pro- is that the graphical represen- HDLs are a common and popular

EE Times-India | January 2008 | eetindia.com 


approach to FPGA design. You can
create the source code with any
text editor. Special HDL editors
like CodeWright and Scriptum
(a free HDL text editor by HDL
Works) offers features such as
HDL templates and highlighting
reserved words not found in or-
dinary text editors. HDLs can be
generic (supported by multiple
simulation and synthesis tool
sets) like Verilog or VHDL (Very
High Speed IC HDL), or vendor-
specific like Altera’s Hardware
Description Language (AHDL),
which is only recognizable by
Altera’s design tool set.
There are two writing styles
for HDL designs, structural or Figure 2: Multiple source files are created for each function and are interconnected through a hierarchical
behavioral. Structural firmware file structure.
is the software equivalent of a
schematic capture design. Like a VHDL file’s behavior. Because initialized U, high impedance ages, such as standard, textio, and
schematic capture, structural de- HDLs are similar to software, Z, weak unknown W, weak 0 L, std_logic_1164. Each of these
signs instantiates or uses vendor- firmware designers should fol- weak 1 H, and don’t care - to packages defines various types,
specific components to construct low some of software develop- represent a single data bit. attributes, procedures, files, and
the desired digital functions. This ment rules. • Std_logic_vector can have so on. Here’s an abbreviated list
type of HLD firmware is vendor- HDL guidelines the same values as std_logic; of selected IEEE packages:
dependent like its graphical 1. Use comments to provide however it represents mul- • standard defines types (such
counterpart and has the same code clarity. tiple bits. as boolean, bit, time, and
disadvantages. Like schematic 2. Indicate active low signals by • A bit can only have a value of integer), subtypes (such as
capture designs, repeating the n, _n, _b, * at the end of the high 1 or low 0, and it repre- natural and positive), and the
design process is necessary for name. sents one data bit. attribute foreign.
different vendors. 3. Signal names should be rela- • Boolean represents true or • textio package defines types
Behavioral HDL firmware tively short but descriptive. false. (such as line and text), files
describes digital functions in For example: • Comments are denoted by (such as input and output),
generic or abstract terms that • A good signal name would double dash marks —. and procedures (such as read,
are generally vendor indepen- be CEn for an active low chip • Comments continue after readline write, and writeline).
dent. This provides enough flex- enable. — until a carriage return. • Std_logic_1164 package de-
ibility for code reuse in different • A bad signal name would be • Each statement ends with a fines types (such as std_ulogic
vendor’s FPGAs so little or no active_low_chip_enable. semicolon ; . and std_ulogic_vector) and
code modification is required. • Use underscores in name • VHDL is not case sensitive. functions (such as nand, and,
Advantages of behavioral designs description for clarity. • No specific format is re- or, nor).
are its flexibility and time and • Synchronize signals to change quired.
cost-savings, and it offers little on a clock edge. • Reserved words aren't valid The work library serves as a
to no vendor dependence. For • Process, routes, modules, and signal names. place to add or delete designs.
designs that require vendor spe- so forth, should perform a • Signal names must start with Designs stored in the work library
cific resources, such as RAM, only single function. a letter; numbers are not get analyzed during synthesis
those components must change • Use formatting, such as tabs acceptable. and simulation. Various tools
for different vendors. and spaces, to provide read- handle libraries in different ways.
VHDL and Verilog are the most ability of code. Library declaration Therefore, users should consult
popular HDL languages. VHDL • Include a header section for The library declaration is the first the tool’s documentation for cor-
files consist of three main parts: each file or module. Sug- section in the source file. This is rect use. To use what’s in a library
library declaration, entity decla- gestive header information where you place the library and or package, the library must be
ration, and architecture section. designer’s name, file descrip- package call-out statements. made visible by using the key-
While not required by VHDL, an tion, and revision or history Libraries and packages define words Library and Use clause.
optional heading section should record. and store components, define The IEEE std_logic_1164 package
be included. This section should signal types, functions, proce- contains the types used in Listing
contain pertinent information, VHDL syntax rules dures, and so forth. Packages and 1. Therefore, the LIBRARY IEEE;
such as the designer’s name, Now for some VHDL specifics, libraries are standardized, such as statement makes it visible and
filename, a brief summary of including data types: the IEEE library, and defined by USE IEEE.std_logic_1164.all; tells
the code, and a revision history. • Std_logic can have values of a user (designer) or vendor. The the tools to use all the contents in
Listing 1 shows an example of high 1, low 0, unknown X, un- IEEE library offers several pack- the std_logic_1164 package.

 eetindia.com | January 2008 | EE Times-India


When a designer has specific
constants, formulas, processes,
and procedures that are used by
multiple modules or submodules
within their design, he or she can
create a custom package. By do-
ing this, the functions in the user-
defined package can be shared
with other designers and projects.
A user-defined library/package
is an easy way to repeatedly use
specific HDL elements in multiple
files with the luxury of only defin- Figure 3: The design serves as the input to the synthesis process, resulting in a netlist that is used as the input to the
ing its elements once. Assuming a place and route or implementation tool.
designer creates a package called
my_package and stores this pack- Entity declaration declaring the architecture is the Listing 1 contains two pro-
age in the library called Test, the The entity declaration section reserved word Architecture fol- cesses. The first is checking_
following command would make immediately follows the library lowed by its name Door_monitor, door_status, which has a sen-
the package visible, thereby allow- declaration. Each entity has an then the reserved word Of, then sitivity list that contains three
ing its contents to be used in the assigned name; Monitor is the the entity’s name Monitor. Signals signals: reset, clock_20mhz, and
source file. entity name of the VHLD code in not defined in the entity section reset_start_timer. The second
LIBRARY Test; Listing 1. Just as the library decla- are defined in this section. process is set_alarm_enable,
USE Test.my_pack ration section makes libraries and The signal assignment format which only has two signals, reset
age.ALL; packages visible to the design, consists of the reserved word Sig- and clock_20mhz, in its sensitivity
the entity section makes the I/Os nal followed by the signal name list. Signals in a process that up-
User/designer-defined pack- visible to other source files and and then the data type (such as date or change following a clock
ages are similar to those supplies the design and can represent the std_logic and std_logic_vector), edge are called synchronous
by vendors, such as Xilinx, whose I/Os as physical FPGA pins. VHDL as in Listing 1. Like names defined signals. Start_500ns_timer in the
packages contain elements such designs can contain one source in the entity, each signal name checking_door_status process is
as RAMs, counters, and buffers. file or a hierarchy of multiple files. must be unique and have a an example of a synchronous
Xilinx’s “vcomponents” package Hierarchical file structures consist data type. This section is also signal. The architecture section
contains constants, attributes, of several files connected through for declaring constants, variables, closes by using the reserved
types, and components that be- the signals declared in their enti- and other data types. word END followed by the
come available once the library ties. Figure 2 shows a simplified Signals can be thought of as architecture’s name.
and package are visible to the hierarchical file structure for a wires used to connect functions
design. The package contains home security system. and store values. After defining all Simulate or synthesize
components like AND3, which On the other hand, if the de- the design’s signals, the designer One or more designers may
is a three-input AND gate, and sign is only one file, the top-level is ready to develop the code that be responsible for a design. A
NAND3, a three-input NAND entity declaration defines all of describes the desired functions. number of factors influence the
gate. The “vcomponent” package the I/O that represents physical The reserved word Begin signifies numbers designers needed,
provides timing information, the FPGA pins. All I/O signals defined the start of the next subsection, such as design complexity and
I/O port names (used to instan- in this section must have unique which combines the concur- size; the designers’ skill level;
tiate components in design), names, indicated signal direction rent and sequential statements. and the designers’ schedule
and other information used by (input or output), and number of Concurrent statements update and availability. Regardless of
synthesis and simulation tools. bits reserved for the signal. From or change value at anytime. The the number of designers, after
The vendor’s package becomes Listing 1, reset is an input, only signal assignment immediately the design is completed, there
visible in the same manner as one data-bit wide and is a std_ following the first reserved word are a couple of options. He or
the standard and user-defined logic data type. The keyword END BEGIN in Listing 1 is an example she may choose to simulate or
libraries. To use the elements in followed by the entity’s name of a concurrent statement. Se- synthesize the design. There
Xilinx’s “vcomponent” package, signifies the end of the entity. All quential statements update isn’t a hard and fast rule stat-
designers must make the library entities must be associated with or change value when signals ing you must simulate before
visible. For example, the follow- an architecture section. in the sensitivity list (see List- synthesis. There are advantages
ing command makes the “Xilinx” ing 1) change state. Signals in to each option, and designers
library with vcomponent package Architecture section “processes” are sequential state- must determine which step is
visible to the design: The architecture section, which ments. Most processes have a most beneficial. In fact, there
LIBRARY Xilinx; contains the circuit description, sensitivity list, process name, and may be times when a designer
USE Xilinx.vcompo is the body of the VHDL source circuit description (HDL code) be- decided to simulate following
nents.ALL; code. The libraries, packages, and tween reserve words BEGIN and the completion of the initial de-
signals work together to develop END PROCESS. The process name sign while another time decide
Once all the libraries and the desired functions. Like the en- precedes the reserved word to synthesize. Each option lets
packages are visible, this section tity, each architecture must have Process, and the sensitivity list is the designer detect and correct
is complete. an assigned name. The format for enclosed in the parenthesis. different types of errors.

EE Times-India | January 2008 | eetindia.com 


Simulating the design prior
to synthesis allows logic errors
and design flaws to be resolved
early in the development process.
Synthesizing lets the designer
resolve synthesis errors prior to
logic errors and design flaws. Ide-
ally, the designer would perform
minimal simulation, leaving the
more stringent testing to a code
tester. The original code designer
shouldn’t test his own code
because he’s less likely to detect
specific design flaws such as:
1. Misinterpretation of require-
ments; if the designer misun-
derstood a requirement, he or
she will test and evaluate the
design based on that misun-
derstanding.
2. It’s more difficult for a person
to find his own errors. A third-
party generally tests the code
more rigorously and is more
eager to find bugs than the
original designer.

Regardless of who performs


the simulations, the process is the
same. For the sake of this article,
we’re going to assume the testing
is performed by a code tester, not
the original designer.
Simulation is the act of verify-
ing the HDL or graphical digital
designs prior to actual hard-
ware validation. The circuit’s
input-signal characteristics are
described in HDL or in graphical
terms that are then applied to
the design. This lets the code
tester observe the outputs’ be- Listing 1: The various sources of a VHDL source file are illustrated here.
havior. It may be necessary to
modify the source code during signer speaks of a testbench, he’s data. An example of an automatic There are three levels of simu-
simulation to resolve any discrep- referring to applying stimulus to testbench would be one that lation: register transfer level
ancies, bugs, or errors. the design in the form of HDL. reads valid data from an external (RTL), functional, and gate level.
Simulation inputs or stimulus Listing 2 shows an example of a file, compares it with simulation Each occurs at a specific place
are inputs that mimic realistic VHDL stimulus or testbench file. data, and writes the final pass/fail in the development process.
circuit I/Os. Stimulus forces the The testbench looks similar to results to an external file. External RTL follows the design stage;
circuit to operate under various the actual VHDL design. Hence, files are useful for duplicating functional follows synthesis and
conditions and states. The great- the same VHDL language rules events seen on actual hardware. after implementation is com-
est benefit of stimulus is the abil- apply. Each tester has a style in Data can be taken from the pleted the gate level simulation.
ity to apply a wide range of both which he or she writes a test- hardware, stored in an external Generally, the stimulus devel-
valid and invalid input-signal bench, which can be automatic file, then read into a testbench and oped for the RTL simulation is
characteristics, test circuit limits, or manual and can use external used as the input stimulus. Many reusable without modification for
vary signal parameters (such as files for simulation and analysis. simulators accept both waveform each level of simulation.
pulse width and frequency), and Automatic testbenches can ana- and testbenches as input stimu-
observe output behavior without lyze simulation data and provide lus; consult your simulator user’s Simulation
damaging hardware. Stimulus can a final result, output error data, manual for acceptable formats. The initial simulation performed
be applied to the design in either or other important information. Some popular simulators are Men- immediately after the design
HDL or graphical/waveform for- Manual testbenches require the tor Graphics’ ModelSim, Aldec’s stage is the RTL simulation.
mat. Generally, when a tester or de- tester to manually analyze the Riviera, and Altera’s Quantus II. This involves directly applying

 eetindia.com | January 2008 | EE Times-India


of hours spent writing the code
should be spent developing and
testing the code.

Design synthesis
While some designers prefer
to proceed directly to simula-
tion, I prefer to synthesize the
design. Synthesis is the process
that reduces and optimizes the
HDL or graphical design logic.
Some third-party synthesis tools
are available as a part of the
FPGA vendor’s complete devel-
opment package. Synplicity’s
Synplify and Mentor Graphics’
LeonardoSpectrum, Precision
RTL, and Precision Physical are
examples of third-party synthe-
sis tools. Xilinx offers ISE Project
Foundation, which is a com-
plete development application
that includes a synthesis tool.
Altera has Quartus II Integrated
Synthesis, QIS.
Although some FPGA ven-
dors offer synthesis, they still
recommend using a third-party’s
synthesis tools. The synthesis
tool must be set up prior to ac-
tually synthesizing the design.
Synplicity’s Synplify goes through
a common set-up process, as it in-
Listing 2: VHDL Testbench is used to provide stimulus to the VHDL source code. volves providing the design files
(completed during design stage)
the stimulus to the design. RTL thesis process hasn’t changed pre- and post-synthesis designs and information about the FPGA.
simulation only lets designers the design. Many, but not all, are equivalent, and the gate level FPGA information includes the
verify that the logic is correct. third-party simulation tools ac- uncovers timing errors. vendor’s name, the specific part
No realistic timing information cept post-synthesis netlists. Some benefits to spending or family, the package type, and
is available to the simulator. Gate-level simulation involves sufficient time generating quality the speed. The synthesis process
Therefore, no serious timing applying stimulus to the netlist testbenches and simulation are takes this information and the
exists for the design. The only created by the implementation reduced time troubleshooting user-defined constraints and
timing information that can process. All internal timing de- hardware (generally, cheaper produces the output netlist. A
be available to the simulator is lays are included in this netlist, to testbench troubleshoot than constraints file specifies informa-
tester generated. Much like in- which provides the tester with hardware troubleshoot) and a de- tion like the critical signal paths
put stimulus, a tester can insert the most accurate design out- crease in the chance of damaging and clock speeds. After complet-
simulated or injected delays put. Again, many, but not all, hardware resulting in a faster time ing set-up, synthesis can begin.
into the original HDL design, as third-party simulation tools can to market. Opting to omit simula- General synthesis flow for tools
in Listing 1. Most synthesis tools perform gate simulation. tion and testbenching will gener- like Synplicity’s Synplify involves
(discussed later) will ignore Ideally, each level of simula- ally cost the project additional three steps, creating structural
these simulated delays. tion is performed at the ap- time and money. Lab testing element, optimizing, and map-
Applying test stimulus to propriate development stage. requires collecting and setting up ping. Figure 3 shows a synthesis
the synthesized or optimized However, if this isn’t possible, test equipment (such as a logic flow diagram.
netlist produced by a synthesis it’s recommended that at a analyzer and oscilloscope) and The first step in the synthesis
tool is a functional simulation. minimum, RTL is performed. As depending on the equipment process is to take the HDL design
Optimized netlists produced by this simulation is performed, it’s used, the designer may have a and compile it into structural
non-vendors apply estimated normal for the original design limited number of signals avail- elements. This means that the
delays that produce more realis- to require modifications due able. Or, the desired signal must HDL design is technology in-
tic simulation output results. The to logic errors. Each simulation be made available on an output, dependent. Synplify graphically
main benefit from performing level offers various benefits. which requires additional time. represents this step as the “RTL
functional simulation is that it RTL uncovers logic errors, the Simulation is valuable and as a Schematic View”, viewable in
lets the tester verify that the syn- functional level verifies that the guideline, at least 2X the number Synplify. The next step involves

EE Times-India | January 2008 | eetindia.com 


optimizing the design, making it Design implementation a slightly different approach to a timing simulation. The final step
smaller and faster by removing The final stage in ≠the FPGA design implementation, so con- is to generate the programming
unnecessary logic and allowing development process is the sult your PAR documentation. file, which can be stored in flash
signals to arrive at the inputs design implementation, also Xilinx’s Foundation or Project memory, PROMs, or directly pro-
or output faster. The goal of known as place and route (PAR). Navigator performs design gramming into the FPGA. JTAG
the optimizing process is the If the FPGA vendor has a com- implementation in three steps, and third-party programmers like
make the design perform better plete development tool, mean- translate, fit, and generate pro- Data I/O are two programming
without changing the circuit’s ing it can perform synthesis, gramming file. methods used to store the pro-
functions. and the design is synthesized Step one, called translate, gramming file in memory. The ap-
The final step in the synthesis using this tool, little or no set- involves verifying that the syn- propriate format depends on the
process involves mapping or up is required for PAR. However, thesized netlist is consistent with FPGA vendor, the programming
associating the design to the if a third-party synthesis tool is the selected FPGA architecture method, and the device used to
vendor specific architecture. used, the implementation tool and there are no inconsistencies hold the programming.
The mapping process takes the must be set up, which involves in the constraint file. Inconsisten- There are various output for-
design and maps or connects directing the PAR tool to the cies would consist of assigning mats; consult your documentation
it using the architecture of the synthesized netlist and possibly two different signals to the same for the correct one. In addition
specific vendor. This means that a constraint file. The constraint pin, assigning a pin to a power to the implementation process
the design connects to vendor- file contains information such or ground pin, or trying to assign creating the programming file,
specific components such as as maximum or minimum tim- a non-existing design signal to there are several output report
look-up tables and registers. ing delays for selected signal(s) a pin. If the design fails either files created, such as a pad file.
The optimized netlist is the and I/O pin assignments. check, the translate step will fail The pad file contains information
output of the synthesis process. Pin assignments can be auto- and the implementation process such as signal pin assignment, part
This netlist may be produced in matic (performed by the tool) or will be stopped. number, and part speed.
one of several formats. Edif is a manual (dictated by the designer). Translate errors must be cor-
general netlist format accepted Automatic pin assignment is rected and the translation step Beyond the basics
by most implementation tools, generally the best option for new must be error free before advanc- This article gives some basic ex-
while .xnf format is specific to designs, as it lets the tool more ef- ing to step two, which is the fit amples of the FPGA development
Xilinx and is only recognized by fectively route the design without stage. This step involves taking process, so a new embedded sys-
Xilinx’s implementation. having fixed pin assignments. It the constraints file and netlist tems designer, manager, techni-
In addition to the optimized may be necessary to manually and distributing the design logic cal lead from other disciplines, or
netlist, many synthesis tools like assign signals to specific pins to in the selected FPGA. If the de- someone wanting to diversify his
Synplify will produce a netlist for achieve easy board routing, to sign is too large or requires more or her skills can understand what
gate-level simulation and other provide the minimum signal route resources or available logic than it takes to develop and imple-
report files. Stimulus applied to for timing-critical signals, or be the selected device offers, the ment a digital design in a FPGA.
this netlist instead of the original compatible with legacy designs. fitter will fail and halt the imple- The generic process provided
HDL design produces the func- There are numerous rea- mentation process. To correct this here will vary depending on the
tional-level simulation, which sons why manual pin assign- type of error, replace the current FPGA tools since each vendor
lets the designer verify that the ments would be necessary. FPGA with a larger one and re- may perform some of these tasks
synthesis process hasn’t changed But regardless of the reason, synthesize, and repeat PAR for the in a slight different manner.
the design’s functions. At this the designer must make this design. A successful fit stage is A good resource for furthering
point, synthesis is complete and information available to the PAR necessary to proceed to generate your knowledge is Essential VHDL
ready for the implementation tool, which is done by creating the programming file stage. RTL Synthesis Done Right (Sundar
process. Each FPGA vendor has its a user constraint file that’s used All timing information is avail- Rajan, F.E. Compton Co, 1998).
own implementation tool, such by the PAR tool. After complet- able and many PAR tools will
as Xilinx’s Project Navigator and ing setup, the PAR process can provide the required files neces-
Altera’s Quartus II’s. begin. Each PAR tool may have sary for the simulator to perform Email   Send inquiry

 eetindia.com | January 2008 | EE Times-India

Potrebbero piacerti anche