FABulous.FABulous_API

FABulous API module for fabric and geometry generation.

This module provides the main API class for managing FPGA fabric generation, including parsing fabric definitions, generating HDL code, creating geometries, and handling various fabric-related operations.

Classes

class FABulous_API(writer, fabricCSV='')[source]

Class for managing fabric and geometry generation.

This class parses fabric data from ‘fabric.csv’, generates fabric layouts, geometries, models for nextpnr, as well as other fabric-related functions.

If ‘fabricCSV’ is provided, parses fabric data and initialises ‘fabricGenerator’ and ‘geometryGenerator’ with parsed data.

If using VHDL, changes the extension from ‘.v’ to’.vhdl’.

Parameters:
  • writer (CodeGenerator) – Object responsible for generating code from code_generator.py

  • fabricCSV (str, optional) – Path to the CSV file containing fabric data, by default “”

geometryGenerator[source]

Object responsible for generating geometry-related outputs.

Type:

GeometryGenerator

fabric[source]

Represents the parsed fabric data.

Type:

Fabric

fileExtension[source]

Default file extension for generated output files (‘.v’ or ‘.vhdl’).

Type:

str

Methods:

addList2Matrix(listFile, matrix)[source]

Convert list into CSV matrix and save it.

Using ‘list2CSV’ defined in ‘fabric_gen.py’.

Parameters:
  • listFile (Path) – List data to be converted.

  • matrix (Path) – File path where the matrix data will be saved.

Return type:

None

bootstrapSwitchMatrix(tileName, outputDir)[source]

Bootstrap the switch matrix for the specified tile.

Using ‘bootstrapSwitchMatrix’ defined in ‘fabric_gen.py’.

Parameters:
  • tileName (str) – Name of the tile for which the switch matrix will be bootstrapped.

  • outputDir (Path) – Directory path where the switch matrix will be generated.

Raises:

ValueError – If tile is not found in fabric.

Return type:

None

genBitStreamSpec()[source]

Generate the bitstream specification object.

Returns:

Bitstream specification object generated by ‘fabricGenerator’.

Return type:

dict

genConfigMem(tileName, configMem)[source]

Generate configuration memory for specified tile.

Parameters:
  • tileName (str) – Name of the tile for which configuration memory will be generated.

  • configMem (Path) – File path where the configuration memory will be saved.

Raises:

ValueError – If tile is not found in fabric.

Return type:

None

genFabric()[source]

Generate the entire fabric layout.

Via ‘generatreFabric’ defined in ‘fabric_gen.py’.

Return type:

None

genFabricIOBels()[source]

Generate the IO BELs for the generative IOs of the fabric.

Return type:

None

genGeometry(geomPadding=8)[source]

Generate geometry based on the fabric data and save it to CSV.

Parameters:

geomPadding (int, optional) – Padding value for geometry generation, by default 8.

Return type:

None

genIOBelForTile(tile_name)[source]

Generate the IO BELs for the generative IOs of a tile.

Config Access Generative IOs will be a separate Bel. Updates the tileDic with the generated IO BELs.

Parameters:

tile_name (str) – Name of the tile to generate IO Bels.

Returns:

The bel object representing the generative IOs.

Return type:

list[Bel]

Raises:

ValueError – If tile not found in fabric. In case of an invalid IO type for generative IOs. If the number of config access ports does not match the number of config bits.

genRoutingModel()[source]

Generate model for Nextpnr based on fabric data.

Returns:

Model generated by ‘model_gen_npnr.genNextpnrModel’.

Return type:

tuple[str, str, str, str]

genSuperTile(tileName)[source]

Generate a super tile based on its name.

Using ‘generateSuperTile’ defined in ‘fabric_gen.py’.

Parameters:

tileName (str) – Name of the super tile generated.

Raises:

ValueError – If super tile is not found in fabric.

Return type:

None

genSwitchMatrix(tileName)[source]

Generate switch matrix for specified tile.

Using ‘genTileSwitchMatrix’ defined in ‘fabric_gen.py’.

Parameters:

tileName (str) – Name of the tile for which the switch matrix will be generated.

Raises:

ValueError – If tile is not found in fabric.

Return type:

None

genTile(tileName)[source]

Generate a tile based on its name.

Using ‘generateTile’ defined in ‘fabric_gen.py’.

Parameters:

tileName (str) – Name of the tile generated.

Raises:

ValueError – If tile is not found in fabric.

Return type:

None

genTopWrapper()[source]

Generate the top wrapper for the fabric.

Using ‘generateTopWrapper’ defined in ‘fabric_gen.py’.

Return type:

None

generateUserDesignTopWrapper(userDesign, topWrapper)[source]

Generate the top wrapper for the user design.

Parameters:
  • userDesign (Path) – Path to the user design file.

  • topWrapper (Path) – Path to the output top wrapper file.

Return type:

None

getBels()[source]

Return all unique Bels within a fabric.

Returns:

List of all unique Bel objects in the fabric.

Return type:

list[Bel]

getSuperTile(tileName, raises_on_miss=False)[source]

Return ‘SuperTile’ object based on ‘tileName’.

Parameters:
  • tileName (str) – Name of the SuperTile.

  • raises_on_miss (bool, optional) – Whether to raise an error if the supertile is not found, by default ‘False’.

Returns:

SuperTile object based on tile name, or None if not found.

Return type:

SuperTile | None

Raises:

KeyError – If the supertile specified by ‘tileName’ is not found and ‘raises_on_miss’ is ‘True’.

getSuperTiles()[source]

Return all SuperTiles within a fabric.

Returns:

Collection of all SuperTile objects in the fabric.

Return type:

Iterable[SuperTile]

getTile(tileName, raises_on_miss=False)[source]

Return ‘Tile’ or ‘SuperTile’ object based on ‘tileName’.

Parameters:
  • tileName (str) – Name of the Tile.

  • raises_on_miss (bool, optional) – Whether to raise an error if the tile is not found, by default ‘False’.

Returns:

‘Tile’ or ‘SuperTile’ object based on tile name, or ‘None’ if not found.

Return type:

Tile | SuperTile | None

Raises:

KeyError – If the tile specified by ‘tileName’ is not found and ‘raises_on_miss’ is ‘True’.

getTiles()[source]

Return all Tiles within a fabric.

Returns:

Collection of all Tile objects in the fabric.

Return type:

Iterable[Tile]

loadFabric(fabric_dir)[source]

Load fabric data from ‘fabric.csv’.

Parameters:

fabric_dir (Path) – Path to CSV file containing fabric data.

Raises:

ValueError – If ‘fabric_dir’ does not end with ‘.csv’

Return type:

None

setWriterOutputFile(outputDir)[source]

Set the output file directory for the write object.

Parameters:

outputDir (Path) – Directory path where output files will be saved.

Return type:

None

Functions