2. Schema API#
This chapter describes all public methods in the SiliconCompiler Schema Python API. Refer to the User Guide for architecture concepts and the glossary for terminology and keyword definitions.
2.1. Useful APIs#
Base schema:
Sets a schema parameter field. |
|
Adds item(s) to a schema parameter list. |
|
Returns a parameter field from the schema. |
|
Returns a tuple of schema dictionary keys. |
|
Returns a schema dictionary. |
|
Checks validity of a keypath. |
|
Unsets a schema parameter. |
|
Remove a schema parameter and its subparameters. |
|
Writes the manifest to a file. |
|
Reads a manifest from disk and replaces the current data with the data in the file. |
|
Create a new schema based on the provided source files. |
Editing schema:
Inserts a |
|
Removes a keypath from the schema. |
|
Finds an item in the schema. |
2.2. Project Classes#
- class siliconcompiler.project.Project(design: Design | str | None = None)[source]#
Bases:
PathSchemaBase,CommandLineSchema,BaseSchemaThe Project class is the core object in SiliconCompiler, representing a complete hardware design project. It manages design parameters, libraries, flowgraphs, metrics, and provides methods for compilation, data collection, and reporting.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_alias(src_dep: Design | str, src_fileset: str, alias_dep: Design | str, alias_fileset: str, clobber: bool = False)[source]#
Adds an aliased fileset mapping to the project.
This method allows you to redirect a fileset reference from a source library/fileset to a different destination library/fileset. This is useful for substituting design components or test environments without modifying the original design.
- Parameters:
src_dep (Union[Design, str]) – The source design library (object or name) from which the fileset is being aliased.
src_fileset (str) – The name of the source fileset to alias.
alias_dep (Union[Design, str]) – The destination design library (object or name) to which the fileset is being redirected. Can be None or an empty string to indicate deletion.
alias_fileset (str) – The name of the destination fileset. Can be None or an empty string to indicate deletion of the fileset reference.
clobber (bool) – If True, any existing alias for (src_dep, src_fileset) will be overwritten. If False, the alias will be added. Defaults to False.
- Raises:
TypeError – If src_dep or alias_dep are not valid types (string or Design).
KeyError – If alias_dep is a string but the corresponding library is not loaded.
ValueError – If src_fileset is not found in src_dep, or if alias_fileset is not found in alias_dep (when alias_fileset is not None).
- add_dep(obj)[source]#
Adds a dependency object (e.g., a Design, Flowgraph, or Checklist) to the project.
This method intelligently adds various types of schema objects to the project’s internal structure. It also handles recursive addition of dependencies if the added object itself is a DependencySchema.
- add_fileset(fileset: List[str] | str, clobber: bool = False)[source]#
Adds one or more filesets to be used in this project.
Filesets are collections of related files within a design. This method allows you to specify which filesets from the selected design library should be included in the current project context.
- Parameters:
fileset (Union[List[str], str]) – The name(s) of the fileset(s) to add. Can be a single string or a list of strings.
clobber (bool) – If True, existing filesets will be replaced by the new ones. If False, new filesets will be added to the existing list. Defaults to False.
- Raises:
TypeError – If fileset is not a string or a list/tuple/set of strings.
ValueError – If any of the specified filesets are not found in the currently selected design.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- check_filepaths(ignore_keys: List[Tuple[str, ...]] | None = None) bool[source]#
Verifies that paths to all files in manifest are valid.
- Parameters:
ignore_keys (list of keypaths) – list of keypaths to ignore while checking
- Returns:
True if all file paths are valid, otherwise False.
- check_manifest() bool[source]#
Performs a comprehensive check of the project’s manifest (configuration) for consistency and validity.
This method verifies that essential options like ‘design’, ‘fileset’, and ‘flow’ are properly set. It also checks if the specified design and flowgraph are loaded, and if filesets within the selected design are valid and have a top module defined. Additionally, it validates any defined fileset aliases, ensuring that source and destination libraries and filesets exist. Error messages are logged for any detected inconsistencies.
- Returns:
True if the manifest is valid and all checks pass, False otherwise.
- Return type:
bool
- classmethod convert(obj: Project) TProject[source]#
Converts a project from one type to another (e.g., Project to Sim).
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod create_cmdline(progname: str | None = None, description: str | None = None, switchlist: List[str] | Set[str] | None = None, version: str | None = None, print_banner: bool = True, use_cfg: bool = False, use_sources: bool = True) TCmdSchema[source]#
Creates an SC command line interface.
Exposes parameters in the SC schema as command line switches, simplifying creation of SC apps with a restricted set of schema parameters exposed at the command line. The order of command line switch settings parsed from the command line is as follows:
read_manifest (-cfg), if specified by use_cfg
read commandline inputs
all other switches
The cmdline interface is implemented using the Python argparse package and the following use restrictions apply.
Help is accessed with the ‘-h’ switch.
Arguments that include spaces must be enclosed with double quotes.
List parameters are entered individually. (ie. -y libdir1 -y libdir2)
For parameters with Boolean types, the switch implies “true”.
Special characters (such as ‘-’) must be enclosed in double quotes.
- Parameters:
progname (str) – Name of program to be executed.
description (str) – Short program description.
switchlist (list of str) – List of SC parameter switches to expose at the command line. By default all SC schema switches are available. Parameter switches should be entered based on the parameter ‘switch’ field in the schema. For parameters with multiple switches, both will be accepted if any one is included in this list.
version (str) – version of this program.
print_banner (bool) – if True, will print the siliconcompiler banner
use_cfg (bool) – if True, add and parse the -cfg flag
use_sources (bool) – if True, add positional arguments for files
- Returns:
new project object
Examples
>>> schema.create_cmdline(progname='sc-show',switchlist=['-input','-cfg']) Creates a command line interface for 'sc-show' app.
>>> schema.create_cmdline(progname='sc')
- property design: Design#
Returns the design object associated with the project.
- Returns:
The Design schema object for the current project.
- Return type:
- Raises:
ValueError – If the design name is not set.
KeyError – If the design has not been loaded into the project’s libraries.
- find_files(*keypath: str, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) List[str | None] | str | None[source]#
Returns absolute paths to files or directories based on the keypath provided.
The keypath provided must point to a schema parameter of type file, dir, or lists of either. Otherwise, it will trigger an error.
- Parameters:
keypath (list of str) – Variable length schema key list.
missing_ok (bool) – If True, silently return None when files aren’t found. If False, print an error and set the error flag.
step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
If keys points to a scalar entry, returns an absolute path to that file/directory, or None if not found. It keys points to a list entry, returns a list of either the absolute paths or None for each entry, depending on whether it is found.
Examples
>>> schema.find_files('input', 'verilog') Returns a list of absolute paths to source files, as specified in the schema.
- find_result(filetype: str = None, step: str = None, index: str = '0', directory: str = 'outputs', filename: str = None) str[source]#
Returns the absolute path of a compilation result file.
This utility function constructs and returns the absolute path to a result file based on the provided arguments. The typical result directory structure is: <build_dir>/<design_name>/<job_name>/<step>/<index>/<directory>/<design>.<filetype>
- Parameters:
filetype (str, optional) – The file extension (e.g., ‘v’, ‘def’, ‘gds’). Required if filename is not provided.
step (str) – The name of the task step (e.g., ‘syn’, ‘place’). Required.
index (str, optional) – The task index within the step. Defaults to “0”.
directory (str, optional) – The node directory within the step to search (e.g., ‘outputs’, ‘reports’). Defaults to “outputs”.
filename (str, optional) – The exact filename to search for. If provided, filetype is ignored for constructing the path. Defaults to None.
- Returns:
The absolute path to the found file, or None if the file is not found.
- Return type:
str
- Raises:
ValueError – If step is not provided, or if [option,fileset] is not set when filename is not provided.
Examples
>>> # Get path to gate-level Verilog from synthesis step >>> vg_filepath = project.find_result('vg', step='syn')
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_filesets() List[Tuple[NamedSchema, str]][source]#
Returns the filesets selected for this project, resolving any aliases.
This method retrieves the filesets defined in
[option,fileset]and applies any aliases specified in[option,alias]to return the effective list of filesets and their parent libraries.- Returns:
A list of tuples, where each tuple contains the parent library (NamedSchema) and the fileset name (str).
- Return type:
List[Tuple[NamedSchema, str]]
- Raises:
KeyError – If an alias points to a library that is not loaded.
- get_flow(name: str | None = None) Flowgraph[source]#
Retrieves a flowgraph by name.
- Parameters:
name (str, optional) – The name of the flowgraph to retrieve. If None, retrieves the currently selected flowgraph.
- Returns:
The Flowgraph object corresponding to the specified name.
- Return type:
- Raises:
KeyError – If the specified flowgraph is not found in the project.
- get_library(library: str) NamedSchema[source]#
Retrieves a library by name from the project.
- Parameters:
library (str) – The name of the library to retrieve.
- Returns:
The NamedSchema object representing the library.
- Return type:
- Raises:
KeyError – If the specified library is not found in the project.
TypeError – If the provided library is not a string.
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- hash_files(*keypath: str, update: bool = True, check: bool = True, verbose: bool = True, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) str | None | List[str | None][source]#
Generates hash values for a list of parameter files.
Generates a hash value for each file found in the keypath. If existing hash values are stored, this method will compare hashes and trigger an error if there’s a mismatch. If the update variable is True, the computed hash values are recorded in the ‘filehash’ field of the parameter, following the order dictated by the files within the ‘value’ parameter field.
Files are located using the find_files() function.
The file hash calculation is performed based on the ‘algo’ setting. Supported algorithms include SHA1, SHA224, SHA256, SHA384, SHA512, and MD5.
- Parameters:
*keypath (str) – Keypath to parameter.
update (bool) – If True, the hash values are recorded in the project object manifest.
check (bool) – If True, checks the newly computed hash against the stored hash.
verbose (bool) – If True, generates log messages.
allow_cache (bool) – If True, hashing check the cached values for specific files, if found, it will use that hash value otherwise the hash will be computed.
skip_missing (bool) – If True, hashing will be skipped when missing files are detected.
- Returns:
A list of hash values.
Examples
>>> hashlist = hash_files('input', 'rtl', 'verilog') Computes, stores, and returns hashes of files in :keypath:`input, rtl, verilog`.
- history(job: str) Project[source]#
Returns a mutable reference to a historical job record as a Project object.
- Parameters:
job (str) – Name of the historical job to retrieve.
- Returns:
The Project object representing the specified historical job.
- Return type:
- Raises:
KeyError – If the specified job does not exist in the history.
- property logger: Logger#
Returns the logger for this project.
- Returns:
The project-specific logger instance.
- Return type:
logging.Logger
- property name: str#
Returns the name of the design.
- Returns:
The name of the top-level design.
- Return type:
str
- property option: OptionSchema#
Provides access to the top-level options schema.
This property is the entry point for configuring global and job-specific parameters that control the compiler’s behavior, such as flow control, logging, and build settings.
- Returns:
The schema object for top-level options.
- Return type:
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- run() TProject[source]#
Executes the compilation flow defined in the project’s flowgraph.
The run method orchestrates the entire compilation process. It starts by initializing the dashboard and then hands off execution to a Scheduler (or ClientScheduler for remote runs). The scheduler manages the step-by-step execution of tasks defined in the flowgraph, respecting dependencies and handling errors.
After the scheduler completes, the dashboard is updated with the final run status, and non-global job parameters are reset. The method returns a Project object representing the completed job’s history.
- Returns:
- A mutable reference to the completed job’s record in the
project history.
- Return type:
Examples
>>> project.run() # Executes the flow, and returns a project object for the completed job.
- set(*args, field='value', clobber=True, step=None, index=None)[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_design(design: Design | str)[source]#
Sets the active design for this project.
This method allows you to specify the primary design that the project will operate on. If a Design object is provided, it is first added as a dependency.
- Parameters:
design (Union[Design, str]) – The design object or its name (string) to be set as the current design.
- Raises:
TypeError – If the provided design is not a string or a Design object.
- set_flow(flow: Flowgraph | str)[source]#
Sets the active flowgraph for this project.
This method allows you to specify the sequence of steps and tasks (the flow) that the project will execute. If a Flowgraph object is provided, it is first added as a dependency.
- Parameters:
flow (Union[Flowgraph, str]) – The flowgraph object or its name (string) to be set as the current flow.
- Raises:
TypeError – If the provided flow is not a string or a Flowgraph object.
- show(filename: str | None = None, screenshot: bool = False, extension: str | None = None, tool: str | None = None, open: bool = False) str[source]#
Opens a graphical viewer for a specified file or the last generated layout.
The show function identifies an appropriate viewer tool based on the file’s extension and the registered showtools. Display settings and technology-specific viewing configurations are read from the project’s in-memory schema. All temporary rendering and display files are stored in a dedicated _show_<jobname> directory within the build directory.
If no filename is provided, the method attempts to automatically find the last generated layout file in the build directory based on supported extensions from registered showtools.
- Parameters:
filename (str, optional) – The path to the file to display. If None, the system attempts to find the most recent layout file. Defaults to None.
screenshot (bool) – If True, the operation is treated as a screenshot request, using ScreenshotTask instead of ShowTask. Defaults to False.
extension (str, optional) – The specific file extension to search for when automatically finding a file (e.g., ‘gds’, ‘lef’). Used only if filename is None. Defaults to None.
tool (str, optional) – The name of the specific showtool to use for displaying the file. If not provided, the tool is selected based on the file extension.
open (bool) – If True, the file is opened with an OpenTask (e.g. an interactive tool session) instead of being rendered with a ShowTask. Mutually exclusive with screenshot. Defaults to False.
- Returns:
- The path to the generated screenshot file if screenshot is True,
otherwise None.
- Return type:
str
Examples
>>> # Display a specific GDS file >>> project.show('build/my_design/job0/write_gds/0/outputs/my_design.gds')
>>> # Automatically find and show the last generated layout >>> project.show()
- snapshot(path: str = None, jobname: str = None, display: bool = True) None[source]#
Creates a snapshot image summarizing a job’s progress and key information.
This function generates a PNG image that provides a visual overview of the compilation job.
- Parameters:
path (str, optional) – The file path where the snapshot image should be saved. If not provided, it defaults to <job_directory>/<design_name>.png.
jobname (str, optional) – The job to snapshot. If not provided, the value in
[option,jobname]will be used.display (bool, optional) – If True, the generated image will be opened for viewing if the system supports it and option,nodisplay is False. Defaults to True.
- Raises:
ValueError – If there is no history to snapshot.
Examples
>>> project.snapshot() # Creates a snapshot image in the default location for the last run.
- summary(jobname: str = None, fd: TextIO = None) None[source]#
Prints a summary of the compilation manifest and results.
Metrics from the specified job are printed out on a per-step basis.
- Parameters:
jobname (str, optional) – The name of the job to summarize. If not provided, the value in
[option,jobname]will be used.fd (TextIO, optional) – If provided, prints the summary to this file descriptor instead of stdout.
- Raises:
ValueError – If there is no history to summarize.
Examples
>>> project.summary() # Prints a summary of the last run to stdout.
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- write_depgraph(filename: str, fontcolor: str = '#000000', background: str = 'transparent', fontsize: str = '14', border: bool = True, landscape: bool = False) None[source]#
Renders and saves the configured fileset dependency graph to a file.
Shows the project’s design and its configured filesets, with any aliases resolved and reflected in the graph.
- Parameters:
filename (filepath) – Output filepath.
fontcolor (str) – Node font RGB color hex value.
background (str) – Background color.
fontsize (str) – Node text font size.
border (bool) – Enables node border if True.
landscape (bool) – Renders graph in landscape layout if True.
Examples
>>> project.write_depgraph('mydump.png') Renders the fileset dependency graph and writes the result to a png file.
- class siliconcompiler.ASIC(design=None)[source]#
Bases:
ProjectThe ASIC class extends the base Project class to provide specialized functionality and schema parameters for Application-Specific Integrated Circuit (ASIC) design flows.
It includes specific constraints (timing, component, pin, area) and ASIC-related options such as PDK selection, main logic library, additional ASIC libraries, delay models, and routing layer limits.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_alias(src_dep: Design | str, src_fileset: str, alias_dep: Design | str, alias_fileset: str, clobber: bool = False)[source]#
Adds an aliased fileset mapping to the project.
This method allows you to redirect a fileset reference from a source library/fileset to a different destination library/fileset. This is useful for substituting design components or test environments without modifying the original design.
- Parameters:
src_dep (Union[Design, str]) – The source design library (object or name) from which the fileset is being aliased.
src_fileset (str) – The name of the source fileset to alias.
alias_dep (Union[Design, str]) – The destination design library (object or name) to which the fileset is being redirected. Can be None or an empty string to indicate deletion.
alias_fileset (str) – The name of the destination fileset. Can be None or an empty string to indicate deletion of the fileset reference.
clobber (bool) – If True, any existing alias for (src_dep, src_fileset) will be overwritten. If False, the alias will be added. Defaults to False.
- Raises:
TypeError – If src_dep or alias_dep are not valid types (string or Design).
KeyError – If alias_dep is a string but the corresponding library is not loaded.
ValueError – If src_fileset is not found in src_dep, or if alias_fileset is not found in alias_dep (when alias_fileset is not None).
- add_asiclib(library: StdCellLibrary | str, clobber: bool = False)[source]#
Adds one or more ASIC logic libraries to be used in the project.
These libraries are typically used for optimization during the ASIC flow, complementing the main library.
- Parameters:
library (Union[StdCellLibrary, str]) – The standard cell library object or its name (string) to add.
clobber (bool) – If True, existing ASIC libraries will be replaced by the new ones. If False, new libraries will be added to the existing list. Defaults to False.
- Returns:
The result of adding the parameter to the schema.
- Return type:
Any
- Raises:
TypeError – If the provided library is not a string or a StdCellLibrary object.
- add_dep(obj)[source]#
Adds a dependency object to the ASIC project, with specialized handling for PDK and standard cell libraries.
This method extends the base Project.add_dep functionality. If the object is a StdCellLibrary or PDK, it is inserted into the project’s library schema, potentially clobbering existing entries. For other dependency types, it defers to the parent class’s add_dep method. It also ensures that internal dependencies are imported.
- Parameters:
(Union[ (obj) – StdCellLibrary, PDK, Design, Flowgraph, Checklist, List, Set, Tuple
]) – The dependency object(s) to add.
- add_fileset(fileset: List[str] | str, clobber: bool = False)[source]#
Adds one or more filesets to be used in this project.
Filesets are collections of related files within a design. This method allows you to specify which filesets from the selected design library should be included in the current project context.
- Parameters:
fileset (Union[List[str], str]) – The name(s) of the fileset(s) to add. Can be a single string or a list of strings.
clobber (bool) – If True, existing filesets will be replaced by the new ones. If False, new filesets will be added to the existing list. Defaults to False.
- Raises:
TypeError – If fileset is not a string or a list/tuple/set of strings.
ValueError – If any of the specified filesets are not found in the currently selected design.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- check_filepaths(ignore_keys: List[Tuple[str, ...]] | None = None) bool[source]#
Verifies that paths to all files in manifest are valid.
- Parameters:
ignore_keys (list of keypaths) – list of keypaths to ignore while checking
- Returns:
True if all file paths are valid, otherwise False.
- check_manifest() bool[source]#
Performs a comprehensive check of the ASIC project’s manifest for consistency and validity, extending the base Project checks.
This method first calls the
Project.check_manifest()method. Then, it performs additional ASIC-specific validations:Asserts that
[asic,pdk]is set and refers to a loaded PDK library.Checks if
[asic,mainlib]is set and refers to a loaded library (warns if not set).Asserts that
[asic,asiclib]contains at least one library and all listed libraries are loaded.Ensures that the mainlib is included in the asiclib list if both are set.
Asserts that
[asic,delaymodel]is set.
- Returns:
True if the manifest is valid and all checks pass, False otherwise.
- Return type:
bool
- property constraint: ASICConstraint#
Provides access to the project’s ASIC design constraints.
- Returns:
The schema object containing all design constraints.
- Return type:
- classmethod convert(obj: Project) TProject[source]#
Converts a project from one type to another (e.g., Project to Sim).
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod create_cmdline(progname: str | None = None, description: str | None = None, switchlist: List[str] | Set[str] | None = None, version: str | None = None, print_banner: bool = True, use_cfg: bool = False, use_sources: bool = True) TCmdSchema[source]#
Creates an SC command line interface.
Exposes parameters in the SC schema as command line switches, simplifying creation of SC apps with a restricted set of schema parameters exposed at the command line. The order of command line switch settings parsed from the command line is as follows:
read_manifest (-cfg), if specified by use_cfg
read commandline inputs
all other switches
The cmdline interface is implemented using the Python argparse package and the following use restrictions apply.
Help is accessed with the ‘-h’ switch.
Arguments that include spaces must be enclosed with double quotes.
List parameters are entered individually. (ie. -y libdir1 -y libdir2)
For parameters with Boolean types, the switch implies “true”.
Special characters (such as ‘-’) must be enclosed in double quotes.
- Parameters:
progname (str) – Name of program to be executed.
description (str) – Short program description.
switchlist (list of str) – List of SC parameter switches to expose at the command line. By default all SC schema switches are available. Parameter switches should be entered based on the parameter ‘switch’ field in the schema. For parameters with multiple switches, both will be accepted if any one is included in this list.
version (str) – version of this program.
print_banner (bool) – if True, will print the siliconcompiler banner
use_cfg (bool) – if True, add and parse the -cfg flag
use_sources (bool) – if True, add positional arguments for files
- Returns:
new project object
Examples
>>> schema.create_cmdline(progname='sc-show',switchlist=['-input','-cfg']) Creates a command line interface for 'sc-show' app.
>>> schema.create_cmdline(progname='sc')
- property design: Design#
Returns the design object associated with the project.
- Returns:
The Design schema object for the current project.
- Return type:
- Raises:
ValueError – If the design name is not set.
KeyError – If the design has not been loaded into the project’s libraries.
- find_files(*keypath: str, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) List[str | None] | str | None[source]#
Returns absolute paths to files or directories based on the keypath provided.
The keypath provided must point to a schema parameter of type file, dir, or lists of either. Otherwise, it will trigger an error.
- Parameters:
keypath (list of str) – Variable length schema key list.
missing_ok (bool) – If True, silently return None when files aren’t found. If False, print an error and set the error flag.
step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
If keys points to a scalar entry, returns an absolute path to that file/directory, or None if not found. It keys points to a list entry, returns a list of either the absolute paths or None for each entry, depending on whether it is found.
Examples
>>> schema.find_files('input', 'verilog') Returns a list of absolute paths to source files, as specified in the schema.
- find_result(filetype: str = None, step: str = None, index: str = '0', directory: str = 'outputs', filename: str = None) str[source]#
Returns the absolute path of a compilation result file.
This utility function constructs and returns the absolute path to a result file based on the provided arguments. The typical result directory structure is: <build_dir>/<design_name>/<job_name>/<step>/<index>/<directory>/<design>.<filetype>
- Parameters:
filetype (str, optional) – The file extension (e.g., ‘v’, ‘def’, ‘gds’). Required if filename is not provided.
step (str) – The name of the task step (e.g., ‘syn’, ‘place’). Required.
index (str, optional) – The task index within the step. Defaults to “0”.
directory (str, optional) – The node directory within the step to search (e.g., ‘outputs’, ‘reports’). Defaults to “outputs”.
filename (str, optional) – The exact filename to search for. If provided, filetype is ignored for constructing the path. Defaults to None.
- Returns:
The absolute path to the found file, or None if the file is not found.
- Return type:
str
- Raises:
ValueError – If step is not provided, or if [option,fileset] is not set when filename is not provided.
Examples
>>> # Get path to gate-level Verilog from synthesis step >>> vg_filepath = project.find_result('vg', step='syn')
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_filesets() List[Tuple[NamedSchema, str]][source]#
Returns the filesets selected for this project, resolving any aliases.
This method retrieves the filesets defined in
[option,fileset]and applies any aliases specified in[option,alias]to return the effective list of filesets and their parent libraries.- Returns:
A list of tuples, where each tuple contains the parent library (NamedSchema) and the fileset name (str).
- Return type:
List[Tuple[NamedSchema, str]]
- Raises:
KeyError – If an alias points to a library that is not loaded.
- get_flow(name: str | None = None) Flowgraph[source]#
Retrieves a flowgraph by name.
- Parameters:
name (str, optional) – The name of the flowgraph to retrieve. If None, retrieves the currently selected flowgraph.
- Returns:
The Flowgraph object corresponding to the specified name.
- Return type:
- Raises:
KeyError – If the specified flowgraph is not found in the project.
- get_library(library: str) NamedSchema[source]#
Retrieves a library by name from the project.
- Parameters:
library (str) – The name of the library to retrieve.
- Returns:
The NamedSchema object representing the library.
- Return type:
- Raises:
KeyError – If the specified library is not found in the project.
TypeError – If the provided library is not a string.
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- hash_files(*keypath: str, update: bool = True, check: bool = True, verbose: bool = True, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) str | None | List[str | None][source]#
Generates hash values for a list of parameter files.
Generates a hash value for each file found in the keypath. If existing hash values are stored, this method will compare hashes and trigger an error if there’s a mismatch. If the update variable is True, the computed hash values are recorded in the ‘filehash’ field of the parameter, following the order dictated by the files within the ‘value’ parameter field.
Files are located using the find_files() function.
The file hash calculation is performed based on the ‘algo’ setting. Supported algorithms include SHA1, SHA224, SHA256, SHA384, SHA512, and MD5.
- Parameters:
*keypath (str) – Keypath to parameter.
update (bool) – If True, the hash values are recorded in the project object manifest.
check (bool) – If True, checks the newly computed hash against the stored hash.
verbose (bool) – If True, generates log messages.
allow_cache (bool) – If True, hashing check the cached values for specific files, if found, it will use that hash value otherwise the hash will be computed.
skip_missing (bool) – If True, hashing will be skipped when missing files are detected.
- Returns:
A list of hash values.
Examples
>>> hashlist = hash_files('input', 'rtl', 'verilog') Computes, stores, and returns hashes of files in :keypath:`input, rtl, verilog`.
- history(job: str) Project[source]#
Returns a mutable reference to a historical job record as a Project object.
- Parameters:
job (str) – Name of the historical job to retrieve.
- Returns:
The Project object representing the specified historical job.
- Return type:
- Raises:
KeyError – If the specified job does not exist in the history.
- property logger: Logger#
Returns the logger for this project.
- Returns:
The project-specific logger instance.
- Return type:
logging.Logger
- property name: str#
Returns the name of the design.
- Returns:
The name of the top-level design.
- Return type:
str
- property option: OptionSchema#
Provides access to the top-level options schema.
This property is the entry point for configuring global and job-specific parameters that control the compiler’s behavior, such as flow control, logging, and build settings.
- Returns:
The schema object for top-level options.
- Return type:
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- run() TProject[source]#
Executes the compilation flow defined in the project’s flowgraph.
The run method orchestrates the entire compilation process. It starts by initializing the dashboard and then hands off execution to a Scheduler (or ClientScheduler for remote runs). The scheduler manages the step-by-step execution of tasks defined in the flowgraph, respecting dependencies and handling errors.
After the scheduler completes, the dashboard is updated with the final run status, and non-global job parameters are reset. The method returns a Project object representing the completed job’s history.
- Returns:
- A mutable reference to the completed job’s record in the
project history.
- Return type:
Examples
>>> project.run() # Executes the flow, and returns a project object for the completed job.
- set(*args, field='value', clobber=True, step=None, index=None)[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_asic_delaymodel(model: str)[source]#
Set the timing delay model used for ASIC timing analysis.
- Parameters:
model (str) – Delay model name (e.g., “nldm”, “ccs”).
- set_asic_routinglayers(min: str = None, max: str = None)[source]#
Sets the minimum and/or maximum metal layers to be used for automated place and route in the ASIC flow.
- Parameters:
min (str, optional) – The name of the minimum metal layer (e.g., ‘M2’). Defaults to None.
max (str, optional) – The name of the maximum metal layer (e.g., ‘M7’). Defaults to None.
- set_design(design: Design | str)[source]#
Sets the active design for this project.
This method allows you to specify the primary design that the project will operate on. If a Design object is provided, it is first added as a dependency.
- Parameters:
design (Union[Design, str]) – The design object or its name (string) to be set as the current design.
- Raises:
TypeError – If the provided design is not a string or a Design object.
- set_flow(flow: Flowgraph | str)[source]#
Sets the active flowgraph for this project.
This method allows you to specify the sequence of steps and tasks (the flow) that the project will execute. If a Flowgraph object is provided, it is first added as a dependency.
- Parameters:
flow (Union[Flowgraph, str]) – The flowgraph object or its name (string) to be set as the current flow.
- Raises:
TypeError – If the provided flow is not a string or a Flowgraph object.
- set_mainlib(library: StdCellLibrary | str)[source]#
Sets the main standard cell library for the ASIC project.
This library is typically the primary logic library used during the ASIC flow. If a StdCellLibrary object is provided, it is first added as a dependency.
- Parameters:
library (Union[StdCellLibrary, str]) – The standard cell library object or its name (string) to be set as the main library.
- Returns:
The result of setting the parameter in the schema.
- Return type:
Any
- Raises:
TypeError – If the provided library is not a string or a StdCellLibrary object.
- set_pdk(pdk: PDK | str)[source]#
Sets the Process Design Kit (PDK) for the ASIC project.
The PDK defines the technology-specific information required for ASIC compilation. If a PDK object is provided, it is first added as a dependency.
- Parameters:
pdk (Union[PDK, str]) – The PDK object or its name (string) to be set as the project’s PDK.
- Returns:
The result of setting the parameter in the schema.
- Return type:
Any
- Raises:
TypeError – If the provided pdk is not a string or a PDK object.
- show(filename: str | None = None, screenshot: bool = False, extension: str | None = None, tool: str | None = None, open: bool = False) str[source]#
Opens a graphical viewer for a specified file or the last generated layout.
The show function identifies an appropriate viewer tool based on the file’s extension and the registered showtools. Display settings and technology-specific viewing configurations are read from the project’s in-memory schema. All temporary rendering and display files are stored in a dedicated _show_<jobname> directory within the build directory.
If no filename is provided, the method attempts to automatically find the last generated layout file in the build directory based on supported extensions from registered showtools.
- Parameters:
filename (str, optional) – The path to the file to display. If None, the system attempts to find the most recent layout file. Defaults to None.
screenshot (bool) – If True, the operation is treated as a screenshot request, using ScreenshotTask instead of ShowTask. Defaults to False.
extension (str, optional) – The specific file extension to search for when automatically finding a file (e.g., ‘gds’, ‘lef’). Used only if filename is None. Defaults to None.
tool (str, optional) – The name of the specific showtool to use for displaying the file. If not provided, the tool is selected based on the file extension.
open (bool) – If True, the file is opened with an OpenTask (e.g. an interactive tool session) instead of being rendered with a ShowTask. Mutually exclusive with screenshot. Defaults to False.
- Returns:
- The path to the generated screenshot file if screenshot is True,
otherwise None.
- Return type:
str
Examples
>>> # Display a specific GDS file >>> project.show('build/my_design/job0/write_gds/0/outputs/my_design.gds')
>>> # Automatically find and show the last generated layout >>> project.show()
- snapshot(path: str = None, jobname: str = None, display: bool = True) None[source]#
Creates a snapshot image summarizing a job’s progress and key information.
This function generates a PNG image that provides a visual overview of the compilation job.
- Parameters:
path (str, optional) – The file path where the snapshot image should be saved. If not provided, it defaults to <job_directory>/<design_name>.png.
jobname (str, optional) – The job to snapshot. If not provided, the value in
[option,jobname]will be used.display (bool, optional) – If True, the generated image will be opened for viewing if the system supports it and option,nodisplay is False. Defaults to True.
- Raises:
ValueError – If there is no history to snapshot.
Examples
>>> project.snapshot() # Creates a snapshot image in the default location for the last run.
- summary(jobname: str = None, fd: TextIO = None) None[source]#
Prints a summary of the compilation manifest and results.
Metrics from the specified job are printed out on a per-step basis.
- Parameters:
jobname (str, optional) – The name of the job to summarize. If not provided, the value in
[option,jobname]will be used.fd (TextIO, optional) – If provided, prints the summary to this file descriptor instead of stdout.
- Raises:
ValueError – If there is no history to summarize.
Examples
>>> project.summary() # Prints a summary of the last run to stdout.
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- write_depgraph(filename: str, fontcolor: str = '#000000', background: str = 'transparent', fontsize: str = '14', border: bool = True, landscape: bool = False) None[source]#
Renders and saves the configured fileset dependency graph to a file.
Shows the project’s design and its configured filesets, with any aliases resolved and reflected in the graph.
- Parameters:
filename (filepath) – Output filepath.
fontcolor (str) – Node font RGB color hex value.
background (str) – Background color.
fontsize (str) – Node text font size.
border (bool) – Enables node border if True.
landscape (bool) – Renders graph in landscape layout if True.
Examples
>>> project.write_depgraph('mydump.png') Renders the fileset dependency graph and writes the result to a png file.
- class siliconcompiler.FPGA(design=None)[source]#
Bases:
ProjectA class for managing FPGA projects, inheriting from the base Project class.
This class extends the base project with FPGA-specific schema for constraints, metrics, and device selection. It provides methods to configure and validate
an FPGA design project.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_alias(src_dep: Design | str, src_fileset: str, alias_dep: Design | str, alias_fileset: str, clobber: bool = False)[source]#
Adds an aliased fileset mapping to the project.
This method allows you to redirect a fileset reference from a source library/fileset to a different destination library/fileset. This is useful for substituting design components or test environments without modifying the original design.
- Parameters:
src_dep (Union[Design, str]) – The source design library (object or name) from which the fileset is being aliased.
src_fileset (str) – The name of the source fileset to alias.
alias_dep (Union[Design, str]) – The destination design library (object or name) to which the fileset is being redirected. Can be None or an empty string to indicate deletion.
alias_fileset (str) – The name of the destination fileset. Can be None or an empty string to indicate deletion of the fileset reference.
clobber (bool) – If True, any existing alias for (src_dep, src_fileset) will be overwritten. If False, the alias will be added. Defaults to False.
- Raises:
TypeError – If src_dep or alias_dep are not valid types (string or Design).
KeyError – If alias_dep is a string but the corresponding library is not loaded.
ValueError – If src_fileset is not found in src_dep, or if alias_fileset is not found in alias_dep (when alias_fileset is not None).
- add_dep(obj)[source]#
Adds a dependency to the project.
If the dependency is an FPGADevice object, it is registered as a library. Otherwise, the request is passed to the parent class’s implementation.
- Parameters:
obj – The dependency object to add. Can be an FPGADevice instance or another type supported by the base Project class.
- add_fileset(fileset: List[str] | str, clobber: bool = False)[source]#
Adds one or more filesets to be used in this project.
Filesets are collections of related files within a design. This method allows you to specify which filesets from the selected design library should be included in the current project context.
- Parameters:
fileset (Union[List[str], str]) – The name(s) of the fileset(s) to add. Can be a single string or a list of strings.
clobber (bool) – If True, existing filesets will be replaced by the new ones. If False, new filesets will be added to the existing list. Defaults to False.
- Raises:
TypeError – If fileset is not a string or a list/tuple/set of strings.
ValueError – If any of the specified filesets are not found in the currently selected design.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- check_filepaths(ignore_keys: List[Tuple[str, ...]] | None = None) bool[source]#
Verifies that paths to all files in manifest are valid.
- Parameters:
ignore_keys (list of keypaths) – list of keypaths to ignore while checking
- Returns:
True if all file paths are valid, otherwise False.
- check_manifest() bool[source]#
Validate the project manifest for FPGA configuration and library availability.
Runs the base project manifest checks, verifies that the
[fpga,device]parameter is set, and confirms the corresponding FPGA library has been loaded into the project.- Returns:
True if the manifest is valid, False otherwise.
- Return type:
bool
- property constraint: FPGAConstraint#
Provides access to the project’s FPGA design constraints.
- Returns:
The schema object containing all design constraints.
- Return type:
- classmethod convert(obj: Project) TProject[source]#
Converts a project from one type to another (e.g., Project to Sim).
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod create_cmdline(progname: str | None = None, description: str | None = None, switchlist: List[str] | Set[str] | None = None, version: str | None = None, print_banner: bool = True, use_cfg: bool = False, use_sources: bool = True) TCmdSchema[source]#
Creates an SC command line interface.
Exposes parameters in the SC schema as command line switches, simplifying creation of SC apps with a restricted set of schema parameters exposed at the command line. The order of command line switch settings parsed from the command line is as follows:
read_manifest (-cfg), if specified by use_cfg
read commandline inputs
all other switches
The cmdline interface is implemented using the Python argparse package and the following use restrictions apply.
Help is accessed with the ‘-h’ switch.
Arguments that include spaces must be enclosed with double quotes.
List parameters are entered individually. (ie. -y libdir1 -y libdir2)
For parameters with Boolean types, the switch implies “true”.
Special characters (such as ‘-’) must be enclosed in double quotes.
- Parameters:
progname (str) – Name of program to be executed.
description (str) – Short program description.
switchlist (list of str) – List of SC parameter switches to expose at the command line. By default all SC schema switches are available. Parameter switches should be entered based on the parameter ‘switch’ field in the schema. For parameters with multiple switches, both will be accepted if any one is included in this list.
version (str) – version of this program.
print_banner (bool) – if True, will print the siliconcompiler banner
use_cfg (bool) – if True, add and parse the -cfg flag
use_sources (bool) – if True, add positional arguments for files
- Returns:
new project object
Examples
>>> schema.create_cmdline(progname='sc-show',switchlist=['-input','-cfg']) Creates a command line interface for 'sc-show' app.
>>> schema.create_cmdline(progname='sc')
- property design: Design#
Returns the design object associated with the project.
- Returns:
The Design schema object for the current project.
- Return type:
- Raises:
ValueError – If the design name is not set.
KeyError – If the design has not been loaded into the project’s libraries.
- find_files(*keypath: str, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) List[str | None] | str | None[source]#
Returns absolute paths to files or directories based on the keypath provided.
The keypath provided must point to a schema parameter of type file, dir, or lists of either. Otherwise, it will trigger an error.
- Parameters:
keypath (list of str) – Variable length schema key list.
missing_ok (bool) – If True, silently return None when files aren’t found. If False, print an error and set the error flag.
step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
If keys points to a scalar entry, returns an absolute path to that file/directory, or None if not found. It keys points to a list entry, returns a list of either the absolute paths or None for each entry, depending on whether it is found.
Examples
>>> schema.find_files('input', 'verilog') Returns a list of absolute paths to source files, as specified in the schema.
- find_result(filetype: str = None, step: str = None, index: str = '0', directory: str = 'outputs', filename: str = None) str[source]#
Returns the absolute path of a compilation result file.
This utility function constructs and returns the absolute path to a result file based on the provided arguments. The typical result directory structure is: <build_dir>/<design_name>/<job_name>/<step>/<index>/<directory>/<design>.<filetype>
- Parameters:
filetype (str, optional) – The file extension (e.g., ‘v’, ‘def’, ‘gds’). Required if filename is not provided.
step (str) – The name of the task step (e.g., ‘syn’, ‘place’). Required.
index (str, optional) – The task index within the step. Defaults to “0”.
directory (str, optional) – The node directory within the step to search (e.g., ‘outputs’, ‘reports’). Defaults to “outputs”.
filename (str, optional) – The exact filename to search for. If provided, filetype is ignored for constructing the path. Defaults to None.
- Returns:
The absolute path to the found file, or None if the file is not found.
- Return type:
str
- Raises:
ValueError – If step is not provided, or if [option,fileset] is not set when filename is not provided.
Examples
>>> # Get path to gate-level Verilog from synthesis step >>> vg_filepath = project.find_result('vg', step='syn')
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_filesets() List[Tuple[NamedSchema, str]][source]#
Returns the filesets selected for this project, resolving any aliases.
This method retrieves the filesets defined in
[option,fileset]and applies any aliases specified in[option,alias]to return the effective list of filesets and their parent libraries.- Returns:
A list of tuples, where each tuple contains the parent library (NamedSchema) and the fileset name (str).
- Return type:
List[Tuple[NamedSchema, str]]
- Raises:
KeyError – If an alias points to a library that is not loaded.
- get_flow(name: str | None = None) Flowgraph[source]#
Retrieves a flowgraph by name.
- Parameters:
name (str, optional) – The name of the flowgraph to retrieve. If None, retrieves the currently selected flowgraph.
- Returns:
The Flowgraph object corresponding to the specified name.
- Return type:
- Raises:
KeyError – If the specified flowgraph is not found in the project.
- get_library(library: str) NamedSchema[source]#
Retrieves a library by name from the project.
- Parameters:
library (str) – The name of the library to retrieve.
- Returns:
The NamedSchema object representing the library.
- Return type:
- Raises:
KeyError – If the specified library is not found in the project.
TypeError – If the provided library is not a string.
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- hash_files(*keypath: str, update: bool = True, check: bool = True, verbose: bool = True, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) str | None | List[str | None][source]#
Generates hash values for a list of parameter files.
Generates a hash value for each file found in the keypath. If existing hash values are stored, this method will compare hashes and trigger an error if there’s a mismatch. If the update variable is True, the computed hash values are recorded in the ‘filehash’ field of the parameter, following the order dictated by the files within the ‘value’ parameter field.
Files are located using the find_files() function.
The file hash calculation is performed based on the ‘algo’ setting. Supported algorithms include SHA1, SHA224, SHA256, SHA384, SHA512, and MD5.
- Parameters:
*keypath (str) – Keypath to parameter.
update (bool) – If True, the hash values are recorded in the project object manifest.
check (bool) – If True, checks the newly computed hash against the stored hash.
verbose (bool) – If True, generates log messages.
allow_cache (bool) – If True, hashing check the cached values for specific files, if found, it will use that hash value otherwise the hash will be computed.
skip_missing (bool) – If True, hashing will be skipped when missing files are detected.
- Returns:
A list of hash values.
Examples
>>> hashlist = hash_files('input', 'rtl', 'verilog') Computes, stores, and returns hashes of files in :keypath:`input, rtl, verilog`.
- history(job: str) Project[source]#
Returns a mutable reference to a historical job record as a Project object.
- Parameters:
job (str) – Name of the historical job to retrieve.
- Returns:
The Project object representing the specified historical job.
- Return type:
- Raises:
KeyError – If the specified job does not exist in the history.
- property logger: Logger#
Returns the logger for this project.
- Returns:
The project-specific logger instance.
- Return type:
logging.Logger
- property name: str#
Returns the name of the design.
- Returns:
The name of the top-level design.
- Return type:
str
- property option: OptionSchema#
Provides access to the top-level options schema.
This property is the entry point for configuring global and job-specific parameters that control the compiler’s behavior, such as flow control, logging, and build settings.
- Returns:
The schema object for top-level options.
- Return type:
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- run() TProject[source]#
Executes the compilation flow defined in the project’s flowgraph.
The run method orchestrates the entire compilation process. It starts by initializing the dashboard and then hands off execution to a Scheduler (or ClientScheduler for remote runs). The scheduler manages the step-by-step execution of tasks defined in the flowgraph, respecting dependencies and handling errors.
After the scheduler completes, the dashboard is updated with the final run status, and non-global job parameters are reset. The method returns a Project object representing the completed job’s history.
- Returns:
- A mutable reference to the completed job’s record in the
project history.
- Return type:
Examples
>>> project.run() # Executes the flow, and returns a project object for the completed job.
- set(*args, field='value', clobber=True, step=None, index=None)[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_design(design: Design | str)[source]#
Sets the active design for this project.
This method allows you to specify the primary design that the project will operate on. If a Design object is provided, it is first added as a dependency.
- Parameters:
design (Union[Design, str]) – The design object or its name (string) to be set as the current design.
- Raises:
TypeError – If the provided design is not a string or a Design object.
- set_flow(flow: Flowgraph | str)[source]#
Sets the active flowgraph for this project.
This method allows you to specify the sequence of steps and tasks (the flow) that the project will execute. If a Flowgraph object is provided, it is first added as a dependency.
- Parameters:
flow (Union[Flowgraph, str]) – The flowgraph object or its name (string) to be set as the current flow.
- Raises:
TypeError – If the provided flow is not a string or a Flowgraph object.
- set_fpga(fpga: str | FPGADevice)[source]#
Sets the target FPGA device for the project.
This method can accept either an FPGADevice object or a string representing the name of the FPGA device. If an object is provided, it is first added as a dependency.
- Parameters:
fpga (FPGADevice or str) – The FPGADevice device to target.
- Raises:
TypeError – If the provided fpga is not an FPGADevice object or a string.
- show(filename: str | None = None, screenshot: bool = False, extension: str | None = None, tool: str | None = None, open: bool = False) str[source]#
Opens a graphical viewer for a specified file or the last generated layout.
The show function identifies an appropriate viewer tool based on the file’s extension and the registered showtools. Display settings and technology-specific viewing configurations are read from the project’s in-memory schema. All temporary rendering and display files are stored in a dedicated _show_<jobname> directory within the build directory.
If no filename is provided, the method attempts to automatically find the last generated layout file in the build directory based on supported extensions from registered showtools.
- Parameters:
filename (str, optional) – The path to the file to display. If None, the system attempts to find the most recent layout file. Defaults to None.
screenshot (bool) – If True, the operation is treated as a screenshot request, using ScreenshotTask instead of ShowTask. Defaults to False.
extension (str, optional) – The specific file extension to search for when automatically finding a file (e.g., ‘gds’, ‘lef’). Used only if filename is None. Defaults to None.
tool (str, optional) – The name of the specific showtool to use for displaying the file. If not provided, the tool is selected based on the file extension.
open (bool) – If True, the file is opened with an OpenTask (e.g. an interactive tool session) instead of being rendered with a ShowTask. Mutually exclusive with screenshot. Defaults to False.
- Returns:
- The path to the generated screenshot file if screenshot is True,
otherwise None.
- Return type:
str
Examples
>>> # Display a specific GDS file >>> project.show('build/my_design/job0/write_gds/0/outputs/my_design.gds')
>>> # Automatically find and show the last generated layout >>> project.show()
- snapshot(path: str = None, jobname: str = None, display: bool = True) None[source]#
Creates a snapshot image summarizing a job’s progress and key information.
This function generates a PNG image that provides a visual overview of the compilation job.
- Parameters:
path (str, optional) – The file path where the snapshot image should be saved. If not provided, it defaults to <job_directory>/<design_name>.png.
jobname (str, optional) – The job to snapshot. If not provided, the value in
[option,jobname]will be used.display (bool, optional) – If True, the generated image will be opened for viewing if the system supports it and option,nodisplay is False. Defaults to True.
- Raises:
ValueError – If there is no history to snapshot.
Examples
>>> project.snapshot() # Creates a snapshot image in the default location for the last run.
- summary(jobname: str = None, fd: TextIO = None) None[source]#
Prints a summary of the compilation manifest and results.
Metrics from the specified job are printed out on a per-step basis.
- Parameters:
jobname (str, optional) – The name of the job to summarize. If not provided, the value in
[option,jobname]will be used.fd (TextIO, optional) – If provided, prints the summary to this file descriptor instead of stdout.
- Raises:
ValueError – If there is no history to summarize.
Examples
>>> project.summary() # Prints a summary of the last run to stdout.
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- write_depgraph(filename: str, fontcolor: str = '#000000', background: str = 'transparent', fontsize: str = '14', border: bool = True, landscape: bool = False) None[source]#
Renders and saves the configured fileset dependency graph to a file.
Shows the project’s design and its configured filesets, with any aliases resolved and reflected in the graph.
- Parameters:
filename (filepath) – Output filepath.
fontcolor (str) – Node font RGB color hex value.
background (str) – Background color.
fontsize (str) – Node text font size.
border (bool) – Enables node border if True.
landscape (bool) – Renders graph in landscape layout if True.
Examples
>>> project.write_depgraph('mydump.png') Renders the fileset dependency graph and writes the result to a png file.
- class siliconcompiler.Lint(design: Design | str | None = None)[source]#
Bases:
ProjectA specialized Project class tailored for linting tasks.
This class can be extended with linting-specific schema parameters, methods, and flows.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_alias(src_dep: Design | str, src_fileset: str, alias_dep: Design | str, alias_fileset: str, clobber: bool = False)[source]#
Adds an aliased fileset mapping to the project.
This method allows you to redirect a fileset reference from a source library/fileset to a different destination library/fileset. This is useful for substituting design components or test environments without modifying the original design.
- Parameters:
src_dep (Union[Design, str]) – The source design library (object or name) from which the fileset is being aliased.
src_fileset (str) – The name of the source fileset to alias.
alias_dep (Union[Design, str]) – The destination design library (object or name) to which the fileset is being redirected. Can be None or an empty string to indicate deletion.
alias_fileset (str) – The name of the destination fileset. Can be None or an empty string to indicate deletion of the fileset reference.
clobber (bool) – If True, any existing alias for (src_dep, src_fileset) will be overwritten. If False, the alias will be added. Defaults to False.
- Raises:
TypeError – If src_dep or alias_dep are not valid types (string or Design).
KeyError – If alias_dep is a string but the corresponding library is not loaded.
ValueError – If src_fileset is not found in src_dep, or if alias_fileset is not found in alias_dep (when alias_fileset is not None).
- add_dep(obj)[source]#
Adds a dependency object (e.g., a Design, Flowgraph, or Checklist) to the project.
This method intelligently adds various types of schema objects to the project’s internal structure. It also handles recursive addition of dependencies if the added object itself is a DependencySchema.
- add_fileset(fileset: List[str] | str, clobber: bool = False)[source]#
Adds one or more filesets to be used in this project.
Filesets are collections of related files within a design. This method allows you to specify which filesets from the selected design library should be included in the current project context.
- Parameters:
fileset (Union[List[str], str]) – The name(s) of the fileset(s) to add. Can be a single string or a list of strings.
clobber (bool) – If True, existing filesets will be replaced by the new ones. If False, new filesets will be added to the existing list. Defaults to False.
- Raises:
TypeError – If fileset is not a string or a list/tuple/set of strings.
ValueError – If any of the specified filesets are not found in the currently selected design.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- check_filepaths(ignore_keys: List[Tuple[str, ...]] | None = None) bool[source]#
Verifies that paths to all files in manifest are valid.
- Parameters:
ignore_keys (list of keypaths) – list of keypaths to ignore while checking
- Returns:
True if all file paths are valid, otherwise False.
- check_manifest() bool[source]#
Performs a comprehensive check of the project’s manifest (configuration) for consistency and validity.
This method verifies that essential options like ‘design’, ‘fileset’, and ‘flow’ are properly set. It also checks if the specified design and flowgraph are loaded, and if filesets within the selected design are valid and have a top module defined. Additionally, it validates any defined fileset aliases, ensuring that source and destination libraries and filesets exist. Error messages are logged for any detected inconsistencies.
- Returns:
True if the manifest is valid and all checks pass, False otherwise.
- Return type:
bool
- classmethod convert(obj: Project) TProject[source]#
Converts a project from one type to another (e.g., Project to Sim).
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod create_cmdline(progname: str | None = None, description: str | None = None, switchlist: List[str] | Set[str] | None = None, version: str | None = None, print_banner: bool = True, use_cfg: bool = False, use_sources: bool = True) TCmdSchema[source]#
Creates an SC command line interface.
Exposes parameters in the SC schema as command line switches, simplifying creation of SC apps with a restricted set of schema parameters exposed at the command line. The order of command line switch settings parsed from the command line is as follows:
read_manifest (-cfg), if specified by use_cfg
read commandline inputs
all other switches
The cmdline interface is implemented using the Python argparse package and the following use restrictions apply.
Help is accessed with the ‘-h’ switch.
Arguments that include spaces must be enclosed with double quotes.
List parameters are entered individually. (ie. -y libdir1 -y libdir2)
For parameters with Boolean types, the switch implies “true”.
Special characters (such as ‘-’) must be enclosed in double quotes.
- Parameters:
progname (str) – Name of program to be executed.
description (str) – Short program description.
switchlist (list of str) – List of SC parameter switches to expose at the command line. By default all SC schema switches are available. Parameter switches should be entered based on the parameter ‘switch’ field in the schema. For parameters with multiple switches, both will be accepted if any one is included in this list.
version (str) – version of this program.
print_banner (bool) – if True, will print the siliconcompiler banner
use_cfg (bool) – if True, add and parse the -cfg flag
use_sources (bool) – if True, add positional arguments for files
- Returns:
new project object
Examples
>>> schema.create_cmdline(progname='sc-show',switchlist=['-input','-cfg']) Creates a command line interface for 'sc-show' app.
>>> schema.create_cmdline(progname='sc')
- property design: Design#
Returns the design object associated with the project.
- Returns:
The Design schema object for the current project.
- Return type:
- Raises:
ValueError – If the design name is not set.
KeyError – If the design has not been loaded into the project’s libraries.
- find_files(*keypath: str, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) List[str | None] | str | None[source]#
Returns absolute paths to files or directories based on the keypath provided.
The keypath provided must point to a schema parameter of type file, dir, or lists of either. Otherwise, it will trigger an error.
- Parameters:
keypath (list of str) – Variable length schema key list.
missing_ok (bool) – If True, silently return None when files aren’t found. If False, print an error and set the error flag.
step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
If keys points to a scalar entry, returns an absolute path to that file/directory, or None if not found. It keys points to a list entry, returns a list of either the absolute paths or None for each entry, depending on whether it is found.
Examples
>>> schema.find_files('input', 'verilog') Returns a list of absolute paths to source files, as specified in the schema.
- find_result(filetype: str = None, step: str = None, index: str = '0', directory: str = 'outputs', filename: str = None) str[source]#
Returns the absolute path of a compilation result file.
This utility function constructs and returns the absolute path to a result file based on the provided arguments. The typical result directory structure is: <build_dir>/<design_name>/<job_name>/<step>/<index>/<directory>/<design>.<filetype>
- Parameters:
filetype (str, optional) – The file extension (e.g., ‘v’, ‘def’, ‘gds’). Required if filename is not provided.
step (str) – The name of the task step (e.g., ‘syn’, ‘place’). Required.
index (str, optional) – The task index within the step. Defaults to “0”.
directory (str, optional) – The node directory within the step to search (e.g., ‘outputs’, ‘reports’). Defaults to “outputs”.
filename (str, optional) – The exact filename to search for. If provided, filetype is ignored for constructing the path. Defaults to None.
- Returns:
The absolute path to the found file, or None if the file is not found.
- Return type:
str
- Raises:
ValueError – If step is not provided, or if [option,fileset] is not set when filename is not provided.
Examples
>>> # Get path to gate-level Verilog from synthesis step >>> vg_filepath = project.find_result('vg', step='syn')
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_filesets() List[Tuple[NamedSchema, str]][source]#
Returns the filesets selected for this project, resolving any aliases.
This method retrieves the filesets defined in
[option,fileset]and applies any aliases specified in[option,alias]to return the effective list of filesets and their parent libraries.- Returns:
A list of tuples, where each tuple contains the parent library (NamedSchema) and the fileset name (str).
- Return type:
List[Tuple[NamedSchema, str]]
- Raises:
KeyError – If an alias points to a library that is not loaded.
- get_flow(name: str | None = None) Flowgraph[source]#
Retrieves a flowgraph by name.
- Parameters:
name (str, optional) – The name of the flowgraph to retrieve. If None, retrieves the currently selected flowgraph.
- Returns:
The Flowgraph object corresponding to the specified name.
- Return type:
- Raises:
KeyError – If the specified flowgraph is not found in the project.
- get_library(library: str) NamedSchema[source]#
Retrieves a library by name from the project.
- Parameters:
library (str) – The name of the library to retrieve.
- Returns:
The NamedSchema object representing the library.
- Return type:
- Raises:
KeyError – If the specified library is not found in the project.
TypeError – If the provided library is not a string.
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- hash_files(*keypath: str, update: bool = True, check: bool = True, verbose: bool = True, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) str | None | List[str | None][source]#
Generates hash values for a list of parameter files.
Generates a hash value for each file found in the keypath. If existing hash values are stored, this method will compare hashes and trigger an error if there’s a mismatch. If the update variable is True, the computed hash values are recorded in the ‘filehash’ field of the parameter, following the order dictated by the files within the ‘value’ parameter field.
Files are located using the find_files() function.
The file hash calculation is performed based on the ‘algo’ setting. Supported algorithms include SHA1, SHA224, SHA256, SHA384, SHA512, and MD5.
- Parameters:
*keypath (str) – Keypath to parameter.
update (bool) – If True, the hash values are recorded in the project object manifest.
check (bool) – If True, checks the newly computed hash against the stored hash.
verbose (bool) – If True, generates log messages.
allow_cache (bool) – If True, hashing check the cached values for specific files, if found, it will use that hash value otherwise the hash will be computed.
skip_missing (bool) – If True, hashing will be skipped when missing files are detected.
- Returns:
A list of hash values.
Examples
>>> hashlist = hash_files('input', 'rtl', 'verilog') Computes, stores, and returns hashes of files in :keypath:`input, rtl, verilog`.
- history(job: str) Project[source]#
Returns a mutable reference to a historical job record as a Project object.
- Parameters:
job (str) – Name of the historical job to retrieve.
- Returns:
The Project object representing the specified historical job.
- Return type:
- Raises:
KeyError – If the specified job does not exist in the history.
- property logger: Logger#
Returns the logger for this project.
- Returns:
The project-specific logger instance.
- Return type:
logging.Logger
- property name: str#
Returns the name of the design.
- Returns:
The name of the top-level design.
- Return type:
str
- property option: OptionSchema#
Provides access to the top-level options schema.
This property is the entry point for configuring global and job-specific parameters that control the compiler’s behavior, such as flow control, logging, and build settings.
- Returns:
The schema object for top-level options.
- Return type:
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- run() TProject[source]#
Executes the compilation flow defined in the project’s flowgraph.
The run method orchestrates the entire compilation process. It starts by initializing the dashboard and then hands off execution to a Scheduler (or ClientScheduler for remote runs). The scheduler manages the step-by-step execution of tasks defined in the flowgraph, respecting dependencies and handling errors.
After the scheduler completes, the dashboard is updated with the final run status, and non-global job parameters are reset. The method returns a Project object representing the completed job’s history.
- Returns:
- A mutable reference to the completed job’s record in the
project history.
- Return type:
Examples
>>> project.run() # Executes the flow, and returns a project object for the completed job.
- set(*args, field='value', clobber=True, step=None, index=None)[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_design(design: Design | str)[source]#
Sets the active design for this project.
This method allows you to specify the primary design that the project will operate on. If a Design object is provided, it is first added as a dependency.
- Parameters:
design (Union[Design, str]) – The design object or its name (string) to be set as the current design.
- Raises:
TypeError – If the provided design is not a string or a Design object.
- set_flow(flow: Flowgraph | str)[source]#
Sets the active flowgraph for this project.
This method allows you to specify the sequence of steps and tasks (the flow) that the project will execute. If a Flowgraph object is provided, it is first added as a dependency.
- Parameters:
flow (Union[Flowgraph, str]) – The flowgraph object or its name (string) to be set as the current flow.
- Raises:
TypeError – If the provided flow is not a string or a Flowgraph object.
- show(filename: str | None = None, screenshot: bool = False, extension: str | None = None, tool: str | None = None, open: bool = False) str[source]#
Opens a graphical viewer for a specified file or the last generated layout.
The show function identifies an appropriate viewer tool based on the file’s extension and the registered showtools. Display settings and technology-specific viewing configurations are read from the project’s in-memory schema. All temporary rendering and display files are stored in a dedicated _show_<jobname> directory within the build directory.
If no filename is provided, the method attempts to automatically find the last generated layout file in the build directory based on supported extensions from registered showtools.
- Parameters:
filename (str, optional) – The path to the file to display. If None, the system attempts to find the most recent layout file. Defaults to None.
screenshot (bool) – If True, the operation is treated as a screenshot request, using ScreenshotTask instead of ShowTask. Defaults to False.
extension (str, optional) – The specific file extension to search for when automatically finding a file (e.g., ‘gds’, ‘lef’). Used only if filename is None. Defaults to None.
tool (str, optional) – The name of the specific showtool to use for displaying the file. If not provided, the tool is selected based on the file extension.
open (bool) – If True, the file is opened with an OpenTask (e.g. an interactive tool session) instead of being rendered with a ShowTask. Mutually exclusive with screenshot. Defaults to False.
- Returns:
- The path to the generated screenshot file if screenshot is True,
otherwise None.
- Return type:
str
Examples
>>> # Display a specific GDS file >>> project.show('build/my_design/job0/write_gds/0/outputs/my_design.gds')
>>> # Automatically find and show the last generated layout >>> project.show()
- snapshot(path: str = None, jobname: str = None, display: bool = True) None[source]#
Creates a snapshot image summarizing a job’s progress and key information.
This function generates a PNG image that provides a visual overview of the compilation job.
- Parameters:
path (str, optional) – The file path where the snapshot image should be saved. If not provided, it defaults to <job_directory>/<design_name>.png.
jobname (str, optional) – The job to snapshot. If not provided, the value in
[option,jobname]will be used.display (bool, optional) – If True, the generated image will be opened for viewing if the system supports it and option,nodisplay is False. Defaults to True.
- Raises:
ValueError – If there is no history to snapshot.
Examples
>>> project.snapshot() # Creates a snapshot image in the default location for the last run.
- summary(jobname: str = None, fd: TextIO = None) None[source]#
Prints a summary of the compilation manifest and results.
Metrics from the specified job are printed out on a per-step basis.
- Parameters:
jobname (str, optional) – The name of the job to summarize. If not provided, the value in
[option,jobname]will be used.fd (TextIO, optional) – If provided, prints the summary to this file descriptor instead of stdout.
- Raises:
ValueError – If there is no history to summarize.
Examples
>>> project.summary() # Prints a summary of the last run to stdout.
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- write_depgraph(filename: str, fontcolor: str = '#000000', background: str = 'transparent', fontsize: str = '14', border: bool = True, landscape: bool = False) None[source]#
Renders and saves the configured fileset dependency graph to a file.
Shows the project’s design and its configured filesets, with any aliases resolved and reflected in the graph.
- Parameters:
filename (filepath) – Output filepath.
fontcolor (str) – Node font RGB color hex value.
background (str) – Background color.
fontsize (str) – Node text font size.
border (bool) – Enables node border if True.
landscape (bool) – Renders graph in landscape layout if True.
Examples
>>> project.write_depgraph('mydump.png') Renders the fileset dependency graph and writes the result to a png file.
- class siliconcompiler.Sim(design: Design | str | None = None)[source]#
Bases:
ProjectA specialized Project class tailored for simulation tasks.
This class can be extended with simulation-specific schema parameters, methods, and flows.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_alias(src_dep: Design | str, src_fileset: str, alias_dep: Design | str, alias_fileset: str, clobber: bool = False)[source]#
Adds an aliased fileset mapping to the project.
This method allows you to redirect a fileset reference from a source library/fileset to a different destination library/fileset. This is useful for substituting design components or test environments without modifying the original design.
- Parameters:
src_dep (Union[Design, str]) – The source design library (object or name) from which the fileset is being aliased.
src_fileset (str) – The name of the source fileset to alias.
alias_dep (Union[Design, str]) – The destination design library (object or name) to which the fileset is being redirected. Can be None or an empty string to indicate deletion.
alias_fileset (str) – The name of the destination fileset. Can be None or an empty string to indicate deletion of the fileset reference.
clobber (bool) – If True, any existing alias for (src_dep, src_fileset) will be overwritten. If False, the alias will be added. Defaults to False.
- Raises:
TypeError – If src_dep or alias_dep are not valid types (string or Design).
KeyError – If alias_dep is a string but the corresponding library is not loaded.
ValueError – If src_fileset is not found in src_dep, or if alias_fileset is not found in alias_dep (when alias_fileset is not None).
- add_dep(obj)[source]#
Adds a dependency object (e.g., a Design, Flowgraph, or Checklist) to the project.
This method intelligently adds various types of schema objects to the project’s internal structure. It also handles recursive addition of dependencies if the added object itself is a DependencySchema.
- add_fileset(fileset: List[str] | str, clobber: bool = False)[source]#
Adds one or more filesets to be used in this project.
Filesets are collections of related files within a design. This method allows you to specify which filesets from the selected design library should be included in the current project context.
- Parameters:
fileset (Union[List[str], str]) – The name(s) of the fileset(s) to add. Can be a single string or a list of strings.
clobber (bool) – If True, existing filesets will be replaced by the new ones. If False, new filesets will be added to the existing list. Defaults to False.
- Raises:
TypeError – If fileset is not a string or a list/tuple/set of strings.
ValueError – If any of the specified filesets are not found in the currently selected design.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- check_filepaths(ignore_keys: List[Tuple[str, ...]] | None = None) bool[source]#
Verifies that paths to all files in manifest are valid.
- Parameters:
ignore_keys (list of keypaths) – list of keypaths to ignore while checking
- Returns:
True if all file paths are valid, otherwise False.
- check_manifest() bool[source]#
Performs a comprehensive check of the project’s manifest (configuration) for consistency and validity.
This method verifies that essential options like ‘design’, ‘fileset’, and ‘flow’ are properly set. It also checks if the specified design and flowgraph are loaded, and if filesets within the selected design are valid and have a top module defined. Additionally, it validates any defined fileset aliases, ensuring that source and destination libraries and filesets exist. Error messages are logged for any detected inconsistencies.
- Returns:
True if the manifest is valid and all checks pass, False otherwise.
- Return type:
bool
- classmethod convert(obj: Project) TProject[source]#
Converts a project from one type to another (e.g., Project to Sim).
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod create_cmdline(progname: str | None = None, description: str | None = None, switchlist: List[str] | Set[str] | None = None, version: str | None = None, print_banner: bool = True, use_cfg: bool = False, use_sources: bool = True) TCmdSchema[source]#
Creates an SC command line interface.
Exposes parameters in the SC schema as command line switches, simplifying creation of SC apps with a restricted set of schema parameters exposed at the command line. The order of command line switch settings parsed from the command line is as follows:
read_manifest (-cfg), if specified by use_cfg
read commandline inputs
all other switches
The cmdline interface is implemented using the Python argparse package and the following use restrictions apply.
Help is accessed with the ‘-h’ switch.
Arguments that include spaces must be enclosed with double quotes.
List parameters are entered individually. (ie. -y libdir1 -y libdir2)
For parameters with Boolean types, the switch implies “true”.
Special characters (such as ‘-’) must be enclosed in double quotes.
- Parameters:
progname (str) – Name of program to be executed.
description (str) – Short program description.
switchlist (list of str) – List of SC parameter switches to expose at the command line. By default all SC schema switches are available. Parameter switches should be entered based on the parameter ‘switch’ field in the schema. For parameters with multiple switches, both will be accepted if any one is included in this list.
version (str) – version of this program.
print_banner (bool) – if True, will print the siliconcompiler banner
use_cfg (bool) – if True, add and parse the -cfg flag
use_sources (bool) – if True, add positional arguments for files
- Returns:
new project object
Examples
>>> schema.create_cmdline(progname='sc-show',switchlist=['-input','-cfg']) Creates a command line interface for 'sc-show' app.
>>> schema.create_cmdline(progname='sc')
- property design: Design#
Returns the design object associated with the project.
- Returns:
The Design schema object for the current project.
- Return type:
- Raises:
ValueError – If the design name is not set.
KeyError – If the design has not been loaded into the project’s libraries.
- find_files(*keypath: str, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) List[str | None] | str | None[source]#
Returns absolute paths to files or directories based on the keypath provided.
The keypath provided must point to a schema parameter of type file, dir, or lists of either. Otherwise, it will trigger an error.
- Parameters:
keypath (list of str) – Variable length schema key list.
missing_ok (bool) – If True, silently return None when files aren’t found. If False, print an error and set the error flag.
step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
If keys points to a scalar entry, returns an absolute path to that file/directory, or None if not found. It keys points to a list entry, returns a list of either the absolute paths or None for each entry, depending on whether it is found.
Examples
>>> schema.find_files('input', 'verilog') Returns a list of absolute paths to source files, as specified in the schema.
- find_result(filetype: str = None, step: str = None, index: str = '0', directory: str = 'outputs', filename: str = None) str[source]#
Returns the absolute path of a compilation result file.
This utility function constructs and returns the absolute path to a result file based on the provided arguments. The typical result directory structure is: <build_dir>/<design_name>/<job_name>/<step>/<index>/<directory>/<design>.<filetype>
- Parameters:
filetype (str, optional) – The file extension (e.g., ‘v’, ‘def’, ‘gds’). Required if filename is not provided.
step (str) – The name of the task step (e.g., ‘syn’, ‘place’). Required.
index (str, optional) – The task index within the step. Defaults to “0”.
directory (str, optional) – The node directory within the step to search (e.g., ‘outputs’, ‘reports’). Defaults to “outputs”.
filename (str, optional) – The exact filename to search for. If provided, filetype is ignored for constructing the path. Defaults to None.
- Returns:
The absolute path to the found file, or None if the file is not found.
- Return type:
str
- Raises:
ValueError – If step is not provided, or if [option,fileset] is not set when filename is not provided.
Examples
>>> # Get path to gate-level Verilog from synthesis step >>> vg_filepath = project.find_result('vg', step='syn')
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_filesets() List[Tuple[NamedSchema, str]][source]#
Returns the filesets selected for this project, resolving any aliases.
This method retrieves the filesets defined in
[option,fileset]and applies any aliases specified in[option,alias]to return the effective list of filesets and their parent libraries.- Returns:
A list of tuples, where each tuple contains the parent library (NamedSchema) and the fileset name (str).
- Return type:
List[Tuple[NamedSchema, str]]
- Raises:
KeyError – If an alias points to a library that is not loaded.
- get_flow(name: str | None = None) Flowgraph[source]#
Retrieves a flowgraph by name.
- Parameters:
name (str, optional) – The name of the flowgraph to retrieve. If None, retrieves the currently selected flowgraph.
- Returns:
The Flowgraph object corresponding to the specified name.
- Return type:
- Raises:
KeyError – If the specified flowgraph is not found in the project.
- get_library(library: str) NamedSchema[source]#
Retrieves a library by name from the project.
- Parameters:
library (str) – The name of the library to retrieve.
- Returns:
The NamedSchema object representing the library.
- Return type:
- Raises:
KeyError – If the specified library is not found in the project.
TypeError – If the provided library is not a string.
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- hash_files(*keypath: str, update: bool = True, check: bool = True, verbose: bool = True, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) str | None | List[str | None][source]#
Generates hash values for a list of parameter files.
Generates a hash value for each file found in the keypath. If existing hash values are stored, this method will compare hashes and trigger an error if there’s a mismatch. If the update variable is True, the computed hash values are recorded in the ‘filehash’ field of the parameter, following the order dictated by the files within the ‘value’ parameter field.
Files are located using the find_files() function.
The file hash calculation is performed based on the ‘algo’ setting. Supported algorithms include SHA1, SHA224, SHA256, SHA384, SHA512, and MD5.
- Parameters:
*keypath (str) – Keypath to parameter.
update (bool) – If True, the hash values are recorded in the project object manifest.
check (bool) – If True, checks the newly computed hash against the stored hash.
verbose (bool) – If True, generates log messages.
allow_cache (bool) – If True, hashing check the cached values for specific files, if found, it will use that hash value otherwise the hash will be computed.
skip_missing (bool) – If True, hashing will be skipped when missing files are detected.
- Returns:
A list of hash values.
Examples
>>> hashlist = hash_files('input', 'rtl', 'verilog') Computes, stores, and returns hashes of files in :keypath:`input, rtl, verilog`.
- history(job: str) Project[source]#
Returns a mutable reference to a historical job record as a Project object.
- Parameters:
job (str) – Name of the historical job to retrieve.
- Returns:
The Project object representing the specified historical job.
- Return type:
- Raises:
KeyError – If the specified job does not exist in the history.
- property logger: Logger#
Returns the logger for this project.
- Returns:
The project-specific logger instance.
- Return type:
logging.Logger
- property name: str#
Returns the name of the design.
- Returns:
The name of the top-level design.
- Return type:
str
- property option: OptionSchema#
Provides access to the top-level options schema.
This property is the entry point for configuring global and job-specific parameters that control the compiler’s behavior, such as flow control, logging, and build settings.
- Returns:
The schema object for top-level options.
- Return type:
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- run() TProject[source]#
Executes the compilation flow defined in the project’s flowgraph.
The run method orchestrates the entire compilation process. It starts by initializing the dashboard and then hands off execution to a Scheduler (or ClientScheduler for remote runs). The scheduler manages the step-by-step execution of tasks defined in the flowgraph, respecting dependencies and handling errors.
After the scheduler completes, the dashboard is updated with the final run status, and non-global job parameters are reset. The method returns a Project object representing the completed job’s history.
- Returns:
- A mutable reference to the completed job’s record in the
project history.
- Return type:
Examples
>>> project.run() # Executes the flow, and returns a project object for the completed job.
- set(*args, field='value', clobber=True, step=None, index=None)[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_design(design: Design | str)[source]#
Sets the active design for this project.
This method allows you to specify the primary design that the project will operate on. If a Design object is provided, it is first added as a dependency.
- Parameters:
design (Union[Design, str]) – The design object or its name (string) to be set as the current design.
- Raises:
TypeError – If the provided design is not a string or a Design object.
- set_flow(flow: Flowgraph | str)[source]#
Sets the active flowgraph for this project.
This method allows you to specify the sequence of steps and tasks (the flow) that the project will execute. If a Flowgraph object is provided, it is first added as a dependency.
- Parameters:
flow (Union[Flowgraph, str]) – The flowgraph object or its name (string) to be set as the current flow.
- Raises:
TypeError – If the provided flow is not a string or a Flowgraph object.
- show(filename: str | None = None, screenshot: bool = False, extension: str | None = None, tool: str | None = None, open: bool = False) str[source]#
Opens a graphical viewer for a specified file or the last generated layout.
The show function identifies an appropriate viewer tool based on the file’s extension and the registered showtools. Display settings and technology-specific viewing configurations are read from the project’s in-memory schema. All temporary rendering and display files are stored in a dedicated _show_<jobname> directory within the build directory.
If no filename is provided, the method attempts to automatically find the last generated layout file in the build directory based on supported extensions from registered showtools.
- Parameters:
filename (str, optional) – The path to the file to display. If None, the system attempts to find the most recent layout file. Defaults to None.
screenshot (bool) – If True, the operation is treated as a screenshot request, using ScreenshotTask instead of ShowTask. Defaults to False.
extension (str, optional) – The specific file extension to search for when automatically finding a file (e.g., ‘gds’, ‘lef’). Used only if filename is None. Defaults to None.
tool (str, optional) – The name of the specific showtool to use for displaying the file. If not provided, the tool is selected based on the file extension.
open (bool) – If True, the file is opened with an OpenTask (e.g. an interactive tool session) instead of being rendered with a ShowTask. Mutually exclusive with screenshot. Defaults to False.
- Returns:
- The path to the generated screenshot file if screenshot is True,
otherwise None.
- Return type:
str
Examples
>>> # Display a specific GDS file >>> project.show('build/my_design/job0/write_gds/0/outputs/my_design.gds')
>>> # Automatically find and show the last generated layout >>> project.show()
- snapshot(path: str = None, jobname: str = None, display: bool = True) None[source]#
Creates a snapshot image summarizing a job’s progress and key information.
This function generates a PNG image that provides a visual overview of the compilation job.
- Parameters:
path (str, optional) – The file path where the snapshot image should be saved. If not provided, it defaults to <job_directory>/<design_name>.png.
jobname (str, optional) – The job to snapshot. If not provided, the value in
[option,jobname]will be used.display (bool, optional) – If True, the generated image will be opened for viewing if the system supports it and option,nodisplay is False. Defaults to True.
- Raises:
ValueError – If there is no history to snapshot.
Examples
>>> project.snapshot() # Creates a snapshot image in the default location for the last run.
- summary(jobname: str = None, fd: TextIO = None) None[source]#
Prints a summary of the compilation manifest and results.
Metrics from the specified job are printed out on a per-step basis.
- Parameters:
jobname (str, optional) – The name of the job to summarize. If not provided, the value in
[option,jobname]will be used.fd (TextIO, optional) – If provided, prints the summary to this file descriptor instead of stdout.
- Raises:
ValueError – If there is no history to summarize.
Examples
>>> project.summary() # Prints a summary of the last run to stdout.
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- write_depgraph(filename: str, fontcolor: str = '#000000', background: str = 'transparent', fontsize: str = '14', border: bool = True, landscape: bool = False) None[source]#
Renders and saves the configured fileset dependency graph to a file.
Shows the project’s design and its configured filesets, with any aliases resolved and reflected in the graph.
- Parameters:
filename (filepath) – Output filepath.
fontcolor (str) – Node font RGB color hex value.
background (str) – Background color.
fontsize (str) – Node text font size.
border (bool) – Enables node border if True.
landscape (bool) – Renders graph in landscape layout if True.
Examples
>>> project.write_depgraph('mydump.png') Renders the fileset dependency graph and writes the result to a png file.
2.3. User Classes#
- class siliconcompiler.Design(name: str | None = None)[source]#
Bases:
DependencySchema,PathSchema,NamedSchemaSchema for a ‘design’.
This class inherits from
DependencySchemaandFileSetSchema, adds parameters and methods specific to describing a design, such as its top module, source filesets, and compilation settings.- active_dataroot(dataroot: str | None = None)#
Use this context to set the dataroot parameter on files and directory parameters.
- Parameters:
dataroot (str) – name of the dataroot
Example
>>> with schema.active_dataroot("lambdalib"): ... schema.set("file", "top.v") Sets the file to top.v and associates lambdalib as the dataroot.
- active_fileset(fileset: str)#
Provides a context to temporarily set an active design fileset.
This is useful for applying a set of configurations to a specific fileset without repeatedly passing its name.
- Raises:
TypeError – If fileset is not a string.
ValueError – If fileset is an empty string.
- Parameters:
fileset (str) – The name of the fileset to activate.
Example
>>> with design.active_fileset("rtl"): ... design.set_topmodule("top") # This sets the top module for the 'rtl' fileset to 'top'.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_define(value: str, fileset: str | None = None, clobber: bool = False) List[str][source]#
Adds preprocessor macro definitions to a fileset.
- Parameters:
value (str or List[str]) – Macro definition.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
- Returns:
List of macro definitions
- Return type:
list[str]
- add_dep(obj: NamedSchema, clobber: bool = True) bool[source]#
Adds a module dependency to this design.
This method extends the base add_dep to prevent a design from adding a dependency on itself.
- Parameters:
obj (NamedSchema) – The dependency object to add.
clobber (bool) – If True, overwrite an existing dependency with the same name.
- Returns:
True if the dependency was added, False otherwise.
- Return type:
bool
- Raises:
TypeError – If obj is not a NamedSchema.
ValueError – If obj has the same name as the current design.
- add_depfileset(dep: Design | str, depfileset: str | None = None, fileset: str | None = None)[source]#
Record a reference to an imported dependency’s fileset.
- Parameters:
dep (
Designor str) – Dependency name or object.depfileset (str) – Dependency fileset, if not specified, the fileset will default to the same as the fileset or if only one fileset is present in the dep that will be chosen.
fileset (str) – Fileset name. If not provided, the active fileset is used.
- add_file(filename: List[Path | str] | Set[Path | str] | Tuple[Path | str, ...] | Path | str, fileset: str | None = None, filetype: str | None = None, clobber: bool = False, dataroot: str | None = None) List[str][source]#
Adds files to a fileset.
Based on the file’s extension, this method can often infer the correct fileset and filetype. For example:
.v -> (source, verilog)
.vhd -> (source, vhdl)
.sdc -> (constraint, sdc)
.lef -> (input, lef)
.def -> (input, def)
etc.
- Parameters:
filename (Path, str, or collection) – File path (Path or str), or a collection (list, tuple, set) of file paths to add.
fileset (str) – Logical group to associate the file with.
filetype (str, optional) – Type of the file (e.g., ‘verilog’, ‘sdc’).
clobber (bool, optional) – If True, clears the list before adding the item. Defaults to False.
dataroot (str, optional) – Data directory reference name.
- Raises:
ValueError – If fileset or filetype cannot be inferred from the file extension.
- Returns:
A list of the file paths that were added.
- Return type:
list[str]
Notes
This method normalizes filename to a string for consistency.
- If filetype is not specified, it is inferred from the
file extension.
- add_idir(value: str, fileset: str | None = None, clobber: bool = False, dataroot: str | None = None) List[str][source]#
Adds include directories to a fileset.
- Parameters:
value (Path or list[Path]) – Include path(s).
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
dataroot (str, optional) – Data directory reference name.
- Returns:
List of include directories
- Return type:
list[str]
- add_lib(value: str, fileset: str | None = None, clobber: bool = False) List[str][source]#
Adds dynamic libraries to a fileset.
- Parameters:
value (str or List[str]) – Libraries.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
- Returns:
List of libraries.
- Return type:
list[str]
- add_libdir(value: str, fileset: str | None = None, clobber: bool = False, dataroot: str | None = None) List[str][source]#
Adds dynamic library directories to a fileset.
- Parameters:
value (Path or list[Path]) – Library path(s).
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
dataroot (str, optional) – Data directory reference name.
- Returns:
List of library directories.
- Return type:
list[str]
- add_undefine(value: str, fileset: str | None = None, clobber: bool = False) List[str][source]#
Adds preprocessor macro (un)definitions to a fileset.
- Parameters:
value (str or List[str]) – Macro (un)definition.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
- Returns:
List of macro (un)definitions
- Return type:
list[str]
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- check_filepaths(ignore_keys: List[Tuple[str, ...]] | None = None) bool[source]#
Verifies that paths to all files in manifest are valid.
- Parameters:
ignore_keys (list of keypaths) – list of keypaths to ignore while checking
- Returns:
True if all file paths are valid, otherwise False.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- copy_fileset(src_fileset: str, dst_fileset: str, clobber: bool = False) None[source]#
Creates a new copy of a source fileset.
The entire configuration of the source fileset is duplicated and stored under the destination fileset’s name.
- Parameters:
src_fileset (str) – The name of the source fileset to copy.
dst_fileset (str) – The name of the new destination fileset.
clobber (bool) – If True, an existing destination fileset will be overwritten. Defaults to False.
- Raises:
ValueError – If the destination fileset already exists and clobber is False.
- find_files(*keypath: str, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) List[str | None] | str | None[source]#
Returns absolute paths to files or directories based on the keypath provided.
The keypath provided must point to a schema parameter of type file, dir, or lists of either. Otherwise, it will trigger an error.
- Parameters:
keypath (list of str) – Variable length schema key list.
missing_ok (bool) – If True, silently return None when files aren’t found. If False, print an error and set the error flag.
step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
If keys points to a scalar entry, returns an absolute path to that file/directory, or None if not found. It keys points to a list entry, returns a list of either the absolute paths or None for each entry, depending on whether it is found.
Examples
>>> schema.find_files('input', 'verilog') Returns a list of absolute paths to source files, as specified in the schema.
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True, name: str | None = None) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
name (str) – name of the schema.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_dataroot(name: str) str[source]#
Returns absolute path to the data directory.
- Raises:
ValueError – is data directory is not found
- Parameters:
name (str) – name of the data directory to find.
- Returns:
Path to the directory root.
Examples
>>> schema.get_dataroot('siliconcompiler') Returns the path to the root of the siliconcompiler data directory.
- get_define(fileset: str | None = None) List[str][source]#
Returns defined macros for a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of macro definitions
- Return type:
list[str]
- get_dep(name: str | None = None, hierarchy: bool = True) List[NamedSchema][source]#
Returns all dependencies associated with this object or a specific one if requested.
- Raises:
KeyError – if the specific module is requested but not found.
- Parameters:
name (str) – Name of the module.
hierarchy (bool) – If True, will return all modules including children, otherwise only this object’s modules are returned.
- Returns:
A list of dependency objects.
- Return type:
list
- get_depfileset(fileset: str | None = None)[source]#
Returns list of dependency filesets.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of dependencies and filesets.
- Return type:
list[tuple(str, str)]
- get_file(fileset: str | None = None, filetype: str | None = None) List[str][source]#
Returns a list of files from one or more filesets.
- Parameters:
fileset (str or list[str]) – Fileset(s) to query. If not provided, the active fileset is used.
filetype (str or list[str], optional) – File type(s) to filter by (e.g., ‘verilog’). If not provided, all filetypes in the fileset are returned.
- Returns:
A list of resolved file paths.
- Return type:
list[str]
- get_fileset(filesets: List[str] | str, alias: Dict[Tuple[str, str], Tuple[NamedSchema, str]] | None = None) List[Tuple[NamedSchema, str]][source]#
Computes the full, recursive list of (design, fileset) tuples required for a given set of top-level filesets.
This method traverses the design’s dependency graph to resolve all depfileset entries, returning a flattened and unique list of all required sources.
- Parameters:
filesets (Union[List[str], str]) – A single fileset name or a list of fileset names to evaluate.
alias (Dict[Tuple[str, str], Tuple[NamedSchema, str]], optional) – A dictionary mapping (design_name, fileset_name) tuples to be substituted during traversal. The value should be a (Design object, new_fileset_name) tuple. This is useful for swapping out library implementations. Defaults to None.
- Returns:
A flattened, unique list of (Design, fileset) tuples representing all dependencies.
- Return type:
List[Tuple[NamedSchema, str]]
- get_idir(fileset: str | None = None) List[str][source]#
Returns include directories for a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of include directories
- Return type:
list[str]
- get_lib(fileset: str | None = None) List[str][source]#
Returns list of dynamic libraries for a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of libraries.
- Return type:
list[str]
- get_libdir(fileset: str | None = None) List[str][source]#
Returns dynamic library directories for a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of library directories.
- Return type:
list[str]
- get_param(name: str, fileset: str | None = None) str[source]#
Returns value of a named fileset parameter.
- Parameters:
name (str) – Parameter name.
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
Parameter value
- Return type:
str
- get_topmodule(fileset: str | None = None) str[source]#
Returns the topmodule of a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
Topmodule name
- Return type:
str
- get_undefine(fileset: str | None = None) List[str][source]#
Returns undefined macros for a fileset.
- Args:
- fileset (str): Fileset name. If not provided, the active fileset is
used.
- Returns:
List of macro (un)definitions
- Return type:
list[str]
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- has_dep(name: NamedSchema | str) bool[source]#
Checks if a specific dependency is present.
- Parameters:
name (str) – Name of the module.
- Returns:
True if the module was found, False otherwise.
- has_file(fileset: str | None = None, filetype: str | None = None) bool[source]#
Returns true if the fileset contains files.
- Parameters:
fileset (str or list[str]) – Fileset(s) to query. If not provided, the active fileset is used.
filetype (str or list[str], optional) – File type(s) to filter by (e.g., ‘verilog’). If not provided, all filetypes in the fileset are returned.
- Returns:
True if the fileset contains files.
- Return type:
bool
- has_fileset(fileset: str) bool[source]#
Checks if a fileset exists in the schema.
- Parameters:
fileset (str) – The name of the fileset to check.
- Returns:
True if the fileset exists, False otherwise.
- Return type:
bool
- has_idir(fileset: str | None = None) bool[source]#
Returns true if idirs are defined for the fileset
- Parameters:
fileset (str or list[str]) – Fileset(s) to query. If not provided, the active fileset is used.
- Returns:
True if the fileset contains directories.
- Return type:
bool
- has_libdir(fileset: str | None = None) bool[source]#
Returns true if library directories are defined for the fileset
- Parameters:
fileset (str or list[str]) – Fileset(s) to query. If not provided, the active fileset is used.
- Returns:
True if the fileset contains directories.
- Return type:
bool
- hash_files(*keypath: str, update: bool = True, check: bool = True, verbose: bool = True, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) str | None | List[str | None][source]#
Generates hash values for a list of parameter files.
Generates a hash value for each file found in the keypath. If existing hash values are stored, this method will compare hashes and trigger an error if there’s a mismatch. If the update variable is True, the computed hash values are recorded in the ‘filehash’ field of the parameter, following the order dictated by the files within the ‘value’ parameter field.
Files are located using the find_files() function.
The file hash calculation is performed based on the ‘algo’ setting. Supported algorithms include SHA1, SHA224, SHA256, SHA384, SHA512, and MD5.
- Parameters:
*keypath (str) – Keypath to parameter.
update (bool) – If True, the hash values are recorded in the project object manifest.
check (bool) – If True, checks the newly computed hash against the stored hash.
verbose (bool) – If True, generates log messages.
allow_cache (bool) – If True, hashing check the cached values for specific files, if found, it will use that hash value otherwise the hash will be computed.
skip_missing (bool) – If True, hashing will be skipped when missing files are detected.
- Returns:
A list of hash values.
Examples
>>> hashlist = hash_files('input', 'rtl', 'verilog') Computes, stores, and returns hashes of files in :keypath:`input, rtl, verilog`.
- property name: str | None#
Returns the name of the schema
- property package: PackageSchema#
Gets the package schema for the design.
- Returns:
The package schema associated with this design.
- Return type:
- read_fileset(filename: str, fileset: str | None = None, fileformat: str | None = None) None[source]#
Imports filesets from a standard formatted text file.
Currently supports Verilog flist format only. Intended to support other formats in the future.
- Parameters:
filename (str or Path) – Input file name.
fileset (str or list[str]) – Fileset to import into. If not provided, the active fileset is used.
fileformat (str, optional) – Import format. Inferred from file extension if not provided.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- remove_dep(name: str | NamedSchema) bool[source]#
Removes a previously registered module.
- Parameters:
name (str) – Name of the module.
- Returns:
True if the module was removed, False if it was not found.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_dataroot(name: str = 'root', path: str | None = None, tag: str | None = None, clobber: bool = False) None[source]#
Registers a data source by name, path, and optional version tag.
This method creates a reference to a data directory, which can be a local path, a Git repository, or a remote archive. This allows other parts of the application to refer to this data source by its unique name.
- Parameters:
name (str, optional) – A unique name to identify the data source. Defaults to “root”.
path (str) – The path to the data source. This is required. It can be a local directory, a file path, a git URL, or an archive URL. If a file path is provided, its parent directory is used as the root.
tag (str, optional) – A version identifier for remote sources, such as a git commit hash, branch, or tag. Defaults to None.
clobber (bool, optional) – If True, allows overwriting an existing data source with the same name. If False (default), attempting to overwrite an existing entry will raise a ValueError.
- Raises:
ValueError – If path is not specified.
ValueError – If a data source with the given name already exists and clobber is False.
Examples
>>> # Register a remote git repository at a specific tag >>> schema.set_dataroot('siliconcompiler_data', ... 'git+https://github.com/siliconcompiler/siliconcompiler', ... tag='v1.0.0') >>> >>> # Register a local directory based on the location of a file >>> schema.set_dataroot('file_data', __file__)
- set_name(name: str | None) None[source]#
Set the name of this object
- Raises:
RuntimeError – if called after object name is set.
- Parameters:
name (str) – name for object
- set_param(name: str, value: str, fileset: str | None = None) str[source]#
Sets a named parameter for a fileset.
- Parameters:
name (str) – Parameter name.
value (str) – Parameter value.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
- Returns:
Parameter value
- Return type:
str
- set_topmodule(value: str, fileset: str | None = None) str[source]#
Sets the topmodule of a fileset.
- Parameters:
value (str) – Topmodule name.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
- Returns:
Topmodule name
- Return type:
str
Notes
first character must be letter or underscore
remaining characters can be letters, digits, or underscores
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- write_depgraph(filename: str, fontcolor: str = '#000000', background: str = 'transparent', fontsize: str = '14', border: bool = True, landscape: bool = False) None[source]#
Renders and saves the dependency graph to a file.
- Parameters:
filename (filepath) – Output filepath.
fontcolor (str) – Node font RGB color hex value.
background (str) – Background color.
fontsize (str) – Node text font size.
border (bool) – Enables node border if True.
landscape (bool) – Renders graph in landscape layout if True.
Examples
>>> schema.write_depgraph('mydump.png') Renders the object dependency graph and writes the result to a png file.
- write_fileset(filename: str, fileset: Iterable[str] | str | None = None, fileformat: str | None = None, depalias: Dict[Tuple[str, str], Tuple[NamedSchema, str]] | None = None, comments: bool = False) None[source]#
Exports filesets to a standard formatted text file.
Currently supports Verilog flist format only. Intended to support other formats in the future. Inferred from file extension if not given.
- Parameters:
filename (str or Path) – Output file name.
fileset (str or list[str]) – Fileset(s) to export. If not provided, the active fileset is used.
fileformat (str, optional) – Export format.
depalias (dict of schema objects) – Map of aliased objects.
comments (bool, optional) – Add comments in output file.
- class siliconcompiler.PDK(name: str | None = None)[source]#
Bases:
ToolLibrarySchemaA schema for managing and validating Process Design Kit (PDK) configurations.
This class defines the structured parameters that constitute a PDK, such as foundry information, process node, metal stackups, and various technology files required for different EDA tools. It extends the ToolLibrarySchema to provide a standardized way of describing and accessing PDK data within the SiliconCompiler framework.
- active_dataroot(dataroot: str | None = None)#
Use this context to set the dataroot parameter on files and directory parameters.
- Parameters:
dataroot (str) – name of the dataroot
Example
>>> with schema.active_dataroot("lambdalib"): ... schema.set("file", "top.v") Sets the file to top.v and associates lambdalib as the dataroot.
- active_fileset(fileset: str)#
Provides a context to temporarily set an active design fileset.
This is useful for applying a set of configurations to a specific fileset without repeatedly passing its name.
- Raises:
TypeError – If fileset is not a string.
ValueError – If fileset is an empty string.
- Parameters:
fileset (str) – The name of the fileset to activate.
Example
>>> with design.active_fileset("rtl"): ... design.set_topmodule("top") # This sets the top module for the 'rtl' fileset to 'top'.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_aprtechfileset(tool: str, fileset: List[str] | str | None = None, clobber: bool = False)[source]#
Adds a fileset containing APR technology files.
- Parameters:
tool (str) – The name of the tool.
fileset (str, optional) – The name of the fileset. Defaults to None, which uses the active fileset.
clobber (bool, optional) – If True, overwrites existing entries. Defaults to False.
- add_define(value: str, fileset: str | None = None, clobber: bool = False) List[str][source]#
Adds preprocessor macro definitions to a fileset.
- Parameters:
value (str or List[str]) – Macro definition.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
- Returns:
List of macro definitions
- Return type:
list[str]
- add_dep(obj: NamedSchema, clobber: bool = True) bool[source]#
Adds a module dependency to this design.
This method extends the base add_dep to prevent a design from adding a dependency on itself.
- Parameters:
obj (NamedSchema) – The dependency object to add.
clobber (bool) – If True, overwrite an existing dependency with the same name.
- Returns:
True if the dependency was added, False otherwise.
- Return type:
bool
- Raises:
TypeError – If obj is not a NamedSchema.
ValueError – If obj has the same name as the current design.
- add_depfileset(dep: Design | str, depfileset: str | None = None, fileset: str | None = None)[source]#
Record a reference to an imported dependency’s fileset.
- Parameters:
dep (
Designor str) – Dependency name or object.depfileset (str) – Dependency fileset, if not specified, the fileset will default to the same as the fileset or if only one fileset is present in the dep that will be chosen.
fileset (str) – Fileset name. If not provided, the active fileset is used.
- add_devmodelfileset(tool: str, type: str, fileset: List[str] | str | None = None, clobber: bool = False)[source]#
Adds a fileset containing device model files.
- Parameters:
tool (str) – The name of the tool.
type (str) – The type of the device model (e.g., ‘spice’).
fileset (str, optional) – The name of the fileset. Defaults to None, which uses the active fileset.
clobber (bool, optional) – If True, overwrites existing entries. Defaults to False.
- add_displayfileset(tool: str, fileset: List[str] | str | None = None, clobber: bool = False)[source]#
Adds a fileset containing display configuration files.
- Parameters:
tool (str) – The name of the tool.
fileset (str, optional) – The name of the fileset. Defaults to None, which uses the active fileset.
clobber (bool, optional) – If True, overwrites existing entries. Defaults to False.
- add_file(filename: List[Path | str] | Set[Path | str] | Tuple[Path | str, ...] | Path | str, fileset: str | None = None, filetype: str | None = None, clobber: bool = False, dataroot: str | None = None) List[str][source]#
Adds files to a fileset.
Based on the file’s extension, this method can often infer the correct fileset and filetype. For example:
.v -> (source, verilog)
.vhd -> (source, vhdl)
.sdc -> (constraint, sdc)
.lef -> (input, lef)
.def -> (input, def)
etc.
- Parameters:
filename (Path, str, or collection) – File path (Path or str), or a collection (list, tuple, set) of file paths to add.
fileset (str) – Logical group to associate the file with.
filetype (str, optional) – Type of the file (e.g., ‘verilog’, ‘sdc’).
clobber (bool, optional) – If True, clears the list before adding the item. Defaults to False.
dataroot (str, optional) – Data directory reference name.
- Raises:
ValueError – If fileset or filetype cannot be inferred from the file extension.
- Returns:
A list of the file paths that were added.
- Return type:
list[str]
Notes
This method normalizes filename to a string for consistency.
- If filetype is not specified, it is inferred from the
file extension.
- add_idir(value: str, fileset: str | None = None, clobber: bool = False, dataroot: str | None = None) List[str][source]#
Adds include directories to a fileset.
- Parameters:
value (Path or list[Path]) – Include path(s).
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
dataroot (str, optional) – Data directory reference name.
- Returns:
List of include directories
- Return type:
list[str]
- add_layermapfileset(tool: str, src: str, dst: str, fileset: List[str] | str | None = None, clobber: bool = False)[source]#
Adds a fileset containing layer map files.
- Parameters:
tool (str) – The name of the tool.
src (str) – The source format or tool name.
dst (str) – The destination format or tool name.
fileset (str, optional) – The name of the fileset. Defaults to None, which uses the active fileset.
clobber (bool, optional) – If True, overwrites existing entries. Defaults to False.
- add_lib(value: str, fileset: str | None = None, clobber: bool = False) List[str][source]#
Adds dynamic libraries to a fileset.
- Parameters:
value (str or List[str]) – Libraries.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
- Returns:
List of libraries.
- Return type:
list[str]
- add_libdir(value: str, fileset: str | None = None, clobber: bool = False, dataroot: str | None = None) List[str][source]#
Adds dynamic library directories to a fileset.
- Parameters:
value (Path or list[Path]) – Library path(s).
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
dataroot (str, optional) – Data directory reference name.
- Returns:
List of library directories.
- Return type:
list[str]
- add_pexmodelfileset(tool: str, corner: str, fileset: List[str] | str | None = None, clobber: bool = False)[source]#
Adds a fileset containing parasitic extraction (pex) model files.
- Parameters:
tool (str) – The name of the tool.
corner (str) – The corner name (e.g., ‘min’, ‘max’).
fileset (str, optional) – The name of the fileset. Defaults to None, which uses the active fileset.
clobber (bool, optional) – If True, overwrites existing entries. Defaults to False.
- add_runsetfileset(type: str, tool: str, name: str, fileset: List[str] | str | None = None, clobber: bool = False)[source]#
Adds a fileset containing a runset for a specific verification task.
- Parameters:
type (str) – The type of task (e.g., ‘lvs’, ‘drc’).
tool (str) – The name of the tool.
name (str) – The name of the runset.
fileset (str, optional) – The name of the fileset. Defaults to None, which uses the active fileset.
clobber (bool, optional) – If True, overwrites existing entries. Defaults to False.
- add_undefine(value: str, fileset: str | None = None, clobber: bool = False) List[str][source]#
Adds preprocessor macro (un)definitions to a fileset.
- Parameters:
value (str or List[str]) – Macro (un)definition.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
- Returns:
List of macro (un)definitions
- Return type:
list[str]
- add_waiverfileset(type: str, tool: str, name: str, fileset: List[str] | str | None = None, clobber: bool = False)[source]#
Adds a fileset containing waiver files for a specific verification task.
- Parameters:
type (str) – The type of task (e.g., ‘lvs’, ‘drc’).
tool (str) – The name of the tool.
name (str) – The name of the waiver set.
fileset (str, optional) – The name of the fileset. Defaults to None, which uses the active fileset.
clobber (bool, optional) – If True, overwrites existing entries. Defaults to False.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- calc_dpw(diewidth: float, dieheight: float) int[source]#
Calculates dies per wafer.
Calculates the gross dies per wafer based on the design area, wafersize, wafer edge margin, and scribe lines. The calculation is done by starting at the center of the wafer and placing as many complete design footprints as possible within a legal placement area.
- Parameters:
diewidth (float) – The width of the die in micrometers (um).
dieheight (float) – The height of the die in micrometers (um).
- Returns:
Number of gross dies per wafer.
- Return type:
int
Examples
>>> dpw = pdk.calc_dpw(1000.0, 1500.0) # Calculates dies per wafer for a 1000x1500 um die.
- calc_yield(diearea: float, model: str = 'poisson') float[source]#
Calculates raw die yield.
Calculates the raw yield of the design as a function of design area and d0 defect density. Calculation can be done based on the poisson model (default) or the murphy model. The die area and the d0 parameters are taken from the pdk dictionary.
Poisson model: dy = exp(-area * d0/100).
Murphy model: dy = ((1-exp(-area * d0/100))/(area * d0/100))^2.
- Parameters:
diearea (float) – The area of the die in square micrometers (um^2).
model (string) – Model to use for calculation (poisson or murphy)
- Returns:
Design yield percentage.
- Return type:
float
Examples
>>> yield = pdk.calc_yield(1500.0) # Calculates yield for a 1500 um^2 die.
- check_filepaths(ignore_keys: List[Tuple[str, ...]] | None = None) bool[source]#
Verifies that paths to all files in manifest are valid.
- Parameters:
ignore_keys (list of keypaths) – list of keypaths to ignore while checking
- Returns:
True if all file paths are valid, otherwise False.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- copy_fileset(src_fileset: str, dst_fileset: str, clobber: bool = False) None[source]#
Creates a new copy of a source fileset.
The entire configuration of the source fileset is duplicated and stored under the destination fileset’s name.
- Parameters:
src_fileset (str) – The name of the source fileset to copy.
dst_fileset (str) – The name of the new destination fileset.
clobber (bool) – If True, an existing destination fileset will be overwritten. Defaults to False.
- Raises:
ValueError – If the destination fileset already exists and clobber is False.
- define_tool_parameter(tool: str, name: str, type: str, help: str, **kwargs)[source]#
Define a new tool parameter for the library.
- find_files(*keypath: str, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) List[str | None] | str | None[source]#
Returns absolute paths to files or directories based on the keypath provided.
The keypath provided must point to a schema parameter of type file, dir, or lists of either. Otherwise, it will trigger an error.
- Parameters:
keypath (list of str) – Variable length schema key list.
missing_ok (bool) – If True, silently return None when files aren’t found. If False, print an error and set the error flag.
step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
If keys points to a scalar entry, returns an absolute path to that file/directory, or None if not found. It keys points to a list entry, returns a list of either the absolute paths or None for each entry, depending on whether it is found.
Examples
>>> schema.find_files('input', 'verilog') Returns a list of absolute paths to source files, as specified in the schema.
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True, name: str | None = None) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
name (str) – name of the schema.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_dataroot(name: str) str[source]#
Returns absolute path to the data directory.
- Raises:
ValueError – is data directory is not found
- Parameters:
name (str) – name of the data directory to find.
- Returns:
Path to the directory root.
Examples
>>> schema.get_dataroot('siliconcompiler') Returns the path to the root of the siliconcompiler data directory.
- get_define(fileset: str | None = None) List[str][source]#
Returns defined macros for a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of macro definitions
- Return type:
list[str]
- get_dep(name: str | None = None, hierarchy: bool = True) List[NamedSchema][source]#
Returns all dependencies associated with this object or a specific one if requested.
- Raises:
KeyError – if the specific module is requested but not found.
- Parameters:
name (str) – Name of the module.
hierarchy (bool) – If True, will return all modules including children, otherwise only this object’s modules are returned.
- Returns:
A list of dependency objects.
- Return type:
list
- get_depfileset(fileset: str | None = None)[source]#
Returns list of dependency filesets.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of dependencies and filesets.
- Return type:
list[tuple(str, str)]
- get_file(fileset: str | None = None, filetype: str | None = None) List[str][source]#
Returns a list of files from one or more filesets.
- Parameters:
fileset (str or list[str]) – Fileset(s) to query. If not provided, the active fileset is used.
filetype (str or list[str], optional) – File type(s) to filter by (e.g., ‘verilog’). If not provided, all filetypes in the fileset are returned.
- Returns:
A list of resolved file paths.
- Return type:
list[str]
- get_fileset(filesets: List[str] | str, alias: Dict[Tuple[str, str], Tuple[NamedSchema, str]] | None = None) List[Tuple[NamedSchema, str]][source]#
Computes the full, recursive list of (design, fileset) tuples required for a given set of top-level filesets.
This method traverses the design’s dependency graph to resolve all depfileset entries, returning a flattened and unique list of all required sources.
- Parameters:
filesets (Union[List[str], str]) – A single fileset name or a list of fileset names to evaluate.
alias (Dict[Tuple[str, str], Tuple[NamedSchema, str]], optional) – A dictionary mapping (design_name, fileset_name) tuples to be substituted during traversal. The value should be a (Design object, new_fileset_name) tuple. This is useful for swapping out library implementations. Defaults to None.
- Returns:
A flattened, unique list of (Design, fileset) tuples representing all dependencies.
- Return type:
List[Tuple[NamedSchema, str]]
- get_idir(fileset: str | None = None) List[str][source]#
Returns include directories for a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of include directories
- Return type:
list[str]
- get_lib(fileset: str | None = None) List[str][source]#
Returns list of dynamic libraries for a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of libraries.
- Return type:
list[str]
- get_libdir(fileset: str | None = None) List[str][source]#
Returns dynamic library directories for a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of library directories.
- Return type:
list[str]
- get_param(name: str, fileset: str | None = None) str[source]#
Returns value of a named fileset parameter.
- Parameters:
name (str) – Parameter name.
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
Parameter value
- Return type:
str
- get_topmodule(fileset: str | None = None) str[source]#
Returns the topmodule of a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
Topmodule name
- Return type:
str
- get_undefine(fileset: str | None = None) List[str][source]#
Returns undefined macros for a fileset.
- Args:
- fileset (str): Fileset name. If not provided, the active fileset is
used.
- Returns:
List of macro (un)definitions
- Return type:
list[str]
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- has_dep(name: NamedSchema | str) bool[source]#
Checks if a specific dependency is present.
- Parameters:
name (str) – Name of the module.
- Returns:
True if the module was found, False otherwise.
- has_file(fileset: str | None = None, filetype: str | None = None) bool[source]#
Returns true if the fileset contains files.
- Parameters:
fileset (str or list[str]) – Fileset(s) to query. If not provided, the active fileset is used.
filetype (str or list[str], optional) – File type(s) to filter by (e.g., ‘verilog’). If not provided, all filetypes in the fileset are returned.
- Returns:
True if the fileset contains files.
- Return type:
bool
- has_fileset(fileset: str) bool[source]#
Checks if a fileset exists in the schema.
- Parameters:
fileset (str) – The name of the fileset to check.
- Returns:
True if the fileset exists, False otherwise.
- Return type:
bool
- has_idir(fileset: str | None = None) bool[source]#
Returns true if idirs are defined for the fileset
- Parameters:
fileset (str or list[str]) – Fileset(s) to query. If not provided, the active fileset is used.
- Returns:
True if the fileset contains directories.
- Return type:
bool
- has_libdir(fileset: str | None = None) bool[source]#
Returns true if library directories are defined for the fileset
- Parameters:
fileset (str or list[str]) – Fileset(s) to query. If not provided, the active fileset is used.
- Returns:
True if the fileset contains directories.
- Return type:
bool
- hash_files(*keypath: str, update: bool = True, check: bool = True, verbose: bool = True, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) str | None | List[str | None][source]#
Generates hash values for a list of parameter files.
Generates a hash value for each file found in the keypath. If existing hash values are stored, this method will compare hashes and trigger an error if there’s a mismatch. If the update variable is True, the computed hash values are recorded in the ‘filehash’ field of the parameter, following the order dictated by the files within the ‘value’ parameter field.
Files are located using the find_files() function.
The file hash calculation is performed based on the ‘algo’ setting. Supported algorithms include SHA1, SHA224, SHA256, SHA384, SHA512, and MD5.
- Parameters:
*keypath (str) – Keypath to parameter.
update (bool) – If True, the hash values are recorded in the project object manifest.
check (bool) – If True, checks the newly computed hash against the stored hash.
verbose (bool) – If True, generates log messages.
allow_cache (bool) – If True, hashing check the cached values for specific files, if found, it will use that hash value otherwise the hash will be computed.
skip_missing (bool) – If True, hashing will be skipped when missing files are detected.
- Returns:
A list of hash values.
Examples
>>> hashlist = hash_files('input', 'rtl', 'verilog') Computes, stores, and returns hashes of files in :keypath:`input, rtl, verilog`.
- property name: str | None#
Returns the name of the schema
- property package: PackageSchema#
Gets the package schema for the design.
- Returns:
The package schema associated with this design.
- Return type:
- read_fileset(filename: str, fileset: str | None = None, fileformat: str | None = None) None[source]#
Imports filesets from a standard formatted text file.
Currently supports Verilog flist format only. Intended to support other formats in the future.
- Parameters:
filename (str or Path) – Input file name.
fileset (str or list[str]) – Fileset to import into. If not provided, the active fileset is used.
fileformat (str, optional) – Import format. Inferred from file extension if not provided.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- remove_dep(name: str | NamedSchema) bool[source]#
Removes a previously registered module.
- Parameters:
name (str) – Name of the module.
- Returns:
True if the module was removed, False if it was not found.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_aprroutinglayers(min: str | None = None, max: str | None = None)[source]#
Sets the minimum and maximum routing layers for the PDK.
- Parameters:
min (str, optional) – The minimum routing layer name. Defaults to None.
max (str, optional) – The maximum routing layer name. Defaults to None.
- set_dataroot(name: str = 'root', path: str | None = None, tag: str | None = None, clobber: bool = False) None[source]#
Registers a data source by name, path, and optional version tag.
This method creates a reference to a data directory, which can be a local path, a Git repository, or a remote archive. This allows other parts of the application to refer to this data source by its unique name.
- Parameters:
name (str, optional) – A unique name to identify the data source. Defaults to “root”.
path (str) – The path to the data source. This is required. It can be a local directory, a file path, a git URL, or an archive URL. If a file path is provided, its parent directory is used as the root.
tag (str, optional) – A version identifier for remote sources, such as a git commit hash, branch, or tag. Defaults to None.
clobber (bool, optional) – If True, allows overwriting an existing data source with the same name. If False (default), attempting to overwrite an existing entry will raise a ValueError.
- Raises:
ValueError – If path is not specified.
ValueError – If a data source with the given name already exists and clobber is False.
Examples
>>> # Register a remote git repository at a specific tag >>> schema.set_dataroot('siliconcompiler_data', ... 'git+https://github.com/siliconcompiler/siliconcompiler', ... tag='v1.0.0') >>> >>> # Register a local directory based on the location of a file >>> schema.set_dataroot('file_data', __file__)
- set_defectdensity(d0: float)[source]#
Sets the process defect density for the PDK.
- Parameters:
d0 (float) – The defect density (defects per cm^2).
- set_edgemargin(margin: float)[source]#
Sets the wafer edge keep-out margin for the PDK.
- Parameters:
margin (float) – The edge margin in millimeters.
- set_foundry(foundry: str)[source]#
Sets the foundry name for the PDK.
- Parameters:
foundry (str) – The name of the foundry.
- set_name(name: str | None) None[source]#
Set the name of this object
- Raises:
RuntimeError – if called after object name is set.
- Parameters:
name (str) – name for object
- set_node(node: float)[source]#
Sets the process node for the PDK.
- Parameters:
node (float) – The process node in nanometers.
- set_param(name: str, value: str, fileset: str | None = None) str[source]#
Sets a named parameter for a fileset.
- Parameters:
name (str) – Parameter name.
value (str) – Parameter value.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
- Returns:
Parameter value
- Return type:
str
- set_scribewidth(x: float, y: float)[source]#
Sets the scribe line width for the PDK.
- Parameters:
x (float) – The horizontal scribe width in millimeters.
y (float) – The vertical scribe width in millimeters.
- set_stackup(stackup: str)[source]#
Sets the metal stackup for the PDK.
- Parameters:
stackup (str) – The name of the metal stackup.
- set_topmodule(value: str, fileset: str | None = None) str[source]#
Sets the topmodule of a fileset.
- Parameters:
value (str) – Topmodule name.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
- Returns:
Topmodule name
- Return type:
str
Notes
first character must be letter or underscore
remaining characters can be letters, digits, or underscores
- set_unitcost(unitcost: float)[source]#
Sets the unit cost for the PDK.
- Parameters:
unitcost (float) – The unit cost in USD.
- set_wafersize(wafersize: float)[source]#
Sets the wafer size for the PDK.
- Parameters:
wafersize (float) – The wafer diameter in millimeters.
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- write_depgraph(filename: str, fontcolor: str = '#000000', background: str = 'transparent', fontsize: str = '14', border: bool = True, landscape: bool = False) None[source]#
Renders and saves the dependency graph to a file.
- Parameters:
filename (filepath) – Output filepath.
fontcolor (str) – Node font RGB color hex value.
background (str) – Background color.
fontsize (str) – Node text font size.
border (bool) – Enables node border if True.
landscape (bool) – Renders graph in landscape layout if True.
Examples
>>> schema.write_depgraph('mydump.png') Renders the object dependency graph and writes the result to a png file.
- write_fileset(filename: str, fileset: Iterable[str] | str | None = None, fileformat: str | None = None, depalias: Dict[Tuple[str, str], Tuple[NamedSchema, str]] | None = None, comments: bool = False) None[source]#
Exports filesets to a standard formatted text file.
Currently supports Verilog flist format only. Intended to support other formats in the future. Inferred from file extension if not given.
- Parameters:
filename (str or Path) – Output file name.
fileset (str or list[str]) – Fileset(s) to export. If not provided, the active fileset is used.
fileformat (str, optional) – Export format.
depalias (dict of schema objects) – Map of aliased objects.
comments (bool, optional) – Add comments in output file.
- class siliconcompiler.Flowgraph(name: str | None = None)[source]#
Bases:
NamedSchema,DocsSchemaSchema for defining and interacting with a flowgraph.
A flowgraph is a directed acyclic graph (DAG) that represents the compilation flow. Each node in the graph is a step/index pair that maps to a specific tool task, and edges represent dependencies between these tasks.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- edge(tail: str, head: str, tail_index: str | int | None = 0, head_index: str | int | None = 0) None[source]#
Creates a directed edge from a tail node to a head node.
Connects the output of a tail node (tail, tail_index) with the input of a head node (head, head_index) by adding the tail node to the ‘input’ list of the head node in the schema.
If the edge already exists, this method does nothing.
The method modifies the following parameter:
[‘<head>’, ‘<head_index>’, ‘input’]
- Parameters:
tail (str) – Step name of the tail node (source).
head (str) – Step name of the head node (destination).
tail_index (int or str, optional) – Index of the tail node. Defaults to 0.
head_index (int or str, optional) – Index of the head node. Defaults to 0.
- Raises:
ValueError – If either the head or tail node is not defined in the flowgraph before calling this method.
Examples
>>> flow.node('place', 'openroad/Place') >>> flow.node('cts', 'openroad/Cts') >>> flow.edge('place', 'cts') # Creates a directed edge from ('place', '0') to ('cts', '0').
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True, name: str | None = None) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
name (str) – name of the schema.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_all_tasks() Set[Type[Task]][source]#
Returns all unique task classes used in this flowgraph.
- Returns:
A set of all imported task classes.
- Return type:
set[Type[Task]]
- get_entry_nodes() Tuple[Tuple[str, str], ...][source]#
Collects all nodes that are entry points to the flowgraph.
Entry nodes are those with no inputs defined. The result is memoized.
- Returns:
A sorted tuple of all entry nodes in the graph.
- Return type:
tuple[tuple(str,str)]
- get_execution_order(reverse: bool | None = False) Tuple[Tuple[Tuple[str, str], ...], ...][source]#
Generates a topologically sorted list of nodes for execution.
This method performs a topological sort of the graph. The result is a tuple of tuples, where each inner tuple represents a “level” of nodes that can be executed in parallel (as their dependencies are met).
The result is memoized for both forward and reverse orders.
- Parameters:
reverse (bool, optional) – If True, the order is reversed, starting from the exit nodes and working backwards to the entry nodes. Defaults to False.
- Returns:
A tuple of tuples, where each inner tuple represents a level of nodes.
- Return type:
tuple[tuple[tuple(str,str)]]
- get_exit_nodes() Tuple[Tuple[str, str], ...][source]#
Collects all nodes that are exit points of the flowgraph.
Exit nodes are those that are not inputs to any other node in the graph. The result is memoized.
- Returns:
A sorted tuple of all exit nodes in the graph.
- Return type:
tuple[tuple(str,str)]
- get_graph_node(step: str, index: str | int | None = None) FlowgraphNodeSchema[source]#
Get the flowgraph node for this step and index
- get_node_outputs(step: str, index: str | int) Tuple[Tuple[str, str], ...][source]#
Returns the nodes that the given node provides input to (its children).
This is the reverse of get_graph_node(step, index).get_input(). The results are computed for all nodes and memoized on the first call.
- Parameters:
step (str) – Step name of the source node.
index (str or int) – Index of the source node.
- Returns:
A sorted tuple of destination nodes (step, index) that take the given node as an input.
- Return type:
tuple[tuple(str,str)]
- Raises:
ValueError – If the specified (step, index) is not a valid node.
- get_nodes() Tuple[Tuple[str, str], ...][source]#
Returns a sorted tuple of all nodes defined in this flowgraph.
A node is represented as a (step, index) tuple. The result is memoized for efficiency.
- Returns:
A sorted tuple of all (step, index) nodes in the graph.
- Return type:
tuple[tuple(str,str)]
- get_task_module(step: str, index: str | int) Type[Task][source]#
Returns the imported Python Task class for a given task node.
- Parameters:
step (str) – Step name of the node.
index (int or str) – Index of the node.
- Returns:
The imported Task class associated with the node.
- Return type:
Type[Task]
- Raises:
ValueError – If the node is not valid.
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- graph(subflow: Flowgraph, name: str | None = None) None[source]#
Instantiates a sub-flowgraph within the current flowgraph.
This method copies all nodes and their internal connections from subflow into the current flowgraph.
If name is provided, it is used as a prefix (e.g., “core.”) for all step names from the subflow to ensure they are unique within the current flowgraph. This prefix is also applied to the internal edges to maintain the sub-flowgraph’s structure.
- Parameters:
subflow (Flowgraph) – The flowgraph to instantiate.
name (str, optional) – A prefix to add to the names of the instantiated steps to ensure they are unique. Defaults to None.
- Raises:
ValueError – If subflow is not a Flowgraph object, or if a step from the sub-flowgraph already exists in the current graph.
- insert_node(step: str, task: Task, before_step: str, index: str | int | None = 0, before_index: str | int | None = 0) None[source]#
Inserts a new node in the graph immediately before a specified node.
The new node (step, index) is placed between the before node (before_step, before_index) and all of the before node’s original inputs. The before node’s inputs are cleared, and it is given a single input: the new node. The new node inherits all the original inputs of the before node.
- Parameters:
step (str) – Step name for the new node.
task (Task or str or Type[Task]) – Task to associate with the new node.
before_step (str) – Step name of the existing node to insert before.
index (int or str, optional) – Index for the new node. Defaults to 0.
before_index (int or str, optional) – Index of the existing node. Defaults to 0.
- Raises:
ValueError – If the before node (before_step, before_index) is not a valid node in the flowgraph.
- classmethod make_docs() TSchema | List[TSchema][source]#
Generate the documentation representation for this schema.
By default, this method returns a standard instance of the class itself. Subclasses can override this method to return a modified or different schema instance, or even a list of schemas, to customize how they appear in the generated documentation.
- Returns:
An instance or list of instances of BaseSchema that represents the schema for documentation purposes.
- property name: str | None#
Returns the name of the schema
- node(step: str, task: Task, index: str | int | None = 0) None[source]#
Creates or updates a flowgraph node.
Creates a flowgraph node by binding a step/index pair to a specific tool task. A tool can be an external executable or one of the built-in functions in the SiliconCompiler framework (e.g., minimum, maximum, join).
If the node (step, index) already exists, its task and tool information will be updated.
The method modifies the following schema parameters for the given step and index:
[‘<step>’, ‘<index>’, ‘tool’]
[‘<step>’, ‘<index>’, ‘task’]
[‘<step>’, ‘<index>’, ‘taskmodule’]
- Parameters:
step (str) – Step name for the node. Must not contain ‘/’.
task (Task or str or Type[Task]) – The task to associate with this node. Can be a task instance, a string in the format ‘<module_path>/<ClassName>’, or a Task class type.
index (int or str, optional) – Index for the step. Defaults to 0. Must not contain ‘/’.
- Raises:
ValueError – If ‘step’ or ‘index’ are reserved names (like ‘default’ or ‘global’) or contain invalid characters (‘/’).
ValueError – If ‘task’ is not a valid Task object, string, or class.
Examples
>>> import siliconcompiler.tools.openroad as openroad >>> # Using a Task class >>> flow.node('place', openroad.Place, index=0) >>> >>> # Using a string identifier >>> flow.node('cts', 'siliconcompiler.tools.openroad/Cts', index=0) >>> >>> # Using a Task instance >>> from siliconcompiler.tools.builtin import Join >>> flow.node('join', Join(), index=0)
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- remove_node(step: str, index: str | int | None = None) None[source]#
Removes a flowgraph node and reconnects its inputs to its outputs.
This operation effectively “stitches” the graph back together by creating new edges from all inputs of the removed node to all outputs of the removed node.
If index is None, all nodes for the given step are removed.
- Parameters:
step (str) – Step name of the node to remove.
index (int or str, optional) – Index of the node to remove. If None, all nodes for the given step are removed. Defaults to None.
- Raises:
ValueError – If the specified step or (step, index) is not a valid node in the flowgraph.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_name(name: str | None) None[source]#
Set the name of this object
- Raises:
RuntimeError – if called after object name is set.
- Parameters:
name (str) – name for object
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- validate(logger: Logger | None = None) bool[source]#
Checks if the flowgraph is valid.
This method performs several checks: * All edges must point to and from valid nodes. * There should be no duplicate edges. * All nodes must have their tool, task, and taskmodule defined. * The graph must not contain any loops (it must be a DAG).
- Parameters:
logger (logging.Logger, optional) – A logger to use for reporting errors. Defaults to None.
- Returns:
True if the graph is valid, False otherwise.
- Return type:
bool
- write_flowgraph(filename: str, fillcolor: str = '#ffffff', fontcolor: str = '#000000', background: str = 'transparent', fontsize: int | str = 14, border: bool = True, landscape: bool = False, show_io: bool | None = None) None[source]#
Renders and saves the compilation flowgraph to a file.
The flow object flowgraph is traversed to create a graphviz (*.dot) file comprised of node, edges, and labels. The dot file is a graphical representation of the flowgraph useful for validating the correctness of the execution flow graph. The dot file is then converted to the appropriate picture or drawing format based on the filename suffix provided. Supported output render formats include png, svg, gif, pdf and a few others. For more information about the graphviz project, see see https://graphviz.org/
- Parameters:
filename (filepath) – Output filepath
fillcolor (str) – Node fill RGB color hex value
fontcolor (str) – Node font RGB color hex value
background (str) – Background color
fontsize (str) – Node text font size
border (bool) – Enables node border if True
landscape (bool) – Renders graph in landscape layout if True
show_io (bool) – Add file input/outputs to graph
Examples
>>> flow.write_flowgraph('mydump.png') Renders the object flowgraph and writes the result to a png file.
- class siliconcompiler.Checklist(name: str | None = None)[source]#
Bases:
NamedSchemaA class for managing a collection of design checklist items and their verification.
This class acts as a container for multiple Criteria objects, each representing an item in a design checklist (e.g., ‘ISO D000’). It provides methods to define, access, and automatically verify these items against flow results.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- check(items: Iterable[str] | None = None, check_ok: bool = False, require_reports: bool = True) bool[source]#
Checks the status of items in a checklist against flow results.
This method validates checklist items by comparing their defined criteria against metrics recorded in the chip’s history. For an item to pass, all its criteria must be met by the associated tasks, considering any waivers.
For items with automated checks (linked to a task), this method verifies that metric values from the flow run satisfy the criteria (e.g., ‘errors == 0’). It also ensures that corresponding EDA reports were generated.
For items without a task, it only checks that a report has been manually added.
- Parameters:
items (Optional[Iterable[str]]) – A list of item names to check. If None, all items in the checklist are checked. Defaults to None.
check_ok (bool) – If True, all checked items must also have their ‘ok’ parameter set to True, indicating manual review. Defaults to False.
require_reports (bool) – If True, asserts that report files exist for all automated checks. Defaults to True.
- Returns:
True if all specified checks pass, False otherwise.
- Return type:
bool
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True, name: str | None = None) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
name (str) – name of the schema.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_criteria(name: str | None = None) Dict[str, Criteria] | Criteria[source]#
Retrieves one or all Criteria items from the checklist.
If a name is provided, it returns the specific Criteria object. If no name is provided, it returns a dictionary of all Criteria objects.
- Parameters:
name (Optional[str], optional) – The name of the item to retrieve. Defaults to None.
- Returns:
A single Criteria object or a dictionary mapping names to Criteria objects.
- Return type:
- Raises:
ValueError – If a name is provided but is not found in the checklist.
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- make_criteria(name: str) Criteria[source]#
Creates a new, named Criteria item within this checklist.
- Parameters:
name (str) – The unique name for the new checklist item.
- Returns:
The newly created Criteria object.
- Return type:
- Raises:
ValueError – If a criteria item with the same name already exists.
- property name: str | None#
Returns the name of the schema
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_name(name: str | None) None[source]#
Set the name of this object
- Raises:
RuntimeError – if called after object name is set.
- Parameters:
name (str) – name for object
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.Task[source]#
Bases:
NamedSchema,PathSchema,DocsSchemaA schema class that defines the parameters and methods for a single task in a compilation flow.
This class provides the framework for setting up, running, and post-processing a tool. It includes methods for managing executables, versions, runtime arguments, and file I/O.
- active_dataroot(dataroot: str | None = None)#
Use this context to set the dataroot parameter on files and directory parameters.
- Parameters:
dataroot (str) – name of the dataroot
Example
>>> with schema.active_dataroot("lambdalib"): ... schema.set("file", "top.v") Sets the file to top.v and associates lambdalib as the dataroot.
- add(*args, field: str = 'value', step: str | None = None, index: int | str | None = None)[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_commandline_option(option: List[str] | str, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Add to the command line options for the task
- Parameters:
option (list of str or str) – options to add to the commandline
clobber (bool) – overwrite existing value
- add_input_file(file: str | None = None, ext: str | None = None, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Add a required input file from the previous step in the flow.
file and ext are mutually exclusive.
- Parameters:
file (str) – full filename
ext (str) – file extension, if specified, the filename will be <top>.<ext>
clobber (bool) – overwrite existing value
- add_licenseserver(name: str, server: str, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Configures a license server connection for the tool.
This sets the environment variables that commercial EDA tools use to find their license server.
- Parameters:
name (str) – The name of the license variable (e.g., ‘LM_LICENSE_FILE’).
server (str) – The server address (e.g., ‘port@host’).
step (str, optional) – The step associated with this setting. Defaults to the current step.
index (str, optional) – The index associated with this setting. Defaults to the current index.
clobber (bool) – If True, overwrite existing values. Otherwise, append to them.
- Returns:
The schema key that was set.
- add_output_file(file: str | None = None, ext: str | None = None, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Add an output file that this task will produce
file and ext are mutually exclusive.
- Parameters:
file (str) – full filename
ext (str) – file extension, if specified, the filename will be <top>.<ext>
clobber (bool) – overwrite existing value
- add_parameter(name: str, type: str, help: str, defvalue=None, **kwargs) Parameter[source]#
Adds a custom parameter (‘var’) to the task definition.
- Parameters:
name (str) – The name of the parameter.
type (str) – The schema type of the parameter.
help (str) – The help string for the parameter.
defvalue – The default value for the parameter.
- add_postscript(script: str, dataroot: str | None = None, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Adds a script to be executed after the main tool command.
This is useful for post-processing tool outputs or performing cleanup actions.
- Parameters:
script (str) – The path to the post-execution script.
dataroot (str, optional) – The data root this path is relative to. Defaults to the active package.
step (str, optional) – The step associated with this setting. Defaults to the current step.
index (str, optional) – The index associated with this setting. Defaults to the current index.
clobber (bool) – If True, overwrite existing values. Otherwise, append to them.
- Returns:
The schema key that was set.
- add_prescript(script: str, dataroot: str | None = None, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Adds a script to be executed before the main tool command.
This is useful for pre-processing files or setting up the environment in ways that go beyond simple environment variables.
- Parameters:
script (str) – The path to the pre-execution script.
dataroot (str, optional) – The data root this path is relative to. Defaults to the active package.
step (str, optional) – The step associated with this setting. Defaults to the current step.
index (str, optional) – The index associated with this setting. Defaults to the current index.
clobber (bool) – If True, overwrite existing values. Otherwise, append to them.
- Returns:
The schema key that was set.
- add_regex(type: str, regex: str, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Adds a regular expression for parsing the tool’s log file.
These regexes are used by the framework to identify errors, warnings, and metrics from the tool’s standard output.
- Parameters:
type (str) – The category of the regex (e.g., ‘error’, ‘warning’).
regex (str) – The regular expression pattern.
step (str, optional) – The step associated with this setting. Defaults to the current step.
index (str, optional) – The index associated with this setting. Defaults to the current index.
clobber (bool) – If True, overwrite existing values. Otherwise, append to them.
- Returns:
The schema key that was set.
- add_required_key(obj: BaseSchema | str, *key: str, step: str | None = None, index: int | str | None = None)[source]#
- Adds a required keypath to the task driver. If the key is valid relative to the task object
the key will be assumed as a task key.
- Parameters:
obj (
BaseSchemaor str) – if this is a string it will be considered part of the key, otherwise the keypath to the obj will be prepended to the keykey (list of str) – required key path
- add_sbom(version: str, sbom: str | List[str], dataroot: str | None = None, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Adds a Software Bill of Materials (SBOM) file for a tool version.
Associates a specific tool version with its corresponding SBOM file, typically in SPDX or CycloneDX format.
- Parameters:
version (str) – The exact tool version this SBOM corresponds to.
sbom (str) – The path to the SBOM file.
dataroot (str, optional) – The data root this path is relative to. Defaults to the active package.
clobber (bool) – If True, overwrite existing values. Otherwise, append to them.
- Returns:
The schema key that was set.
- add_version(version: List[str] | str, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Adds a supported version specifier for the tool.
SiliconCompiler checks the tool’s actual version against these specifiers to ensure compatibility. Versions should follow the PEP-440 standard (e.g., ‘>=5.6’, ‘==1.2.3’).
- Parameters:
version (str) – The version specifier string.
step (str, optional) – The step associated with this setting. Defaults to the current step.
index (str, optional) – The index associated with this setting. Defaults to the current index.
clobber (bool) – If True, overwrite existing values. Otherwise, append to them.
- Returns:
The schema key that was set.
- add_vswitch(switch: List[str] | str, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Adds the command-line switch used to print the tool’s version.
This switch is passed to the executable to get its version string for checking.
- Parameters:
switch (str) – The version switch (e.g., ‘-v’, ‘–version’).
clobber (bool) – If True, overwrite existing values. Otherwise, append to them.
- Returns:
The schema key that was set.
- add_warningoff(type: str, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Adds a warning message or code to be suppressed during log parsing.
Any warning that matches a regex in this list will be ignored by the framework.
- Parameters:
type (str) – The warning message or code to suppress.
step (str, optional) – The step associated with this setting. Defaults to the current step.
index (str, optional) – The index associated with this setting. Defaults to the current index.
clobber (bool) – If True, overwrite existing values. Otherwise, append to them.
- Returns:
The schema key that was set.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- check_exe_version(reported_version: str) bool[source]#
Checks if the reported version of a tool satisfies the requirements specified in the schema.
- Parameters:
reported_version (str) – The version string reported by the tool.
- Returns:
True if the version is acceptable, False otherwise.
- Return type:
bool
- check_filepaths(ignore_keys: List[Tuple[str, ...]] | None = None) bool[source]#
Verifies that paths to all files in manifest are valid.
- Parameters:
ignore_keys (list of keypaths) – list of keypaths to ignore while checking
- Returns:
True if all file paths are valid, otherwise False.
- compute_input_file_node_name(filename: str, step: str, index: str) str[source]#
Generates a unique name for an input file based on its originating node.
- Parameters:
filename (str) – The original name of the input file.
step (str) – The step name of the originating node.
index (str) – The index of the originating node.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- property design_name: str#
The name of the design.
- Type:
str
- property design_topmodule: str#
The top module of the design for the current node.
- Type:
str
- find_files(*keypath: str, missing_ok: bool = False, step: str | None = None, index: int | str | None = None)[source]#
Returns absolute paths to files or directories based on the keypath provided.
The keypath provided must point to a schema parameter of type file, dir, or lists of either. Otherwise, it will trigger an error.
- Parameters:
keypath (list of str) – Variable length schema key list.
missing_ok (bool) – If True, silently return None when files aren’t found. If False, print an error and set the error flag.
step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
If keys points to a scalar entry, returns an absolute path to that file/directory, or None if not found. It keys points to a list entry, returns a list of either the absolute paths or None for each entry, depending on whether it is found.
Examples
>>> schema.find_files('input', 'verilog') Returns a list of absolute paths to source files, as specified in the schema.
- classmethod find_task(project: Project) Set[TTask] | TTask[source]#
Finds registered task(s) in a project that match the calling class.
This method searches through all tasks configured in the provided project and returns those that meet specific criteria derived from the class on which this method is called. The filtering is based on three levels:
Class Type: The primary filter ensures that any found task object is an instance of the calling class (cls).
Tool Name: If the calling class (cls) implements the tool() method, the search is narrowed to tasks with that specific tool name.
Task Name: If the calling class (cls) implements the task() method, the search is further narrowed to tasks with that name.
The method conveniently returns a single object if only one match is found, or a set of objects if multiple matches are found.
- Parameters:
project (Project) – The project instance to search within.
- Returns:
A single Task instance if exactly one match is found, otherwise a set of matching Task instances.
- Return type:
- Raises:
TypeError – If the project argument is not a valid Project object.
ValueError – If no tasks matching the specified criteria are found in the project.
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True, name: str | None = None) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
name (str) – name of the schema.
- generate_replay_script(filepath: str, workdir: str, include_path: bool = True) None[source]#
Generates a shell script to replay the task’s execution.
- Parameters:
filepath (str) – The path to write the replay script to.
workdir (str) – The path to the run’s working directory.
include_path (bool) – If True, includes PATH information.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: int | str | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_commandline_options(step: str | None = None, index: int | str | None = None) List[str][source]#
Returns the command line options specified
- get_dataroot(name: str) str[source]#
Returns absolute path to the data directory.
- Raises:
ValueError – is data directory is not found
- Parameters:
name (str) – name of the data directory to find.
- Returns:
Path to the directory root.
Examples
>>> schema.get_dataroot('siliconcompiler') Returns the path to the root of the siliconcompiler data directory.
- get_exe() str | None[source]#
Determines the absolute path for the task’s executable.
- Raises:
TaskExecutableNotFound – If the executable cannot be found in the system PATH.
- Returns:
The absolute path to the executable, or None if not specified.
- Return type:
str
- get_exe_version(workdir: str | None = None) str | None[source]#
Gets the version of the task’s executable by running it with a version switch.
- Raises:
TaskExecutableNotFound – If the executable is not found.
NotImplementedError – If the parse_version method is not implemented.
- Parameters:
workdir (str) – The working directory to use for the version check. If None, the current working directory is used.
- Returns:
The parsed version string.
- Return type:
str
- get_files_from_input_nodes() Dict[str, List[Tuple[str, str]]][source]#
Returns a dictionary of files from input nodes, mapped to the node they originated from.
- get_fileset_file_keys(filetype: str) List[Tuple[NamedSchema, Tuple[str, ...]]][source]#
Collect a set of keys for a particular filetype.
- Parameters:
filetype (str) – Name of the filetype
- Returns:
list of (object, keypath)
- get_logpath(log: str) str[source]#
Returns the relative path to a specified log file.
- Parameters:
log (str) – The type of log file (e.g., ‘exe’, ‘sc’).
- Returns:
The relative path to the log file from the node’s workdir.
- Return type:
str
- get_runtime_arguments() List[str][source]#
Constructs the command-line arguments needed to run the task.
- Returns:
A list of command-line arguments.
- Return type:
list
- get_runtime_environmental_variables(include_path: bool = True) Dict[str, str][source]#
Determines the environment variables needed for the task.
- Parameters:
include_path (bool) – If True, includes the PATH variable.
- Returns:
A dictionary of environment variable names to their values.
- Return type:
dict
- get_tcl_variables(manifest: BaseSchema | None = None) Dict[str, str][source]#
Gets a dictionary of variables to define for the task in a Tcl manifest.
- Parameters:
manifest (BaseSchema, optional) – The manifest to retrieve values from.
- Returns:
A dictionary of variable names and their Tcl-formatted values.
- Return type:
dict
- get_threads(step: str | None = None, index: int | str | None = None) int[source]#
Returns the number of threads requested.
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- has_breakpoint() bool[source]#
Checks if a breakpoint is set for this task.
- Returns:
True if a breakpoint is active, False otherwise.
- Return type:
bool
- has_postscript(step: str | None = None, index: int | str | None = None) bool[source]#
Checks if any post-execution scripts are configured for the task.
- Parameters:
step (str, optional) – The step to check. Defaults to the current step.
index (str, optional) – The index to check. Defaults to the current index.
- Returns:
True if one or more post-scripts are set, False otherwise.
- has_prescript(step: str | None = None, index: int | str | None = None) bool[source]#
Checks if any pre-execution scripts are configured for the task.
- Parameters:
step (str, optional) – The step to check. Defaults to the current step.
index (str, optional) – The index to check. Defaults to the current index.
- Returns:
True if one or more pre-scripts are set, False otherwise.
- hash_files(*keypath: str, update: bool = True, check: bool = True, verbose: bool = True, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) str | None | List[str | None][source]#
Generates hash values for a list of parameter files.
Generates a hash value for each file found in the keypath. If existing hash values are stored, this method will compare hashes and trigger an error if there’s a mismatch. If the update variable is True, the computed hash values are recorded in the ‘filehash’ field of the parameter, following the order dictated by the files within the ‘value’ parameter field.
Files are located using the find_files() function.
The file hash calculation is performed based on the ‘algo’ setting. Supported algorithms include SHA1, SHA224, SHA256, SHA384, SHA512, and MD5.
- Parameters:
*keypath (str) – Keypath to parameter.
update (bool) – If True, the hash values are recorded in the project object manifest.
check (bool) – If True, checks the newly computed hash against the stored hash.
verbose (bool) – If True, generates log messages.
allow_cache (bool) – If True, hashing check the cached values for specific files, if found, it will use that hash value otherwise the hash will be computed.
skip_missing (bool) – If True, hashing will be skipped when missing files are detected.
- Returns:
A list of hash values.
Examples
>>> hashlist = hash_files('input', 'rtl', 'verilog') Computes, stores, and returns hashes of files in :keypath:`input, rtl, verilog`.
- property index: str#
The index for the current runtime.
- Type:
str
- property logger: Logger#
The logger instance.
- Type:
logging.Logger
- classmethod make_docs()[source]#
Generate the documentation representation for this schema.
By default, this method returns a standard instance of the class itself. Subclasses can override this method to return a modified or different schema instance, or even a list of schemas, to customize how they appear in the generated documentation.
- Returns:
An instance or list of instances of BaseSchema that represents the schema for documentation purposes.
- property name: str#
The name of this task.
- Type:
str
- property node: SchedulerNode#
The scheduler node for the current runtime.
- Type:
SchedulerNode
- property nodeworkdir: str#
The path to the node’s working directory.
- Type:
str
- normalize_version(version: str) str[source]#
Normalizes a version string to a standard format. Can be overridden.
- parse_version(stdout: str) str[source]#
Parses the tool’s version from its stdout. Must be implemented by subclasses.
- post_process() None[source]#
A hook for post-processing after the main tool execution. Can be overridden.
- pre_process() None[source]#
A hook for pre-processing before the main tool execution. Can be overridden.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- record_metric(metric: str, value: int | float, source_file: List[Path | str] | Path | str | None = None, source_unit: str | None = None, quiet: bool = False)[source]#
Records a metric and associates the source file with it.
- Parameters:
metric (str) – metric to record
value (float/int) – value of the metric that is being recorded
source (str) – file the value came from
source_unit (str) – unit of the value, if not provided it is assumed to have no units
quiet (bool) – dont generate warning on missing metric
Examples
>>> self.record_metric('cellarea', 500.0, 'reports/metrics.json', \ source_units='um^2') Records the metric cell area and notes the source as 'reports/metrics.json'
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- run_task(workdir: str, quiet: bool, breakpoint: bool, nice: int | None, timeout: int | None) int[source]#
Executes the task’s main process.
This method handles the full lifecycle of running the tool, including setting up the work directory, writing manifests, redirecting I/O, monitoring for timeouts, and recording metrics.
- Parameters:
workdir (str) – The path to the node’s working directory.
quiet (bool) – If True, suppresses execution output.
breakpoint (bool) – If True, attempts to run with a breakpoint.
nice (int) – The POSIX nice level for the process.
timeout (int) – The execution timeout in seconds.
- Returns:
The return code from the execution.
- Return type:
int
- runtime(node: SchedulerNode, step: str | None = None, index: int | str | None = None, relpath: str | None = None)#
A context manager to set the runtime information for a task.
This method creates a temporary copy of the task object with runtime information (like the current step, index, and working directories) populated from a SchedulerNode. This allows methods within the context to access runtime-specific configuration and paths.
- Parameters:
node (SchedulerNode) – The scheduler node for this runtime context.
- runtime_options() List[int | str | Path][source]#
Constructs the default runtime options for the task. Can be extended.
- select_input_nodes() List[Tuple[str, str]][source]#
Determines which preceding nodes are inputs to this task.
- set(*args, field: str = 'value', step: str | None = None, index: int | str | None = None, clobber: bool = True)[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_dataroot(name: str = 'root', path: str | None = None, tag: str | None = None, clobber: bool = False) None[source]#
Registers a data source by name, path, and optional version tag.
This method creates a reference to a data directory, which can be a local path, a Git repository, or a remote archive. This allows other parts of the application to refer to this data source by its unique name.
- Parameters:
name (str, optional) – A unique name to identify the data source. Defaults to “root”.
path (str) – The path to the data source. This is required. It can be a local directory, a file path, a git URL, or an archive URL. If a file path is provided, its parent directory is used as the root.
tag (str, optional) – A version identifier for remote sources, such as a git commit hash, branch, or tag. Defaults to None.
clobber (bool, optional) – If True, allows overwriting an existing data source with the same name. If False (default), attempting to overwrite an existing entry will raise a ValueError.
- Raises:
ValueError – If path is not specified.
ValueError – If a data source with the given name already exists and clobber is False.
Examples
>>> # Register a remote git repository at a specific tag >>> schema.set_dataroot('siliconcompiler_data', ... 'git+https://github.com/siliconcompiler/siliconcompiler', ... tag='v1.0.0') >>> >>> # Register a local directory based on the location of a file >>> schema.set_dataroot('file_data', __file__)
- set_environmentalvariable(name: str, value: str, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Sets an environment variable for the tool’s execution context.
The specified variable will be set in the shell environment before the tool’s executable is launched.
- Parameters:
name (str) – The name of the environment variable (e.g., ‘PATH’).
value (str) – The value to assign to the variable.
step (str, optional) – The step associated with this setting. Defaults to the current step.
index (str, optional) – The index associated with this setting. Defaults to the current index.
clobber (bool) – If True, overwrite existing values. Otherwise, append to them.
- Returns:
The schema key that was set.
- set_exe(exe: str | None = None, vswitch: List[str] | str | None = None, format: str | None = None, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Sets the executable, version switch, and script format for a tool.
This is a convenience method that bundles the configuration of a tool’s core executable properties.
- Parameters:
exe (str, optional) – The name of the tool’s executable binary.
vswitch (List[str], optional) – The command-line switch used to make the executable print its version (e.g., ‘–version’).
format (str, optional) – The format of the entry script, if any (e.g., ‘tcl’, ‘python’).
step (str, optional) – The step associated with this setting. Defaults to the current step.
index (str, optional) – The index associated with this setting. Defaults to the current index.
clobber (bool) – If True, overwrite existing values. Otherwise, append to them.
- Returns:
A list of the schema keys that were set.
- set_logdestination(type: str, dest: str, suffix: str | None = None, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Configures the destination for log files.
This method sets where log files are written (‘file’ or ‘api’) and can specify a custom file suffix.
- Parameters:
type (str) – The type of log (e.g., ‘report’, ‘metric’).
dest (str) – The destination, either ‘file’ or ‘api’.
suffix (str, optional) – A custom suffix for the log file name.
step (str, optional) – The step associated with this setting. Defaults to the current step.
index (str, optional) – The index associated with this setting. Defaults to the current index.
clobber (bool) – If True, overwrite existing values.
- Returns:
A list of the schema keys that were set.
- set_name(name: str | None) None[source]#
Set the name of this object
- Raises:
RuntimeError – if called after object name is set.
- Parameters:
name (str) – name for object
- set_path(path: str, dataroot: str | None = None, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Sets the directory path where the tool’s executable is located.
This path is prepended to the system’s PATH environment variable during execution.
- Parameters:
path (str) – The directory path to the tool’s executable.
dataroot (str, optional) – The data root this path is relative to. Defaults to the active package.
step (str, optional) – The step associated with this setting. Defaults to the current step.
index (str, optional) – The index associated with this setting. Defaults to the current index.
clobber (bool) – If True, overwrite existing values. Otherwise, append to them.
- Returns:
The schema key that was set.
- set_refdir(dir: Path | str, dataroot: str | None = None, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Sets the reference directory for tool scripts and auxiliary files.
This is often used by script-based tools to find helper scripts or resource files relative to the main entry script.
- Parameters:
dir (str) – The path to the reference directory.
dataroot (str, optional) – The data root this path is relative to. Defaults to the active package.
step (str, optional) – The step associated with this setting. Defaults to the current step.
index (str, optional) – The index associated with this setting. Defaults to the current index.
clobber (bool) – If True, overwrite existing values.
- Returns:
The schema key that was set.
- set_script(script: Path | str, dataroot: str | None = Ellipsis, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Sets the main entry script for a script-based tool (e.g., a TCL script).
- Parameters:
script (str) – The path to the entry script.
dataroot (str, optional) – The data root this path is relative to. Defaults to the active package.
step (str, optional) – The step associated with this setting. Defaults to the current step.
index (str, optional) – The index associated with this setting. Defaults to the current index.
clobber (bool) – If True, overwrite existing values.
- Returns:
The schema key that was set.
- set_threads(max_threads: int | None = None, step: str | None = None, index: int | str | None = None, clobber: bool = False)[source]#
Sets the requested thread count for the task
- Parameters:
max_threads (int) – if provided the requested thread count will be set this value, otherwise the current machines core count will be used.
clobber (bool) – overwrite existing value
- setup_work_directory(workdir: str, remove_exist: bool = True) None[source]#
Creates the runtime directories needed to execute a task.
- Parameters:
workdir (str) – The path to the node’s working directory.
remove_exist (bool) – If True, removes the directory if it already exists.
- property step: str#
The step for the current runtime.
- Type:
str
- unset(*args: str, step: str | None = None, index: int | str | None = None)[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.FPGADevice(name: str = None)[source]#
Bases:
ToolLibrarySchemaA schema for configuring FPGA-related parameters.
This class extends ToolLibrarySchema to provide a structured way to define and access FPGA-specific settings like part name and LUT size.
- active_dataroot(dataroot: str | None = None)#
Use this context to set the dataroot parameter on files and directory parameters.
- Parameters:
dataroot (str) – name of the dataroot
Example
>>> with schema.active_dataroot("lambdalib"): ... schema.set("file", "top.v") Sets the file to top.v and associates lambdalib as the dataroot.
- active_fileset(fileset: str)#
Provides a context to temporarily set an active design fileset.
This is useful for applying a set of configurations to a specific fileset without repeatedly passing its name.
- Raises:
TypeError – If fileset is not a string.
ValueError – If fileset is an empty string.
- Parameters:
fileset (str) – The name of the fileset to activate.
Example
>>> with design.active_fileset("rtl"): ... design.set_topmodule("top") # This sets the top module for the 'rtl' fileset to 'top'.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_define(value: str, fileset: str | None = None, clobber: bool = False) List[str][source]#
Adds preprocessor macro definitions to a fileset.
- Parameters:
value (str or List[str]) – Macro definition.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
- Returns:
List of macro definitions
- Return type:
list[str]
- add_dep(obj: NamedSchema, clobber: bool = True) bool[source]#
Adds a module dependency to this design.
This method extends the base add_dep to prevent a design from adding a dependency on itself.
- Parameters:
obj (NamedSchema) – The dependency object to add.
clobber (bool) – If True, overwrite an existing dependency with the same name.
- Returns:
True if the dependency was added, False otherwise.
- Return type:
bool
- Raises:
TypeError – If obj is not a NamedSchema.
ValueError – If obj has the same name as the current design.
- add_depfileset(dep: Design | str, depfileset: str | None = None, fileset: str | None = None)[source]#
Record a reference to an imported dependency’s fileset.
- Parameters:
dep (
Designor str) – Dependency name or object.depfileset (str) – Dependency fileset, if not specified, the fileset will default to the same as the fileset or if only one fileset is present in the dep that will be chosen.
fileset (str) – Fileset name. If not provided, the active fileset is used.
- add_file(filename: List[Path | str] | Set[Path | str] | Tuple[Path | str, ...] | Path | str, fileset: str | None = None, filetype: str | None = None, clobber: bool = False, dataroot: str | None = None) List[str][source]#
Adds files to a fileset.
Based on the file’s extension, this method can often infer the correct fileset and filetype. For example:
.v -> (source, verilog)
.vhd -> (source, vhdl)
.sdc -> (constraint, sdc)
.lef -> (input, lef)
.def -> (input, def)
etc.
- Parameters:
filename (Path, str, or collection) – File path (Path or str), or a collection (list, tuple, set) of file paths to add.
fileset (str) – Logical group to associate the file with.
filetype (str, optional) – Type of the file (e.g., ‘verilog’, ‘sdc’).
clobber (bool, optional) – If True, clears the list before adding the item. Defaults to False.
dataroot (str, optional) – Data directory reference name.
- Raises:
ValueError – If fileset or filetype cannot be inferred from the file extension.
- Returns:
A list of the file paths that were added.
- Return type:
list[str]
Notes
This method normalizes filename to a string for consistency.
- If filetype is not specified, it is inferred from the
file extension.
- add_idir(value: str, fileset: str | None = None, clobber: bool = False, dataroot: str | None = None) List[str][source]#
Adds include directories to a fileset.
- Parameters:
value (Path or list[Path]) – Include path(s).
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
dataroot (str, optional) – Data directory reference name.
- Returns:
List of include directories
- Return type:
list[str]
- add_lib(value: str, fileset: str | None = None, clobber: bool = False) List[str][source]#
Adds dynamic libraries to a fileset.
- Parameters:
value (str or List[str]) – Libraries.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
- Returns:
List of libraries.
- Return type:
list[str]
- add_libdir(value: str, fileset: str | None = None, clobber: bool = False, dataroot: str | None = None) List[str][source]#
Adds dynamic library directories to a fileset.
- Parameters:
value (Path or list[Path]) – Library path(s).
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
dataroot (str, optional) – Data directory reference name.
- Returns:
List of library directories.
- Return type:
list[str]
- add_undefine(value: str, fileset: str | None = None, clobber: bool = False) List[str][source]#
Adds preprocessor macro (un)definitions to a fileset.
- Parameters:
value (str or List[str]) – Macro (un)definition.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
- Returns:
List of macro (un)definitions
- Return type:
list[str]
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- check_filepaths(ignore_keys: List[Tuple[str, ...]] | None = None) bool[source]#
Verifies that paths to all files in manifest are valid.
- Parameters:
ignore_keys (list of keypaths) – list of keypaths to ignore while checking
- Returns:
True if all file paths are valid, otherwise False.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- copy_fileset(src_fileset: str, dst_fileset: str, clobber: bool = False) None[source]#
Creates a new copy of a source fileset.
The entire configuration of the source fileset is duplicated and stored under the destination fileset’s name.
- Parameters:
src_fileset (str) – The name of the source fileset to copy.
dst_fileset (str) – The name of the new destination fileset.
clobber (bool) – If True, an existing destination fileset will be overwritten. Defaults to False.
- Raises:
ValueError – If the destination fileset already exists and clobber is False.
- define_tool_parameter(tool: str, name: str, type: str, help: str, **kwargs)[source]#
Define a new tool parameter for the library.
- find_files(*keypath: str, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) List[str | None] | str | None[source]#
Returns absolute paths to files or directories based on the keypath provided.
The keypath provided must point to a schema parameter of type file, dir, or lists of either. Otherwise, it will trigger an error.
- Parameters:
keypath (list of str) – Variable length schema key list.
missing_ok (bool) – If True, silently return None when files aren’t found. If False, print an error and set the error flag.
step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
If keys points to a scalar entry, returns an absolute path to that file/directory, or None if not found. It keys points to a list entry, returns a list of either the absolute paths or None for each entry, depending on whether it is found.
Examples
>>> schema.find_files('input', 'verilog') Returns a list of absolute paths to source files, as specified in the schema.
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True, name: str | None = None) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
name (str) – name of the schema.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_dataroot(name: str) str[source]#
Returns absolute path to the data directory.
- Raises:
ValueError – is data directory is not found
- Parameters:
name (str) – name of the data directory to find.
- Returns:
Path to the directory root.
Examples
>>> schema.get_dataroot('siliconcompiler') Returns the path to the root of the siliconcompiler data directory.
- get_define(fileset: str | None = None) List[str][source]#
Returns defined macros for a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of macro definitions
- Return type:
list[str]
- get_dep(name: str | None = None, hierarchy: bool = True) List[NamedSchema][source]#
Returns all dependencies associated with this object or a specific one if requested.
- Raises:
KeyError – if the specific module is requested but not found.
- Parameters:
name (str) – Name of the module.
hierarchy (bool) – If True, will return all modules including children, otherwise only this object’s modules are returned.
- Returns:
A list of dependency objects.
- Return type:
list
- get_depfileset(fileset: str | None = None)[source]#
Returns list of dependency filesets.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of dependencies and filesets.
- Return type:
list[tuple(str, str)]
- get_file(fileset: str | None = None, filetype: str | None = None) List[str][source]#
Returns a list of files from one or more filesets.
- Parameters:
fileset (str or list[str]) – Fileset(s) to query. If not provided, the active fileset is used.
filetype (str or list[str], optional) – File type(s) to filter by (e.g., ‘verilog’). If not provided, all filetypes in the fileset are returned.
- Returns:
A list of resolved file paths.
- Return type:
list[str]
- get_fileset(filesets: List[str] | str, alias: Dict[Tuple[str, str], Tuple[NamedSchema, str]] | None = None) List[Tuple[NamedSchema, str]][source]#
Computes the full, recursive list of (design, fileset) tuples required for a given set of top-level filesets.
This method traverses the design’s dependency graph to resolve all depfileset entries, returning a flattened and unique list of all required sources.
- Parameters:
filesets (Union[List[str], str]) – A single fileset name or a list of fileset names to evaluate.
alias (Dict[Tuple[str, str], Tuple[NamedSchema, str]], optional) – A dictionary mapping (design_name, fileset_name) tuples to be substituted during traversal. The value should be a (Design object, new_fileset_name) tuple. This is useful for swapping out library implementations. Defaults to None.
- Returns:
A flattened, unique list of (Design, fileset) tuples representing all dependencies.
- Return type:
List[Tuple[NamedSchema, str]]
- get_idir(fileset: str | None = None) List[str][source]#
Returns include directories for a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of include directories
- Return type:
list[str]
- get_lib(fileset: str | None = None) List[str][source]#
Returns list of dynamic libraries for a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of libraries.
- Return type:
list[str]
- get_libdir(fileset: str | None = None) List[str][source]#
Returns dynamic library directories for a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of library directories.
- Return type:
list[str]
- get_param(name: str, fileset: str | None = None) str[source]#
Returns value of a named fileset parameter.
- Parameters:
name (str) – Parameter name.
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
Parameter value
- Return type:
str
- get_topmodule(fileset: str | None = None) str[source]#
Returns the topmodule of a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
Topmodule name
- Return type:
str
- get_undefine(fileset: str | None = None) List[str][source]#
Returns undefined macros for a fileset.
- Args:
- fileset (str): Fileset name. If not provided, the active fileset is
used.
- Returns:
List of macro (un)definitions
- Return type:
list[str]
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- has_dep(name: NamedSchema | str) bool[source]#
Checks if a specific dependency is present.
- Parameters:
name (str) – Name of the module.
- Returns:
True if the module was found, False otherwise.
- has_file(fileset: str | None = None, filetype: str | None = None) bool[source]#
Returns true if the fileset contains files.
- Parameters:
fileset (str or list[str]) – Fileset(s) to query. If not provided, the active fileset is used.
filetype (str or list[str], optional) – File type(s) to filter by (e.g., ‘verilog’). If not provided, all filetypes in the fileset are returned.
- Returns:
True if the fileset contains files.
- Return type:
bool
- has_fileset(fileset: str) bool[source]#
Checks if a fileset exists in the schema.
- Parameters:
fileset (str) – The name of the fileset to check.
- Returns:
True if the fileset exists, False otherwise.
- Return type:
bool
- has_idir(fileset: str | None = None) bool[source]#
Returns true if idirs are defined for the fileset
- Parameters:
fileset (str or list[str]) – Fileset(s) to query. If not provided, the active fileset is used.
- Returns:
True if the fileset contains directories.
- Return type:
bool
- has_libdir(fileset: str | None = None) bool[source]#
Returns true if library directories are defined for the fileset
- Parameters:
fileset (str or list[str]) – Fileset(s) to query. If not provided, the active fileset is used.
- Returns:
True if the fileset contains directories.
- Return type:
bool
- hash_files(*keypath: str, update: bool = True, check: bool = True, verbose: bool = True, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) str | None | List[str | None][source]#
Generates hash values for a list of parameter files.
Generates a hash value for each file found in the keypath. If existing hash values are stored, this method will compare hashes and trigger an error if there’s a mismatch. If the update variable is True, the computed hash values are recorded in the ‘filehash’ field of the parameter, following the order dictated by the files within the ‘value’ parameter field.
Files are located using the find_files() function.
The file hash calculation is performed based on the ‘algo’ setting. Supported algorithms include SHA1, SHA224, SHA256, SHA384, SHA512, and MD5.
- Parameters:
*keypath (str) – Keypath to parameter.
update (bool) – If True, the hash values are recorded in the project object manifest.
check (bool) – If True, checks the newly computed hash against the stored hash.
verbose (bool) – If True, generates log messages.
allow_cache (bool) – If True, hashing check the cached values for specific files, if found, it will use that hash value otherwise the hash will be computed.
skip_missing (bool) – If True, hashing will be skipped when missing files are detected.
- Returns:
A list of hash values.
Examples
>>> hashlist = hash_files('input', 'rtl', 'verilog') Computes, stores, and returns hashes of files in :keypath:`input, rtl, verilog`.
- property name: str | None#
Returns the name of the schema
- property package: PackageSchema#
Gets the package schema for the design.
- Returns:
The package schema associated with this design.
- Return type:
- read_fileset(filename: str, fileset: str | None = None, fileformat: str | None = None) None[source]#
Imports filesets from a standard formatted text file.
Currently supports Verilog flist format only. Intended to support other formats in the future.
- Parameters:
filename (str or Path) – Input file name.
fileset (str or list[str]) – Fileset to import into. If not provided, the active fileset is used.
fileformat (str, optional) – Import format. Inferred from file extension if not provided.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- remove_dep(name: str | NamedSchema) bool[source]#
Removes a previously registered module.
- Parameters:
name (str) – Name of the module.
- Returns:
True if the module was removed, False if it was not found.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_dataroot(name: str = 'root', path: str | None = None, tag: str | None = None, clobber: bool = False) None[source]#
Registers a data source by name, path, and optional version tag.
This method creates a reference to a data directory, which can be a local path, a Git repository, or a remote archive. This allows other parts of the application to refer to this data source by its unique name.
- Parameters:
name (str, optional) – A unique name to identify the data source. Defaults to “root”.
path (str) – The path to the data source. This is required. It can be a local directory, a file path, a git URL, or an archive URL. If a file path is provided, its parent directory is used as the root.
tag (str, optional) – A version identifier for remote sources, such as a git commit hash, branch, or tag. Defaults to None.
clobber (bool, optional) – If True, allows overwriting an existing data source with the same name. If False (default), attempting to overwrite an existing entry will raise a ValueError.
- Raises:
ValueError – If path is not specified.
ValueError – If a data source with the given name already exists and clobber is False.
Examples
>>> # Register a remote git repository at a specific tag >>> schema.set_dataroot('siliconcompiler_data', ... 'git+https://github.com/siliconcompiler/siliconcompiler', ... tag='v1.0.0') >>> >>> # Register a local directory based on the location of a file >>> schema.set_dataroot('file_data', __file__)
- set_lutsize(lut: int)[source]#
Sets the LUT size for the FPGA.
- Parameters:
lut (int) – The number of inputs for the lookup table.
- Returns:
The result of the set operation.
- Return type:
Any
- set_name(name: str | None) None[source]#
Set the name of this object
- Raises:
RuntimeError – if called after object name is set.
- Parameters:
name (str) – name for object
- set_param(name: str, value: str, fileset: str | None = None) str[source]#
Sets a named parameter for a fileset.
- Parameters:
name (str) – Parameter name.
value (str) – Parameter value.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
- Returns:
Parameter value
- Return type:
str
- set_partname(name: str)[source]#
Sets the FPGA part name.
- Parameters:
name (str) – The name of the FPGA part.
- Returns:
The result of the set operation.
- Return type:
Any
- set_topmodule(value: str, fileset: str | None = None) str[source]#
Sets the topmodule of a fileset.
- Parameters:
value (str) – Topmodule name.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
- Returns:
Topmodule name
- Return type:
str
Notes
first character must be letter or underscore
remaining characters can be letters, digits, or underscores
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- write_depgraph(filename: str, fontcolor: str = '#000000', background: str = 'transparent', fontsize: str = '14', border: bool = True, landscape: bool = False) None[source]#
Renders and saves the dependency graph to a file.
- Parameters:
filename (filepath) – Output filepath.
fontcolor (str) – Node font RGB color hex value.
background (str) – Background color.
fontsize (str) – Node text font size.
border (bool) – Enables node border if True.
landscape (bool) – Renders graph in landscape layout if True.
Examples
>>> schema.write_depgraph('mydump.png') Renders the object dependency graph and writes the result to a png file.
- write_fileset(filename: str, fileset: Iterable[str] | str | None = None, fileformat: str | None = None, depalias: Dict[Tuple[str, str], Tuple[NamedSchema, str]] | None = None, comments: bool = False) None[source]#
Exports filesets to a standard formatted text file.
Currently supports Verilog flist format only. Intended to support other formats in the future. Inferred from file extension if not given.
- Parameters:
filename (str or Path) – Output file name.
fileset (str or list[str]) – Fileset(s) to export. If not provided, the active fileset is used.
fileformat (str, optional) – Export format.
depalias (dict of schema objects) – Map of aliased objects.
comments (bool, optional) – Add comments in output file.
- class siliconcompiler.StdCellLibrary(name: str | None = None)[source]#
Bases:
ToolLibrarySchemaA class for managing standard cell library schemas.
- active_dataroot(dataroot: str | None = None)#
Use this context to set the dataroot parameter on files and directory parameters.
- Parameters:
dataroot (str) – name of the dataroot
Example
>>> with schema.active_dataroot("lambdalib"): ... schema.set("file", "top.v") Sets the file to top.v and associates lambdalib as the dataroot.
- active_fileset(fileset: str)#
Provides a context to temporarily set an active design fileset.
This is useful for applying a set of configurations to a specific fileset without repeatedly passing its name.
- Raises:
TypeError – If fileset is not a string.
ValueError – If fileset is an empty string.
- Parameters:
fileset (str) – The name of the fileset to activate.
Example
>>> with design.active_fileset("rtl"): ... design.set_topmodule("top") # This sets the top module for the 'rtl' fileset to 'top'.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_asic_aprfileset(fileset: str = None)[source]#
Adds a mapping between filesets defined in the library.
- Parameters:
fileset (str) – name of the fileset
- add_asic_celllist(type: str, cells: List[str] | str)[source]#
Adds a standard cell library to the specified type.
- Parameters:
type (str) – category of cell type
cells (list of str) – cells to add
- add_asic_libcornerfileset(corner: str, model: str, fileset: List[str] | str | None = None)[source]#
Adds a mapping between filesets a corners defined in the library.
- Parameters:
corner (str) – name of the timing or parasitic corner
model (str) – type of delay modeling used, eg. ccs, nldm, etc.
fileset (str) – name of the fileset
- add_asic_pdk(pdk: str | PDK, default: bool = True)[source]#
Adds the PDK associated with this library.
- Parameters:
(class (pdk) – PDK): pdk to associate
default (bool) – if True, sets this PDK in [asic,pdk]
- add_asic_pexcornerfileset(corner: str, fileset: List[str] | str | None = None)[source]#
Adds a mapping between filesets a corners defined in the library.
- Parameters:
corner (str) – name of the timing or parasitic corner
fileset (str) – name of the fileset
- add_asic_site(site: List[str] | str)[source]#
Adds a standard site to the library.
- Parameters:
site (list of str or str) – sites to add
- add_asic_stackup(stackup: str | List[str])[source]#
Set the stackups supported by this library.
- Parameters:
stackup (str or list of str) – stackups supported
- add_define(value: str, fileset: str | None = None, clobber: bool = False) List[str][source]#
Adds preprocessor macro definitions to a fileset.
- Parameters:
value (str or List[str]) – Macro definition.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
- Returns:
List of macro definitions
- Return type:
list[str]
- add_dep(obj: NamedSchema, clobber: bool = True) bool[source]#
Adds a module dependency to this design.
This method extends the base add_dep to prevent a design from adding a dependency on itself.
- Parameters:
obj (NamedSchema) – The dependency object to add.
clobber (bool) – If True, overwrite an existing dependency with the same name.
- Returns:
True if the dependency was added, False otherwise.
- Return type:
bool
- Raises:
TypeError – If obj is not a NamedSchema.
ValueError – If obj has the same name as the current design.
- add_depfileset(dep: Design | str, depfileset: str | None = None, fileset: str | None = None)[source]#
Record a reference to an imported dependency’s fileset.
- Parameters:
dep (
Designor str) – Dependency name or object.depfileset (str) – Dependency fileset, if not specified, the fileset will default to the same as the fileset or if only one fileset is present in the dep that will be chosen.
fileset (str) – Fileset name. If not provided, the active fileset is used.
- add_file(filename: List[Path | str] | Set[Path | str] | Tuple[Path | str, ...] | Path | str, fileset: str | None = None, filetype: str | None = None, clobber: bool = False, dataroot: str | None = None) List[str][source]#
Adds files to a fileset.
Based on the file’s extension, this method can often infer the correct fileset and filetype. For example:
.v -> (source, verilog)
.vhd -> (source, vhdl)
.sdc -> (constraint, sdc)
.lef -> (input, lef)
.def -> (input, def)
etc.
- Parameters:
filename (Path, str, or collection) – File path (Path or str), or a collection (list, tuple, set) of file paths to add.
fileset (str) – Logical group to associate the file with.
filetype (str, optional) – Type of the file (e.g., ‘verilog’, ‘sdc’).
clobber (bool, optional) – If True, clears the list before adding the item. Defaults to False.
dataroot (str, optional) – Data directory reference name.
- Raises:
ValueError – If fileset or filetype cannot be inferred from the file extension.
- Returns:
A list of the file paths that were added.
- Return type:
list[str]
Notes
This method normalizes filename to a string for consistency.
- If filetype is not specified, it is inferred from the
file extension.
- add_idir(value: str, fileset: str | None = None, clobber: bool = False, dataroot: str | None = None) List[str][source]#
Adds include directories to a fileset.
- Parameters:
value (Path or list[Path]) – Include path(s).
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
dataroot (str, optional) – Data directory reference name.
- Returns:
List of include directories
- Return type:
list[str]
- add_lib(value: str, fileset: str | None = None, clobber: bool = False) List[str][source]#
Adds dynamic libraries to a fileset.
- Parameters:
value (str or List[str]) – Libraries.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
- Returns:
List of libraries.
- Return type:
list[str]
- add_libdir(value: str, fileset: str | None = None, clobber: bool = False, dataroot: str | None = None) List[str][source]#
Adds dynamic library directories to a fileset.
- Parameters:
value (Path or list[Path]) – Library path(s).
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
dataroot (str, optional) – Data directory reference name.
- Returns:
List of library directories.
- Return type:
list[str]
- add_undefine(value: str, fileset: str | None = None, clobber: bool = False) List[str][source]#
Adds preprocessor macro (un)definitions to a fileset.
- Parameters:
value (str or List[str]) – Macro (un)definition.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
clobber (bool, optional) – Clears existing list before adding item.
- Returns:
List of macro (un)definitions
- Return type:
list[str]
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- check_filepaths(ignore_keys: List[Tuple[str, ...]] | None = None) bool[source]#
Verifies that paths to all files in manifest are valid.
- Parameters:
ignore_keys (list of keypaths) – list of keypaths to ignore while checking
- Returns:
True if all file paths are valid, otherwise False.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- copy_fileset(src_fileset: str, dst_fileset: str, clobber: bool = False) None[source]#
Creates a new copy of a source fileset.
The entire configuration of the source fileset is duplicated and stored under the destination fileset’s name.
- Parameters:
src_fileset (str) – The name of the source fileset to copy.
dst_fileset (str) – The name of the new destination fileset.
clobber (bool) – If True, an existing destination fileset will be overwritten. Defaults to False.
- Raises:
ValueError – If the destination fileset already exists and clobber is False.
- define_tool_parameter(tool: str, name: str, type: str, help: str, **kwargs)[source]#
Define a new tool parameter for the library.
- find_files(*keypath: str, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) List[str | None] | str | None[source]#
Returns absolute paths to files or directories based on the keypath provided.
The keypath provided must point to a schema parameter of type file, dir, or lists of either. Otherwise, it will trigger an error.
- Parameters:
keypath (list of str) – Variable length schema key list.
missing_ok (bool) – If True, silently return None when files aren’t found. If False, print an error and set the error flag.
step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
If keys points to a scalar entry, returns an absolute path to that file/directory, or None if not found. It keys points to a list entry, returns a list of either the absolute paths or None for each entry, depending on whether it is found.
Examples
>>> schema.find_files('input', 'verilog') Returns a list of absolute paths to source files, as specified in the schema.
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True, name: str | None = None) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
name (str) – name of the schema.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_dataroot(name: str) str[source]#
Returns absolute path to the data directory.
- Raises:
ValueError – is data directory is not found
- Parameters:
name (str) – name of the data directory to find.
- Returns:
Path to the directory root.
Examples
>>> schema.get_dataroot('siliconcompiler') Returns the path to the root of the siliconcompiler data directory.
- get_define(fileset: str | None = None) List[str][source]#
Returns defined macros for a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of macro definitions
- Return type:
list[str]
- get_dep(name: str | None = None, hierarchy: bool = True) List[NamedSchema][source]#
Returns all dependencies associated with this object or a specific one if requested.
- Raises:
KeyError – if the specific module is requested but not found.
- Parameters:
name (str) – Name of the module.
hierarchy (bool) – If True, will return all modules including children, otherwise only this object’s modules are returned.
- Returns:
A list of dependency objects.
- Return type:
list
- get_depfileset(fileset: str | None = None)[source]#
Returns list of dependency filesets.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of dependencies and filesets.
- Return type:
list[tuple(str, str)]
- get_file(fileset: str | None = None, filetype: str | None = None) List[str][source]#
Returns a list of files from one or more filesets.
- Parameters:
fileset (str or list[str]) – Fileset(s) to query. If not provided, the active fileset is used.
filetype (str or list[str], optional) – File type(s) to filter by (e.g., ‘verilog’). If not provided, all filetypes in the fileset are returned.
- Returns:
A list of resolved file paths.
- Return type:
list[str]
- get_fileset(filesets: List[str] | str, alias: Dict[Tuple[str, str], Tuple[NamedSchema, str]] | None = None) List[Tuple[NamedSchema, str]][source]#
Computes the full, recursive list of (design, fileset) tuples required for a given set of top-level filesets.
This method traverses the design’s dependency graph to resolve all depfileset entries, returning a flattened and unique list of all required sources.
- Parameters:
filesets (Union[List[str], str]) – A single fileset name or a list of fileset names to evaluate.
alias (Dict[Tuple[str, str], Tuple[NamedSchema, str]], optional) – A dictionary mapping (design_name, fileset_name) tuples to be substituted during traversal. The value should be a (Design object, new_fileset_name) tuple. This is useful for swapping out library implementations. Defaults to None.
- Returns:
A flattened, unique list of (Design, fileset) tuples representing all dependencies.
- Return type:
List[Tuple[NamedSchema, str]]
- get_idir(fileset: str | None = None) List[str][source]#
Returns include directories for a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of include directories
- Return type:
list[str]
- get_lib(fileset: str | None = None) List[str][source]#
Returns list of dynamic libraries for a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of libraries.
- Return type:
list[str]
- get_libdir(fileset: str | None = None) List[str][source]#
Returns dynamic library directories for a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
List of library directories.
- Return type:
list[str]
- get_param(name: str, fileset: str | None = None) str[source]#
Returns value of a named fileset parameter.
- Parameters:
name (str) – Parameter name.
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
Parameter value
- Return type:
str
- get_topmodule(fileset: str | None = None) str[source]#
Returns the topmodule of a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
Topmodule name
- Return type:
str
- get_undefine(fileset: str | None = None) List[str][source]#
Returns undefined macros for a fileset.
- Args:
- fileset (str): Fileset name. If not provided, the active fileset is
used.
- Returns:
List of macro (un)definitions
- Return type:
list[str]
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- has_dep(name: NamedSchema | str) bool[source]#
Checks if a specific dependency is present.
- Parameters:
name (str) – Name of the module.
- Returns:
True if the module was found, False otherwise.
- has_file(fileset: str | None = None, filetype: str | None = None) bool[source]#
Returns true if the fileset contains files.
- Parameters:
fileset (str or list[str]) – Fileset(s) to query. If not provided, the active fileset is used.
filetype (str or list[str], optional) – File type(s) to filter by (e.g., ‘verilog’). If not provided, all filetypes in the fileset are returned.
- Returns:
True if the fileset contains files.
- Return type:
bool
- has_fileset(fileset: str) bool[source]#
Checks if a fileset exists in the schema.
- Parameters:
fileset (str) – The name of the fileset to check.
- Returns:
True if the fileset exists, False otherwise.
- Return type:
bool
- has_idir(fileset: str | None = None) bool[source]#
Returns true if idirs are defined for the fileset
- Parameters:
fileset (str or list[str]) – Fileset(s) to query. If not provided, the active fileset is used.
- Returns:
True if the fileset contains directories.
- Return type:
bool
- has_libdir(fileset: str | None = None) bool[source]#
Returns true if library directories are defined for the fileset
- Parameters:
fileset (str or list[str]) – Fileset(s) to query. If not provided, the active fileset is used.
- Returns:
True if the fileset contains directories.
- Return type:
bool
- hash_files(*keypath: str, update: bool = True, check: bool = True, verbose: bool = True, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) str | None | List[str | None][source]#
Generates hash values for a list of parameter files.
Generates a hash value for each file found in the keypath. If existing hash values are stored, this method will compare hashes and trigger an error if there’s a mismatch. If the update variable is True, the computed hash values are recorded in the ‘filehash’ field of the parameter, following the order dictated by the files within the ‘value’ parameter field.
Files are located using the find_files() function.
The file hash calculation is performed based on the ‘algo’ setting. Supported algorithms include SHA1, SHA224, SHA256, SHA384, SHA512, and MD5.
- Parameters:
*keypath (str) – Keypath to parameter.
update (bool) – If True, the hash values are recorded in the project object manifest.
check (bool) – If True, checks the newly computed hash against the stored hash.
verbose (bool) – If True, generates log messages.
allow_cache (bool) – If True, hashing check the cached values for specific files, if found, it will use that hash value otherwise the hash will be computed.
skip_missing (bool) – If True, hashing will be skipped when missing files are detected.
- Returns:
A list of hash values.
Examples
>>> hashlist = hash_files('input', 'rtl', 'verilog') Computes, stores, and returns hashes of files in :keypath:`input, rtl, verilog`.
- property name: str | None#
Returns the name of the schema
- property package: PackageSchema#
Gets the package schema for the design.
- Returns:
The package schema associated with this design.
- Return type:
- read_fileset(filename: str, fileset: str | None = None, fileformat: str | None = None) None[source]#
Imports filesets from a standard formatted text file.
Currently supports Verilog flist format only. Intended to support other formats in the future.
- Parameters:
filename (str or Path) – Input file name.
fileset (str or list[str]) – Fileset to import into. If not provided, the active fileset is used.
fileformat (str, optional) – Import format. Inferred from file extension if not provided.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- remove_dep(name: str | NamedSchema) bool[source]#
Removes a previously registered module.
- Parameters:
name (str) – Name of the module.
- Returns:
True if the module was removed, False if it was not found.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_dataroot(name: str = 'root', path: str | None = None, tag: str | None = None, clobber: bool = False) None[source]#
Registers a data source by name, path, and optional version tag.
This method creates a reference to a data directory, which can be a local path, a Git repository, or a remote archive. This allows other parts of the application to refer to this data source by its unique name.
- Parameters:
name (str, optional) – A unique name to identify the data source. Defaults to “root”.
path (str) – The path to the data source. This is required. It can be a local directory, a file path, a git URL, or an archive URL. If a file path is provided, its parent directory is used as the root.
tag (str, optional) – A version identifier for remote sources, such as a git commit hash, branch, or tag. Defaults to None.
clobber (bool, optional) – If True, allows overwriting an existing data source with the same name. If False (default), attempting to overwrite an existing entry will raise a ValueError.
- Raises:
ValueError – If path is not specified.
ValueError – If a data source with the given name already exists and clobber is False.
Examples
>>> # Register a remote git repository at a specific tag >>> schema.set_dataroot('siliconcompiler_data', ... 'git+https://github.com/siliconcompiler/siliconcompiler', ... tag='v1.0.0') >>> >>> # Register a local directory based on the location of a file >>> schema.set_dataroot('file_data', __file__)
- set_name(name: str | None) None[source]#
Set the name of this object
- Raises:
RuntimeError – if called after object name is set.
- Parameters:
name (str) – name for object
- set_param(name: str, value: str, fileset: str | None = None) str[source]#
Sets a named parameter for a fileset.
- Parameters:
name (str) – Parameter name.
value (str) – Parameter value.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
- Returns:
Parameter value
- Return type:
str
- set_topmodule(value: str, fileset: str | None = None) str[source]#
Sets the topmodule of a fileset.
- Parameters:
value (str) – Topmodule name.
fileset (str, optional) – Fileset name. If not provided, the active fileset is used.
- Returns:
Topmodule name
- Return type:
str
Notes
first character must be letter or underscore
remaining characters can be letters, digits, or underscores
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- write_depgraph(filename: str, fontcolor: str = '#000000', background: str = 'transparent', fontsize: str = '14', border: bool = True, landscape: bool = False) None[source]#
Renders and saves the dependency graph to a file.
- Parameters:
filename (filepath) – Output filepath.
fontcolor (str) – Node font RGB color hex value.
background (str) – Background color.
fontsize (str) – Node text font size.
border (bool) – Enables node border if True.
landscape (bool) – Renders graph in landscape layout if True.
Examples
>>> schema.write_depgraph('mydump.png') Renders the object dependency graph and writes the result to a png file.
- write_fileset(filename: str, fileset: Iterable[str] | str | None = None, fileformat: str | None = None, depalias: Dict[Tuple[str, str], Tuple[NamedSchema, str]] | None = None, comments: bool = False) None[source]#
Exports filesets to a standard formatted text file.
Currently supports Verilog flist format only. Intended to support other formats in the future. Inferred from file extension if not given.
- Parameters:
filename (str or Path) – Output file name.
fileset (str or list[str]) – Fileset(s) to export. If not provided, the active fileset is used.
fileformat (str, optional) – Export format.
depalias (dict of schema objects) – Map of aliased objects.
comments (bool, optional) – Add comments in output file.
2.4. ASIC Constraint Classes#
- class siliconcompiler.asic.ASICConstraint[source]#
Bases:
BaseSchemaA container for ASIC (Application-Specific Integrated Circuit) design constraints.
This class aggregates various types of constraints necessary for the physical design flow, such as timing, component placement, pin assignments, and floorplan area.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- property area: ASICAreaConstraint#
Provides access to the floorplan/area constraints.
- Returns:
The schema object for area constraints.
- Return type:
- property component: ASICComponentConstraints#
Provides access to the component placement constraints.
- Returns:
The schema object for component constraints.
- Return type:
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- property pin: ASICPinConstraints#
Provides access to pin assignment constraints.
- Returns:
The schema object for pin constraints.
- Return type:
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- property timing: ASICTimingConstraintSchema#
Provides access to the timing constraints.
- Returns:
The schema object for timing constraints.
- Return type:
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.constraints.ASICTimingConstraintSchema[source]#
Bases:
BaseSchemaManages a collection of ASIC timing scenarios for design constraints.
This class provides methods to add, retrieve, create, and remove individual
ASICTimingScenarioSchemaobjects, allowing for organized management of various timing-related constraints for different operating conditions or analysis modes.- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_mode(mode: TimingModeSchema)[source]#
Adds a timing mode to the design configuration.
This method is responsible for incorporating a new or updated timing mode into the system’s configuration. If a mode with the same name already exists, it will be overwritten (clobber=True).
- Parameters:
mode – The
TimingModeSchemaobject representing the timing mode to add. This object must have a valid name defined via its name() method.- Raises:
TypeError – If the provided mode argument is not an instance of
TimingModeSchema.ValueError – If the mode object’s name() method returns None, indicating that the mode does not have a defined name.
- add_scenario(scenario: ASICTimingScenarioSchema)[source]#
Adds a timing scenario to the design configuration.
This method is responsible for incorporating a new or updated timing scenario into the system’s configuration. If a scenario with the same name already exists, it will be overwritten (clobber=True).
- Parameters:
scenario – The
ASICTimingScenarioSchemaobject representing the timing scenario to add. This object must have a valid name defined via its name() method.- Raises:
TypeError – If the provided scenario argument is not an instance of
ASICTimingScenarioSchema.ValueError – If the scenario object’s name() method returns None, indicating that the scenario does not have a defined name.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- copy_mode(mode: str, name: str, insert: bool = True) TimingModeSchema[source]#
Copies an existing timing mode, renames it, and optionally adds it to the design.
This method retrieves the mode identified by
mode, creates a deep copy of it, and renames the copy toname. Ifinsertis True, the new mode is immediately added to the configuration.- Parameters:
mode (str) – The name of the existing mode to be copied.
name (str) – The name to assign to the new copied mode.
insert (bool, optional) – Whether to add the newly created mode to the configuration. Defaults to True.
- Returns:
The newly created copy of the mode.
- Return type:
TimingModeSchema
- Raises:
LookupError – If the source mode specified by
modedoes not exist.
- copy_scenario(scenario: str, name: str, insert: bool = True) ASICTimingScenarioSchema[source]#
Copies an existing timing scenario, renames it, and optionally adds it to the design.
This method retrieves the scenario identified by
scenario, creates a deep copy of it, and renames the copy toname. Ifinsertis True, the new scenario is immediately added to the configuration.- Parameters:
scenario (str) – The name of the existing scenario to be copied.
name (str) – The name to assign to the new copied scenario.
insert (bool, optional) – Whether to add the newly created scenario to the configuration. Defaults to True.
- Returns:
The newly created copy of the scenario.
- Return type:
- Raises:
LookupError – If the source scenario specified by
scenariodoes not exist.
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_mode(mode: str | None = None) TimingModeSchema | Dict[str, TimingModeSchema][source]#
Retrieves one or all timing modes from the configuration.
This method provides flexibility to fetch either a specific timing mode by its name or a collection of all currently defined modes.
- Parameters:
mode (str, optional) – The name (string) of the specific timing mode to retrieve. If this argument is omitted or set to None, the method will return a dictionary containing all available timing modes.
- Returns:
- The
TimingModeSchemaobject corresponding to the specified mode name.
- If mode is None: A dictionary where keys are mode names (str) and
values are their respective
TimingModeSchemaobjects.
- The
- Return type:
If mode is provided
- Raises:
LookupError – If a specific mode name is provided but no mode with that name is found in the configuration.
- get_scenario(scenario: str | None = None) ASICTimingScenarioSchema | Dict[str, ASICTimingScenarioSchema][source]#
Retrieves one or all timing scenarios from the configuration.
This method provides flexibility to fetch either a specific timing scenario by its name or a collection of all currently defined scenarios.
- Parameters:
scenario (str, optional) – The name (string) of the specific timing scenario to retrieve. If this argument is omitted or set to None, the method will return a dictionary containing all available timing scenarios.
- Returns:
- The
ASICTimingScenarioSchemaobject corresponding to the specified scenario name.
- If scenario is None: A dictionary where keys are scenario names (str) and
values are their respective
ASICTimingScenarioSchemaobjects.
- The
- Return type:
If scenario is provided
- Raises:
LookupError – If a specific scenario name is provided but no scenario with that name is found in the configuration.
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- make_mode(mode: str) TimingModeSchema[source]#
Creates and adds a new timing mode with the specified name.
This method initializes a new
TimingModeSchemaobject with the given name and immediately adds it to the constraint configuration. It ensures that a mode with the same name does not already exist, preventing accidental overwrites.- Parameters:
mode (str) – The name for the new timing mode. This name must be a non-empty string and unique within the current configuration.
- Returns:
- The newly created
TimingModeSchema object.
- The newly created
- Return type:
TimingModeSchema- Raises:
ValueError – If the provided mode name is empty or None.
LookupError – If a mode with the specified mode name already exists in the configuration.
- make_scenario(scenario: str) ASICTimingScenarioSchema[source]#
Creates and adds a new timing scenario with the specified name.
This method initializes a new
ASICTimingScenarioSchemaobject with the given name and immediately adds it to the constraint configuration. It ensures that a scenario with the same name does not already exist, preventing accidental overwrites.- Parameters:
scenario (str) – The name for the new timing scenario. This name must be a non-empty string and unique within the current configuration.
- Returns:
- class:ASICTimingScenarioSchema: The newly created
ASICTimingScenarioSchema object.
- class:ASICTimingScenarioSchema: The newly created
- Raises:
ValueError – If the provided scenario name is empty or None.
LookupError – If a scenario with the specified scenario name already exists in the configuration.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- remove_mode(mode: str) bool[source]#
Removes a timing mode from the design configuration.
This method deletes the specified timing mode from the system’s configuration.
- Parameters:
mode (str) – The name of the timing mode to remove. This name must be a non-empty string.
- Returns:
- True if the mode was successfully removed, False if no
mode with the given name was found.
- Return type:
bool
- Raises:
ValueError – If the provided mode name is empty or None.
- remove_scenario(scenario: str) bool[source]#
Removes a timing scenario from the design configuration.
This method deletes the specified timing scenario from the system’s configuration.
- Parameters:
scenario (str) – The name of the timing scenario to remove. This name must be a non-empty string.
- Returns:
- True if the scenario was successfully removed, False if no
scenario with the given name was found.
- Return type:
bool
- Raises:
ValueError – If the provided scenario name is empty or None.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.constraints.ASICTimingScenarioSchema(name: str | None = None)[source]#
Bases:
NamedSchemaRepresents a single timing scenario for ASIC design constraints.
This class encapsulates various parameters that define a specific timing scenario, such as operating voltage, temperature, library corners, PEX corners, operating mode, SDC filesets, and timing checks to be performed.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_check(check: List[str] | str, clobber: bool = False, step: str | None = None, index: int | str | None = None)[source]#
Adds a check to the design process.
- Parameters:
check (Union[List[str], str]) – One or more checks to add.
clobber (bool) – If True, existing checks at the specified step/index will be overwritten. If False (default), the check will be added.
step (str, optional) – step name.
index (str, optional) – index name.
- add_libcorner(libcorner: List[str] | str, clobber: bool = False, step: str | None = None, index: int | str | None = None)[source]#
Adds a library corner to the design.
- Parameters:
libcorner (Union[List[str], str]) – One or more library corners to add.
clobber (bool) – If True, existing library corners at the specified step/index will be overwritten. If False (default), the library corner will be added.
step (str, optional) – step name.
index (str, optional) – index name.
- add_sdcfileset(design: Design | str, fileset: str, clobber: bool = False, step: str | None = None, index: int | str | None = None)[source]#
Adds an SDC fileset for a given design.
- Parameters:
design (
Designor str) – The design object or the name of the design to associate the fileset with.fileset (str) – The name of the SDC fileset to add.
clobber (bool) – If True, existing SDC filesets for the design at the specified step/index will be overwritten. If False (default), the SDC fileset will be added.
step (str, optional) – step name.
index (str, optional) – index name.
- Raises:
TypeError – If design is not a Design object or a string, or if fileset is not a string.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True, name: str | None = None) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
name (str) – name of the schema.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_check(step: str | None = None, index: int | str | None = None) Set[str][source]#
Gets the set of checks configured for the design process.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
A set of check names.
- get_libcorner(step: str | None = None, index: int | str | None = None) Set[str][source]#
Gets the set of library corners.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
A set of library corner names.
- get_mode(step: str | None = None, index: int | str | None = None) str[source]#
Gets the operational mode currently set for the design.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
The name of the operational mode.
- get_opcond(step: str | None = None, index: int | str | None = None) str[source]#
Gets the operating condition currently set for the design.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
The name of the operating condition.
- get_pexcorner(step: str | None = None, index: int | str | None = None) str[source]#
Gets the parasitic extraction (PEX) corner currently set for the design.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
The name of the PEX corner.
- get_pin_voltage(pin: str, step: str | None = None, index: int | str | None = None) float[source]#
Gets the voltage of a specified pin.
- Parameters:
pin (str) – The name of the pin.
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
The voltage of the pin.
- Raises:
LookupError – If the specified pin does not have a voltage defined.
- get_sdcfileset(step: str | None = None, index: int | str | None = None) List[Tuple[str, str]][source]#
Gets the list of SDC filesets.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
A list of tuples, where each tuple contains the design name and the SDC fileset name.
- get_temperature(step: str | None = None, index: int | str | None = None) float[source]#
Gets the temperature currently set for the design.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
The temperature in degrees Celsius.
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- property name: str | None#
Returns the name of the schema
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- remove_pin_voltage(pin: str) None[source]#
Removes the voltage of a specified pin.
- Parameters:
pin (str) – The name of the pin.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_mode(mode: str, step: str | None = None, index: int | str | None = None)[source]#
Sets the operational mode for the design.
- Parameters:
mode (str) – The operational mode to set (e.g., “func”, “scan”).
step (str, optional) – step name.
index (str, optional) – index name.
- set_name(name: str | None) None[source]#
Set the name of this object
- Raises:
RuntimeError – if called after object name is set.
- Parameters:
name (str) – name for object
- set_opcond(opcond: str, step: str | None = None, index: int | str | None = None)[source]#
Sets the operating condition for the design.
- Parameters:
opcond (str) – The operating condition to set (e.g., “WC”, “BC”).
step (str, optional) – step name.
index (str, optional) – index name.
- set_pexcorner(pexcorner: str, step: str | None = None, index: int | str | None = None)[source]#
Sets the parasitic extraction (PEX) corner for the design.
- Parameters:
pexcorner (str) – The name of the PEX corner to set.
step (str, optional) – step name.
index (str, optional) – index name.
- set_pin_voltage(pin: str, voltage: float, step: str | None = None, index: int | str | None = None)[source]#
Sets the voltage for a specified pin.
- Parameters:
pin (str) – The name of the pin.
voltage (float) – The voltage value to set.
step (str, optional) – step name.
index (str, optional) – index name.
- set_temperature(temperature: float, step: str | None = None, index: int | str | None = None)[source]#
Sets the temperature for the design.
- Parameters:
temperature (float) – The temperature value to set in degrees Celsius.
step (str, optional) – step name.
index (str, optional) – index name.
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.constraints.ASICAreaConstraint[source]#
Bases:
BaseSchemaManages various area-related constraints for an ASIC design.
This class provides a structured way to define and retrieve constraints related to the die area, core area, core margin, target density, and aspect ratio of the physical layout. These constraints are essential for automated floorplanning and physical design tasks.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- calc_diearea(step: str | None = None, index: int | str | None = None) float[source]#
Calculates the area of a rectilinear die.
Uses the shoelace formula to calculate the design area from the (x,y) point tuples in the ‘diearea’ parameter. If ‘diearea’ contains only two points, they are treated as the lower-left and upper-right corners of a rectangle. (Ref: https://en.wikipedia.org/wiki/Shoelace_formula)
- Parameters:
step (str, optional) – The step in a workflow to retrieve from. Defaults to None.
index (str, optional) – The index within a step to retrieve from. Defaults to None.
- Returns:
The calculated design area in square schema units.
- Return type:
float
Examples
>>> # In the context of a 'pdk' object >>> area = asic.get('constraint').calc_diearea()
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_aspectratio(step: str | None = None, index: int | str | None = None) float[source]#
Retrieves the current layout aspect ratio.
- Parameters:
step (str, optional) – The step in a workflow to retrieve from. Defaults to None.
index (Union[str, int], optional) – The index within a step to retrieve from. Defaults to None.
- Returns:
The current aspect ratio value.
- Return type:
float
- get_corearea(step: str | None = None, index: int | str | None = None) List[Tuple[float, float]][source]#
Retrieves the current core area definition.
- Parameters:
step (str, optional) – The step in a workflow to retrieve from. Defaults to None.
index (Union[str, int], optional) – The index within a step to retrieve from. Defaults to None.
- Returns:
- A list of (x, y) tuples representing
the coordinates that define the core area.
- Return type:
List[Tuple[float, float]]
- get_coremargin(step: str | None = None, index: int | str | None = None) float[source]#
Retrieves the current core margin.
- Parameters:
step (str, optional) – The step in a workflow to retrieve from. Defaults to None.
index (Union[str, int], optional) – The index within a step to retrieve from. Defaults to None.
- Returns:
The current core margin value.
- Return type:
float
- get_density(step: str | None = None, index: int | str | None = None) float[source]#
Retrieves the current target layout density.
- Parameters:
step (str, optional) – The step in a workflow to retrieve from. Defaults to None.
index (Union[str, int], optional) – The index within a step to retrieve from. Defaults to None.
- Returns:
The current density value.
- Return type:
float
- get_diearea(step: str | None = None, index: int | str | None = None) List[Tuple[float, float]][source]#
Retrieves the current die area definition.
- Parameters:
step (str, optional) – The step in a workflow to retrieve from. Defaults to None.
index (Union[str, int], optional) – The index within a step to retrieve from. Defaults to None.
- Returns:
- A list of (x, y) tuples representing
the coordinates that define the die area.
- Return type:
List[Tuple[float, float]]
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_aspectratio(aspectratio: float, step: str | None = None, index: int | str | None = None)[source]#
Sets the layout aspect ratio.
This method validates the aspectratio input to ensure it’s a positive number.
- Parameters:
aspectratio (float) – The aspect ratio value (height / width). Must be a number greater than 0.0.
step (str, optional) – The step in a workflow to associate this setting with. Defaults to None.
index (Union[str, int], optional) – The index within a step to associate this setting with. Defaults to None.
- Raises:
TypeError – If aspectratio is not a number.
ValueError – If aspectratio is zero or negative.
- Returns:
The return value from the internal set method call.
- set_corearea(points: List[Tuple[float, float]], step: str | None = None, index: int | str | None = None)[source]#
Sets the core area using a list of points defining its boundary.
- Parameters:
points (List[Tuple[float, float]]) – A list of (x, y) tuples representing the coordinates that define the core area.
step (str, optional) – The step in a workflow to associate this setting with. Defaults to None.
index (Union[str, int], optional) – An index or identifier within a step. Defaults to None.
- Returns:
The return value from the internal set method call.
- set_corearea_rectangle(dieheight: float, diewidth: float, coremargin: float | Tuple[float, float], step: str | None = None, index: int | str | None = None)[source]#
Sets the core area as a rectangle within a die area, based on margins.
The core area is calculated by subtracting the margins from the die dimensions. Margins can be uniform (single float) or specified separately for x and y.
- Parameters:
dieheight (float) – The height of the die area. Must be > 0.
diewidth (float) – The width of the die area. Must be > 0.
coremargin (Union[float, Tuple[float, float]]) – The margin(s) to apply. - If a float, it’s applied uniformly to all four sides. - If a tuple of two floats, it’s (x_margin, y_margin).
step (str, optional) – The step in a workflow to associate this setting with. Defaults to None.
index (Union[str, int], optional) – The index within a step to associate this setting with. Defaults to None.
- Raises:
TypeError – If dieheight/diewidth are not numbers, or if coremargin is not a number or a tuple of two numbers.
ValueError – If dimensions are invalid or margins are too large.
- Returns:
The return value from the internal set_corearea method call.
- set_coremargin(coremargin: float, step: str | None = None, index: int | str | None = None)[source]#
Sets the core margin.
This method validates the coremargin input to ensure it’s a non-negative number.
- Parameters:
coremargin (float) – The core margin value in schema units (e.g., um). Must be a number greater than or equal to 0.0.
step (str, optional) – The step in a workflow to associate this setting with. Defaults to None.
index (Union[str, int], optional) – The index within a step to associate this setting with. Defaults to None.
- Raises:
TypeError – If coremargin is not a number.
ValueError – If coremargin is negative.
- Returns:
The return value from the internal set method call.
- set_density(density: float, aspectratio: float | None = None, coremargin: float | None = None, step: str | None = None, index: int | str | None = None)[source]#
Sets the target layout density.
This method validates the density input to ensure it’s a number between 0 (exclusive) and 100 (inclusive). Optionally, it can also set the aspect ratio and core margin if provided.
- Parameters:
density (float) – The target density value (0 < density <= 100).
aspectratio (float, optional) – The aspect ratio to set. If provided, set_aspectratio will be called. Defaults to None.
coremargin (float, optional) – The core margin to set. If provided, set_coremargin will be called. Defaults to None.
step (str, optional) – The step in a workflow to associate this setting with. Defaults to None.
index (Union[str, int], optional) – The index within a step to associate this setting with. Defaults to None.
- Raises:
TypeError – If density is not a number.
ValueError – If density is not within the valid range (0, 100].
- Returns:
A list of return values from the internal set calls.
- Return type:
list
- set_diearea(points: List[Tuple[float, float]], step: str | None = None, index: int | str | None = None)[source]#
Sets the die area using a list of points defining its boundary.
- Parameters:
points (List[Tuple[float, float]]) – A list of (x, y) tuples representing the coordinates that define the die area.
step (str, optional) – The step in a workflow to associate this setting with. Defaults to None.
index (Union[str, int], optional) – The index within a step to associate this setting with. Defaults to None.
- Returns:
The return value from the internal set method call.
- set_diearea_rectangle(height: float, width: float, coremargin: float | Tuple[float, float] | None = None, step: str | None = None, index: int | str | None = None)[source]#
Sets the die area as a rectangle with its bottom-left corner at (0,0).
Optionally, it can also set the core area as a rectangle based on the provided core margin.
- Parameters:
height (float) – The height of the rectangular die area. Must be > 0.
width (float) – The width of the rectangular die area. Must be > 0.
coremargin (Union[float, Tuple[float, float]], optional) – The margin for the core area. Can be a single float (uniform margin) or a tuple of two floats (x, y margins). If provided, set_corearea_rectangle will be called. Defaults to None.
step (str, optional) – The step in a workflow to associate this setting with. Defaults to None.
index (Union[str, int], optional) – The index within a step to associate this setting with. Defaults to None.
- Raises:
TypeError – If height or width are not numbers.
ValueError – If height or width are zero or negative.
- Returns:
A list of return values from the internal set calls.
- Return type:
list
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.constraints.ASICPinConstraints[source]#
Bases:
BaseSchemaManages a collection of ASIC pin constraints.
This class provides methods to add, retrieve, create, and remove individual
ASICPinConstraintobjects, allowing for organized management of pin-level placement and property constraints.- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_pinconstraint(pin: ASICPinConstraint)[source]#
Adds a pin constraint to the design configuration.
This method incorporates a new or updated pin constraint into the system’s configuration. If a constraint with the same name already exists, it will be overwritten (clobber=True).
- Parameters:
pin – The
ASICPinConstraintobject representing the pin constraint to add. This object must have a valid name defined via its name() method.- Raises:
TypeError – If the provided pin argument is not an instance of
ASICPinConstraint.ValueError – If the pin object’s name() method returns None, indicating that the pin constraint does not have a defined name.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- copy_pinconstraint(pin: str, name: str, insert: bool = True) ASICPinConstraint[source]#
Copies an existing pin constraint, renames it, and optionally adds it to the design.
This method retrieves the pin constraint identified by
pin, creates a deep copy of it, and renames the copy toname. Ifinsertis True, the new constraint is immediately added to the configuration.- Parameters:
pin (str) – The name of the existing pin constraint to be copied.
name (str) – The name to assign to the new copied constraint.
insert (bool, optional) – Whether to add the newly created constraint to the configuration. Defaults to True.
- Returns:
The newly created copy of the pin constraint.
- Return type:
- Raises:
LookupError – If the source pin constraint specified by
pindoes not exist.
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_pinconstraint(pin: str | None = None)[source]#
Retrieves one or all pin constraints from the configuration.
This method provides flexibility to fetch either a specific pin constraint by its name or a collection of all currently defined constraints.
- Parameters:
pin (str, optional) – The name (string) of the specific pin constraint to retrieve. If this argument is omitted or set to None, the method will return a dictionary containing all available pin constraints.
- Returns:
- The
ASICPinConstraintobject corresponding to the specified pin constraint name.
- If pin is None: A dictionary where keys are pin constraint names (str) and
values are their respective
ASICPinConstraintobjects.
- The
- Return type:
If pin is provided
- Raises:
LookupError – If a specific pin name is provided but no pin constraint with that name is found in the configuration.
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- make_pinconstraint(pin: str) ASICPinConstraint[source]#
Creates and adds a new pin constraint with the specified name.
This method initializes a new
ASICPinConstraintobject with the given name and immediately adds it to the design configuration. It ensures that a constraint with the same name does not already exist, preventing accidental overwrites.- Parameters:
pin (str) – The name for the new pin constraint. This name must be a non-empty string and unique within the current configuration.
- Returns:
class:ASICPinConstraint: The newly created
ASICPinConstraintobject.- Raises:
ValueError – If the provided pin name is empty or None.
LookupError – If a pin constraint with the specified pin name already exists in the configuration.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- remove_pinconstraint(pin: str) bool[source]#
Removes a pin constraint from the design configuration.
This method deletes the specified pin constraint from the system’s configuration.
- Parameters:
pin (str) – The name of the pin constraint to remove. This name must be a non-empty string.
- Returns:
- True if the pin constraint was successfully removed, False if no
pin constraint with the given name was found.
- Return type:
bool
- Raises:
ValueError – If the provided pin name is empty or None.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.constraints.ASICPinConstraint(name: str | None = None)[source]#
Bases:
NamedSchemaRepresents a single ASIC pin constraint within the design configuration.
This class defines various constraints that can be applied to an individual ASIC pin, such as its placement, dimensions (width, length), shape, metal layer, and its relative position on the chip’s side.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True, name: str | None = None) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
name (str) – name of the schema.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_layer(step: str | None = None, index: int | str | None = None) str[source]#
Retrieves the current metal layer constraint of the pin.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
The metal layer of the pin.
- Return type:
str
- get_length(step: str | None = None, index: int | str | None = None) float[source]#
Retrieves the current length constraint of the pin.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
The length of the pin in micrometers (um).
- Return type:
float
- get_order(step: str | None = None, index: int | str | None = None) int[source]#
Retrieves the current order constraint of the pin.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
The relative order of the pin on its side.
- Return type:
int
- get_placement(step: str | None = None, index: int | str | None = None) Tuple[float, float][source]#
Retrieves the current placement constraint of the pin.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
- A tuple (x, y) representing the pin’s center
coordinates in micrometers (um).
- Return type:
Tuple[float, float]
- get_shape(step: str | None = None, index: int | str | None = None) str[source]#
Retrieves the current shape constraint of the pin.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
The shape of the pin.
- Return type:
str
- get_side(step: str | None = None, index: int | str | None = None) int[source]#
Retrieves the current side constraint of the pin.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
The integer representation of the side (1 for lower left, etc.).
- Return type:
int
- get_width(step: str | None = None, index: int | str | None = None) float[source]#
Retrieves the current width constraint of the pin.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
The width of the pin in micrometers (um).
- Return type:
float
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- property name: str | None#
Returns the name of the schema
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_layer(layer: str, step: str | None = None, index: int | str | None = None)[source]#
Sets the metal layer constraint for the pin.
- Parameters:
layer (str) – The name of the metal layer for the pin. This can be a PDK-specific metal stack name (e.g., ‘m4’) or an integer (e.g., ‘1’ for the lowest routing layer).
step (str, optional) – step name.
index (str, optional) – index name.
- set_length(length: float, step: str | None = None, index: int | str | None = None)[source]#
Sets the length constraint for the pin.
- Parameters:
length (float) – The desired length of the pin in micrometers (um). Must be a positive numeric value.
step (str, optional) – step name.
index (str, optional) – index name.
- Raises:
TypeError – If length is not an int or float.
ValueError – If length is not a positive value.
- set_name(name: str | None) None[source]#
Set the name of this object
- Raises:
RuntimeError – if called after object name is set.
- Parameters:
name (str) – name for object
- set_order(order: int, step: str | None = None, index: int | str | None = None)[source]#
Sets the relative order constraint for the pin on its assigned side.
- Parameters:
order (int) – The relative position of the pin in a vector of pins on the specified side. Counting is done clockwise.
step (str, optional) – step name.
index (str, optional) – index name.
- set_placement(x: float, y: float, step: str | None = None, index: int | str | None = None)[source]#
Sets the placement constraint for the pin.
- Parameters:
x (float) – The X-coordinate for the pin’s center in micrometers (um) relative to the lower-left corner of the substrate.
y (float) – The Y-coordinate for the pin’s center in micrometers (um) relative to the lower-left corner of the substrate.
step (str, optional) – step name.
index (str, optional) – index name.
- Raises:
TypeError – If x or y is not an int or float.
- set_shape(shape: str, step: str | None = None, index: int | str | None = None)[source]#
Sets the shape constraint for the pin.
- Parameters:
shape (str) – The desired shape of the pin. Valid values include ‘circle’, ‘rectangle’, ‘square’, ‘hexagon’, ‘octagon’, ‘oval’, ‘pill’, or ‘polygon’.
step (str, optional) – step name.
index (str, optional) – index name.
- set_side(side: int | str, step: str | None = None, index: int | str | None = None)[source]#
Sets the side constraint for the pin, indicating where it should be placed.
- Parameters:
side (Union[int, str]) – The side of the block where the pin should be placed. Can be an integer or a string (‘left’, ‘west’, ‘top’, ‘north’, ‘right’, ‘east’, ‘bottom’, ‘south’).
step (str, optional) – step name.
index (str, optional) – index name.
- Raises:
TypeError – If side is not an int or string.
ValueError – If side is an unrecognized string value or a non-positive integer.
- set_width(width: float, step: str | None = None, index: int | str | None = None)[source]#
Sets the width constraint for the pin.
- Parameters:
width (float) – The desired width of the pin in micrometers (um). Must be a positive numeric value.
step (str, optional) – step name.
index (str, optional) – index name.
- Raises:
TypeError – If width is not an int or float.
ValueError – If width is not a positive value.
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.constraints.ASICComponentConstraints[source]#
Bases:
BaseSchemaManages a collection of ASIC component constraints.
This class provides methods to add, retrieve, create, and remove individual
ASICComponentConstraintobjects, allowing for organized management of component-level placement and property constraints.- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_component(component: ASICComponentConstraint)[source]#
Adds a component constraint to the design configuration.
This method incorporates a new or updated component constraint into the system’s configuration. If a constraint with the same name already exists, it will be overwritten (clobber=True).
- Parameters:
component – The
ASICComponentConstraintobject representing the component constraint to add. This object must have a valid name defined via its name() method.- Raises:
TypeError – If the provided component argument is not an instance of ASICComponentConstraint.
ValueError – If the component object’s name() method returns None, indicating that the component constraint does not have a defined name.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- copy_component(component: str, name: str, insert: bool = True) ASICComponentConstraint[source]#
Copies an existing component constraint, renames it, and optionally adds it to the design.
This method retrieves the component constraint identified by
component, creates a deep copy of it, and renames the copy toname. Ifinsertis True, the new constraint is immediately added to the configuration.- Parameters:
component (str) – The name of the existing component constraint to be copied.
name (str) – The name to assign to the new copied constraint.
insert (bool, optional) – Whether to add the newly created constraint to the configuration. Defaults to True.
- Returns:
The newly created copy of the component constraint.
- Return type:
- Raises:
LookupError – If the source component constraint specified by
componentdoes not exist.
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_component(component: str | None = None)[source]#
Retrieves one or all component constraints from the configuration.
This method provides flexibility to fetch either a specific component constraint by its name or a collection of all currently defined constraints.
- Parameters:
component (str, optional) – The name (string) of the specific component constraint to retrieve. If this argument is omitted or set to None, the method will return a dictionary containing all available component constraints.
- Returns:
- The
ASICComponentConstraintobject corresponding to the specified component name.
- If component is None: A dictionary where keys are component names (str) and
values are their respective
ASICComponentConstraintobjects.
- The
- Return type:
If component is provided
- Raises:
LookupError – If a specific component name is provided but no component constraint with that name is found in the configuration.
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- make_component(component: str) ASICComponentConstraint[source]#
Creates and adds a new component constraint with the specified name.
This method initializes a new
ASICComponentConstraintobject with the given name and immediately adds it to the design configuration. It ensures that a constraint with the same name does not already exist, preventing accidental overwrites.- Parameters:
component (str) – The name for the new component constraint. This name must be a non-empty string and unique within the current configuration.
- Returns:
The newly created
ASICComponentConstraintobject.- Return type:
- Raises:
ValueError – If the provided component name is empty or None.
LookupError – If a component constraint with the specified component name already exists in the configuration.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- remove_component(component: str) bool[source]#
Removes a component constraint from the design configuration.
This method deletes the specified component constraint from the system’s configuration.
- Parameters:
component (str) – The name of the component constraint to remove. This name must be a non-empty string.
- Returns:
- True if the component constraint was successfully removed, False if no
component constraint with the given name was found.
- Return type:
bool
- Raises:
ValueError – If the provided component name is empty or None.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.constraints.ASICComponentConstraint(name: str | None = None)[source]#
Bases:
NamedSchemaRepresents a single ASIC component constraint within the design configuration.
This class defines various constraints that can be applied to an individual ASIC component instance, such as its placement, part name (cell name), keepout halo, and rotation.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True, name: str | None = None) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
name (str) – name of the schema.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_halo(step: str | None = None, index: int | str | None = None) Tuple[float, float][source]#
Retrieves the current placement keepout halo constraint of the component.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
- A tuple (horizontal, vertical) representing the
halo extents in micrometers (um).
- Return type:
Tuple[float, float]
- get_partname(step: str | None = None, index: int | str | None = None) str[source]#
Retrieves the current part name (cell name) constraint of the component.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
The part name of the component.
- Return type:
str
- get_placement(step: str | None = None, index: int | str | None = None) Tuple[float, float][source]#
Retrieves the current placement constraint of the component.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
- A tuple (x, y) representing the component’s
anchor point coordinates in micrometers (um).
- Return type:
Tuple[float, float]
- get_rotation(step: str | None = None, index: int | str | None = None) str[source]#
Retrieves the current rotation constraint of the component.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
The rotation of the component.
- Return type:
str
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- property name: str | None#
Returns the name of the schema
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_halo(x: float, y: float, step: str | None = None, index: int | str | None = None)[source]#
Sets the placement keepout halo constraint around the component.
- Parameters:
x (float) – The horizontal extent of the halo in micrometers (um). Must be a non-negative numeric value.
y (float) – The vertical extent of the halo in micrometers (um). Must be a non-negative numeric value.
step (str, optional) – step name.
index (str, optional) – index name.
- Raises:
TypeError – If x or y is not an int or float.
ValueError – If x or y is a negative value.
- set_name(name: str | None) None[source]#
Set the name of this object
- Raises:
RuntimeError – if called after object name is set.
- Parameters:
name (str) – name for object
- set_partname(name: str, step: str | None = None, index: int | str | None = None)[source]#
Sets the part name (cell name) constraint for the component.
- Parameters:
name (str) – The name of the model, type, or variant of the placed component. This is required for instances not in the design netlist.
step (str, optional) – step name.
index (str, optional) – index name.
- Raises:
ValueError – If name is an empty string or None.
- set_placement(x: float, y: float, step: str | None = None, index: int | str | None = None)[source]#
Sets the placement constraint for the component.
- Parameters:
x (float) – The X-coordinate for the component’s anchor point in micrometers (um) relative to the substrate origin.
y (float) – The Y-coordinate for the component’s anchor point in micrometers (um) relative to the substrate origin.
step (str, optional) – step name.
index (str, optional) – index name.
- Raises:
TypeError – If x or y is not an int or float.
- set_rotation(rotation: str, step: str | None = None, index: int | str | None = None)[source]#
Sets the rotation constraint for the component.
- Parameters:
rotation (str) – The desired rotation of the component. Valid values are defined by the rotations list schema help (e.g., ‘R0’, ‘R90’, ‘MX’, ‘MZ_R90’).
step (str, optional) – step name.
index (str, optional) – index name.
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
2.5. FPGA Constraint Classes#
- class siliconcompiler.fpga.FPGAConstraint[source]#
Bases:
BaseSchemaA container for FPGA (Field-Programmable Gate Array) design constraints.
This class aggregates various types of constraints necessary for the FPGA implementation flow, such as timing, component placement, and pin assignments.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- property component: FPGAComponentConstraints#
Provides access to the component placement constraints.
- Returns:
The schema object for component constraints.
- Return type:
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- property pin: FPGAPinConstraints#
Provides access to pin assignment constraints.
- Returns:
The schema object for pin constraints.
- Return type:
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- property timing: FPGATimingConstraintSchema#
Provides access to the timing constraints.
- Returns:
The schema object for timing constraints.
- Return type:
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.constraints.FPGATimingConstraintSchema[source]#
Bases:
BaseSchemaManages a collection of FPGA timing scenarios for design constraints.
This class provides methods to add, retrieve, create, and remove individual
FPGATimingScenarioSchemaobjects, allowing for organized management of various timing-related constraints for different operating conditions or analysis modes.- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_mode(mode: TimingModeSchema)[source]#
Adds a timing mode to the design configuration.
This method is responsible for incorporating a new or updated timing mode into the system’s configuration. If a mode with the same name already exists, it will be overwritten (clobber=True).
- Parameters:
mode – The
TimingModeSchemaobject representing the timing mode to add. This object must have a valid name defined via its name() method.- Raises:
TypeError – If the provided mode argument is not an instance of
TimingModeSchema.ValueError – If the mode object’s name() method returns None, indicating that the mode does not have a defined name.
- add_scenario(scenario: FPGATimingScenarioSchema)[source]#
Adds a timing scenario to the design configuration.
This method is responsible for incorporating a new or updated timing scenario into the system’s configuration. If a scenario with the same name already exists, it will be overwritten (clobber=True).
- Parameters:
scenario – The
FPGATimingScenarioSchemaobject representing the timing scenario to add. This object must have a valid name defined via its name() method.- Raises:
TypeError – If the provided scenario argument is not an instance of
FPGATimingScenarioSchema.ValueError – If the scenario object’s name() method returns None, indicating that the scenario does not have a defined name.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- copy_mode(mode: str, name: str, insert: bool = True) TimingModeSchema[source]#
Copies an existing timing mode, renames it, and optionally adds it to the design.
This method retrieves the mode identified by
mode, creates a deep copy of it, and renames the copy toname. Ifinsertis True, the new mode is immediately added to the configuration.- Parameters:
mode (str) – The name of the existing mode to be copied.
name (str) – The name to assign to the new copied mode.
insert (bool, optional) – Whether to add the newly created mode to the configuration. Defaults to True.
- Returns:
The newly created copy of the mode.
- Return type:
TimingModeSchema
- Raises:
LookupError – If the source mode specified by
modedoes not exist.
- copy_scenario(scenario: str, name: str, insert: bool = True) FPGATimingScenarioSchema[source]#
Copies an existing timing scenario, renames it, and optionally adds it to the design.
This method retrieves the scenario identified by
scenario, creates a deep copy of it, and renames the copy toname. Ifinsertis True, the new scenario is immediately added to the configuration.- Parameters:
scenario (str) – The name of the existing scenario to be copied.
name (str) – The name to assign to the new copied scenario.
insert (bool, optional) – Whether to add the newly created scenario to the configuration. Defaults to True.
- Returns:
The newly created copy of the scenario.
- Return type:
- Raises:
LookupError – If the source scenario specified by
scenariodoes not exist.
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_mode(mode: str | None = None) TimingModeSchema | Dict[str, TimingModeSchema][source]#
Retrieves one or all timing modes from the configuration.
This method provides flexibility to fetch either a specific timing mode by its name or a collection of all currently defined modes.
- Parameters:
mode (str, optional) – The name (string) of the specific timing mode to retrieve. If this argument is omitted or set to None, the method will return a dictionary containing all available timing modes.
- Returns:
- The
TimingModeSchemaobject corresponding to the specified mode name.
- If mode is None: A dictionary where keys are mode names (str) and
values are their respective
TimingModeSchemaobjects.
- The
- Return type:
If mode is provided
- Raises:
LookupError – If a specific mode name is provided but no mode with that name is found in the configuration.
- get_scenario(scenario: str | None = None) FPGATimingScenarioSchema | Dict[str, FPGATimingScenarioSchema][source]#
Retrieves one or all timing scenarios from the configuration.
This method provides flexibility to fetch either a specific timing scenario by its name or a collection of all currently defined scenarios.
- Parameters:
scenario (str, optional) – The name (string) of the specific timing scenario to retrieve. If this argument is omitted or set to None, the method will return a dictionary containing all available timing scenarios.
- Returns:
- The
FPGATimingScenarioSchemaobject corresponding to the specified scenario name.
- If scenario is None: A dictionary where keys are scenario names (str) and
values are their respective
FPGATimingScenarioSchemaobjects.
- The
- Return type:
If scenario is provided
- Raises:
LookupError – If a specific scenario name is provided but no scenario with that name is found in the configuration.
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- make_mode(mode: str) TimingModeSchema[source]#
Creates and adds a new timing mode with the specified name.
This method initializes a new
TimingModeSchemaobject with the given name and immediately adds it to the constraint configuration. It ensures that a mode with the same name does not already exist, preventing accidental overwrites.- Parameters:
mode (str) – The name for the new timing mode. This name must be a non-empty string and unique within the current configuration.
- Returns:
- The newly created
TimingModeSchema object.
- The newly created
- Return type:
TimingModeSchema- Raises:
ValueError – If the provided mode name is empty or None.
LookupError – If a mode with the specified mode name already exists in the configuration.
- make_scenario(scenario: str) FPGATimingScenarioSchema[source]#
Creates and adds a new timing scenario with the specified name.
This method initializes a new
FPGATimingScenarioSchemaobject with the given name and immediately adds it to the constraint configuration. It ensures that a scenario with the same name does not already exist, preventing accidental overwrites.- Parameters:
scenario (str) – The name for the new timing scenario. This name must be a non-empty string and unique within the current configuration.
- Returns:
- The newly created
FPGATimingScenarioSchema object.
- The newly created
- Return type:
- Raises:
ValueError – If the provided scenario name is empty or None.
LookupError – If a scenario with the specified scenario name already exists in the configuration.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- remove_mode(mode: str) bool[source]#
Removes a timing mode from the design configuration.
This method deletes the specified timing mode from the system’s configuration.
- Parameters:
mode (str) – The name of the timing mode to remove. This name must be a non-empty string.
- Returns:
- True if the mode was successfully removed, False if no
mode with the given name was found.
- Return type:
bool
- Raises:
ValueError – If the provided mode name is empty or None.
- remove_scenario(scenario: str) bool[source]#
Removes a timing scenario from the design configuration.
This method deletes the specified timing scenario from the system’s configuration.
- Parameters:
scenario (str) – The name of the timing scenario to remove. This name must be a non-empty string.
- Returns:
- True if the scenario was successfully removed, False if no
scenario with the given name was found.
- Return type:
bool
- Raises:
ValueError – If the provided scenario name is empty or None.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.constraints.FPGATimingScenarioSchema(name: str | None = None)[source]#
Bases:
NamedSchemaRepresents a single timing scenario for FPGA design constraints.
This class encapsulates various parameters that define a specific timing scenario and operating mode.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True, name: str | None = None) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
name (str) – name of the schema.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_mode(step: str | None = None, index: int | str | None = None) str[source]#
Gets the operational mode currently set for the design.
- Parameters:
step (str, optional) – step name.
index (str, optional) – index name.
- Returns:
The name of the operational mode.
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- property name: str | None#
Returns the name of the schema
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_mode(mode: str, step: str | None = None, index: int | str | None = None)[source]#
Sets the operational mode for the design.
- Parameters:
mode (str) – The operational mode to set (e.g., “func”, “scan”).
step (str, optional) – step name.
index (str, optional) – index name.
- set_name(name: str | None) None[source]#
Set the name of this object
- Raises:
RuntimeError – if called after object name is set.
- Parameters:
name (str) – name for object
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.constraints.FPGAComponentConstraints[source]#
Bases:
BaseSchema- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.constraints.FPGAPinConstraints[source]#
Bases:
BaseSchema- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
2.6. Core Schema Classes#
- class siliconcompiler.schema.BaseSchema[source]#
This class maintains the access and file IO operations for the schema. It can be modified using
EditableSchema.- _from_dict(manifest: Dict, keypath: List[str] | Tuple[str, ...], version: Tuple[int, ...] | None = None, lazyload: LazyLoad = LazyLoad.ON) Tuple[Set[Tuple[str, ...]], Set[Tuple[str, ...]]][source]#
Decodes a dictionary into a schema object
- Parameters:
manifest (dict) – Manifest to decide.
keypath (list of str) – Path to the current keypath.
version ((int, int, int)) – Version of the dictionary schema
- _parent(root: bool = False) BaseSchema[source]#
Returns the parent of this schema section, if root is true the root parent will be returned.
- Parameters:
root (bool) – if true, returns the root of the schemas.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.schema.EditableSchema(schema: BaseSchema)[source]#
This class provides access to modify the underlying schema. This should only be used when creating new schema entries.
- Parameters:
schema (
BaseSchema) – schema to modify
- copy() BaseSchema[source]#
Creates a copy of the schema object, disconnected from any parent schema
- insert(*args: str | BaseSchema | Parameter, clobber: bool = False) None[source]#
Inserts a
Parameteror aBaseSchemato the schema, based on the keypath and value provided in the*args.- Parameters:
args (list) – Parameter keypath followed by a item to add.
clobber (boolean) – If true, will overwrite existing value, otherwise will raise a KeyError if it is already defined.
Examples
>>> schema.insert('option', 'value', Parameter('str')) Adds the keypath [option,value] with a string parameter.
- remove(*keypath: str) None[source]#
Removes a keypath from the schema.
- Parameters:
keypath (list) – keypath to be removed.
Examples
>>> schema.remove('option', 'value') Removes the keypath [option,value] from the schema.
- search(*keypath: str) BaseSchema | Parameter[source]#
Finds an item in the schema. This will raise a KeyError if the path is not found.
- Parameters:
keypath (list) – keypath to be found.
Examples
>>> schema.search('option', 'value') Returns the parameter stored in at [option,value].
- class siliconcompiler.schema.SafeSchema[source]#
Bases:
BaseSchemaThis object can handle any schema without any class dependencies. This is useful when reading in a schema in an external tool.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = False) SafeSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.schema.Journal(keyprefix: List[str] | Tuple[str, ...] | None = None)[source]#
This class provides the ability to record the schema transactions:
BaseSchema.set(),BaseSchema.add(),BaseSchema.remove(),BaseSchema.unset(), andBaseSchema.get().- Parameters:
keyprefix (list of str) – keypath to prefix on to recorded path
- static access(schema: BaseSchema) Journal[source]#
Access a journal from a schema
- Parameters:
schema (
BaseSchema) – schema to replay transactions to access journal
- add_type(value: str) None[source]#
Adds a new access type to the journal record.
- Parameters:
value (str) – access type
- from_dict(manifest: List[Dict]) None[source]#
Import a journal from a manifest dictionary
- Parameters:
manifest (dict) – Manifest to decode.
- get_child(*keypath: str) Journal[source]#
Get a child journal based on a new keypath
- Parameters:
keypath (list of str) – keypath to prefix on to recorded path
- has_journaling() bool[source]#
Returns true if the schema is currently setup and is the root of the journal and has data
- property keypath: Tuple[str, ...]#
Returns the reference key path for this journal
- record(record_type: str, key: List[str] | Tuple[str, ...], value=None, field: str | None = None, step: str | None = None, index: str | int | None = None) None[source]#
Record the schema transaction
- remove_type(value: str) None[source]#
Removes a new access type to the journal record.
- Parameters:
value (str) – access type
- replay(schema: BaseSchema) None[source]#
Replay journal into a schema
- Parameters:
schema (
BaseSchema) – schema to replay transactions to
- static replay_file(schema: BaseSchema, filepath: str) None[source]#
Replay a journal into a schema from a manifest
- Parameters:
schema (
BaseSchema) – schema to replay transactions tofilepath (path) – path to manifest
- class siliconcompiler.schema.NamedSchema(name: str | None = None)[source]#
Bases:
BaseSchemaThis object provides a named
BaseSchema.- Parameters:
name (str) – name of the schema
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True, name: str | None = None) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
name (str) – name of the schema.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- property name: str | None#
Returns the name of the schema
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_name(name: str | None) None[source]#
Set the name of this object
- Raises:
RuntimeError – if called after object name is set.
- Parameters:
name (str) – name for object
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.schema.Parameter(type: str, require: bool = False, defvalue=None, scope: Scope = Scope.GLOBAL, copy: bool = False, lock: bool = False, hashalgo: str = 'sha256', notes: str | None = None, unit: str | None = None, shorthelp: str | None = None, switch: List[str] | str | None = None, example: List[str] | str | None = None, help: str | None = None, pernode: PerNode = PerNode.NEVER, **kwargs)[source]#
Leaf nodes in the schema. This holds all the information for a given keypath.
- Parameters:
type (str) – type for the parameter, see
parametertype.NodeTypefor supported types.require (bool) – require field
defvalue (any) – defvalue field
scope (
Scope) – scope fieldcopy (bool) – copy field
lock (bool) – bool field
hashalgo (str) – hashalgo field
notes (str) – notes field
unit (str) – unit field
shorthelp (str) – shorthelp field
switch (list of str) – switch field
example (list of str) – example field
help (str) – help field
pernode (
PerNode) – pernode fieldkwargs – forwarded to default value constructor
- add(value, field: str = 'value', step: str | None = None, index: str | int | None = None) bool | List[NodeValue] | NodeValue[source]#
Adds item(s) to a list.
- Parameters:
value (any) – Value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> param.add('hello.v') Adds the file 'hello.v' the parameter.
- add_commandline_arguments(argparser: ArgumentParser, *keypath: str, switchlist: Set[str] | List[str] | str | None = None) Tuple[str | None, List[str] | None][source]#
Adds commandline arguments for this parameter.
- Parameters:
argparser (argparse.ArgumentParser) – argument parser to add switches to
keypath (list of str) – keypath where this parameter is located.
switchlist (list of str) – if provided will limited the switched added to those in this list
- Returns:
key for argument parsing to lookup values in. switches (list of str): list of switches added.
- Return type:
dest (str)
- copy(key: Tuple[str, ...] | None = None) Parameter[source]#
Returns a copy of this parameter.
- Parameters:
key (list of str) – keypath to this schema
- property default: NodeValue | NodeSetValue | NodeListValue#
Gets a copy of the default value.
- classmethod from_dict(manifest: Dict, keypath: Tuple[str, ...], version: Tuple[int, ...] | None) Parameter[source]#
Create a new parameter based on the provided dictionary.
- Parameters:
manifest (dict) – Manifest to decide.
keypath (list of str) – Path to the current keypath.
version (packaging.Version) – Version of the dictionary schema
- get(field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns the value in a parameter field.
- Parameters:
field (str) – Parameter field to fetch.
step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Field value for the parameter.
Examples
>>> value = param.get() Returns the value stored in the parameter.
- getdict(include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
- Parameters:
include_default (boolean) – If true will include default values
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> param.getdict() Returns the complete dictionary for the parameter
- gettcl(step: str | None = None, index: str | int | None = None) str | None[source]#
Returns a tcl string for this parameter.
- Parameters:
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- getvalues(return_defvalue: bool = True, return_values: bool = True) List[Tuple[Any | NodeValue | NodeSetValue | NodeListValue, str | None, str | None]][source]#
Returns all values (global and pernode) associated with a particular parameter.
Returns a list of tuples of the form (value, step, index). The list is in no particular order. For the global value, step and index are None. If return_defvalue is True, the default parameter value is added to the list in place of a global value if a global value is not set.
- has_value(step: str | None = None, index: str | int | None = None) bool[source]#
Returns whether the parameter as a value.
A value counts as set if a user has set a global value OR a value for the provided step/index.
- property is_directory: bool#
Returns true if this parameter’s type contains a
dirtype.This is true for plain
dirparameters as well as for container types whose leaf isdir(e.g.[dir],{dir}, or tuples containingdir).
- property is_file: bool#
Returns true if this parameter’s type contains a
filetype.This is true for plain
fileparameters as well as for container types whose leaf isfile(e.g.[file],{file}, or tuples containingfile).
- property is_path: bool#
Returns true if this parameter’s type contains a
fileordirtype. Useful for code paths that treat files and directories the same (e.g. resolving, hashing, or copying path-like values).
- is_set(step: str | None = None, index: str | int | None = None) bool[source]#
Returns whether a user has set a value for this parameter.
A value counts as set if a user has set a global value OR a value for the provided step/index.
- parse_commandline_arguments(value: str, *keypath: str) Tuple[Tuple[str, ...], str | None, str | None, str][source]#
Parse and set the values provided form the commandline parser.
- Parameters:
value (str) – string from commandline
keypath (list of str) – keypath to this parameter
- set(value, field: str = 'value', step: str | None = None, index: str | int | None = None, clobber: bool = True) bool | List[NodeValue] | NodeValue[source]#
Sets a parameter field.
- Parameters:
value (any) – Value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> param.set('top') Sets the value to 'top'
- unset(step: str | None = None, index: str | int | None = None) bool[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- class siliconcompiler.schema.parametervalue.NodeListValue(base: NodeValue | FileNodeValue | DirectoryNodeValue)[source]#
Holds the data for a list schema type.
- Parameters:
base (
NodeValue) – base type for this list.
- add(value, field: str = 'value') Tuple[NodeValue | FileNodeValue | DirectoryNodeValue, ...][source]#
Adds the value in a specific field and ensures it has been normalized.
- Returns:
tuple of modified values
- Parameters:
value (any) – value to set
field (str) – field to set
- copy() NodeListValue[source]#
Returns a copy of this value.
- property fields: Tuple[str | None, ...]#
Returns a list of valid fields for this value
- get(field: str | None = 'value')[source]#
Returns the value in the specified field
- Parameters:
field (str) – name of schema field.
- getdict() Dict[source]#
Returns a schema dictionary.
Examples
>>> value.getdict() Returns the complete dictionary for the value
- gettcl() str[source]#
Returns the tcl representation for the value
- Parameters:
field (str) – name of schema field.
- property has_value: bool#
Returns true if this node has a value.
- set(value, field: str = 'value') Tuple[NodeValue | FileNodeValue | DirectoryNodeValue, ...][source]#
Sets the value in a specific field and ensures it has been normalized.
- Returns:
tuple of modified values
- Parameters:
value (any) – value to set
field (str) – field to set
- property type#
Returns the type for this value
- property values: List[NodeValue | FileNodeValue | DirectoryNodeValue]#
Returns a copy of the values stored in the list
- class siliconcompiler.schema.parametervalue.NodeSetValue(base: NodeValue | FileNodeValue | DirectoryNodeValue)[source]#
Holds the data for a set schema type.
- Parameters:
base (
NodeValue) – base type for this set.
- add(value, field: str = 'value') Tuple[NodeValue | FileNodeValue | DirectoryNodeValue, ...][source]#
Adds the value in a specific field and ensures it has been normalized.
- Returns:
tuple of modified values
- Parameters:
value (any) – value to set
field (str) – field to set
- copy() NodeSetValue[source]#
Returns a copy of this value.
- property fields: Tuple[str | None, ...]#
Returns a list of valid fields for this value
- get(field: str | None = 'value')[source]#
Returns the value in the specified field
- Parameters:
field (str) – name of schema field.
- getdict() Dict[source]#
Returns a schema dictionary.
Examples
>>> value.getdict() Returns the complete dictionary for the value
- gettcl() str[source]#
Returns the tcl representation for the value
- Parameters:
field (str) – name of schema field.
- property has_value: bool#
Returns true if this node has a value.
- property type#
Returns the type for this value
- property values: List[NodeValue | FileNodeValue | DirectoryNodeValue]#
Returns a copy of the values stored in the list
- class siliconcompiler.schema.parametervalue.NodeValue(sctype, value=None)[source]#
Holds the data for a parameter.
- Parameters:
sctype (str) – type for this value
value (any) – default value for this parameter
- add(value, field: str = 'value') NodeValue[source]#
Not valid for this datatype, will raise a ValueError
- property fields: Tuple[str | None, ...]#
Returns a list of valid fields for this value
- classmethod from_dict(manifest: Dict, keypath: Tuple[str, ...], version: Tuple[int, ...] | None, sctype)[source]#
Create a new value based on the provided dictionary.
- Parameters:
manifest (dict) – Manifest to decide.
keypath (list of str) – Path to the current keypath.
version (packaging.Version) – Version of the dictionary schema
sctype (str) – schema type for this value
- get(field: str | None = 'value')[source]#
Returns the value in the specified field
- Parameters:
field (str) – name of schema field.
- getdict() Dict[source]#
Returns a schema dictionary.
Examples
>>> value.getdict() Returns the complete dictionary for the value
- gettcl() str[source]#
Returns the tcl representation for the value
- Parameters:
field (str) – name of schema field.
- property has_value: bool#
Returns true if this node has a value.
- set(value, field: str = 'value') NodeValue[source]#
Sets the value in a specific field and ensures it has been normalized.
- Returns:
self
- Parameters:
value (any) – value to set
field (str) – field to set
- sign(person: str, key: str, salt: str | None = None) None[source]#
Generate a signature for this value.
- Parameters:
person (str) – Identification for this person signing this value
key (str) – Key to used to sign this value
salt (bytes) – salt to use, if not specified, a random number will be selected.
- property type#
Returns the type for this value
- class siliconcompiler.schema.parametervalue.PathNodeValue(type, value: str | Path | None = None, dataroot: str | None = None)[source]#
Bases:
NodeValueHolds the path data for a parameter.
- Parameters:
type (str) – type of path
value (any) – default value for this parameter
- add(value, field: str = 'value') NodeValue[source]#
Not valid for this datatype, will raise a ValueError
- property fields: Tuple[str | None, ...]#
Returns a list of valid fields for this value
- classmethod from_dict(manifest: Dict, keypath: Tuple[str, ...], version: Tuple[int, ...] | None, sctype)[source]#
Create a new value based on the provided dictionary.
- Parameters:
manifest (dict) – Manifest to decide.
keypath (list of str) – Path to the current keypath.
version (packaging.Version) – Version of the dictionary schema
sctype (str) – schema type for this value
- static generate_hashed_path(path: str | Path | None, dataroot: str | None) str | None[source]#
Utility to map file to an unambiguous name based on its path.
The mapping looks like: path/to/file.ext => file_<hash(‘path/to’)>.ext
- Parameters:
path (str) – path to directory or file
dataroot (str) – name of dataroot this file belongs to
- get(field: str | None = 'value')[source]#
Returns the value in the specified field
- Parameters:
field (str) – name of schema field.
- get_hashed_filename() str | None[source]#
Utility to map file to an unambiguous name based on its path.
The mapping looks like: path/to/file.ext => file_<hash(‘path/to’)>.ext
- getdict() Dict[source]#
Returns a schema dictionary.
Examples
>>> value.getdict() Returns the complete dictionary for the value
- gettcl() str[source]#
Returns the tcl representation for the value
- Parameters:
field (str) – name of schema field.
- property has_value: bool#
Returns true if this node has a value.
- hash(function: str, **kwargs) str | None[source]#
Compute the hash for this path.
Keyword arguments are derived from
resolve_path().- Parameters:
function (str) – name of hashing function to use.
- static hash_directory(dirname: str | Path | None, hashobj=None, hashfunction: str | None = None) str | None[source]#
Compute the hash for this directory.
- Parameters:
dirname (path) – directory to hash
hashobj (hashlib.) – hashing object
hashfunction (str) – name of hashing function to use
- static hash_file(filename: str | Path | None, hashobj=None, hashfunction: str | None = None) str | None[source]#
Compute the hash for this file.
- Parameters:
filename (path) – file to hash
hashobj (hashlib.) – hashing object
hashfunction (str) – name of hashing function to use
- resolve_path(search: List[str] | None = None, collection_dir: str | None = None) str | None[source]#
Resolve the path of this value.
Returns the absolute path if found, otherwise raises a FileNotFoundError.
- Parameters:
search (list of paths) – list of paths to search to check for the path.
collection_dir (path) – path to collection directory.
- set(value, field: str = 'value') PathNodeValue[source]#
Sets the value in a specific field and ensures it has been normalized.
- Returns:
self
- Parameters:
value (any) – value to set
field (str) – field to set
- sign(person: str, key: str, salt: str | None = None) None[source]#
Generate a signature for this value.
- Parameters:
person (str) – Identification for this person signing this value
key (str) – Key to used to sign this value
salt (bytes) – salt to use, if not specified, a random number will be selected.
- property type: str#
Returns the type for this value
- class siliconcompiler.schema.parametervalue.DirectoryNodeValue(value: str | Path | None = None, dataroot: str | None = None)[source]#
Bases:
PathNodeValueHolds the directory data for a parameter.
- Parameters:
value (any) – default value for this parameter
- add(value, field: str = 'value') NodeValue[source]#
Not valid for this datatype, will raise a ValueError
- property fields: Tuple[str | None, ...]#
Returns a list of valid fields for this value
- classmethod from_dict(manifest: Dict, keypath: Tuple[str, ...], version: Tuple[int, ...] | None, sctype)[source]#
Create a new value based on the provided dictionary.
- Parameters:
manifest (dict) – Manifest to decide.
keypath (list of str) – Path to the current keypath.
version (packaging.Version) – Version of the dictionary schema
sctype (str) – schema type for this value
- static generate_hashed_path(path: str | Path | None, dataroot: str | None) str | None[source]#
Utility to map file to an unambiguous name based on its path.
The mapping looks like: path/to/file.ext => file_<hash(‘path/to’)>.ext
- Parameters:
path (str) – path to directory or file
dataroot (str) – name of dataroot this file belongs to
- get(field: str | None = 'value')[source]#
Returns the value in the specified field
- Parameters:
field (str) – name of schema field.
- get_hashed_filename() str | None[source]#
Utility to map file to an unambiguous name based on its path.
The mapping looks like: path/to/file.ext => file_<hash(‘path/to’)>.ext
- getdict() Dict[source]#
Returns a schema dictionary.
Examples
>>> value.getdict() Returns the complete dictionary for the value
- gettcl() str[source]#
Returns the tcl representation for the value
- Parameters:
field (str) – name of schema field.
- property has_value: bool#
Returns true if this node has a value.
- hash(function: str, **kwargs) str | None[source]#
Compute the hash for this directory.
Keyword arguments are derived from
resolve_path().- Parameters:
function (str) – name of hashing function to use.
- static hash_directory(dirname: str | Path | None, hashobj=None, hashfunction: str | None = None) str | None[source]#
Compute the hash for this directory.
- Parameters:
dirname (path) – directory to hash
hashobj (hashlib.) – hashing object
hashfunction (str) – name of hashing function to use
- static hash_file(filename: str | Path | None, hashobj=None, hashfunction: str | None = None) str | None[source]#
Compute the hash for this file.
- Parameters:
filename (path) – file to hash
hashobj (hashlib.) – hashing object
hashfunction (str) – name of hashing function to use
- resolve_path(search: List[str] | None = None, collection_dir: str | None = None) str | None[source]#
Resolve the path of this value.
Returns the absolute path if found, otherwise raises a FileNotFoundError.
- Parameters:
search (list of paths) – list of paths to search to check for the path.
collection_dir (path) – path to collection directory.
- set(value, field: str = 'value') PathNodeValue[source]#
Sets the value in a specific field and ensures it has been normalized.
- Returns:
self
- Parameters:
value (any) – value to set
field (str) – field to set
- sign(person: str, key: str, salt: str | None = None) None[source]#
Generate a signature for this value.
- Parameters:
person (str) – Identification for this person signing this value
key (str) – Key to used to sign this value
salt (bytes) – salt to use, if not specified, a random number will be selected.
- property type: str#
Returns the type for this value
- class siliconcompiler.schema.parametervalue.FileNodeValue(value: str | Path | None = None, dataroot: str | None = None)[source]#
Bases:
PathNodeValueHolds the file data for a parameter.
- Parameters:
value (any) – default value for this parameter
- add(value, field: str = 'value') FileNodeValue[source]#
Adds the value in a specific field and ensures it has been normalized.
- Returns:
self
- Parameters:
value (any) – value to set
field (str) – field to set
- property fields: Tuple[str | None, ...]#
Returns a list of valid fields for this value
- classmethod from_dict(manifest: Dict, keypath: Tuple[str, ...], version: Tuple[int, ...] | None, sctype)[source]#
Create a new value based on the provided dictionary.
- Parameters:
manifest (dict) – Manifest to decide.
keypath (list of str) – Path to the current keypath.
version (packaging.Version) – Version of the dictionary schema
sctype (str) – schema type for this value
- static generate_hashed_path(path: str | Path | None, dataroot: str | None) str | None[source]#
Utility to map file to an unambiguous name based on its path.
The mapping looks like: path/to/file.ext => file_<hash(‘path/to’)>.ext
- Parameters:
path (str) – path to directory or file
dataroot (str) – name of dataroot this file belongs to
- get(field: str | None = 'value')[source]#
Returns the value in the specified field
- Parameters:
field (str) – name of schema field.
- get_hashed_filename() str | None[source]#
Utility to map file to an unambiguous name based on its path.
The mapping looks like: path/to/file.ext => file_<hash(‘path/to’)>.ext
- getdict() Dict[source]#
Returns a schema dictionary.
Examples
>>> value.getdict() Returns the complete dictionary for the value
- gettcl() str[source]#
Returns the tcl representation for the value
- Parameters:
field (str) – name of schema field.
- property has_value: bool#
Returns true if this node has a value.
- hash(function: str, **kwargs) str | None[source]#
Compute the hash for this file.
Keyword arguments are derived from
resolve_path().- Parameters:
function (str) – name of hashing function to use.
- static hash_directory(dirname: str | Path | None, hashobj=None, hashfunction: str | None = None) str | None[source]#
Compute the hash for this directory.
- Parameters:
dirname (path) – directory to hash
hashobj (hashlib.) – hashing object
hashfunction (str) – name of hashing function to use
- static hash_file(filename: str | Path | None, hashobj=None, hashfunction: str | None = None) str | None[source]#
Compute the hash for this file.
- Parameters:
filename (path) – file to hash
hashobj (hashlib.) – hashing object
hashfunction (str) – name of hashing function to use
- resolve_path(search: List[str] | None = None, collection_dir: str | None = None) str | None[source]#
Resolve the path of this value.
Returns the absolute path if found, otherwise raises a FileNotFoundError.
- Parameters:
search (list of paths) – list of paths to search to check for the path.
collection_dir (path) – path to collection directory.
- set(value, field: str = 'value') FileNodeValue[source]#
Sets the value in a specific field and ensures it has been normalized.
- Returns:
self
- Parameters:
value (any) – value to set
field (str) – field to set
- sign(person: str, key: str, salt: str | None = None) None[source]#
Generate a signature for this value.
- Parameters:
person (str) – Identification for this person signing this value
key (str) – Key to used to sign this value
salt (bytes) – salt to use, if not specified, a random number will be selected.
- property type: str#
Returns the type for this value
- class siliconcompiler.schema.parametertype.NodeType(sctype)[source]#
Schema type decoding and encoding class.
- Parameters:
sctype (str or
NodeType) – schema type
- class siliconcompiler.schema.parametertype.NodeEnumType(*values)[source]#
Type for schema data type
- Parameters:
values (list of str) – list of legal values for this type.
- property values#
Returns a set of the legal values for this enum.
- class siliconcompiler.schema.parameter.Scope(value)[source]#
Enum for scope Schema parameters
- GLOBAL = 'global'#
- JOB = 'job'#
- SCRATCH = 'scratch'#
- class siliconcompiler.schema.parameter.PerNode(value)[source]#
Enum for pernode Schema parameters
- NEVER = 'never'#
- OPTIONAL = 'optional'#
- REQUIRED = 'required'#
- class siliconcompiler.schema.DocsSchema[source]#
Bases:
BaseSchemaA base class for customizing documentation generation.
This class provides a hook (make_docs) that can be overridden by subclasses to control how a schema is represented in documentation.
- classmethod make_docs() TSchema | List[TSchema][source]#
Generate the documentation representation for this schema.
By default, this method returns a standard instance of the class itself. Subclasses can override this method to return a modified or different schema instance, or even a list of schemas, to customize how they appear in the generated documentation.
- Returns:
An instance or list of instances of BaseSchema that represents the schema for documentation purposes.
2.7. Supporting Classes#
- class siliconcompiler.schema_support.dependencyschema.DependencySchema[source]#
Bases:
BaseSchemaSchema extension to add
add_dep()capability to a schema section.- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_dep(obj: NamedSchema, clobber: bool = True) bool[source]#
Adds a module to this object.
- Parameters:
obj (
NamedSchema) – Module to add.clobber (bool) – If true will insert the object and overwrite any existing with the same name.
- Returns:
True if object was imported, otherwise false.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- check_filepaths(ignore_keys: List[Tuple[str, ...]] | None = None) bool[source]#
Verifies that paths to all files in manifest are valid.
- Parameters:
ignore_keys (list of keypaths) – list of keypaths to ignore while checking
- Returns:
True if all file paths are valid, otherwise False.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_dep(name: str | None = None, hierarchy: bool = True) List[NamedSchema][source]#
Returns all dependencies associated with this object or a specific one if requested.
- Raises:
KeyError – if the specific module is requested but not found.
- Parameters:
name (str) – Name of the module.
hierarchy (bool) – If True, will return all modules including children, otherwise only this object’s modules are returned.
- Returns:
A list of dependency objects.
- Return type:
list
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- has_dep(name: NamedSchema | str) bool[source]#
Checks if a specific dependency is present.
- Parameters:
name (str) – Name of the module.
- Returns:
True if the module was found, False otherwise.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- remove_dep(name: str | NamedSchema) bool[source]#
Removes a previously registered module.
- Parameters:
name (str) – Name of the module.
- Returns:
True if the module was removed, False if it was not found.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- write_depgraph(filename: str, fontcolor: str = '#000000', background: str = 'transparent', fontsize: str = '14', border: bool = True, landscape: bool = False) None[source]#
Renders and saves the dependency graph to a file.
- Parameters:
filename (filepath) – Output filepath.
fontcolor (str) – Node font RGB color hex value.
background (str) – Background color.
fontsize (str) – Node text font size.
border (bool) – Enables node border if True.
landscape (bool) – Renders graph in landscape layout if True.
Examples
>>> schema.write_depgraph('mydump.png') Renders the object dependency graph and writes the result to a png file.
- class siliconcompiler.schema_support.option.OptionSchema[source]#
Bases:
BaseSchemaSchema for top-level configuration options.
This class defines global and job-specific parameters that control the compiler’s behavior, such as flow control, logging, build settings, and remote execution. It provides getter and setter methods for each parameter.
- add_alias(value: List[Tuple[str, str, str, str]] | Tuple[str, str, str, str], clobber: bool = False)[source]#
Adds or sets fileset aliases.
- Parameters:
value (Union[List[Tuple[str, str, str, str]], Tuple[str, str, str, str]]) – The alias or aliases to add.
clobber (bool, optional) – If True, replaces existing aliases. If False, appends to them. Defaults to False.
- add_fileset(value: List[str] | str, clobber: bool = False)[source]#
Adds or sets selected design filesets.
- Parameters:
value (Union[List[str], str]) – The fileset or filesets to add.
clobber (bool, optional) – If True, replaces existing filesets. If False, appends to them. Defaults to False.
- add_from(value: List[str] | str, clobber: bool = False)[source]#
Adds or sets the starting step(s) for execution.
- Parameters:
value (Union[List[str], str]) – The step or steps to add.
clobber (bool, optional) – If True, replaces existing steps. If False, appends to them. Defaults to False.
- add_prune(value: List[Tuple[str, str]] | Tuple[str, str], clobber: bool = False)[source]#
Adds or sets nodes to prune from the flowgraph.
- Parameters:
value (Union[List[Tuple[str, str]], Tuple[str, str]]) – The node or nodes to add.
clobber (bool, optional) – If True, replaces existing nodes. If False, appends to them. Defaults to False.
- add_to(value: List[str] | str, clobber: bool = False)[source]#
Adds or sets the ending step(s) for execution.
- Parameters:
value (Union[List[str], str]) – The step or steps to add.
clobber (bool, optional) – If True, replaces existing steps. If False, appends to them. Defaults to False.
- get_alias() List[Tuple[str, str, str, str]][source]#
Gets the list of fileset aliases.
- Returns:
A list of alias tuples.
- Return type:
List[Tuple[str, str, str, str]]
- get_autoissue() bool[source]#
Gets the autoissue flag.
- Returns:
The current value of the autoissue flag.
- Return type:
bool
- get_breakpoint(step: str | None = None, index: str | None = None) bool[source]#
Checks if a breakpoint is set on a specific step.
- Parameters:
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- Returns:
True if a breakpoint is set.
- Return type:
bool
- get_builddir() str[source]#
Gets the build directory path.
- Returns:
The path to the build directory.
- Return type:
str
- get_cachedir() str[source]#
Gets the path to the user cache directory.
- Returns:
The filepath to the cache directory.
- Return type:
str
- get_clean() bool[source]#
Gets the clean job flag.
- Returns:
True if the previous job should be cleaned up.
- Return type:
bool
- get_continue(step: str | None = None, index: str | None = None) bool[source]#
Gets the continue-on-error flag for a step.
- Parameters:
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- Returns:
True if the flow should continue on error.
- Return type:
bool
- get_credentials() str[source]#
Gets the path to the user credentials file.
- Returns:
The filepath to the credentials file.
- Return type:
str
- get_design() str[source]#
Gets the top-level design library name.
- Returns:
The name of the design.
- Return type:
str
- get_env(key: str) str[source]#
Gets an environment variable.
- Parameters:
key (str) – The name of the environment variable.
- Returns:
The value of the environment variable.
- Return type:
str
- get_fileset() List[str][source]#
Gets the list of selected design filesets.
- Returns:
A list of fileset names.
- Return type:
List[str]
- get_from() List[str][source]#
Gets the list of starting steps for execution.
- Returns:
A list of step names.
- Return type:
List[str]
- get_hash() bool[source]#
Gets the file hashing flag.
- Returns:
True if file hashing is enabled.
- Return type:
bool
- get_jobincr() bool[source]#
Gets the job name auto-increment flag.
- Returns:
True if job name auto-increment is enabled.
- Return type:
bool
- get_nice(step: str | None = None, index: str | None = None) int[source]#
Gets the tool scheduling priority (nice level).
- Parameters:
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- Returns:
The nice value.
- Return type:
int
- get_nodashboard() bool[source]#
Gets the dashboard disable flag.
- Returns:
True if the dashboard is disabled.
- Return type:
bool
- get_nodisplay() bool[source]#
Gets the headless execution (no-display) flag.
- Returns:
True if GUI windows are disabled.
- Return type:
bool
- get_novercheck(step: str | None = None, index: str | None = None) bool[source]#
Gets the version checking disable flag for a step.
- Parameters:
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- Returns:
True if version checking is disabled.
- Return type:
bool
- get_optmode(step: str | None = None, index: str | None = None) int[source]#
Gets the optimization mode.
- Parameters:
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- Returns:
The optimization mode level.
- Return type:
int
- get_prune() List[Tuple[str, str]][source]#
Gets the list of nodes to prune from the flowgraph.
- Returns:
A list of (step, index) tuples to prune.
- Return type:
List[Tuple[str, str]]
- get_quiet(step: str | None = None, index: str | None = None) bool[source]#
Gets the quiet execution flag for a step.
- Parameters:
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- Returns:
True if quiet execution is enabled.
- Return type:
bool
- get_remote() bool[source]#
Gets the remote processing flag.
- Returns:
True if remote processing is enabled.
- Return type:
bool
- get_timeout(step: str | None = None, index: str | None = None) float[source]#
Gets the timeout value for a step in seconds.
- Parameters:
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- Returns:
The timeout value in seconds.
- Return type:
float
- get_to() List[str][source]#
Gets the list of ending steps for execution.
- Returns:
A list of step names.
- Return type:
List[str]
- get_track(step: str | None = None, index: str | None = None) bool[source]#
Gets the provenance tracking flag for a step.
- Parameters:
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- Returns:
True if tracking is enabled.
- Return type:
bool
- property scheduler: SchedulerSchema#
Provides access to the scheduler sub-schema.
- Returns:
The schema object for scheduler settings.
- Return type:
- set(*args, field='value', clobber=True, step=None, index=None)[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_autoissue(value: bool)[source]#
Sets the autoissue flag.
- Parameters:
value (bool) – The desired value for the autoissue flag.
- set_breakpoint(value: bool, step: str | None = None, index: str | None = None)[source]#
Sets a breakpoint on a specific step.
- Parameters:
value (bool) – The value to set for the breakpoint flag.
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- set_builddir(value: str)[source]#
Sets the build directory path.
- Parameters:
value (str) – The path to the build directory.
- set_cachedir(value: str)[source]#
Sets the path to the user cache directory.
- Parameters:
value (str) – The filepath to the cache directory.
- set_clean(value: bool)[source]#
Sets the clean job flag.
- Parameters:
value (bool) – The value to set for the clean flag.
- set_continue(value: bool, step: str | None = None, index: str | None = None)[source]#
Sets the continue-on-error flag for a step.
- Parameters:
value (bool) – The value for the continue flag.
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- set_credentials(value: str)[source]#
Sets the path to the user credentials file.
- Parameters:
value (str) – The filepath to the credentials file.
- set_design(value: str)[source]#
Sets the top-level design library name.
- Parameters:
value (str) – The name of the design.
- set_env(key: str, value: str)[source]#
Sets an environment variable.
- Parameters:
key (str) – The name of the environment variable.
value (str) – The value to set.
- set_flow(value: str)[source]#
Sets the target flow name.
- Parameters:
value (str) – The name of the flow to set.
- set_hash(value: bool)[source]#
Sets the file hashing flag.
- Parameters:
value (bool) – The value to set for the hash flag.
- set_jobincr(value: bool)[source]#
Sets the job name auto-increment flag.
- Parameters:
value (bool) – The value for the job-increment flag.
- set_nice(value: int, step: str | None = None, index: str | None = None)[source]#
Sets the tool scheduling priority (nice level).
- Parameters:
value (int) – The nice value to set.
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- set_nodashboard(value: bool)[source]#
Sets the dashboard disable flag.
- Parameters:
value (bool) – The value for the no-dashboard flag.
- set_nodisplay(value: bool)[source]#
Sets the headless execution (no-display) flag.
- Parameters:
value (bool) – The value to set for the no-display flag.
- set_novercheck(value: bool, step: str | None = None, index: str | None = None)[source]#
Sets the version checking disable flag for a step.
- Parameters:
value (bool) – The value for the no-version-check flag.
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- set_optmode(value: int, step: str | None = None, index: str | None = None)[source]#
Sets the optimization mode.
- Parameters:
value (int) – The optimization mode level to set.
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- set_quiet(value: bool, step: str | None = None, index: str | None = None)[source]#
Sets the quiet execution flag for a step.
- Parameters:
value (bool) – The value to set for the quiet flag.
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- set_remote(value: bool)[source]#
Sets the remote processing flag.
- Parameters:
value (bool) – The value to set for the remote flag.
- set_timeout(value: float, step: str | None = None, index: str | None = None)[source]#
Sets the timeout value for a step in seconds.
- Parameters:
value (float) – The timeout value in seconds.
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- set_track(value: bool, step: str | None = None, index: str | None = None)[source]#
Sets the provenance tracking flag for a step.
- Parameters:
value (bool) – The value for the track flag.
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- write_defaults() None[source]#
Saves all non-default settings to the configuration file.
This method iterates through all parameters known to the system (via self.allkeys()). It compares the current value of each parameter against its default value.
Any parameter whose current value differs from its default is collected. This list of non-default settings is then serialized as a JSON array to the file specified by default_options_file().
If all parameters are set to their default values, the list will be empty, and no file will be written.
- class siliconcompiler.schema_support.option.SchedulerSchema[source]#
Bases:
BaseSchemaSchema for configuring job scheduler settings.
This class defines all parameters related to the job scheduler, such as the scheduler type, resource constraints (cores, memory), and notification settings. It provides getter and setter methods for each parameter to allow for easy manipulation of the configuration.
- add_msgcontact(value: List[str] | str, step: str | None = None, index: str | None = None, clobber: bool = False)[source]#
Adds or sets the contact list for scheduler event messages.
- Parameters:
value (Union[List[str], str]) – An email address or a list of them.
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
clobber (bool, optional) – If True, replaces the existing contact list. If False, appends to it. Defaults to False.
- add_msgevent(value: List[str] | str, step: str | None = None, index: str | None = None, clobber: bool = False)[source]#
Adds or sets the event triggers for sending messages.
- Parameters:
value (Union[List[str], str]) – A single event or a list of events.
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
clobber (bool, optional) – If True, replaces existing events. If False, appends to them. Defaults to False.
- add_options(value: List[str] | str, step: str | None = None, index: str | None = None, clobber: bool = False)[source]#
Adds or sets advanced pass-through options for the scheduler.
- Parameters:
value (Union[List[str], str]) – A single option or a list of options.
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
clobber (bool, optional) – If True, replaces existing options. If False, appends to them. Defaults to False.
- get_cores(step: str | None = None, index: str | None = None) int[source]#
Gets the number of CPU cores required for the job.
- Parameters:
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- Returns:
The number of CPU cores.
- Return type:
int
- get_defer(step: str | None = None, index: str | None = None) str[source]#
Gets the deferred start time for the job.
- Parameters:
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- Returns:
The defer time string (e.g., ‘16:00’, ‘now+1hour’).
- Return type:
str
- get_maxnodes() int[source]#
Gets the maximum number of concurrent nodes for a job.
- Returns:
The maximum number of nodes.
- Return type:
int
- get_maxthreads() int[source]#
Gets the maximum number of threads for each task in a job.
- Returns:
The maximum number of threads.
- Return type:
int
- get_memory(step: str | None = None, index: str | None = None) int[source]#
Gets the memory required for the job in megabytes.
- Parameters:
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- Returns:
The amount of memory in MB.
- Return type:
int
- get_msgcontact(step: str | None = None, index: str | None = None) List[str][source]#
Gets the contact list for scheduler event messages.
- Parameters:
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- Returns:
A list of email addresses.
- Return type:
List[str]
- get_msgevent(step: str | None = None, index: str | None = None) List[str][source]#
Gets the event triggers for sending messages.
- Parameters:
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- Returns:
A list of message event triggers (e.g., ‘fail’, ‘end’).
- Return type:
List[str]
- get_name(step: str | None = None, index: str | None = None) str[source]#
Gets the scheduler platform name.
- Parameters:
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- Returns:
The name of the scheduler (e.g., ‘slurm’, ‘lsf’).
- Return type:
str
- get_options(step: str | None = None, index: str | None = None) List[str][source]#
Gets the advanced pass-through options for the scheduler.
- Parameters:
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- Returns:
A list of scheduler options.
- Return type:
List[str]
- get_queue(step: str | None = None, index: str | None = None) str[source]#
Gets the scheduler queue (or partition) for the job.
- Parameters:
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- Returns:
The name of the queue.
- Return type:
str
- set_cores(value: int, step: str | None = None, index: str | None = None)[source]#
Sets the number of CPU cores required for the job.
- Parameters:
value (int) – The number of CPU cores to set.
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- set_defer(value: str, step: str | None = None, index: str | None = None)[source]#
Sets the deferred start time for the job.
- Parameters:
value (str) – The defer time string to set.
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- set_maxnodes(value: int)[source]#
Sets the maximum number of concurrent nodes for a job.
- Parameters:
value (int) – The maximum number of nodes to set.
- set_maxthreads(value: int)[source]#
Sets the maximum number of threads for each task in a job.
- Parameters:
value (int) – The maximum number of threads to set.
- set_memory(value: int, step: str | None = None, index: str | None = None)[source]#
Sets the memory required for the job in megabytes.
- Parameters:
value (int) – The amount of memory in MB to set.
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- set_name(value: str, step: str | None = None, index: str | None = None)[source]#
Sets the scheduler platform name.
- Parameters:
value (str) – The name of the scheduler to set.
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- set_queue(value: str, step: str | None = None, index: str | None = None)[source]#
Sets the scheduler queue (or partition) for the job.
- Parameters:
value (str) – The name of the queue to set.
step (str, optional) – The flowgraph step. Defaults to None.
index (str, optional) – The flowgraph step index. Defaults to None.
- class siliconcompiler.schema_support.cmdlineschema.CommandLineSchema[source]#
Class to provide the
create_cmdline()option to a schema object.This class should not be instantiated by itself.
Examples
- class NewSchema(BaseSchema, CommandLineSchema):
creates a new class with the commandline options available
- classmethod create_cmdline(progname: str | None = None, description: str | None = None, switchlist: List[str] | Set[str] | None = None, version: str | None = None, print_banner: bool = True, use_cfg: bool = False, use_sources: bool = True) TCmdSchema[source]#
Creates an SC command line interface.
Exposes parameters in the SC schema as command line switches, simplifying creation of SC apps with a restricted set of schema parameters exposed at the command line. The order of command line switch settings parsed from the command line is as follows:
read_manifest (-cfg), if specified by use_cfg
read commandline inputs
all other switches
The cmdline interface is implemented using the Python argparse package and the following use restrictions apply.
Help is accessed with the ‘-h’ switch.
Arguments that include spaces must be enclosed with double quotes.
List parameters are entered individually. (ie. -y libdir1 -y libdir2)
For parameters with Boolean types, the switch implies “true”.
Special characters (such as ‘-’) must be enclosed in double quotes.
- Parameters:
progname (str) – Name of program to be executed.
description (str) – Short program description.
switchlist (list of str) – List of SC parameter switches to expose at the command line. By default all SC schema switches are available. Parameter switches should be entered based on the parameter ‘switch’ field in the schema. For parameters with multiple switches, both will be accepted if any one is included in this list.
version (str) – version of this program.
print_banner (bool) – if True, will print the siliconcompiler banner
use_cfg (bool) – if True, add and parse the -cfg flag
use_sources (bool) – if True, add positional arguments for files
- Returns:
new project object
Examples
>>> schema.create_cmdline(progname='sc-show',switchlist=['-input','-cfg']) Creates a command line interface for 'sc-show' app.
>>> schema.create_cmdline(progname='sc')
- class siliconcompiler.schema_support.pathschema.PathSchemaBase[source]#
Bases:
BaseSchemaSchema extension to add simpler find_files and check_filepaths
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- check_filepaths(ignore_keys: List[Tuple[str, ...]] | None = None) bool[source]#
Verifies that paths to all files in manifest are valid.
- Parameters:
ignore_keys (list of keypaths) – list of keypaths to ignore while checking
- Returns:
True if all file paths are valid, otherwise False.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- find_files(*keypath: str, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) List[str | None] | str | None[source]#
Returns absolute paths to files or directories based on the keypath provided.
The keypath provided must point to a schema parameter of type file, dir, or lists of either. Otherwise, it will trigger an error.
- Parameters:
keypath (list of str) – Variable length schema key list.
missing_ok (bool) – If True, silently return None when files aren’t found. If False, print an error and set the error flag.
step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
If keys points to a scalar entry, returns an absolute path to that file/directory, or None if not found. It keys points to a list entry, returns a list of either the absolute paths or None for each entry, depending on whether it is found.
Examples
>>> schema.find_files('input', 'verilog') Returns a list of absolute paths to source files, as specified in the schema.
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- hash_files(*keypath: str, update: bool = True, check: bool = True, verbose: bool = True, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) str | None | List[str | None][source]#
Generates hash values for a list of parameter files.
Generates a hash value for each file found in the keypath. If existing hash values are stored, this method will compare hashes and trigger an error if there’s a mismatch. If the update variable is True, the computed hash values are recorded in the ‘filehash’ field of the parameter, following the order dictated by the files within the ‘value’ parameter field.
Files are located using the find_files() function.
The file hash calculation is performed based on the ‘algo’ setting. Supported algorithms include SHA1, SHA224, SHA256, SHA384, SHA512, and MD5.
- Parameters:
*keypath (str) – Keypath to parameter.
update (bool) – If True, the hash values are recorded in the project object manifest.
check (bool) – If True, checks the newly computed hash against the stored hash.
verbose (bool) – If True, generates log messages.
allow_cache (bool) – If True, hashing check the cached values for specific files, if found, it will use that hash value otherwise the hash will be computed.
skip_missing (bool) – If True, hashing will be skipped when missing files are detected.
- Returns:
A list of hash values.
Examples
>>> hashlist = hash_files('input', 'rtl', 'verilog') Computes, stores, and returns hashes of files in :keypath:`input, rtl, verilog`.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.schema_support.pathschema.PathSchema[source]#
Bases:
PathSchemaBaseSchema extension to add support for path handling with dataroots
- active_dataroot(dataroot: str | None = None)#
Use this context to set the dataroot parameter on files and directory parameters.
- Parameters:
dataroot (str) – name of the dataroot
Example
>>> with schema.active_dataroot("lambdalib"): ... schema.set("file", "top.v") Sets the file to top.v and associates lambdalib as the dataroot.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- check_filepaths(ignore_keys: List[Tuple[str, ...]] | None = None) bool[source]#
Verifies that paths to all files in manifest are valid.
- Parameters:
ignore_keys (list of keypaths) – list of keypaths to ignore while checking
- Returns:
True if all file paths are valid, otherwise False.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- find_files(*keypath: str, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) List[str | None] | str | None[source]#
Returns absolute paths to files or directories based on the keypath provided.
The keypath provided must point to a schema parameter of type file, dir, or lists of either. Otherwise, it will trigger an error.
- Parameters:
keypath (list of str) – Variable length schema key list.
missing_ok (bool) – If True, silently return None when files aren’t found. If False, print an error and set the error flag.
step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
If keys points to a scalar entry, returns an absolute path to that file/directory, or None if not found. It keys points to a list entry, returns a list of either the absolute paths or None for each entry, depending on whether it is found.
Examples
>>> schema.find_files('input', 'verilog') Returns a list of absolute paths to source files, as specified in the schema.
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_dataroot(name: str) str[source]#
Returns absolute path to the data directory.
- Raises:
ValueError – is data directory is not found
- Parameters:
name (str) – name of the data directory to find.
- Returns:
Path to the directory root.
Examples
>>> schema.get_dataroot('siliconcompiler') Returns the path to the root of the siliconcompiler data directory.
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- hash_files(*keypath: str, update: bool = True, check: bool = True, verbose: bool = True, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) str | None | List[str | None][source]#
Generates hash values for a list of parameter files.
Generates a hash value for each file found in the keypath. If existing hash values are stored, this method will compare hashes and trigger an error if there’s a mismatch. If the update variable is True, the computed hash values are recorded in the ‘filehash’ field of the parameter, following the order dictated by the files within the ‘value’ parameter field.
Files are located using the find_files() function.
The file hash calculation is performed based on the ‘algo’ setting. Supported algorithms include SHA1, SHA224, SHA256, SHA384, SHA512, and MD5.
- Parameters:
*keypath (str) – Keypath to parameter.
update (bool) – If True, the hash values are recorded in the project object manifest.
check (bool) – If True, checks the newly computed hash against the stored hash.
verbose (bool) – If True, generates log messages.
allow_cache (bool) – If True, hashing check the cached values for specific files, if found, it will use that hash value otherwise the hash will be computed.
skip_missing (bool) – If True, hashing will be skipped when missing files are detected.
- Returns:
A list of hash values.
Examples
>>> hashlist = hash_files('input', 'rtl', 'verilog') Computes, stores, and returns hashes of files in :keypath:`input, rtl, verilog`.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_dataroot(name: str = 'root', path: str | None = None, tag: str | None = None, clobber: bool = False) None[source]#
Registers a data source by name, path, and optional version tag.
This method creates a reference to a data directory, which can be a local path, a Git repository, or a remote archive. This allows other parts of the application to refer to this data source by its unique name.
- Parameters:
name (str, optional) – A unique name to identify the data source. Defaults to “root”.
path (str) – The path to the data source. This is required. It can be a local directory, a file path, a git URL, or an archive URL. If a file path is provided, its parent directory is used as the root.
tag (str, optional) – A version identifier for remote sources, such as a git commit hash, branch, or tag. Defaults to None.
clobber (bool, optional) – If True, allows overwriting an existing data source with the same name. If False (default), attempting to overwrite an existing entry will raise a ValueError.
- Raises:
ValueError – If path is not specified.
ValueError – If a data source with the given name already exists and clobber is False.
Examples
>>> # Register a remote git repository at a specific tag >>> schema.set_dataroot('siliconcompiler_data', ... 'git+https://github.com/siliconcompiler/siliconcompiler', ... tag='v1.0.0') >>> >>> # Register a local directory based on the location of a file >>> schema.set_dataroot('file_data', __file__)
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.schema_support.filesetschema.FileSetSchema[source]#
Bases:
NamedSchema,PathSchemaBaseSchema for storing and managing file sets.
This class provides methods to add, retrieve, and manage named groups of files, known as filesets.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_define(value: str, clobber: bool = False) List[str][source]#
Adds preprocessor macro definitions to a fileset.
- Parameters:
value (str or List[str]) – Macro definition.
clobber (bool, optional) – Clears existing list before adding item.
- Returns:
List of macro definitions
- Return type:
list[str]
- add_depfileset(dep: str, depfileset: str | None = None)[source]#
Record a reference to an imported dependency’s fileset.
- Parameters:
dep (
Designor str) – Dependency name or object.depfileset (str) – Dependency fileset, if not specified, the fileset will default to the same as the fileset or if only one fileset is present in the dep that will be chosen.
fileset (str) – Fileset name. If not provided, the active fileset is used.
- add_file(filename: List[Path | str] | Set[Path | str] | Tuple[Path | str, ...] | Path | str, filetype: str | None = None, clobber: bool = False, dataroot: str | None = None) List[str][source]#
Adds files to a fileset.
Based on the file’s extension, this method can often infer the correct fileset and filetype. For example:
.v -> (source, verilog)
.vhd -> (source, vhdl)
.sdc -> (constraint, sdc)
.lef -> (input, lef)
.def -> (input, def)
etc.
- Parameters:
filename (Path, str, or collection) – File path (Path or str), or a collection (list, tuple, set) of file paths to add.
filetype (str, optional) – Type of the file (e.g., ‘verilog’, ‘sdc’).
clobber (bool, optional) – If True, clears the list before adding the item. Defaults to False.
dataroot (str, optional) – Data directory reference name.
- Raises:
ValueError – If fileset or filetype cannot be inferred from the file extension.
- Returns:
A list of the file paths that were added.
- Return type:
list[str]
Notes
This method normalizes filename to a string for consistency.
- If filetype is not specified, it is inferred from the
file extension.
- add_idir(value: str, clobber: bool = False, dataroot: str | None = None) List[str][source]#
Adds include directories to a fileset.
- Parameters:
value (Path or list[Path]) – Include path(s).
clobber (bool, optional) – Clears existing list before adding item.
dataroot (str, optional) – Data directory reference name.
- Returns:
List of include directories
- Return type:
list[str]
- add_lib(value: str, clobber: bool = False) List[str][source]#
Adds dynamic libraries to a fileset.
- Parameters:
value (str or List[str]) – Libraries.
clobber (bool, optional) – Clears existing list before adding item.
- Returns:
List of libraries.
- Return type:
list[str]
- add_libdir(value: str, clobber: bool = False, dataroot: str | None = None) List[str][source]#
Adds dynamic library directories to a fileset.
- Parameters:
value (Path or list[Path]) – Library path(s).
clobber (bool, optional) – Clears existing list before adding item.
dataroot (str, optional) – Data directory reference name.
- Returns:
List of library directories.
- Return type:
list[str]
- add_undefine(value: str, clobber: bool = False) List[str][source]#
Adds preprocessor macro (un)definitions to a fileset.
- Parameters:
value (str or List[str]) – Macro (un)definition.
clobber (bool, optional) – Clears existing list before adding item.
- Returns:
List of macro (un)definitions
- Return type:
list[str]
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- check_filepaths(ignore_keys: List[Tuple[str, ...]] | None = None) bool[source]#
Verifies that paths to all files in manifest are valid.
- Parameters:
ignore_keys (list of keypaths) – list of keypaths to ignore while checking
- Returns:
True if all file paths are valid, otherwise False.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- find_files(*keypath: str, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) List[str | None] | str | None[source]#
Returns absolute paths to files or directories based on the keypath provided.
The keypath provided must point to a schema parameter of type file, dir, or lists of either. Otherwise, it will trigger an error.
- Parameters:
keypath (list of str) – Variable length schema key list.
missing_ok (bool) – If True, silently return None when files aren’t found. If False, print an error and set the error flag.
step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
If keys points to a scalar entry, returns an absolute path to that file/directory, or None if not found. It keys points to a list entry, returns a list of either the absolute paths or None for each entry, depending on whether it is found.
Examples
>>> schema.find_files('input', 'verilog') Returns a list of absolute paths to source files, as specified in the schema.
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True, name: str | None = None) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
name (str) – name of the schema.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_define() List[str][source]#
Returns defined macros for a fileset.
- Returns:
List of macro definitions
- Return type:
list[str]
- get_depfileset()[source]#
Returns list of dependency filesets.
- Returns:
List of dependencies and filesets.
- Return type:
list[tuple(str, str)]
- get_file(filetype: str | None = None) List[str][source]#
Returns a list of files.
- Parameters:
filetype (str or list[str], optional) – File type(s) to filter by (e.g., ‘verilog’). If not provided, all filetypes in the fileset are returned.
- Returns:
A list of resolved file paths.
- Return type:
list[str]
- get_idir() List[str][source]#
Returns include directories for a fileset.
- Returns:
List of include directories
- Return type:
list[str]
- get_lib() List[str][source]#
Returns list of dynamic libraries for a fileset.
- Returns:
List of libraries.
- Return type:
list[str]
- get_libdir() List[str][source]#
Returns dynamic library directories for a fileset.
- Returns:
List of library directories.
- Return type:
list[str]
- get_param(name: str) str[source]#
Returns value of a named fileset parameter.
- Parameters:
name (str) – Parameter name.
- Returns:
Parameter value
- Return type:
str
- get_topmodule() str[source]#
Returns the topmodule of a fileset.
- Parameters:
fileset (str) – Fileset name. If not provided, the active fileset is used.
- Returns:
Topmodule name
- Return type:
str
- get_undefine() List[str][source]#
Returns undefined macros for a fileset.
- Returns:
List of macro (un)definitions
- Return type:
list[str]
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- has_file(filetype: str | None = None) bool[source]#
Returns true if the fileset contains files.
- Parameters:
filetype (str or list[str], optional) – File type(s) to filter by (e.g., ‘verilog’). If not provided, all filetypes in the fileset are returned.
- Returns:
True if the fileset contains files.
- Return type:
bool
- has_idir() bool[source]#
Returns true if idirs are defined for the fileset
- Returns:
True if the fileset contains directories.
- Return type:
bool
- has_libdir() bool[source]#
Returns true if library directories are defined for the fileset
- Returns:
True if the fileset contains directories.
- Return type:
bool
- hash_files(*keypath: str, update: bool = True, check: bool = True, verbose: bool = True, missing_ok: bool = False, step: str | None = None, index: int | str | None = None) str | None | List[str | None][source]#
Generates hash values for a list of parameter files.
Generates a hash value for each file found in the keypath. If existing hash values are stored, this method will compare hashes and trigger an error if there’s a mismatch. If the update variable is True, the computed hash values are recorded in the ‘filehash’ field of the parameter, following the order dictated by the files within the ‘value’ parameter field.
Files are located using the find_files() function.
The file hash calculation is performed based on the ‘algo’ setting. Supported algorithms include SHA1, SHA224, SHA256, SHA384, SHA512, and MD5.
- Parameters:
*keypath (str) – Keypath to parameter.
update (bool) – If True, the hash values are recorded in the project object manifest.
check (bool) – If True, checks the newly computed hash against the stored hash.
verbose (bool) – If True, generates log messages.
allow_cache (bool) – If True, hashing check the cached values for specific files, if found, it will use that hash value otherwise the hash will be computed.
skip_missing (bool) – If True, hashing will be skipped when missing files are detected.
- Returns:
A list of hash values.
Examples
>>> hashlist = hash_files('input', 'rtl', 'verilog') Computes, stores, and returns hashes of files in :keypath:`input, rtl, verilog`.
- property name: str | None#
Returns the name of the schema
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- set_name(name: str | None) None[source]#
Set the name of this object
- Raises:
RuntimeError – if called after object name is set.
- Parameters:
name (str) – name for object
- set_param(name: str, value: str) str[source]#
Sets a named parameter for a fileset.
- Parameters:
name (str) – Parameter name.
value (str) – Parameter value.
- Returns:
Parameter value
- Return type:
str
- set_topmodule(value: str) str[source]#
Sets the topmodule of a fileset.
- Parameters:
value (str) – Topmodule name.
- Returns:
Topmodule name
- Return type:
str
Notes
first character must be letter or underscore
remaining characters can be letters, digits, or underscores
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
- class siliconcompiler.flowgraph.FlowgraphNodeSchema[source]#
Bases:
BaseSchemaSchema definition for a single node within a flowgraph.
This class defines the parameters that can be set on a per-node basis, such as inputs, weights, goals, and the task to execute.
- add_args(arg: List[str] | str, clobber: bool = False)[source]#
Adds command-line arguments specific to this node.
- Parameters:
arg (list[str] or str) – The argument or list of arguments to add.
clobber (bool, optional) – If True, replaces all existing args with the new ones. If False, appends. Defaults to False.
- add_goal(metric: str, weight: float)[source]#
Sets a goal for a specific metric for this node.
Goals are used to determine if a task run is acceptable.
- Parameters:
metric (str) – The name of the metric (e.g., ‘errors’, ‘setupwns’).
weight (float) – The goal value (e.g., 0 for ‘errors’).
- add_weight(metric: str, weight: float)[source]#
Sets a weight for a specific metric for this node.
Weights are used in optimization tasks to define the “cost” of a particular metric.
- Parameters:
metric (str) – The name of the metric (e.g., ‘errors’, ‘area’).
weight (float) – The weight value.
- get_args() List[str][source]#
Gets the list of command-line arguments for this node.
- Returns:
The list of arguments.
- Return type:
list[str]
- get_goal(metric: str) float | None[source]#
Gets the goal for a specific metric for this node.
- Parameters:
metric (str) – The name of the metric.
- Returns:
The goal value, or None if not set.
- Return type:
float or None
- get_input() List[Tuple[str, str]][source]#
Gets the list of input nodes (dependencies) for this node.
- Returns:
A list of (step, index) tuples.
- Return type:
list[tuple(str,str)]
- get_task() str[source]#
Gets the task associated with this node.
- Returns:
The name of the task (e.g., ‘place’).
- Return type:
str
- get_taskmodule() str[source]#
Gets the fully qualified Python module/class for this node’s task.
- Returns:
The task module string (e.g., ‘siliconcompiler.tools.openroad/Place’).
- Return type:
str
- get_tool() str[source]#
Gets the tool associated with this node.
- Returns:
The name of the tool (e.g., ‘openroad’).
- Return type:
str
- class siliconcompiler.flowgraph.RuntimeFlowgraph(base: Flowgraph, args: Tuple[str, str] | None = None, from_steps: Set[str] | List[str] | None = None, to_steps: Set[str] | List[str] | None = None, prune_nodes: Set[Tuple[str, str]] | List[Tuple[str, str]] | None = None)[source]#
Bases:
objectA runtime representation of a flowgraph for a specific execution.
This class creates a “view” of a base Flowgraph that considers runtime options such as the start step (-from), end step (-to), and nodes to exclude (-prune). It computes the precise subgraph of nodes that need to be executed for a given run.
- get_completed_nodes(record: RecordSchema | None = None) List[Tuple[str, str]][source]#
Finds all nodes in this runtime graph that have successfully completed.
- Parameters:
record (Schema, optional) – A schema object containing run records to check for node status. Defaults to None.
- Returns:
A sorted list of successfully completed nodes.
- Return type:
list[tuple(str,str)]
- get_entry_nodes() Tuple[Tuple[str, str], ...][source]#
Returns the entry nodes for this runtime graph.
This includes user-defined -from nodes (if they are part of the graph) and any nodes whose inputs are pruned or outside the computed graph.
- Returns:
A sorted tuple of all entry nodes.
- Return type:
tuple[tuple(str,str)]
- get_execution_order() Tuple[Tuple[Tuple[str, str], ...], ...][source]#
Returns the execution order of the nodes in this runtime graph.
- Returns:
A tuple of tuples representing parallel execution levels.
- Return type:
tuple[tuple[tuple(str,str)]]
- get_exit_nodes() Tuple[Tuple[str, str], ...][source]#
Returns the exit nodes for this runtime graph.
- Returns:
A tuple of all exit nodes.
- Return type:
tuple[tuple(str,str)]
- get_node_inputs(step: str, index: str, record: RecordSchema | None = None) List[Tuple[str, str]][source]#
Gets the inputs for a specific node in the runtime graph.
If a record object is provided, this method will traverse through any input nodes that were SKIPPED to find the true, non-skipped inputs.
- Parameters:
step (str) – Step name of the node.
index (str) – Index of the node.
record (Schema, optional) – A schema object containing run records. Used to check the status of input nodes. Defaults to None.
- Returns:
A list of input nodes.
- Return type:
list[tuple(str,str)]
- get_nodes() Tuple[Tuple[str, str], ...][source]#
Returns the nodes that are part of this runtime graph.
- Returns:
A tuple of all nodes in the runtime graph.
- Return type:
tuple[tuple(str,str)]
- get_nodes_starting_at(step: str, index: str | int) Tuple[Tuple[str, str], ...][source]#
Returns all nodes reachable from a given starting node in this runtime graph.
- Parameters:
step (str) – The step name of the starting node.
index (str or int) – The index of the starting node.
- Returns:
A tuple of all reachable nodes.
- Return type:
tuple[tuple(str,str)]
- static validate(flow: Flowgraph, from_steps: Set[str] | List[str] | None = None, to_steps: Set[str] | List[str] | None = None, prune_nodes: Set[Tuple[str, str]] | List[Tuple[str, str]] | None = None, logger: Logger | None = None) bool[source]#
Validates runtime options against a flowgraph.
Checks for undefined steps and ensures that pruning does not break the graph by removing all entry/exit points or creating disjoint paths.
- Parameters:
flow (Flowgraph) – The flowgraph to validate against.
from_steps (list[str], optional) – List of start steps. Defaults to None.
to_steps (list[str], optional) – List of end steps. Defaults to None.
prune_nodes (list[tuple(str,str)], optional) – List of nodes to prune. Defaults to None.
logger (logging.Logger, optional) – Logger for error reporting. Defaults to None.
- Returns:
True if the runtime configuration is valid, False otherwise.
- Return type:
bool
- class siliconcompiler.tool.TaskError[source]#
Bases:
ExceptionError indicating that task execution cannot continue and should be terminated.
- add_note()#
Exception.add_note(note) – add a note to the exception
- with_traceback()#
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class siliconcompiler.tool.TaskTimeout(*args, timeout=None, **kwargs)[source]#
Bases:
TaskErrorError indicating a timeout has occurred during task execution.
- Parameters:
timeout (float) – The execution time in seconds at which the timeout occurred.
- add_note()#
Exception.add_note(note) – add a note to the exception
- with_traceback()#
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class siliconcompiler.tool.TaskExecutableNotFound[source]#
Bases:
TaskErrorError indicating that the required tool executable could not be found.
- add_note()#
Exception.add_note(note) – add a note to the exception
- with_traceback()#
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class siliconcompiler.schema_support.packageschema.PackageSchema[source]#
Bases:
PathSchemaA class for managing package-related schema data.
- add_author(identifier: str, name: str = None, email: str = None, organization: str = None)[source]#
Add or update author information for the package.
- Parameters:
identifier (str) – A unique identifier for the author.
name (str, optional) – The author’s name. Defaults to None.
email (str, optional) – The author’s email address. Defaults to None.
organization (str, optional) – The author’s organization. Defaults to None.
- add_doc(type: str, path: str, dataroot: str = None)[source]#
Add documentation to the package.
- Parameters:
type (str) – The type of documentation (e.g., “manual”, “api”).
path (str) – The path to the documentation file.
dataroot (str, optional) – The data reference for the package. Defaults to None, which uses the active package.
- Returns:
The result of the add operation.
- add_license(name: str)[source]#
Add a license name to the package.
- Parameters:
name (str) – The name of the license.
- add_licensefile(file: str, dataroot: str = None)[source]#
Add a license file to the package.
- Parameters:
file (str) – The path to the license file.
dataroot (str, optional) – The data reference for the package. Defaults to None, which uses the active package.
- get_author(identifier: str = None)[source]#
Returns the author information for a specific author or all authors.
- Parameters:
identifier (str) – A unique identifier for the author, if None returns all
- get_description() str[source]#
Get the description of the package.
- Returns:
The description string.
- Return type:
str
- get_doc(type: str = None) List[str] | Dict[str, List[str]][source]#
Get documentation files for the package.
- Parameters:
type (str, optional) – The type of documentation to retrieve. If None, returns all documentation organized by type. Defaults to None.
- get_license() List[str][source]#
Get a list of license names associated with the package.
- Returns:
A list of license names.
- Return type:
List[str]
- get_licensefile() List[str][source]#
Get a list of license file paths associated with the package.
- Returns:
A list of file paths.
- Return type:
List[str]
- get_version() str[source]#
Get the version of the package.
- Returns:
The version string.
- Return type:
str
- set_description(desc: str)[source]#
Set the description of the package.
- Parameters:
desc (str) – The description string.
- class siliconcompiler.checklist.Criteria(name: str | None = None)[source]#
Bases:
NamedSchemaSchema for defining a single checklist item’s criteria.
This class holds all the configurable parameters for a specific checklist item, such as its description, requirements, validation criteria, and associated reports or waivers.
- add_criteria(value: List[str] | str, clobber: bool = False) None[source]#
Adds one or more signoff criteria to the checklist item.
- Parameters:
value (Union[List[str], str]) – A single criterion string or a list of strings.
clobber (bool) – If True, replaces the existing list with the new value. If False, appends to the existing list. Defaults to False.
- add_rationale(value: List[str] | str, clobber: bool = False) None[source]#
Adds one or more rationale codes or descriptions to the checklist item.
- Parameters:
value (Union[List[str], str]) – A single rationale string or a list of strings.
clobber (bool) – If True, replaces the existing list with the new value. If False, appends to the existing list. Defaults to False.
- add_report(value: List[str] | str, clobber: bool = False) None[source]#
Adds one or more report filepaths to the checklist item.
- Parameters:
value (Union[List[str], str]) – A single filepath string or a list of strings.
clobber (bool) – If True, replaces the existing list with the new value. If False, appends to the existing list. Defaults to False.
- add_task(value: List[Tuple[str, str, str]] | Tuple[str, str, str], clobber: bool = False) None[source]#
Adds one or more flowgraph tasks to verify the checklist item.
- Parameters:
value (Union[List[Tuple], Tuple]) – A single task tuple or a list of tuples.
clobber (bool) – If True, replaces the existing list with the new value. If False, appends to the existing list. Defaults to False.
- add_waiver(metric: str, value: List[Path | str] | Path | str, clobber: bool = False) None[source]#
Adds one or more waiver reports for a specific metric.
- Parameters:
metric (str) – The metric to which the waiver applies.
value (Union[List, Path, str]) – A single filepath or a list of filepaths.
clobber (bool) – If True, replaces the existing list with the new value. If False, appends to the existing list. Defaults to False.
- get_criteria() List[str][source]#
Retrieves the list of signoff criteria.
Each criterion is a string in the format ‘metric op value’ (e.g., ‘errors == 0’).
- Returns:
A list of criteria strings.
- Return type:
List[str]
- get_dataformat() str | None[source]#
Retrieves the description of acceptable data file formats.
- Returns:
A free-text description of the data format, or None if not set.
- Return type:
Optional[str]
- get_description() str | None[source]#
Retrieves the short, one-line description of the checklist item.
- Returns:
The description string, or None if not set.
- Return type:
Optional[str]
- get_ok() bool[source]#
Retrieves the manual ‘ok’ status of the checklist item.
A value of True indicates a human has reviewed and approved the item.
- Returns:
The boolean status, or False if not set.
- Return type:
bool
- get_rationale() List[str][source]#
Retrieves the rationale codes or descriptions for the checklist item.
- Returns:
A list of rationale strings.
- Return type:
List[str]
- get_report() List[str][source]#
Retrieves the list of report filepaths documenting validation.
- Returns:
A list of filepaths.
- Return type:
List[str]
- get_requirement() str | None[source]#
Retrieves the detailed requirement description for the checklist item.
- Returns:
The requirement description, which can be a multi-line string, or None if not set.
- Return type:
Optional[str]
- get_task() List[Tuple[str, str, str]][source]#
Retrieves the flowgraph tasks used to verify this checklist item.
Each task is represented as a tuple of (job, step, index).
- Returns:
A list of task tuples.
- Return type:
List[Tuple[str, str, str]]
- get_waiver(metric: str) List[Path | str][source]#
Retrieves waiver report files for a specific metric.
- Parameters:
metric (str) – The metric for which to retrieve waivers.
- Returns:
A list of filepaths for the specified metric’s waivers.
- Return type:
List[Union[Path, str]]
- set_dataformat(value: str | None)[source]#
Sets the description of acceptable data file formats for signoff.
- Parameters:
value (Optional[str]) – A free-text description of the data format.
- set_description(value: str | None) None[source]#
Sets the short, one-line description for the checklist item.
- Parameters:
value (Optional[str]) – The description string to set.
- class siliconcompiler.library.ToolLibrarySchema(name: str | None = None)[source]#
Bases:
DesignA class for managing tool-related library schemas.
- class siliconcompiler.schema_support.record.RecordSchema[source]#
Bases:
BaseSchemaA class for managing run record data.
- clear(step: str, index: str | int, keep: List[str] | None = None) None[source]#
Clear all saved metrics for a given step and index.
- Parameters:
step (str) – Step name to clear.
index (str or int) – Index name to clear.
keep (list of str) – list of records to keep.
- static get_cloud_information() Dict[str, str | None][source]#
Return information about the cloud environment.
- Returns:
{ “region”: str }
- get_earliest_time(type: RecordTime) float | None[source]#
Returns the earliest recorded time.
- Parameters:
type (
RecordTime) – type of time to record
- static get_ip_information() Dict[str, str | None][source]#
Return information about the ip and mac address of this machine.
- Returns:
{ “ip”: str, “mac”: str }
- get_latest_time(type: RecordTime) float | None[source]#
Returns the last recorded time.
- Parameters:
type (
RecordTime) – type of time to record
- static get_machine_information() Dict[str, str | None][source]#
Return information about the machine.
- Returns:
{ “name”: str, “system”: str, “distro”: str, “osversion”: str, “kernelversion”: str, “arch”: str }
- get_recorded_time(step: str, index: str | int, type: RecordTime) float | None[source]#
Returns the time recorded for a given record, or None if nothing is recorded.
- Parameters:
step (str) – Step name to associate.
index (str or int) – Index name to associate.
type (
RecordTime) – type of time to record
- static get_user_information() Dict[str, str | None][source]#
Return information about the user.
Return format: {“username”: str}
- record_python_packages() None[source]#
Record the python packages currently available in the environment.
- record_time(step: str, index: str | int, type: RecordTime) float[source]#
Record the time of the record.
- Returns:
time recorded.
- Parameters:
step (str) – Step name to associate.
index (str or int) – Index name to associate.
type (
RecordTime) – type of time to record
- record_tool(step: str, index: str | int, info: str | List[str] | int, type: RecordTool) None[source]#
Record information about the tool used during this record.
- Parameters:
step (str) – Step name to associate.
index (str or int) – Index name to associate.
info (any) – Information to record.
type (
RecordTool) – type of tool information being recorded
- record_userinformation(step: str, index: str | int) None[source]#
Records information about the current machine and user. Uses information from
get_machine_information(),get_user_information(),get_cloud_information(), andget_ip_information().- Parameters:
step (str) – Step name to associate.
index (str or int) – Index name to associate.
- class siliconcompiler.schema_support.metric.MetricSchema[source]#
Bases:
BaseSchemaSchema for storing and accessing metrics collected during a run.
This class provides a structured way to define, record, and report various metrics such as runtime, memory usage, and design quality indicators for each step of a compilation flow.
- clear(step: str, index: int | str) None[source]#
Clears all saved metrics for a given step and index.
- Parameters:
step (str) – The step name to clear metrics for.
index (str or int) – The index to clear metrics for.
- get_formatted_metric(metric: str, step: str, index: int | str) str[source]#
Retrieves and formats a metric for display.
Handles special formatting for memory (binary units), time, and adds SI suffixes for other float values.
- Parameters:
metric (str) – The name of the metric to format.
step (str) – The step of the metric.
index (str) – The index of the metric.
- Returns:
The formatted, human-readable metric value as a string.
- Return type:
str
- record(step: str, index: str | int, metric: str, value: float | int, unit: str | None = None)[source]#
Records a metric value for a specific step and index.
This method handles unit conversion if the metric is defined with a unit in the schema.
- Parameters:
step (str) – The step to record the metric for.
index (str or int) – The index to record the metric for.
metric (str) – The name of the metric to record.
value (int or float) – The value of the metric.
unit (str, optional) – The unit of the provided value. If the schema defines a unit for this metric, the value will be converted. Defaults to None.
- Returns:
The recorded value after any unit conversion.
- record_tasktime(step: str, index: str | int, record: RecordSchema)[source]#
Records the task time for a given node based on start and end times.
- Parameters:
step (str) – The step of the node.
index (str or int) – The index of the node.
record (RecordSchema) – The record schema containing timing data.
- Returns:
True if the time was successfully recorded, False otherwise.
- Return type:
bool
- record_totaltime(step: str, index: str | int, flow: Flowgraph, record: RecordSchema)[source]#
Records the cumulative total time up to the end of a given node.
This method calculates the total wall-clock time by summing the durations of all previously executed parallel tasks.
- Parameters:
step (str) – The step of the node.
index (str or int) – The index of the node.
flow (Flowgraph) – The flowgraph containing the nodes.
record (RecordSchema) – The record schema containing timing data.
- Returns:
True if the time was successfully recorded, False otherwise.
- Return type:
bool
- summary(headers: List[Tuple[str, str | None]], nodes: List[Tuple[str, str]] | None = None, column_width: int = 15, fd: TextIO | None = None, max_line_width: int | None = None) None[source]#
Prints a formatted summary of metrics to a file descriptor.
- Parameters:
headers (List[Tuple[str, str]]) – A list of (title, value) tuples to print in the header section of the summary.
nodes (List[Tuple[str, str]], optional) – A list of (step, index) tuples to include. Defaults to all nodes.
column_width (int, optional) – The width for each column in the table. Defaults to 15.
fd (TextIO, optional) – The file descriptor to write to. Defaults to sys.stdout.
max_line_width (int, optional) – The maximum line width for the summary table. Defaults to the terminal width or 4 times the column width, whichever is larger.
- summary_table(nodes: List[Tuple[str, str]] | None = None, column_width: int = 15, formatted: bool = True, trim_empty_metrics: bool = True) DataFrame[source]#
Generates a summary of metrics as a pandas DataFrame.
- Parameters:
nodes (List[Tuple[str, str]], optional) – A list of (step, index) tuples to include in the summary. If None, all nodes with metrics are included. Defaults to None.
column_width (int, optional) – The width for each column. Defaults to 15.
formatted (bool, optional) – If True, metric values are formatted for human readability. Defaults to True.
trim_empty_metrics (bool, optional) – If True, metrics that have no value for any of the specified nodes are excluded. Defaults to True.
- Returns:
A DataFrame containing the metric summary.
- Return type:
pandas.DataFrame
- class siliconcompiler.Schematic(name: str = None)[source]#
Bases:
BaseSchemaBasic schematic entry class for designing systems with real physical components.
- add(*args, field: str = 'value', step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Adds item(s) to a schema parameter list.
Adds item(s) to schema parameter list based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to add.
field (str) – Parameter field to modify.
step (str) – Step name to modify for parameters that may be specified on a per-node basis.
index (str) – Index name to modify for parameters that may be specified on a per-node basis.
Examples
>>> schema.add('input', 'rtl', 'verilog', 'hello.v') Adds the file 'hello.v' to the [input,rtl,verilog] key.
- add_component(name: str, part: Part) Component[source]#
Adds component (instance) to the schematic object.
- Parameters:
name (str) – Instance name
part (str, obj) – Instance partname/cellname.
- Returns:
Pin direction
- Return type:
str
- add_net(name: str) Net[source]#
Add a named net to the schematic.
This method creates a new net in the schematic, storing its name and vector bit range in the SC schema. If the net name includes a bus notation (e.g., “data[7:0]”), the bit range is automatically extracted.
- Parameters:
name (str) – The name of the net. Can include a vector range in the form “netname[max:min]” (e.g., “data[7:0]”).
- Returns:
The created net object.
- Return type:
Net
- add_part(name: str, pins: List[str]) Part[source]#
Adds part declaration. This is an interface/header type declaration required for all parts to be instantiated in the schematic.
- Parameters:
name (str) – Part name (e.g., NAND2).
pins (list str) – List of all part pins. Vector pins use bus character [] (eg. in[7:0])
- Returns:
Part object
- Return type:
str
- add_pin(name: str, direction: str) Pin[source]#
Add a pin to the schematic object.
This method creates a new pin in the schematic, storing its name, direction, and optional vector bit range in the SC schema. If the pin name includes a bus notation (e.g., “data[7:0]”), the bit range is automatically extracted.
- Parameters:
name (str) – The name of the pin. Can include a vector range (e.g., “in”, “sel”, or “data[7:0]”).
direction (str) – The pin direction; one of “input”, “output”, or “inout”.
- Returns:
The created pin object.
- Return type:
Pin
- all_pins() list[str][source]#
Get a list of all pins in the schematic.
- Returns:
A list of pin names defined in the schematic.
- Return type:
list[str]
- allkeys(*keypath: str, include_default: bool = True) Set[Tuple[str, ...]][source]#
Returns all keypaths in the schema as a set of tuples.
- Arg:
- keypath (list of str): Keypath prefix to search under. The
returned keypaths do not include the prefix.
- connect(src: Pin, dst: Pin, net: Net | None = None)[source]#
Connect pin to net.
- Parameters:
src (Pin) – Source pin to connect
dst (Pin) – Destination pin to connect
net (Net) – Net name. Not needed for primary pin.
- copy(key: Tuple[str, ...] | None = None) TSchema[source]#
Returns a copy of this schema.
- Parameters:
key (list of str) – keypath to this schema
- classmethod from_manifest(filepath: None | str = None, cfg: None | Dict = None, lazyload: bool = True) TSchema[source]#
Create a new schema based on the provided source files.
The two arguments to this method are mutually exclusive.
- Parameters:
filepath (path) – Initial manifest.
cfg (dict) – Initial configuration dictionary.
- get(*keypath: str, field: str | None = 'value', step: str | None = None, index: str | int | None = None)[source]#
Returns a parameter field from the schema.
Returns a schema parameter field based on the keypath provided in the
*keypath. The returned type is consistent with the type field of the parameter. Accessing a non-existent keypath raises a KeyError.- Parameters:
keypath (list of str) – Keypath to access.
field (str) – Parameter field to fetch, if None will return the
Parameterobject stored, if field is ‘schema’ the schema at this keypath will be returned.step (str) – Step name to access for parameters that may be specified on a per-node basis.
index (str) – Index name to access for parameters that may be specified on a per-node basis.
- Returns:
Value found for the keypath and field provided.
Examples
>>> foundry = schema.get('pdk', 'virtual', 'foundry') Returns the value of [pdk,virtual,foundry].
- get_netrange(name: str | Net) Tuple[int, int][source]#
Get the vector bit range of a named net.
- Parameters:
name (str | Net) – The name of the net, or a Net object with a name attribute.
- Returns:
The bit range of the net as (max, min). For scalar nets, this defaults to (0, 0).
- Return type:
tuple[int, int]
- get_partname(inst: Component) str[source]#
Returns part name of named component.
- Parameters:
inst (Component) – Component object
- Returns:
Part name (str)
- get_pindir(name: str | Pin) str[source]#
Get the direction of a named pin.
- Parameters:
name (str | Pin) – The name of the pin (e.g., “in”, “sel”) or a Pin object with a name attribute.
- Returns:
The direction of the pin (“input”, “output”, or “inout”).
- Return type:
str
- get_pinrange(name: str | Pin) Tuple[int, int][source]#
Get the vector bit range of a pin.
- Parameters:
name (str | Pin) – The name of the pin, or a Pin object with a name attribute.
- Returns:
The vector bit range of the pin as (max, min).
- Return type:
tuple[int, int]
- getdict(*keypath: str, include_default: bool = True, values_only: bool = False) Dict[source]#
Returns a schema dictionary.
Searches the schema for the keypath provided and returns a complete dictionary.
- Parameters:
keypath (list of str) – Variable length ordered schema key list
include_default (boolean) – If true will include default key paths
values_only (boolean) – If true will only return values
- Returns:
A schema dictionary
Examples
>>> pdk = schema.getdict('pdk') Returns the complete dictionary found for the keypath [pdk]
- getkeys(*keypath: str) Tuple[str, ...][source]#
Returns a tuple of schema dictionary keys.
Searches the schema for the keypath provided and returns a list of keys found, excluding the generic ‘default’ key.
- Parameters:
keypath (list of str) – Keypath to get keys for.
- Returns:
tuple of keys found for the keypath provided.
Examples
>>> keylist = schema.getkeys('pdk') Returns all keys for the [pdk] keypath.
- read_manifest(filepath: str) None[source]#
Reads a manifest from disk and replaces the current data with the data in the file.
- Parameters:
filename (path) – Path to a manifest file to be loaded.
Examples
>>> schema.read_manifest('mychip.json') Loads the file mychip.json into the current Schema object.
- read_verilog(filename)[source]#
Read Verilog netlist file into data structure.
- Parameters:
filename (str or Path) – Path to the output netlist file.
- remove(*keypath: str)[source]#
Remove a schema parameter and its subparameters.
- Parameters:
keypath (list) – Parameter keypath to clear.
- set(*args, field: str = 'value', clobber: bool = True, step: str | None = None, index: str | int | None = None) List[NodeValue] | NodeValue | None[source]#
Sets a schema parameter field.
Sets a schema parameter field based on the keypath and value provided in the
*args. New schema entries are automatically created for keypaths that overlap with ‘default’ entries.- Parameters:
args (list) – Parameter keypath followed by a value to set.
field (str) – Parameter field to set.
clobber (bool) – Existing value is overwritten if True.
step (str) – Step name to set for parameters that may be specified on a per-node basis.
index (str) – Index name to set for parameters that may be specified on a per-node basis.
Examples
>>> schema.set('design', 'top') Sets the [design] value to 'top'
- unset(*keypath: str, step: str | None = None, index: str | int | None = None) None[source]#
Unsets a schema parameter.
This method effectively undoes any previous calls to
set()made to the given keypath and step/index. For parameters with required or no per-node values, unsetting a parameter always causes it to revert to its default value, and future calls toset()withclobber=Falsewill once again be able to modify the value.If you unset a particular step/index for a parameter with optional per-node values, note that the newly returned value will be the global value if it has been set. To completely return the parameter to its default state, the global value has to be unset as well.
unset()has no effect if called on a parameter that has not been previously set.- Parameters:
keypath (list) – Parameter keypath to clear.
step (str) – Step name to unset for parameters that may be specified on a per-node basis.
index (str) – Index name to unset for parameters that may be specified on a per-node basis.
- valid(*keypath: str, default_valid: bool = False, check_complete: bool = False) bool[source]#
Checks validity of a keypath.
Checks the validity of a parameter keypath and returns True if the keypath is valid and False if invalid.
- Parameters:
keypath (list of str) – keypath to check if valid.
default_valid (bool) – Whether to consider “default” in valid
wildcard. (keypaths as a)
check_complete (bool) – Require the keypath be a complete path.
- Returns:
Boolean indicating validity of keypath.
Examples
>>> check = schema.valid('design') Returns True >>> check = schema.valid('blah') Returns False. >>> check = schema.valid('metric', 'foo', '0', 'tasktime', default_valid=True) Returns True, even if "foo" and "0" aren't in current configuration.
2.8. Inheritance#