1. Parsers API
This section describes the Parsers API providing public classes and methods to parse OpenFPGA, Yosys and VPR generated output files, as presented in Fig. 1.1.
Fig. 1.1 Output generated files by the OpenFPGA framework, parsed by the OpenFPGA-Softcores platform.
1.1. Yosys Parsers
blif_parser
This Python library parses a Berkeley Logic Interchange Format (BLIF) and Extended BLIF (EBLIF) files, and generate a Python object for convenient use. A BLIF file can contain many models and references to models described in other BLIF files. A model is a flattened hierarchical circuit. For a detailed description of the BLIF file format, see the BLIF documentation.
In this library, the BlifParser object is a list of BlifModel objects.
>>> parser = BlifParser("<blif_filename>")
>>> model = parser[0] # get the first model in the file
>>> model.get_instance("a[0]") # get the instance name of the point "a[0]"
>>> model.get_pin("a[0]") # get the pin name of the point "a[0]"
>>> model.subckts # list() type
>>> model.names # dict() type
>>> model.latches # dict() type
- class parsers.blif_parser.BlifModel(name, **kwargs)
Object to store model properties of a design and its hierarchical elements. For a given point, it returns the equivalent pin name of an element, and the Verilog netlist instance name when the element type is a
.subckt.- Variables
name (str) – Name of the BLIF model.
inputs (list) – All input signals used by the model.
outputs (list) – All output signals used by the model.
names (dict) – All logic-gate (LUT) elements describe in the model.
latches (dict) – All generic-latch elements describe in the model.
subckts (list) – All model-reference elements describe in the model.
conns (dict) – All direct-connection elements describe in the model.
- Parameters
- get_instance(point_name)
Get the Verilog instance name of a
.subcktelement.Note
Works only when the
--cnameoption is enabled when Yosys generates its output BLIF file with thewrite_blifcommand.
- get_pin(point_name, element_type=None)
Get the pin name of any element type.
The point name is composed of the unique output name and the pin input or output of the element. Examples of pin name format according to the element type:
.names: in[#], out[#].latch: D[0], Q[0].subckt: data_out[#], data_in[#], …
- get_pin_latch(point_name)
Get the pin name for a point of a
.latchelement.
- get_pin_names(point_name)
Get the pin name for a point of a
.nameselement.
- class parsers.blif_parser.BlifParser(filename)
Parse a BLIF/EBLIF file (generated by Yosys) using pre-defined regex keywords to create a list of
BlifModelobjects, which describe the full design. If there is only one model in the BLIF file, then the index zero will be used to access it.BLIF primitives supported:
.model,.inputs,.outputs,.names,.latch,.subckt,.cname,.attr,.connBLIF primitives not supported:
.cycle,.clock,.clock_event,.area,.delay,.start_kiss,.end_kiss,.i,.o,.p,.s,.exdc,.mlatch,.latch_order, …- Variables
- Parameters
filename (str) – File name of the BLIF/EBLIF file.
- get_instance(point_name)
Get the Verilog instance name of a point across all subckt.
- get_pin(point_name, element_type=None)
Get the pin name of a point across all models.
yosys_log_parser
- class parsers.yosys_log_parser.YosysLogParser(logger_filename='yosys_output.log', searchdir='run_dir/latest')
Parse Yosys
.logfile to extract the number of signals and cells used to map the design on the FPGA.Data extracted from the Yosys parser:
number of LUTs,
number of internal signals,
number of input signals,
number of output signals,
number of wires,
number of public wires,
number of bits per wires,
number of bits per public wires,
total number of cells,
detailed count per type of cells.
1.2. VPR Parsers
vpr_net_parser
This Python library parses a .net file, generated by the VPR packer.
In this library, the VprNetParser object provides methods to retrieve
Physical Block (PB) information. Since the XML structure could be consequent,
all PB are stored in a Look-Up-Table (LUT) with its associated point to
save execution time.
>>> rpt = VprNetParser("<net-filename>")
>>> rpt.get_block("a.in[0]") # return the Element object having the point 'a'
>>> rpt.get_pin("a.in[0]") # return the pin name of 'in[0]' mapped on the PB
- class parsers.vpr_net_parser.VprNetParser(filename, debug=False)
Parse the XML structure describing the mapping of the benchmark design on the FPGA architecture target. Since this object is use collaboratively with the VPR timing report files, points are used to retrieve the block properties, such as id, hierarchy or pin_name.
startpoints are outputs, listed in the
.placereport,endpoints are inputs, listed in the
.routereport.
- Variables
filename (str) – XML file name to parse.
debug (bool) – Enable the debugging mode.
root (
Element) – object pointing on the XML root instance.pbs (list) – List of Element refering to all Physical Blocks.
lut (dict) – Look-up-table associating of every point name to its Element object for fast-searches.
- Parameters
- get_block(point_name)
Get the block object containing the given point_name.
- get_pin(point_name, block=None)
Get the pin name of block containing the given point_name.
- parsers.vpr_net_parser.pdebug(text, print_mesg=True, prefix='[DEBUG] ', retval=None)
Print a debugging message with the right format and return.
vpr_place_parser
This Python library parses a .place file, generated by the VPR placer.
In this library, the VprPlaceParser object provide a method to retrieve
all physical block position on the FPGA grid.
>>> rpt = VprPlaceParser("<place-filename>")
>>> rpt.get_coordinates("a[0]") # block coordinates containing the point 'a[0]'
>>> rpt.get_coordinates(10) # block coordinates of the block ID #10
- class parsers.vpr_place_parser.VprPlaceParser(filename)
Parse a
.placefile (generated by VPR) to extract block placement. This object save private look-up-table where block ID and point name are used as keys to get the block coordinates on the FPGA grid.- Variables
- Parameters
filename (str) – VPR
.placefile name to parse.
vpr_route_parser
This Python library parses a .route file, generated by the VPR router.
In this library, the VprRouteParser object contains private look-up-table
of Net objects accesible by net name or net identifier keys. Each
Net could be iterate as a list to go through all nodes composing the path.
>>> rpt = VprRouteParser("<route-filename>")
>>> rpt.get_net(100) # Net object, a list of nodes
>>> rpt.get_global_net("clk") # list of block using the global 'clk' net
- class parsers.vpr_route_parser.Net(*args, **kwargs)
Object to store net properties and to manipulate each node as a Python list object.
- Variables
- Parameters
*args – Variable length argument list.
**kwargs – Arbitrary keyword arguments.
- get_route(start, end)
Trace the net path between nodes.
- class parsers.vpr_route_parser.VprRouteParser(filename)
Parse a
.routefile (generated by VPR) to extract node properties.Routing segment keywords:
CHANX : horizontal channel,
CHANY : vertical channel,
IPIN : input pin,
OPIN : output pin,
SINK : sink of a certain input class,
SOURCE : source of a certain output pin class.
- Variables
- Parameters
filename (str) – VPR
.routefile name to parse.
- get_global_net(net_id_or_name)
Get the global net according the net ID or the point name.
- get_net(net_id_or_name)
Get the
Netobject according to the net ID or the point name.
- print_net(net_id_or_name)
List all node in a given net for debugging purpose.
vpr_report_timing_parser
This Python library parses a report timing file, generated by the VPR placer
or router. In this library, the VprReportTimingParser object provides
methods to iterate each Path object, which are a list of point.
rpt = VprReportTimingParser("<rpt-timing-filename>")
for path in rpt.paths: # for each path in the file
for point in path: # for each point in the Path object
print(point) # print the point (dict type)
- class parsers.vpr_report_timing_parser.Path(*args, **kwargs)
Define the
Pathobject to store path properties and manipulate each point composing the path like a Python list object.- Variables
id (int) – Unique path identifier.
startpoint (str) – First point of the path.
endpoint (str) – Last point of the path.
type** (str) – Path type (setup or hold).
arrival_time (float) – Total arrival delay time.
required_time (float) – Total required delay time.
slack_time (float) – Total slack time of the path.
- class parsers.vpr_report_timing_parser.VprReportTimingParser(filename, nb_paths=None)
Parse a report timing file (generated by VPR) to analyze paths and theirs point through which they pass. This object store each
Pathobject like a list item that could be accessed by iteration. When the paths are grouped, this enables to reconstruct the connection tree of each signal in order to perform the routing congestion of the design.Note
All paths in the design are listed thanks to the VPR command option:
--timing_report_npaths -1.- Variables
filename (str) – VPR report timing file name to parse.
nb_paths (int) – Save parsing time by reading the first paths.
fileinfo (dict) – File description and information.
paths (list) – All
Pathlisted in the report timing file.groups (dict) – All group of
Pathhaving the same start point.stats (dict) – Statistics of the paths.
- Parameters
- print_groups(debug=False)
Print path grouped by startpoint, to debug.
- Parameters
debug (bool) – Enable verbose mode.
- print_stats()
Print basic statistic information.
vpr_log_parser
- class parsers.vpr_log_parser.VprLogParser(stats_filename='vpr_stat.result', logger_filename='vpr_stdout.log', searchdir='run_dir/latest')
Parse VPR
.logand.resultfiles to extract place and routing information when the design is mapped on the FPGA.Data extracted from the VPR parser:
Physical Block (PB) types and their occupation ratio,
device grid dimensions,
device (best) channel width,
maximum design frequency,
critical path of the design,
average net length,
average bends per net,
average wire segment per net,
maximum segments used by a net,
total routing area,
total logic block area,
total wire length.