JHDL 0.2
| JHDL Doc Home Page
| User's Manual Home Page
| << | <
| > | >>
XC4000TechMapper Documentation
Hopefully by now we've hammered into your brain the idea that the Logic
class has no brains. All the magic for instantiating gates and tech-mapping
them comes from the TechMapper object. Therefore this page
exists to document precisely how the XC4000TechMapper interprets
mapping and placement hints.
An outline of this documentation is as follows.
-
The map() command
-
The place() command
-
Autodetection of user-specified techmap hints
The map method is used to pack gates into LUTs and flip-flops.
As per the Logic API, map takes a list of inputs and a single
output. It composes the network of gates between the inputs and the
output, and tries to pack them into a single LUT or CLB. The XC4000TechMapper
imposes the following constraints on the input and output wires:
-
The input and output wires must be either 1-bit or a single common "generic"
width. For example, the following set of wire widths would be valid:
{ 1, 8, 8, 1, 8 }. On the other hand, the following set would be
invalid, because there is more than one "generic" width: { 1, 8, 4, 1,
8 }. (Basically, in this case "generic" means anything other than
1-bit).
When the XC4000TechMapper detects that the wire list includes
a "generic" width, it simply does a for loop to iterate through
the map call. For example, the following map command:
map( w_8bit_in, w_1bit_in, w_8bit_out );
is the same as doing:
for( int i=0; i<8; i++ )
map( w_8bit_in.getWire(i), w_1bit_in, w_8bit_out.getWire(i));
The input list must precisely define a correct fan-in of
the output. In other words, if we have the following network:
Wire o = or( and( a, b ), and( c, d ) );
The following map calls would be illegal: map( a, b, c,
o ) and map( a, b, c, d, e, o ). The former is invalid
because d is fan-in to the network, but is not included in the map
list. The latter case is invalid because e is listed as fan-in,
but is not truly fan-in to the network.
The mapped network must be entirely composed of asynchronous gates,
with the exception that the output wire may be driven by an fdce.
This is simply an architectural constraint -- a CLB only has registers
directly on the outputs of the CLB. If there is an fdce driving
the output, the XC4000TechMapper maps the network behind the fdce
to a LUT (or LUTs), and then constrains the fdce and the LUT to
be in the same CLB.
The XC4000TechMapper follows the mapping strategy outlined below.
-
If the input list has four or less bits, the asynchronous network is mapped
to a LUT.
-
If the input list has five or more bits, the mapper tries to decompose
the network to fit into a single CLB. The mapper does not perform
logic rearrangement. Therefore, the designer needs to structure wide
functions so as to be amenable to a CLB. For example, the output
stage of the network needs to be a function of three inputs or less(to
map to an H-LUT). The subnetworks that drive the H-LUT inputs need
to be functions of four inputs or less, etc. Refer to the Xilinx
XC4000 documentation for CLB structure if this isn't inherently clear.
Some examples will communicate this the best; these wide functions can
be mapped:
and( a, and(b, or(c,d,e)), or(f,g) );
or ( xor(w,x,y,z), v );
and( and( a, b, c, d), and(e, f, g, h), i ); // 9-input AND
The following functions can not be mapped:
// Last stage of network has fanin of four
and( a, and(b,c), or(d,e), or(f,g) );
// One of H-LUT subnetworks has fanin of five
or ( xor(u,w,x,y,z), v);
// Total network fanin > 9 (impossible for a CLB)
and( and( a, b, c, d, e), and(f, g, h, i), j );
Any time that multiple LUTs, and fdce's as mentioned above, are
inferred by a single map call, they are all constrained to the same
CLB. What happens is that the last LUT or fdce in the network
is labelled as the "master" of the network. Any time that the "master"
is placed (or the master's output wire), the dependent cells get placed
as well.
Let's illustrate all of the above with a full example. Here, we create
a registered 9-input function, and then map it:
Wire out = reg( or( a, and(b,c,d,e), xor( and(f,g), or(h,i) ));
map( a,b,c,d,e,f,g,h,i, out );
place( out, 4, 3 ); // same as place( out, "R3C4" );
This maps the "or" function to the H-LUT of R3C4; the "and" function to
the F-LUT of R3C4; the "xor" function to the G-LUT of R3C4; and the register
to either FFX or FFY or R3C4.
As per the Logic API, the map() command will optionally accept
a string of mapping hints. The string has two allowable formats:
-
The string can be a standard RLOC string. The RLOC will be directly
applied to all FMAPs created (and an fdce in the mapped network,
if applicable). This may be a little confusing, since RLOCs also
specify placement information. But we did this simply because the
Xilinx RLOC methodology ties mapping and placement together very tightly
(i.e. in a single RLOC string), and it doesn't make sense to try to combat
that. For example, the following map() call will both map
the logic to a LUT, and place the LUT. This is often the most concise
form of mapping and placement.
Wire out = and( or(a,b), c );
map( a, b, c, out, "R2C4.F" );
-
The string can specify a mapping hint *only* (i.e. no placement), using
the following syntax:
-
FF=FFX or FF=FFY; or alternatively, this can simply be abbreviated to .FFX or .FFY
-
LUT=F or LUT=G or LUT=H; or alternatively, this can simply be abbreviated to .F, .G, or .H
Because your mapped network can contain both LUTs and an fdce, you
may combine two hints, delimited by a comma. For example:
Wire out = reg( and(a, b, c) );
map( a, b, c, out, "LUT=G,FF=FFY" );
will map the "and"gate to a G-LUT, and the register to FFY, all in the
same CLB. You could then specify the placement of both the LUT and
the register with a place( out, 0, 0 ) sort of command.
This syntax is particularly useful when you want to do careful iterated
placement. For example:
Wire out = mux( a, b, sel );
map( a, b, sel, out, ".G" );
place( out, 0, 0, 0, 1 );
This will layout the mux in a single column, one bit per CLB, using only
G-LUTs. In this case we only wanted to specify mapping in the map-hint
string, since the placement couldn't be represented with a simple RLOC
string. Also notice that in this case, we used the abbreviated
form: ".G" instead of "LUT=G" to set the LUT placement.
Any LUT-packing hints for wide functions (i.e. fanin of 5 or more) are
ignored.
The place() method gives placement hints to cells. The effect
of the call depends largely on the kind of cell being placed:
-
Xilinx "Placeable" cell
If the cell is Placeable (these are: FMAP, HMAP, fdce,
fdpe, carry-blocks, and a very select few other cells in the XC4K
library), it checks to see if the cell is an FMAP or HMAP. If
so, it infers the mapped gate network, and checks the network for
fanin / fanout errors as detailed above. In any case, it
applies the placement hint to the cell (and to any mapped
logic). (Note that Placeable is an interface in the XC4K
library; it is different than the adjective "placeable", and will
always be differentiated by boldface). - Non-Placeable
hierarchical cell
If the cell is a non-leaf (i.e. it has substructure), it simply
applies the placement hint. Upon netlisting, the
XC4000TechMapper checks to see if the cell can be placed (see the
rules for placing hierarchical
cells), and throws an exception if it cannot be placed. -
Non-Placeable leaf cell
If the non-Placeable cell is a leaf cell, the mapper will try
to perform a simple mapping first, making a map() call with the
inputs and output to the cell in the wire lists. If there is more
than one output, the mapper simply throws an exception and says that you
must map the cell first.
-
Wire
If a wire is the placed object, this *always* implies placing the cell
that is the structural source of that wire. "Structural source" implies
the cell at the current level of hierarchy that has that wire as an output,
as opposed to the "simulation source", which is the cell that actually
drives the wire (and may be at a different level of hierarchy). This
construction was made simply because in many Logic designs, you
never get explicit references to the gates themselves -- all Logic
functions return the output wires, not the gates themselves. If the
wire has more than one bit and the bits are driven by different sources,
then the mapper uses the iterated placement algorithms to place all the
source cells.
In all cases except for the first, the mapper first checks to see if
there is a LUT-mapping for a given gate. If so, the placement
hint is applied to the FMAP / HMAP symbol that the cell was mapped to,
instead of the cell itself. Also, remember that the Xilinx XC4000
tools use a "raster-order" placement convention, where the coordinate
(0,0) is in the upper-left-hand corner of the chip, and Y increases as
you move "south."
A hierarchical cell can only be placed if all its substructure is placed
as well. This is simply as per the Xilinx M1 tools. A cell
is considered placed if it has both an X and Y placement hint, or if that
cell has been mapped to a LUT with a FMAP / HMAP which is placed.
There are some primitives in the Xilinx library which *cannot* be placed
-- such things as vcc, gnd, startup, etc. Obviously,
these cells are excluded from the placement requirement; all such cells
are tagged with a dummy UnmappableCell interface in the XC4K library
to indicate to the XC4000TechMapper that they never can be mapped
/ placed.
When you call place() on a wire, with both an (x,y) pair and a
(dx,dy) pair as parameters, the XC4000TechMapper tries to
perform iterated placement. Iterated placement is a great shortcut
for placing regular structures that drive a single wire. For
example, if we call:
Wire in = wire(8);
Wire out = reg(in);
we can place all the registers with a single place() command,
like this:
place(out, 2, 3, 0, 1);
The (2,3) pair gives the initial position for the placement, and the
(0,1) pair gives the positional increment. This place()
command places out[0] at (2,3); out[1] at
(2,4); out[2] at (2,5); and so forth. So in other words,
as the mapper iterates through bits 0 .. (N-1) of the wire
parameter, when it encounters a new cell it places that cell at the
"current position", and then increments the current position by
(dx,dy). Therefore, one cell can drive multiple bits in the
wire, and the iterated placement algorithm will still work. As with
the non-iterated placement, the XC4000TechMapper uses the Xilinx
raster-order placement convention. Therefore a positive dy value will
cause your iterated placement to start "north" and iterate "south".
In order to qualify for iterated placement, a wire must meet the following
conditions:
-
All bits in the wire must be driven.,
-
Any cell that drives bits of the wire can only drive 1 bit, or drive
contiguous bits. If it drives several non-contiguous bits (i.e. drives
bits 1,2, and 6 of a wire), an exception will be thrown.,
Some more examples are in order:
out = reg( in );
place( out, 6, 3, 1, 2 ); // bit 0 will be in R3C6; bit 1 in R5C7; bit 2 in R7C8 ...
or
place( out, 0, 4, 0, -3 ); // bit 0 will be in R4C0; bit 1 in R1C0; bit 2 in R-2C0 ...
Wire result = wire(16);
new alu4( ... , range( result, 3, 0 ), ... );
new alu4( ... , range( result, 7, 4 ), ... );
new alu4( ... , range( result, 11, 8 ), ... );
new alu4( ... , range( result, 15,12 ), ... );
place( result, 0, 0, 0, 2 ); // first ALU (bits 3..0) will be in R0C0;
// second ALU (bits 7..4) will be in R2C0;
// third ALU (bits 11..8) will be in R4C0;
// fourth ALU (bits 15..12) will be in R6C0;
Iterated Placement: Max-Packing
The Logic class provides a special placement value called MAX_PACK.
The Logic class simply defines this to mean "maximal packing of
FPGA primitives". In XC4000-CLB terms, this means "2 bits per CLB".
The MAX_PACK value has no meaning to the XC4000TechMapper
for regular (not iterated) placement. But when it is given as an
iterated placement dy hint, it is a powerful tool for highly efficient
designs. (Note that MAX_PACK for the dx hint is invalid, because
of XC4000 CLB architecture).
When MAX_PACK is given as the dy hint, it will try to place all the
cells that drive the wire in alternating F / G-LUTs, or in alternating
FFX / FFY registers. The iteration can begin with F or G (FFX or
FFY), as directed by a ".F" or ".G" (".FFX" or ".FFY") extension in the
initial placement string. Remember that Xilinx counts increasing
Y from north to south, and that F is more south than G (FFX is more south
than FFY); therefore, if dy is positive, the iterated placer places in
the G-LUT first (FFY), and then the F-LUT (FFX) in a given CLB. If
no ".F" or ".G" is specified in the initial placement, then the defaults
are to start in G if MAX_PACK is specified, and to start in F if
-MAX_PACK is specified.
When doing MAX_PACKing, the placed wire is subject to the following
additional constraints:
-
All the source cells for the wire must be fdces or single-LUT memories
(ram16x1, ram16x1s, rom16x1), or the cells must be FMAPed.
-
The cells to be placed must all be of the same type (i.e. all fdces,
or all rom16x1s, etc.)
Some examples should help to clarify the rules mentioned above:
Wire out = reg( in ); // Must either be pure FDCEs, or...
** OR **
Wire out = < anything you want...>
map( <inputs>, out ); // ... or must be all FMAPed.
place( out, 2, 0, 0, MAX_PACK,".G" ); // bit 0 will be in R0C2.G; bit 1 will be in R0C2.F; bit 2 will be in R1C2.G ...
place( out, 2, 0, 0, MAX_PACK,".F" ); // bit 0 will be in R0C2.F; bit 1 will be in R1C2.G; bit 2 will be in R1C2.F ...
place( out, 2, 0, 0, MAX_PACK ); // same as first case (default is to start with G when dy is positive)
place( out, 2, 5, 0, -MAX_PACK, ".G" ); // bit 0 will be in R5C2.G; bit 1 will be in R4C2.F; bit 2 will be in R4C2.G ...
place( out, 2, 5, 0, -MAX_PACK, ".F" ); // bit 0 will be in R5C2.F; bit 1 will be in R5C2.G; bit 0 will be in R4C2.F ...
place( out, 2, 5, 0, -MAX_PACK ); // same as second case (default is to start with F when dy is negative)
The map() and place() methods should be sufficient for most
tech-mapping requirements. However, in some cases the user may want
to explicitly lay down FMAPs and assign RLOC properties himself.
The XC4000TechMapper, in its final stages of mapping, will automatically
detect any user-instantiated techmap hints, and include these in all the
error checking.
| JHDL Doc Home Page
| User's Manual Home Page
| << | <
| > | >>
Copyright (c) 1998-1999 Brigham Young University. All
rights reserved.
Reproduction in whole or in part in any form or
medium without express permission of Brigham Young University is
prohibited.