2001-09-03 01:58:49 +02:00
|
|
|
|
|
|
|
|
FPGA LOADABLE CODE GENERATOR FOR Icarus Verilog
|
|
|
|
|
|
|
|
|
|
Copyright 2001 Stephen Williams
|
2003-03-24 01:47:54 +01:00
|
|
|
$Id: fpga.txt,v 1.6 2003/03/24 00:47:54 steve Exp $
|
2001-09-06 06:28:39 +02:00
|
|
|
|
|
|
|
|
The FPGA code generator supports a variety of FPGA devices, writing
|
|
|
|
|
XNF or EDIF depending on the target. You can select the architecture
|
|
|
|
|
of the device, and the detailed part name. The architecture is used to
|
|
|
|
|
select library primitives, and the detailed part name is written into
|
|
|
|
|
the generated file for the use of downstream tools.
|
2001-09-03 01:58:49 +02:00
|
|
|
|
|
|
|
|
INVOKING THE FPGA TARGET
|
|
|
|
|
|
2001-09-06 06:28:39 +02:00
|
|
|
The code generator is invoked with the -tfpga flag to iverilog. It
|
|
|
|
|
understands the part= and the arch= parameters, which can be set with
|
|
|
|
|
the -p flag of iverilog:
|
2001-09-03 01:58:49 +02:00
|
|
|
|
|
|
|
|
iverilog -parch=virtex -fpart=v50-pq240-6 -tfpga foo.vl
|
|
|
|
|
|
2002-04-30 06:26:42 +02:00
|
|
|
This example selects the Virtex architecture, and give the detailed
|
2001-09-06 06:28:39 +02:00
|
|
|
part number as v50-pq240-6. The output is written into a.out unless a
|
|
|
|
|
different output file is specified with the -o flag.
|
|
|
|
|
|
|
|
|
|
The following is a list of architecture types that this code generator
|
|
|
|
|
supports.
|
|
|
|
|
|
|
|
|
|
* arch=generic-edif
|
|
|
|
|
|
|
|
|
|
This is generic EDIF code. It doesn't necessarily work because the
|
|
|
|
|
external library is not available to the code generator. But, what it
|
|
|
|
|
does is generate generic style gates that a portability library can
|
|
|
|
|
map to target gates if desired.
|
|
|
|
|
|
2001-09-03 01:58:49 +02:00
|
|
|
* arch=generic-xnf
|
|
|
|
|
|
|
|
|
|
If this is selected, then the output is formatted as an XNF file,
|
|
|
|
|
suitable for most any type of device. The devices that it emits
|
|
|
|
|
are generic devices from the unified library. Some devices are macros,
|
2002-04-30 06:26:42 +02:00
|
|
|
youmay need to further resolve the generated XNF to get working
|
2001-09-03 01:58:49 +02:00
|
|
|
code for your part.
|
|
|
|
|
|
|
|
|
|
* arch=virtex
|
|
|
|
|
|
|
|
|
|
If this is selected, then the output is formatted as an EDIF 200 file,
|
|
|
|
|
suitable for Virtex class devices. This is supposed to know that you
|
|
|
|
|
are targeting a Virtex part, so can generate primitives instead of
|
2001-09-06 06:28:39 +02:00
|
|
|
using external macros. It includes the VIRTEX internal library, and
|
|
|
|
|
should work properly for any Virtex part.
|
2001-09-03 01:58:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
XNF ROOT PORTS
|
|
|
|
|
|
2003-03-24 01:47:54 +01:00
|
|
|
NOTE: As parts are moved over to EDIF format, XNF support will be
|
|
|
|
|
phased out. Current Xilinx implementation tools will accept EDIF
|
|
|
|
|
format files even for the older parts, and non-Xilinx implementation
|
|
|
|
|
tools accept nothing else.
|
|
|
|
|
|
2001-09-03 01:58:49 +02:00
|
|
|
When the output format is XNF, the code generator will generate "SIG"
|
|
|
|
|
records for the signals that are ports of the root module. The name is
|
|
|
|
|
declared as an external pin that this macro makes available.
|
|
|
|
|
|
|
|
|
|
The name given to the macro pin is generated from the base name of the
|
|
|
|
|
signal. If the signal is one bit wide, then the pin name is exactly
|
|
|
|
|
the module port name. If the port is a vector, then the pin number is
|
|
|
|
|
given as a vector. For example, the module:
|
|
|
|
|
|
|
|
|
|
module main(out, in);
|
|
|
|
|
output out;
|
|
|
|
|
input [2:0] in;
|
|
|
|
|
[...]
|
|
|
|
|
endmodule
|
|
|
|
|
|
|
|
|
|
leads to these SIG, records:
|
|
|
|
|
|
|
|
|
|
SIG, main/out, PIN=out
|
|
|
|
|
SIG, main/in<2>, PIN=in2
|
|
|
|
|
SIG, main/in<1>, PIN=in1
|
|
|
|
|
SIG, main/in<0>, PIN=in0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EDIF ROOT PORTS
|
|
|
|
|
|
|
|
|
|
The EDIF format is more explicit about the interface into an EDIF
|
|
|
|
|
file. The code generator uses that control to generate an explicit
|
|
|
|
|
interface definition into the design. (This is *not* the same as the
|
|
|
|
|
PADS of a part.) The generated EDIF interface section contains port
|
|
|
|
|
definitions, including the proper direction marks.
|
|
|
|
|
|
2001-09-16 03:48:16 +02:00
|
|
|
With the (rename ...) s-exp in EDIF, it is possible to assign
|
|
|
|
|
arbitrary text to port names. The EDIF code generator therefore does
|
|
|
|
|
not resort to the mangling that is needed for the XNF target. The base
|
|
|
|
|
name of the signal that is an input or output is used as the name of
|
|
|
|
|
the port, complete with the proper case.
|
2001-09-03 01:58:49 +02:00
|
|
|
|
2001-09-16 03:48:16 +02:00
|
|
|
However, since the ports are single bit ports, the name of vectors
|
|
|
|
|
includes the string "[0]" where the number is the bit number. For
|
|
|
|
|
example, the module:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module main(out, in);
|
|
|
|
|
output out;
|
|
|
|
|
input [2:0] in;
|
|
|
|
|
[...]
|
|
|
|
|
endmodule
|
|
|
|
|
|
|
|
|
|
creates these ports:
|
|
|
|
|
|
|
|
|
|
out OUTPUT
|
|
|
|
|
in[0] INPUT
|
|
|
|
|
in[1] INPUT
|
|
|
|
|
in[2] INPUT
|
|
|
|
|
|
2002-04-30 06:26:42 +02:00
|
|
|
Target tools, including Xilinx Foundation tools, understand the []
|
|
|
|
|
characters in the name and recollect the signals into a proper bus
|
2001-09-16 03:48:16 +02:00
|
|
|
when presenting the vector to the user.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PADS AND PIN ASSIGNMENT
|
|
|
|
|
|
|
|
|
|
The ports of a root module may be assigned to specific pins, or to a
|
|
|
|
|
generic pad. If a signal (that is a port) has a PAD attribute, then
|
|
|
|
|
the value of that attribute is a list of numbers, one for each bit of
|
|
|
|
|
the signal, that specifies the pin for each bit of the signal. For
|
|
|
|
|
example:
|
|
|
|
|
|
|
|
|
|
module main(out, in);
|
|
|
|
|
output out;
|
|
|
|
|
input [2:0] in;
|
|
|
|
|
[...]
|
|
|
|
|
$attribute(out, "PAD", "10");
|
|
|
|
|
$attribute(in, "PAD", "20,21,22");
|
|
|
|
|
endmodule
|
|
|
|
|
|
|
|
|
|
In this example, port ``out'' is assigned to pin 10, and port ``in''
|
2002-04-30 06:26:42 +02:00
|
|
|
is assigned to pins 20-22. If the architecture supports it, a pin
|
2001-09-16 03:48:16 +02:00
|
|
|
number of 0 means let the back end tools choose a pin.
|
|
|
|
|
|
|
|
|
|
NOTE: If a module port is assigned to a pin (and therefore attached to
|
|
|
|
|
a PAD) then it is *not* connected to a port of the EDIF file. This is
|
|
|
|
|
because the PAD (and possibly IBUF or OBUF) would become an extra
|
|
|
|
|
driver to the port. An error.
|
|
|
|
|
|
|
|
|
|
|
2001-09-17 00:26:47 +02:00
|
|
|
SPECIAL DEVICES
|
|
|
|
|
|
|
|
|
|
The code generator supports the "cellref" attribute attached to logic
|
|
|
|
|
devices to cause specific device types be generated, instead of the
|
|
|
|
|
usual device that the code generator might generate. For example, to
|
|
|
|
|
get a clock buffer out of a Verilog buf:
|
|
|
|
|
|
|
|
|
|
buf my_gbuf(out, in);
|
|
|
|
|
$attribute(my_buf, "cellref", "GBUF:O,I");
|
|
|
|
|
|
|
|
|
|
The "cellref" attribute tells the code generator to use the given
|
|
|
|
|
cell. The syntax of the value is:
|
|
|
|
|
|
|
|
|
|
<cell type>:<pin name>,...
|
|
|
|
|
|
|
|
|
|
The cell type is the name of the library part to use. The pin names
|
|
|
|
|
are the names of the type in the library, in the order that the logic
|
|
|
|
|
device pins are connected.
|
|
|
|
|
|
|
|
|
|
|
2001-09-16 03:48:16 +02:00
|
|
|
COMPILING WITH XILINX FOUNDATION
|
|
|
|
|
|
|
|
|
|
Compile a single-file design with command line tools like so:
|
|
|
|
|
|
|
|
|
|
% iverilog -parch=virtex -o foo.edf foo.vl
|
|
|
|
|
% edif2ngd foo.edf foo.ngo
|
|
|
|
|
% ngdbuild -p v50-pq240 foo.ngo foo.ngd
|
|
|
|
|
% map -o map.ncd foo.ngd
|
|
|
|
|
% par -w map.ncd foo.ncd
|
2001-09-03 01:58:49 +02:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
$Log: fpga.txt,v $
|
2003-03-24 01:47:54 +01:00
|
|
|
Revision 1.6 2003/03/24 00:47:54 steve
|
|
|
|
|
Add new virtex2 architecture family, and
|
|
|
|
|
also the new edif.h EDIF management functions.
|
|
|
|
|
|
2002-04-30 06:26:42 +02:00
|
|
|
Revision 1.5 2002/04/30 04:26:42 steve
|
|
|
|
|
Spelling errors.
|
|
|
|
|
|
2001-09-17 00:26:47 +02:00
|
|
|
Revision 1.4 2001/09/16 22:26:47 steve
|
|
|
|
|
Support the cellref attribute.
|
|
|
|
|
|
2001-09-16 03:48:16 +02:00
|
|
|
Revision 1.3 2001/09/16 01:48:16 steve
|
|
|
|
|
Suppor the PAD attribute on signals.
|
|
|
|
|
|
2001-09-06 06:28:39 +02:00
|
|
|
Revision 1.2 2001/09/06 04:28:40 steve
|
|
|
|
|
Separate the virtex and generic-edif code generators.
|
|
|
|
|
|
2001-09-03 01:58:49 +02:00
|
|
|
Revision 1.1 2001/09/02 23:58:49 steve
|
|
|
|
|
Add documentation for the code generator.
|
|
|
|
|
|