netlist_carpentry.io.read.yosys.read_config
¶
Classes:
ReadConfig
¶
Bases: BaseModel
Methods:
-
yosys_commands–Formats the predefined Yosys script template with the current properties.
-
shell_script–Creates the content for the shell script (setup and yosys commands).
Attributes:
-
files(List[Path]) –A list of paths for readable design files, which Yosys should read.
-
output(Optional[Path]) –The path to the output location, where the resulting generic netlist will be stored.
-
top(Optional[str]) –The top module to set. If None, the top module is auto-selected. Defaults to None.
-
json_path(Optional[Path]) –The path where to save the intermediate JSON netlist. If None, it is only temporarily created and removed afterwards. Defaults to None.
-
techmaps(Optional[List[Path]]) –Any techmaps to apply. Defaults to None, in which case no techmaps are applied.
-
share(ShareStrategy) –Whether Yosys should apply resource-sharing algorithms to simplify circuit size at the (possible) cost of timing.
-
environments(Optional[List[Path]]) –Any additional environments to load. On Linux, this conforms to
source path/to/env -
yosys_plugins(Optional[List[str]]) –Any additional Yosys modules to load when starting Yosys.
-
no_hierarchy(bool) –This property only has an effect if
topis None, in which case a top module would be auto-selected. -
keep_memory_cells(bool) –Whether to keep memory cells (with dedicated address and data ports) or split them down into FFs and MUX trees.
-
insbuf(bool) –Whether to insert buffer cells for directly connected wires. Defaults to True.
-
yosys_executable(str) –The shell command to start Yosys. Defaults to
CFG.yosys_executable, which provides the initially selected Yosys executable. -
read_pass(str) –The formatted Yosys read passes for each file in
ReadConfig.files. -
hierarchy_pass(str) –The formatted Yosys hierarchy pass, depending on
ReadConfig.topandReadConfig.no_hierarchy. -
memory_pass(str) –The formatted Yosys memory pass, with or without
-nomap, depending onReadConfig.keep_memory_cells. -
techmap_pass(str) –The formatted Yosys techmap pass, where each techmap is applied in the order given in
ReadConfig.techmaps. -
share_pass(str) –The formatted Yosys share pass for resource sharing as specified in
ReadConfig.share. -
insbuf_pass(str) –The formatted Yosys insbuf pass which inserts buffers between directly connected wires.
-
environment_activation(str) –The shell commands to activate the given environments.
-
yosys_plugin_str(str) –The formatted string that loads additional Yosys plugins.
files
instance-attribute
¶
A list of paths for readable design files, which Yosys should read.
May contain Verilog, SystemVerilog, JSON and VHDL (if GHDL is installed and loaded). May also contain paths to directories. In this case, each file within the directory must be in one of the mentioned formats.
output
class-attribute
instance-attribute
¶
The path to the output location, where the resulting generic netlist will be stored.
If None, no output file is generated. Does not affect the json_path property however.
If json_path is specified, a JSON netlist will be printed regardless of the value of this property. Defaults to None.
The path suffix (i.e. the file ending) determines whether the netlist is written in JSON, Verilog or SystemVerilog format.
top
class-attribute
instance-attribute
¶
The top module to set. If None, the top module is auto-selected. Defaults to None.
json_path
class-attribute
instance-attribute
¶
The path where to save the intermediate JSON netlist. If None, it is only temporarily created and removed afterwards. Defaults to None.
techmaps
class-attribute
instance-attribute
¶
Any techmaps to apply. Defaults to None, in which case no techmaps are applied.
share
class-attribute
instance-attribute
¶
Whether Yosys should apply resource-sharing algorithms to simplify circuit size at the (possible) cost of timing.
environments
class-attribute
instance-attribute
¶
Any additional environments to load. On Linux, this conforms to source path/to/env
and is executed before Yosys is called. Defaults to None, in which case, no environments are activated.
yosys_plugins
class-attribute
instance-attribute
¶
Any additional Yosys modules to load when starting Yosys.
Common plugins are GHDL and SLang. Loading both can be achieved with yosys_plugins=["ghdl", "slang"].
no_hierarchy
class-attribute
instance-attribute
¶
no_hierarchy: bool = False
This property only has an effect if top is None, in which case a top module would be auto-selected.
Whether to ignore the hierarchy completely. If True, the hierarchy pass is omitted completely. Defaults to False.
keep_memory_cells
class-attribute
instance-attribute
¶
keep_memory_cells: bool = False
Whether to keep memory cells (with dedicated address and data ports) or split them down into FFs and MUX trees.
If True, Yosys will introduce mem_v2 cells whenever it infers a memory unit.
If False, Yosys will map all memory cells to FFs and Mux trees.
insbuf
class-attribute
instance-attribute
¶
insbuf: bool = True
Whether to insert buffer cells for directly connected wires. Defaults to True.
yosys_executable
property
¶
yosys_executable: str
The shell command to start Yosys. Defaults to CFG.yosys_executable, which provides the initially selected Yosys executable.
Defaults of CFG.yosys_executable is yosys, which is normally used to run Yosys.
If Netlist Carpentry is unable to start Yosys via yosys, it falls back to using yowasp-yosys.
read_pass
property
¶
read_pass: str
The formatted Yosys read passes for each file in ReadConfig.files.
hierarchy_pass
property
¶
hierarchy_pass: str
The formatted Yosys hierarchy pass, depending on ReadConfig.top and ReadConfig.no_hierarchy.
memory_pass
property
¶
memory_pass: str
The formatted Yosys memory pass, with or without -nomap, depending on ReadConfig.keep_memory_cells.
techmap_pass
property
¶
techmap_pass: str
The formatted Yosys techmap pass, where each techmap is applied in the order given in ReadConfig.techmaps.
share_pass
property
¶
share_pass: str
The formatted Yosys share pass for resource sharing as specified in ReadConfig.share.
Sharing is disabled if ReadConfig.share is "off".
insbuf_pass
property
¶
insbuf_pass: str
The formatted Yosys insbuf pass which inserts buffers between directly connected wires.
environment_activation
property
¶
environment_activation: str
The shell commands to activate the given environments.
yosys_plugin_str
property
¶
yosys_plugin_str: str
The formatted string that loads additional Yosys plugins.
yosys_commands
¶
yosys_commands() -> str
Formats the predefined Yosys script template with the current properties.
Returns:
-
str(str) –The formatted Yosys script template, so that these commands form a synthesis flow that produces a generic netlist for the current properties of this ReadConfig.
shell_script
¶
Creates the content for the shell script (setup and yosys commands).
This method collects the Yosys command and sets up environments (if given) and loads
Yosys plugins (if specified), before the Yosys commands are written.
The content is only written into a file if a path is given.
Parameters:
-
(path¶Optional[Path], default:None) –The path where to save the script content. If None, it will not be written to a file. Defaults to None.
Returns: