file_parser.py¶
- fabric_generator.file_parser.parseConfigMem(fileName: str, maxFramePerCol: int, frameBitPerRow: int, globalConfigBits: int) List[fabric_generator.fabric.ConfigMem] ¶
Parse the config memory csv file into a list of ConfigMem objects
- Parameters
- Raises
ValueError – Invalid amount of frame entries in the config memory csv file
ValueError – Too many value in bit mask
ValueError – Length of bit mask does not match with the number of frame bits per row
ValueError – Bit mast does not have enough value matching the number of the given config bits
ValueError – repeated config bit entry in ‘:’ separated format in config bit range
ValueError – repeated config bit entry in list format in config bit range
ValueError – Invalid range entry in config bit range
- Returns
_description_
- Return type
List[ConfigMem]
- fabric_generator.file_parser.parseFabricCSV(fileName: str) fabric_generator.fabric.Fabric ¶
Pares a csv file and returns a fabric object.
- Parameters
fileName (str) – the directory of the csv file.
- Raises
ValueError – File provide need to be a csv file.
ValueError – The csv file does not exist.
ValueError – Cannot find the FabricBegin and FabricEnd region.
ValueError – Cannot find the ParametersBegin and ParametersEnd region.
ValueError – The bel entry extension can only be “.v” or “.vhdl”.
ValueError – The matrix entry extension can only be “.list”, “.csv”, “.v” or “.vhdl”.
ValueError – Unknown tile description entry in csv file.
ValueError – Unknown tile in the fabric entry in csv file.
ValueError – Unknown super tile in the super tile entry in csv file.
ValueError – Invalid ConfigBitMode in parameter entry in csv file.
ValueError – Invalid MultiplexerStyle in parameter entry in csv file.
ValueError – Invalid parameter entry in csv file.
- Returns
The fabric object.
- Return type
- fabric_generator.file_parser.parseFileVHDL(filename: str, belPrefix: str = '') Tuple[List[Tuple[str, fabric_generator.fabric.IO]], List[Tuple[str, fabric_generator.fabric.IO]], List[Tuple[str, fabric_generator.fabric.IO]], List[Tuple[str, fabric_generator.fabric.IO]], int, bool, Dict[str, int]] ¶
Parse a VHDL bel file and return all the related information of the bel. The tuple returned for relating to ports will be a list of (belName, IO) pair.
For further example of bel mapping please look at parseFileVerilog
- Parameters
- Raises
ValueError – File not found
ValueError – No permission to access the file
ValueError – Cannot find the port section in the file which defines the bel ports.
- Returns
Bel internal ports, bel external ports, bel config ports, bel shared ports, number of configuration bit in the bel, whether the bel have UserCLK, and the bel config bit mapping.
- Return type
Tuple[List[Tuple[str, IO]], List[Tuple[str, IO]], List[Tuple[str, IO]], List[Tuple[str, IO]], int, bool, Dict[str, int]]
- fabric_generator.file_parser.parseFileVerilog(filename: str, belPrefix: str = '') Tuple[List[Tuple[str, fabric_generator.fabric.IO]], List[Tuple[str, fabric_generator.fabric.IO]], List[Tuple[str, fabric_generator.fabric.IO]], List[Tuple[str, fabric_generator.fabric.IO]], int, bool, Dict[str, Dict]] ¶
Parse a Verilog bel file and return all the related information of the bel. The tuple returned for relating to ports will be a list of (belName, IO) pair.
The function will also parse and record all the FABulous attribute which all starts with
(* FABulous, <type>, ... *)
The <type> can be one the following:
BelMap
EXTERNAL
SHARED_PORT
GLOBAL
CONFIG_PORT
The BelMap attribute will specify the bel mapping for the bel. This attribute should be placed before the start of the module The bel mapping is then used for generating the bitstream specification. Each of the entry in the attribute will have the following format:
<name> = <value>
<name>
is the name of the feature and<value>
will be the bit position of the feature. ie.INIT=0
will specify that the featureINIT
is located at bit 0. Since a single feature can be mapped to multiple bits, this is currently done by specifying multiple entries for the same feature. This will be changed in the future. The bit specification is done in the following way:INIT_a_1=1, INIT_a_2=2, ...
The name of the feature will be converted to
INIT_a[1]
,INIT_a[2]
for the above example. This is necessary because Verilog does not allow square brackets as part of the attribute name.EXTERNAL attribute will notify FABulous to put the pin in the top module during the fabric generation.
SHARED_PORT attribute will notify FABulous this the pin is shared between multiple bels. Attribute need to go with the EXTERNAL attribute.
GLOBAL attribute will notify FABulous to stop parsing any pin after this attribute.
CONFIG_PORT attribute will notify FABulous the port is for configuration.
Example
(* FABulous, BelMap, single_bit_feature=0, //single bit feature, single_bit_feature=0 multiple_bits_0=1, //multiple bit feature bit0, multiple_bits[0]=1 multiple_bits_1=2 //multiple bit feature bit1, multiple_bits[1]=2 *) module exampleModule (externalPin, normalPin1, normalPin2, sharedPin, globalPin); (* FABulous, EXTERNAL *) input externalPin; input normalPin; (* FABulous, EXTERNAL, SHARED_PORT *) input sharedPin; (* FABulous, GLOBAL) input globalPin; output normalPin2; //do not get parsed ...
- Parameters
- Raises
ValueError – File not found
ValueError – No permission to access the file
- Returns
Bel internal ports, bel external ports, bel config ports, bel shared ports, number of configuration bit in the bel, whether the bel have UserCLK, and the bel config bit mapping.
- Return type
Tuple[List[Tuple[str, IO]], List[Tuple[str, IO]], List[Tuple[str, IO]], List[Tuple[str, IO]], int, bool, Dict[str, Dict]]
-
fabric_generator.file_parser.parseList(fileName: str, collect: Literal[
'pair'] = 'pair') List[Tuple[str, str]] ¶ -
fabric_generator.file_parser.parseList(fileName: str, collect: Literal[
'source','sink']) Dict[str, List[str]] parse a list file and expand the list file information into a list of tuples.
- Parameters
fileName (str) –
””
collect (Literal["", "source", "sink"], optional) – Collect value by source, sink or just as pair. Defaults to “pair”.
- Raises
ValueError – The file does not exist.
ValueError – Invalid format in the list file.
- Returns
Return either a list of connection pair or a dictionary of lists which is collected by the specified option, source or sink.
- Return type
- fabric_generator.file_parser.parseMatrix(fileName: str, tileName: str) Dict[str, List[str]] ¶
parse the matrix csv into a dictionary from destination to source
- Parameters
- Raises
ValueError – Non matching matrix file content and tile name
- Returns
dictionary from destination to a list of source
- Return type