JHDL 0.2

| JHDL Doc Home Page | User's Manual Home Page | << | < | > | >>


XC4000TechMapper Documentation

The JHDL XC4000TechMapper


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.

  1. The map() command
  2. The place() command
  3. Autodetection of user-specified techmap hints


The map() command

Requirements for mapped Wires

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:


Mapping strategies

The XC4000TechMapper follows the mapping strategy outlined below. 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.


Mapping Hint Syntax

As per the Logic API, the map() command will optionally accept a string of mapping hints. The string has two allowable formats:
  1. 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.
  2.     Wire out = and( or(a,b), c );
        map( a, b, c, out, "R2C4.F" );
  3. The string can specify a mapping hint *only* (i.e. no placement), using the following syntax:
  4. 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() command

Interpretation of the place command

The place() method gives placement hints to cells. The effect of the call depends largely on the kind of cell being placed: 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."


Hierarchical placement rules

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.


Iterated placement

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:

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:

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)

Autodetection of user-specified tech-mapping hints

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.