Project IceStorm aims at documenting the bitstream format of Lattice iCE40 FPGAs and providing simple tools for analyzing and creating bitstream files. This is work in progress.
The image on the right shows the span-wires of a left (or right) io cell (click to enlarge).
A left/right io cell has 16 connections named span4_vert_t_0 to span4_vert_t_15 on its top edge and 16 connections named span4_vert_b_0 to span4_vert_b_15 on its bottom edge. The nets span4_vert_t_0 to span4_vert_t_11 are connected to span4_vert_b_4 to span4_vert_b_15. The span-4 and span-12 wires of the adjacent logic cell are connected to the nets span4_horz_0 to span4_horz_47 and span12_horz_0 to span12_horz_23.
A top/bottom io cell has 16 connections named span4_vert_l_0 to span4_vert_l_15 on its top edge and 16 connections named span4_vert_r_0 to span4_vert_r_15 on its bottom edge. The nets span4_vert_l_0 to span4_vert_l_11 are connected to span4_vert_r_4 to span4_vert_r_15. The span-4 and span-12 wires of the adjacent logic cell are connected to the nets span4_vert_0 to span4_vert_47 and span12_vert_0 to span12_vert_23.
The vertical span4 wires of left/right io cells are connected "around the corner" to the horizontal span4 wires of the top/bottom io cells. For example span4_vert_b_0 of IO cell (0 1) is connected to span4_horz_l_0 (span4_horz_r_4) of IO cell (1 0).
Note that unlike the span-wires connection LOGIC and RAM tiles, the span-wires connecting IO tiles to each other are not pairwise crossed out.
Each IO tile contains two IO blocks. Each IO block essentially implements the SB_IO primitive from the Lattice iCE Technology Library. Some inputs are shared between the two IO blocks. The following table lists how the wires in the logic tile map to the SB_IO primitive ports:
|SB_IO Port||IO Block 0||IO Block 1|
Like the inputs to logic cells, the inputs to IO blocks are routed to the IO block via a two-stage process. A signal is first routed to one of 16 local tracks in the IO tile and then from the local track to the IO block.
The io_global/latch signal is shared among all IO tiles on an edge of the chip and is driven by fabout from one dedicated IO tile on that edge. For the HX1K chips the tiles driving the io_global/latch signal are: (0, 7), (13, 10), (5, 0), and (8, 17)
A logic tile sends the output of its eight logic cells to its neighbour tiles. An IO tile does the same thing with the four D_IN signals created by its two IO blocks. The D_IN signals map to logic function indices as follows:
|Function Index||D_IN Wire|
For example the signal io_1/D_IN_0 in IO tile (0, 5) can be seen as neigh_op_lft_2 and neigh_op_lft_6 in LOGIC tile (1, 5).
Each IO Tile has 2 NegClk configuration bits, suggesting that the clock signals can be inverted independently for the the two IO blocks in the tile. However, the Lattice tools refuse to pack two IO blocks with different clock polarity into the same IO tile. In our tests we only managed to either set or clear both NegClk bits.
Each IO block has two IoCtrl IE bits that enable the input buffers and two IoCtrl REN bits that enable the pull up resistors. Both bits are active low, i.e. an unused IO tile will have both IE bits set and both REN bits cleared (the default behavior is to enable pullup resistors on all unused pins). Note that icebox_explain.py will ignore all IO tiles that only have the two IoCtrl IE bits set.
However, the IoCtrl IE_0/IE_1 and IoCtrl REN_0/REN_1 do not necessarily configure the IO PIN that are connected to the IO block in the same tile, and if they do the numbers (0/1) do not necessarily match. As a general rule, the pins on the right and bottom side of the chips match up with the IO blocks and for the pins on the left and top side the numbers must be swapped. But in some cases the IO block and the set of IE/REN are not even located in the same tile. The following table lists the correlation between IO blocks and IE/REN bits for the 1K chip:
When an input pin pair is used as LVDS pair (IO standard SB_LVDS_INPUT, bank 3 / left edge only), then the four bits IoCtrl IE_0/IE_1 and IoCtrl REN_0/REN_1 are all set, as well as the IoCtrl LVDS bit.
In the iCE 8k devices the IoCtrl IE bits are active high. So an unused IO tile on an 8k chip has all bits cleared.
iCE40 FPGAs have 8 global nets. Each global net can be driven directly from an IO pin. In the FPGA bitstream, routing of external signals to global nets is not controlled by bits in the IO tile. Instead bits that do not belong to any tile are used. In IceBox nomenclature such bits are called "extra bits".
The following table lists which pins / IO blocks may be used to drive which global net, and what .extra statements in the IceStorm ASCII file format to represent the corresponding configuration bits:
|IO Tile +|
|0||93||13 8 1||.extra_bit 0 330 142|
|1||21||0 8 1||.extra_bit 0 331 142|
|2||128||7 17 0||.extra_bit 1 330 143|
|3||50||7 0 0||.extra_bit 1 331 143|
|4||20||0 9 0||.extra_bit 1 330 142|
|5||94||13 9 0||.extra_bit 1 331 142|
|6||49||6 0 1||.extra_bit 0 330 143|
|7||129||6 17 1||.extra_bit 0 331 143|
Signals internal to the FPGA can also be routed to the global nets. This is done by routing the signal to the fabout net on an IO tile. The same set of I/O tiles is used for this, but in this case each of the I/O tiles corresponds to a different global net:
|IO Tile||7 0||7 17||13 9||0 9||6 17||6 0||0 8||13 8|
Each LOGIC, IO, and RAMB tile has 8 ColBufCtrl bits, one for each global net. In most tiles this bits have no function, but in tiles in rows 4, 5, 12, and 13 (for RAM columns: rows 3, 5, 11, and 13) this bits control which global nets are driven to the column of tiles below and/or above that tile (including that tile), as illustrated in the image to the right (click to enlarge).
In 8k chips the rows 8, 9, 24, and 25 contain the column buffers. 8k RAMB and RAMT tiles can control column buffers, so the pattern looks the same for RAM, LOGIC, and IO columns.
The SB_WARMBOOT primitive in iCE40 FPGAs has three inputs and no outputs. The three inputs of that cell are driven by the fabout signal from three IO tiles. In HX1K chips the tiles connected to the SB_WARMBOOT primitive are:
|Warmboot Pin||IO Tile|
The PLL primitives in iCE40 FPGAs are configured using the PLLCONFIG_* bits in the IO tiles. The configuration for a single PLL cell is spread out over many IO tiles. For example, the PLL cell in the 1K chip are configured as follows (bits listed from LSB to MSB):
The PLL inputs are routed to the PLL via the fabout signal from various IO tiles. The non-clock PLL outputs are routed via otherwise unused neigh_op_* signals in fabric corners. For example in case of the 1k chip:
|Tile||Net-Segment||SB_PLL40_* Port Name|
The PLL clock outputs are fed directly into the input path of certain IO tiles. In case of the 1k chip the PORTA clock is fed into PIO 1 of IO Tile (6 0) and the PORTB clock is fed into PIO 0 of IO Tile (7 0). Because of this, those two PIOs can only be used as output Pins by the FPGA fabric when the PLL ports are being used.