3. 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.

3.1. Useful APIs#

Base schema:

BaseSchema.set

Sets a schema parameter field.

BaseSchema.add

Adds item(s) to a schema parameter list.

BaseSchema.get

Returns a parameter field from the schema.

BaseSchema.getkeys

Returns a tuple of schema dictionary keys.

BaseSchema.getdict

Returns a schema dictionary.

BaseSchema.valid

Checks validity of a keypath.

BaseSchema.unset

Unsets a schema parameter.

BaseSchema.remove

Remove a schema parameter and its subparameters.

BaseSchema.write_manifest

Writes the manifest to a file.

BaseSchema.read_manifest

Reads a manifest from disk and replaces the current data with the data in the file.

BaseSchema.from_manifest

Create a new schema based on the provided source files.

Editing schema:

EditableSchema.insert

Inserts a Parameter or a BaseSchema to the schema, based on the keypath and value provided in the *args.

EditableSchema.remove

Removes a keypath from the schema.

EditableSchema.search

Finds an item in the schema.

3.2. Metrics Classes#

class siliconcompiler.RecordSchema[source]#

Bases: BaseSchema

add(*args, field='value', step=None, index=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, include_default=True)[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.

clear(step, index, keep=None)[source]#

Clear all saved metrics for a given step and index

Parameters:
  • step (str) – Step name to clear.

  • index (str) – Index name to clear.

  • keep (list of str) – list of records to keep.

copy(key=None)[source]#

Returns a copy of this schema.

Parameters:

key (list of str) – keypath to this schema

classmethod from_manifest(filepath=None, cfg=None)[source]#

Create a new schema based on the provided source files.

The two arguments to this class are mutually exclusive.

Parameters:
  • filepath (path) – Initial manifest.

  • cfg (dict) – Initial configuration dictionary.

get(*keypath, field='value', step=None, index=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 Parameter object 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].
static get_cloud_information()[source]#

Return information about the cloud environment.

Return format: {

“region”: str

}

static get_ip_information()[source]#

Return information about the ip and mac address of this machine.

Return format: {

“ip”: str, “mac”: str

}

static get_machine_information()[source]#

Return information about the machine.

Return format: {

“machine”: str, “system”: str, “distro”: str, “osversion”: str, “kernelversion”: str, “arch”: str

}

get_recorded_time(step, index, type)[source]#

Returns the time recorded for a given record.

Parameters:
  • step (str) – Step name to associate.

  • index (str) – Index name to associate.

  • type (RecordTime) – type of time to record

static get_user_information()[source]#

Return information about the user.

Return format: {“username”: str}

getdict(*keypath, include_default=True)[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

Returns:

A schema dictionary

Examples

>>> pdk = schema.getdict('pdk')
Returns the complete dictionary found for the keypath [pdk]
getkeys(*keypath)[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 = chip.getkeys('pdk')
Returns all keys for the [pdk] keypath.
read_manifest(filepath)[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_python_packages()[source]#

Record the python packages currently available in the environment.

record_time(step, index, type)[source]#

Record the time of the record.

Returns:

time recorded.

Parameters:
  • step (str) – Step name to associate.

  • index (str) – Index name to associate.

  • type (RecordTime) – type of time to record

record_tool(step, index, info, type)[source]#

Record information about the tool used during this record.

Parameters:
  • step (str) – Step name to associate.

  • index (str) – Index name to associate.

  • info (any) – Information to record.

  • type (RecordTool) – type of tool information being recorded

record_userinformation(step, index)[source]#

Records information about the current machine and user. Uses information from get_machine_information(), get_user_information(), get_cloud_information(), and get_ip_information().

Parameters:
  • step (str) – Step name to associate.

  • index (str) – Index name to associate.

record_version(step, index)[source]#

Records the versions for SiliconCompiler and python.

Parameters:
  • step (str) – Step name to associate.

  • index (str) – Index name to associate.

remove(*keypath)[source]#

Remove a schema parameter and its subparameters.

Parameters:

keypath (list) – Parameter keypath to clear.

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'
unset(*keypath, step=None, index=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 to set() with clobber=False will 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, default_valid=False, check_complete=False)[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_manifest(filepath)[source]#

Writes the manifest to a file.

Parameters:

filename (filepath) – Output filepath.

Examples

>>> schema.write_manifest('mydump.json')
Dumps the current manifest into mydump.json
class siliconcompiler.MetricSchema[source]#

Bases: BaseSchema

add(*args, field='value', step=None, index=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, include_default=True)[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.

clear(step, index)[source]#

Clear all saved metrics for a given step and index

Parameters:
  • step (str) – Step name to clear.

  • index (str/int) – Index name to clear.

copy(key=None)[source]#

Returns a copy of this schema.

Parameters:

key (list of str) – keypath to this schema

classmethod from_manifest(filepath=None, cfg=None)[source]#

Create a new schema based on the provided source files.

The two arguments to this class are mutually exclusive.

Parameters:
  • filepath (path) – Initial manifest.

  • cfg (dict) – Initial configuration dictionary.

get(*keypath, field='value', step=None, index=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 Parameter object 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, include_default=True)[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

Returns:

A schema dictionary

Examples

>>> pdk = schema.getdict('pdk')
Returns the complete dictionary found for the keypath [pdk]
getkeys(*keypath)[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 = chip.getkeys('pdk')
Returns all keys for the [pdk] keypath.
read_manifest(filepath)[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(step, index, metric, value, unit=None)[source]#

Record a metric

Parameters:
  • step (str) – step to record

  • index (str/int) – index to record

  • metric (str) – name of metric

  • value (int/float) – value to record

  • unit (str) – unit associated with value

remove(*keypath)[source]#

Remove a schema parameter and its subparameters.

Parameters:

keypath (list) – Parameter keypath to clear.

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'
unset(*keypath, step=None, index=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 to set() with clobber=False will 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, default_valid=False, check_complete=False)[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_manifest(filepath)[source]#

Writes the manifest to a file.

Parameters:

filename (filepath) – Output filepath.

Examples

>>> schema.write_manifest('mydump.json')
Dumps the current manifest into mydump.json
class siliconcompiler.PDKSchema(name=None, package=None)[source]#

Bases: NamedSchema, PackageSchema

add(*args, field='value', step=None, index=None, package=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.

  • package (str) – Name of package to associate with this value.

Examples

>>> schema.add('input', 'rtl', 'verilog', 'hello.v')
Adds the file 'hello.v' to the [input,rtl,verilog] key.
allkeys(*keypath, include_default=True)[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=None)[source]#

Returns a copy of this schema.

Parameters:

key (list of str) – keypath to this schema

classmethod from_manifest(filepath=None, cfg=None)[source]#

Create a new schema based on the provided source files.

The two arguments to this class are mutually exclusive.

Parameters:
  • filepath (path) – Initial manifest.

  • cfg (dict) – Initial configuration dictionary.

get(*keypath, field='value', step=None, index=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 Parameter object 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, include_default=True)[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

Returns:

A schema dictionary

Examples

>>> pdk = schema.getdict('pdk')
Returns the complete dictionary found for the keypath [pdk]
getkeys(*keypath)[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 = chip.getkeys('pdk')
Returns all keys for the [pdk] keypath.
name()[source]#

Returns the name of the schema

read_manifest(filepath)[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)[source]#

Remove a schema parameter and its subparameters.

Parameters:

keypath (list) – Parameter keypath to clear.

set(*args, field='value', clobber=True, step=None, index=None, package=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.

  • package (str) – Name of package to associate with this value.

Examples

>>> schema.set('design', 'top')
Sets the [design] value to 'top'
unset(*keypath, step=None, index=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 to set() with clobber=False will 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, default_valid=False, check_complete=False)[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_manifest(filepath)[source]#

Writes the manifest to a file.

Parameters:

filename (filepath) – Output filepath.

Examples

>>> schema.write_manifest('mydump.json')
Dumps the current manifest into mydump.json
class siliconcompiler.FlowgraphSchema(name=None)[source]#

Bases: NamedSchema

add(*args, field='value', step=None, index=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, include_default=True)[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=None)[source]#

Returns a copy of this schema.

Parameters:

key (list of str) – keypath to this schema

edge(tail, head, tail_index=0, head_index=0)[source]#

Creates a directed edge from a tail node to a head node.

Connects the output of a tail node with the input of a head node by setting the ‘input’ field of the head node in the schema flowgraph.

The method modifies the following parameters:

[<head>,<head_index>,input]

Parameters:
  • tail (str) – Name of tail node

  • head (str) – Name of head node

  • tail_index (int/str) – Index of tail node to connect

  • head_index (int/str) – Index of head node to connect

Examples

>>> chip.edge('place', 'cts')
Creates a directed edge from place to cts.
classmethod from_manifest(filepath=None, cfg=None)[source]#

Create a new schema based on the provided source files.

The two arguments to this class are mutually exclusive.

Parameters:
  • filepath (path) – Initial manifest.

  • cfg (dict) – Initial configuration dictionary.

get(*keypath, field='value', step=None, index=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 Parameter object 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_entry_nodes()[source]#

Collect all step/indices that represent the entry nodes for the flowgraph

get_execution_order(reverse=False)[source]#

Generates a list of nodes in the order they will be executed.

Parameters:

reverse (boolean) – if True, the nodes will be ordered from exit nodes to entry nodes.

get_exit_nodes()[source]#

Collect all step/indices that represent the exit nodes for the flowgraph

get_node_outputs(step, index)[source]#

Returns the nodes the given nodes provides input to.

Parameters:
  • step (str) – step name

  • index (str/int)

get_nodes()[source]#

Returns all the nodes defined in this flowgraph

getdict(*keypath, include_default=True)[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

Returns:

A schema dictionary

Examples

>>> pdk = schema.getdict('pdk')
Returns the complete dictionary found for the keypath [pdk]
getkeys(*keypath)[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 = chip.getkeys('pdk')
Returns all keys for the [pdk] keypath.
graph(subflow, name=None)[source]#

Instantiates a named flow as a graph in the current flowgraph.

Parameters:
  • subflow (str) – Name of flow to instantiate

  • name (str) – Name of instance

Examples

>>> chip.graph(asicflow)
Instantiates a flow named 'asicflow'.
name()[source]#

Returns the name of the schema

node(step, task, index=0)[source]#

Creates a flowgraph node.

Creates a flowgraph node by binding a step to a tool specific task. A tool can be an external executable or one of the built in functions in the SiliconCompiler framework). Built in functions include: minimum, maximum, join, mux, verify.

The method modifies the following schema parameters:

  • [<step>,<index>,tool,<tool>]

  • [<step>,<index>,task,<task>]

  • [<step>,<index>,taskmodule,<taskmodule>]

Parameters:
  • step (str) – Step name

  • task (module/str) – Task to associate with this node

  • index (int/str) – Step index

Examples

>>> import siliconcomiler.tools.openroad.place as place
>>> flow.node('apr_place', place, index=0)
Creates a 'place' task with step='apr_place' and index=0 and binds it to the
'openroad' tool.
read_manifest(filepath)[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)[source]#

Remove a schema parameter and its subparameters.

Parameters:

keypath (list) – Parameter keypath to clear.

remove_node(step, index=None)[source]#

Remove a flowgraph node.

Parameters:
  • step (str) – Step name

  • index (int/str) – Step index

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'
unset(*keypath, step=None, index=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 to set() with clobber=False will 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, default_valid=False, check_complete=False)[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=None)[source]#

Check if flowgraph is valid.

  • Checks if all edges have valid nodes

  • Checks that there are no duplicate edges

  • Checks if nodes are defined properly

  • Checks if there are any loops present in the graph

Returns True if valid, False otherwise.

Parameters:

logger (logging.Logger) – logger to use for reporting

write_manifest(filepath)[source]#

Writes the manifest to a file.

Parameters:

filename (filepath) – Output filepath.

Examples

>>> schema.write_manifest('mydump.json')
Dumps the current manifest into mydump.json
class siliconcompiler.ChecklistSchema(name=None)[source]#

Bases: NamedSchema

add(*args, field='value', step=None, index=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, include_default=True)[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=None)[source]#

Returns a copy of this schema.

Parameters:

key (list of str) – keypath to this schema

classmethod from_manifest(filepath=None, cfg=None)[source]#

Create a new schema based on the provided source files.

The two arguments to this class are mutually exclusive.

Parameters:
  • filepath (path) – Initial manifest.

  • cfg (dict) – Initial configuration dictionary.

get(*keypath, field='value', step=None, index=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 Parameter object 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, include_default=True)[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

Returns:

A schema dictionary

Examples

>>> pdk = schema.getdict('pdk')
Returns the complete dictionary found for the keypath [pdk]
getkeys(*keypath)[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 = chip.getkeys('pdk')
Returns all keys for the [pdk] keypath.
name()[source]#

Returns the name of the schema

read_manifest(filepath)[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)[source]#

Remove a schema parameter and its subparameters.

Parameters:

keypath (list) – Parameter keypath to clear.

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'
unset(*keypath, step=None, index=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 to set() with clobber=False will 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, default_valid=False, check_complete=False)[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_manifest(filepath)[source]#

Writes the manifest to a file.

Parameters:

filename (filepath) – Output filepath.

Examples

>>> schema.write_manifest('mydump.json')
Dumps the current manifest into mydump.json
class siliconcompiler.ToolSchema(name=None)[source]#

Bases: NamedSchema

add(*args, field='value', step=None, index=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, include_default=True)[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)[source]#

Check if the reported version matches the versions specified in ['tool', <tool>, 'version'].

Parameters:

reported_version (str) – version to check

Returns:

True if the version matched, false otherwise

copy(key=None)[source]#

Returns a copy of this schema.

Parameters:

key (list of str) – keypath to this schema

classmethod from_manifest(filepath=None, cfg=None)[source]#

Create a new schema based on the provided source files.

The two arguments to this class are mutually exclusive.

Parameters:
  • filepath (path) – Initial manifest.

  • cfg (dict) – Initial configuration dictionary.

generate_replay_script(filepath, workdir, include_path=True)[source]#

Generate a replay script for the task.

Parameters:
  • filepath (path) – path to the file to write

  • workdir (path) – path to the run work directory

  • include_path (bool) – include path information in environmental variables

get(*keypath, field='value', step=None, index=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 Parameter object 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_exe()[source]#

Determines the absolute path for the specified executable.

Raises:

TaskExecutableNotFound – if executable not found.

Returns:

path to executable, or None if not specified

get_exe_version()[source]#

Gets the version of the specified executable.

Raises:
  • TaskExecutableNotFound – if executable not found.

  • NotImplementedError – if parse_version() has not be implemented.

Returns:

version determined by parse_version().

get_runtime_arguments()[source]#

Constructs the arguments needed to run the task.

Returns:

command (list)

get_runtime_environmental_variables(include_path=True)[source]#

Determine the environmental variables needed for the task

Parameters:

include_path (bool) – if True, includes PATH variable

Returns:

dictionary of environmental variable to value mapping

Return type:

dict of str

getdict(*keypath, include_default=True)[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

Returns:

A schema dictionary

Examples

>>> pdk = schema.getdict('pdk')
Returns the complete dictionary found for the keypath [pdk]
getkeys(*keypath)[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 = chip.getkeys('pdk')
Returns all keys for the [pdk] keypath.
logger()[source]#
Returns:

logger

name()[source]#

Returns the name of the schema

node()[source]#
Returns:

step and index for the current runtime

read_manifest(filepath)[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)[source]#

Remove a schema parameter and its subparameters.

Parameters:

keypath (list) – Parameter keypath to clear.

run_task(workdir, quiet, loglevel, breakpoint, nice, timeout)[source]#

Run the task.

Raises:
  • TaskError – raised if the task failed to complete and should not be considered complete.

  • TaskTimeout – raised if the task reaches a timeout

Parameters:
  • workdir (path) – path to the run work directory

  • quiet (bool) – if True, execution output is suppressed

  • loglevel (str) – logging level

  • breakpoint (bool) – if True, will attempt to execute with a breakpoint

  • nice (int) – POSIX nice level to use in execution

  • timeout (int) – timeout to use for execution

Returns:

return code from the execution

schema(type=None)[source]#

Get useful section of the schema.

Parameters:

type (str) – schema section to find, if None returns the root schema.

Returns:

schema section.

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_runtime(chip)[source]#

Sets the runtime information needed to properly execute a task. Note: unstable API

Parameters:

chip (Chip) – root schema for the runtime information

setup_work_directory(workdir, remove_exist=True)[source]#

Create the runtime directories needed to execute a task.

Parameters:
  • workdir (path) – path to the run work directory

  • remove_exist (bool) – if True, removes the existing directory

task()[source]#
Returns:

task name

unset(*keypath, step=None, index=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 to set() with clobber=False will 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, default_valid=False, check_complete=False)[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_manifest(filepath)[source]#

Writes the manifest to a file.

Parameters:

filename (filepath) – Output filepath.

Examples

>>> schema.write_manifest('mydump.json')
Dumps the current manifest into mydump.json
write_task_manifest(directory, backup=True)[source]#

Write the manifest needed for the task

Parameters:
  • directory (path) – directory to write the manifest into.

  • backup (bool) – if True and an existing manifest is found a backup is kept.

class siliconcompiler.ASICSchema[source]#

Bases: BaseSchema

add(*args, field='value', step=None, index=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, include_default=True)[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=None)[source]#

Returns a copy of this schema.

Parameters:

key (list of str) – keypath to this schema

classmethod from_manifest(filepath=None, cfg=None)[source]#

Create a new schema based on the provided source files.

The two arguments to this class are mutually exclusive.

Parameters:
  • filepath (path) – Initial manifest.

  • cfg (dict) – Initial configuration dictionary.

get(*keypath, field='value', step=None, index=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 Parameter object 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, include_default=True)[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

Returns:

A schema dictionary

Examples

>>> pdk = schema.getdict('pdk')
Returns the complete dictionary found for the keypath [pdk]
getkeys(*keypath)[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 = chip.getkeys('pdk')
Returns all keys for the [pdk] keypath.
read_manifest(filepath)[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)[source]#

Remove a schema parameter and its subparameters.

Parameters:

keypath (list) – Parameter keypath to clear.

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'
unset(*keypath, step=None, index=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 to set() with clobber=False will 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, default_valid=False, check_complete=False)[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_manifest(filepath)[source]#

Writes the manifest to a file.

Parameters:

filename (filepath) – Output filepath.

Examples

>>> schema.write_manifest('mydump.json')
Dumps the current manifest into mydump.json
class siliconcompiler.FPGASchema[source]#

Bases: BaseSchema

add(*args, field='value', step=None, index=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, include_default=True)[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=None)[source]#

Returns a copy of this schema.

Parameters:

key (list of str) – keypath to this schema

classmethod from_manifest(filepath=None, cfg=None)[source]#

Create a new schema based on the provided source files.

The two arguments to this class are mutually exclusive.

Parameters:
  • filepath (path) – Initial manifest.

  • cfg (dict) – Initial configuration dictionary.

get(*keypath, field='value', step=None, index=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 Parameter object 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, include_default=True)[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

Returns:

A schema dictionary

Examples

>>> pdk = schema.getdict('pdk')
Returns the complete dictionary found for the keypath [pdk]
getkeys(*keypath)[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 = chip.getkeys('pdk')
Returns all keys for the [pdk] keypath.
read_manifest(filepath)[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)[source]#

Remove a schema parameter and its subparameters.

Parameters:

keypath (list) – Parameter keypath to clear.

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'
unset(*keypath, step=None, index=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 to set() with clobber=False will 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, default_valid=False, check_complete=False)[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_manifest(filepath)[source]#

Writes the manifest to a file.

Parameters:

filename (filepath) – Output filepath.

Examples

>>> schema.write_manifest('mydump.json')
Dumps the current manifest into mydump.json

3.3. Full API#

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, keypath, version=None)[source]#

Decodes a dictionary into a schema object

Parameters:
  • manifest (dict) – Manifest to decide.

  • keypath (list of str) – Path to the current keypath.

  • version (packaging.Version) – Version of the dictionary schema

add(*args, field='value', step=None, index=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, include_default=True)[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=None)[source]#

Returns a copy of this schema.

Parameters:

key (list of str) – keypath to this schema

classmethod from_manifest(filepath=None, cfg=None)[source]#

Create a new schema based on the provided source files.

The two arguments to this class are mutually exclusive.

Parameters:
  • filepath (path) – Initial manifest.

  • cfg (dict) – Initial configuration dictionary.

get(*keypath, field='value', step=None, index=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 Parameter object 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, include_default=True)[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

Returns:

A schema dictionary

Examples

>>> pdk = schema.getdict('pdk')
Returns the complete dictionary found for the keypath [pdk]
getkeys(*keypath)[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 = chip.getkeys('pdk')
Returns all keys for the [pdk] keypath.
read_manifest(filepath)[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)[source]#

Remove a schema parameter and its subparameters.

Parameters:

keypath (list) – Parameter keypath to clear.

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'
unset(*keypath, step=None, index=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 to set() with clobber=False will 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, default_valid=False, check_complete=False)[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_manifest(filepath)[source]#

Writes the manifest to a file.

Parameters:

filename (filepath) – Output filepath.

Examples

>>> schema.write_manifest('mydump.json')
Dumps the current manifest into mydump.json
class siliconcompiler.schema.EditableSchema(schema)[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

insert(*args, clobber=False)[source]#

Inserts a Parameter or a BaseSchema to 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)[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)[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: BaseSchema

This object can handle any schema without any class dependencies. This is useful when reading in a schema in an external tool.

add(*args, field='value', step=None, index=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, include_default=True)[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=None)[source]#

Returns a copy of this schema.

Parameters:

key (list of str) – keypath to this schema

classmethod from_manifest(filepath=None, cfg=None)[source]#

Create a new schema based on the provided source files.

The two arguments to this class are mutually exclusive.

Parameters:
  • filepath (path) – Initial manifest.

  • cfg (dict) – Initial configuration dictionary.

get(*keypath, field='value', step=None, index=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 Parameter object 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, include_default=True)[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

Returns:

A schema dictionary

Examples

>>> pdk = schema.getdict('pdk')
Returns the complete dictionary found for the keypath [pdk]
getkeys(*keypath)[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 = chip.getkeys('pdk')
Returns all keys for the [pdk] keypath.
read_manifest(filepath)[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)[source]#

Remove a schema parameter and its subparameters.

Parameters:

keypath (list) – Parameter keypath to clear.

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'
unset(*keypath, step=None, index=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 to set() with clobber=False will 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, default_valid=False, check_complete=False)[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_manifest(filepath)[source]#

Writes the manifest to a file.

Parameters:

filename (filepath) – Output filepath.

Examples

>>> schema.write_manifest('mydump.json')
Dumps the current manifest into mydump.json
class siliconcompiler.schema.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

create_cmdline(progname, description=None, switchlist=None, additional_args=None, version=None, print_banner=None, input_map_handler=None, preprocess_keys=None, post_process=None, logger=None)[source]#

Creates a Schema 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:

  1. loglevel, if available in schema

  2. read_manifest([cfg]), if available in schema

  3. read inputs with input_map_handler

  4. all other switches

  5. Run post_process

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.

  • Compiler compatible switches include: -D, -I, -O{0,1,2,3}

  • Legacy switch formats are supported: +libext+, +incdir+

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.

  • input_map (dict of str) – Dictionary mapping file extensions to input filetypes. This is used to automatically assign positional source arguments to [‘input’, ‘fileset’, …] keypaths based on their file extension. If None, the CLI will not accept positional source arguments.

  • additional_args (dict of dict) – Dictionary of extra arguments to add to the command line parser, with the arguments matching the argparse.add_argument() call.

  • version (str) – Version to report when calling with -version

  • print_banner (function) – Function callback to print command line banner

  • input_map_handler (function) – Function callback handle inputs to the input map

  • preprocess_keys (function) – Function callback to preprocess keys that need to be corrected

  • post_process (function) – Function callback to process arguments before returning

Returns:

None if additional_args is not provided, otherwise a dictionary with the

command line options detected from the additional_args

Examples

>>> schema.create_cmdline(progname='sc-show',switchlist=['-input','-cfg'])
Creates a command line interface for 'sc-show' app.
>>> schema.create_cmdline(progname='sc', input_map={'v': ('rtl', 'verilog')})
All sources ending in .v will be stored in ['input', 'rtl', 'verilog']
>>> extra = schema.create_cmdline(progname='sc',
                                  additional_args={'-demo': {'action': 'store_true'}})
Returns extra = {'demo': False/True}
class siliconcompiler.schema.JournalingSchema(schema, keyprefix=None)[source]#

Bases: BaseSchema

This class provides the ability to record the schema transactions: set(), add(), remove(), and unset().

Parameters:
  • schema (BaseSchema) – schema to track

  • keyprefix (list of str) – keypath to prefix on to recorded path

add(*args, field='value', step=None, index=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_journaling_type(value)[source]#

Adds a new access type to the journal record.

Parameters:

value (str) – access type

allkeys(*keypath, include_default=True)[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=None)[source]#

Returns a copy of this schema.

Parameters:

key (list of str) – keypath to this schema

classmethod from_manifest(filepath=None, cfg=None)[source]#

Create a new schema based on the provided source files.

The two arguments to this class are mutually exclusive.

Parameters:
  • filepath (path) – Initial manifest.

  • cfg (dict) – Initial configuration dictionary.

get(*keypath, field='value', step=None, index=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 Parameter object 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_base_schema()[source]#

Returns the base schema

get_journal()[source]#

Returns a copy of the current journal

get_journaling_types()[source]#

Returns the current schema accesses that are being recorded

getdict(*keypath, include_default=True)[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

Returns:

A schema dictionary

Examples

>>> pdk = schema.getdict('pdk')
Returns the complete dictionary found for the keypath [pdk]
getkeys(*keypath)[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 = chip.getkeys('pdk')
Returns all keys for the [pdk] keypath.
import_journal(schema=None, cfg=None)[source]#

Import the journaled transactions from a different schema. Only one argument is supported at a time.

Parameters:
  • schema (JournalingSchema) – schema to replay transactions from

  • cfg (dict) – dictionary to replay transactions from

is_journaling()[source]#

Returns true if the schema is currently setup for journaling

read_journal(filename)[source]#

Reads a manifest and replays the journal

read_manifest(filepath)[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)[source]#

Remove a schema parameter and its subparameters.

Parameters:

keypath (list) – Parameter keypath to clear.

remove_journaling_type(value)[source]#

Removes a new access type to the journal record.

Parameters:

value (str) – access 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'
start_journal()[source]#

Start journaling the schema transactions

stop_journal()[source]#

Stop journaling the schema transactions

unset(*keypath, step=None, index=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 to set() with clobber=False will 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, default_valid=False, check_complete=False)[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_manifest(filepath)[source]#

Writes the manifest to a file.

Parameters:

filename (filepath) – Output filepath.

Examples

>>> schema.write_manifest('mydump.json')
Dumps the current manifest into mydump.json
class siliconcompiler.schema.NamedSchema(name=None)[source]#

Bases: BaseSchema

This object provides a named BaseSchema.

Parameters:

name (str) – name of the schema

add(*args, field='value', step=None, index=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, include_default=True)[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=None)[source]#

Returns a copy of this schema.

Parameters:

key (list of str) – keypath to this schema

classmethod from_manifest(filepath=None, cfg=None)[source]#

Create a new schema based on the provided source files.

The two arguments to this class are mutually exclusive.

Parameters:
  • filepath (path) – Initial manifest.

  • cfg (dict) – Initial configuration dictionary.

get(*keypath, field='value', step=None, index=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 Parameter object 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, include_default=True)[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

Returns:

A schema dictionary

Examples

>>> pdk = schema.getdict('pdk')
Returns the complete dictionary found for the keypath [pdk]
getkeys(*keypath)[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 = chip.getkeys('pdk')
Returns all keys for the [pdk] keypath.
name()[source]#

Returns the name of the schema

read_manifest(filepath)[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)[source]#

Remove a schema parameter and its subparameters.

Parameters:

keypath (list) – Parameter keypath to clear.

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'
unset(*keypath, step=None, index=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 to set() with clobber=False will 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, default_valid=False, check_complete=False)[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_manifest(filepath)[source]#

Writes the manifest to a file.

Parameters:

filename (filepath) – Output filepath.

Examples

>>> schema.write_manifest('mydump.json')
Dumps the current manifest into mydump.json
class siliconcompiler.schema.PackageSchema(package=None)[source]#

Bases: BaseSchema

This object provides easier access to the package field in the path datatypes.

Parameters:

package (str) – name of the package

add(*args, field='value', step=None, index=None, package=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.

  • package (str) – Name of package to associate with this value.

Examples

>>> schema.add('input', 'rtl', 'verilog', 'hello.v')
Adds the file 'hello.v' to the [input,rtl,verilog] key.
allkeys(*keypath, include_default=True)[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=None)[source]#

Returns a copy of this schema.

Parameters:

key (list of str) – keypath to this schema

classmethod from_manifest(filepath=None, cfg=None)[source]#

Create a new schema based on the provided source files.

The two arguments to this class are mutually exclusive.

Parameters:
  • filepath (path) – Initial manifest.

  • cfg (dict) – Initial configuration dictionary.

get(*keypath, field='value', step=None, index=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 Parameter object 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, include_default=True)[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

Returns:

A schema dictionary

Examples

>>> pdk = schema.getdict('pdk')
Returns the complete dictionary found for the keypath [pdk]
getkeys(*keypath)[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 = chip.getkeys('pdk')
Returns all keys for the [pdk] keypath.
read_manifest(filepath)[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)[source]#

Remove a schema parameter and its subparameters.

Parameters:

keypath (list) – Parameter keypath to clear.

set(*args, field='value', clobber=True, step=None, index=None, package=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.

  • package (str) – Name of package to associate with this value.

Examples

>>> schema.set('design', 'top')
Sets the [design] value to 'top'
unset(*keypath, step=None, index=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 to set() with clobber=False will 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, default_valid=False, check_complete=False)[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_manifest(filepath)[source]#

Writes the manifest to a file.

Parameters:

filename (filepath) – Output filepath.

Examples

>>> schema.write_manifest('mydump.json')
Dumps the current manifest into mydump.json
class siliconcompiler.schema.Parameter(type, require=False, defvalue=None, scope=Scope.JOB, copy=False, lock=False, hashalgo='sha256', notes=None, unit=None, shorthelp=None, switch=None, example=None, help=None, pernode=PerNode.NEVER)[source]#

Leaf nodes in the schema. This holds all the information for a given keypath.

Parameters:
  • type (str) – type for the parameter, see parametertype.NodeType for supported types.

  • require (bool) – require field

  • defvalue (any) – defvalue field

  • scope (Scope) – scope field

  • copy (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 field

add(value, field='value', step=None, index=None)[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, *keypath, switchlist=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=None)[source]#

Returns a copy of this parameter.

Parameters:

key (list of str) – keypath to this schema

property default#

Gets a copy of the default value.

classmethod from_dict(manifest, keypath, version)[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='value', step=None, index=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=True)[source]#

Returns a schema dictionary.

Parameters:

include_default (boolean) – If true will include default values

Returns:

A schema dictionary

Examples

>>> param.getdict()
Returns the complete dictionary for the parameter
gettcl(step=None, index=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=True)[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.

is_empty()[source]#

Utility function to check key for an empty value.

is_list()[source]#

Returns true is this parameter is a list type

is_set(step=None, index=None)[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, *keypath)[source]#

Parse and set the values provided form the commandline parser.

Parameters:
  • value (str) – string from commandline

  • keypath (list of str) – leypath to this parameter

set(value, field='value', step=None, index=None, clobber=True)[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=None, index=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 to set() with clobber=False will 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)[source]#

Holds the data for a list schema type.

Parameters:

base (NodeValue) – base type for this list.

add(value, field='value')[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()[source]#

Returns a copy of this value.

property fields#

Returns a list of valid fields for this value

get(field='value')[source]#

Returns the value in the specified field

Parameters:

field (str) – name of schema field.

getdict()[source]#

Returns a schema dictionary.

Examples

>>> value.getdict()
Returns the complete dictionary for the value
set(value, field='value')[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#

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='value')[source]#

Not valid for this datatype, will raise a ValueError

copy()[source]#

Returns a copy of this value.

property fields#

Returns a list of valid fields for this value

classmethod from_dict(manifest, keypath, version, 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='value')[source]#

Returns the value in the specified field

Parameters:

field (str) – name of schema field.

getdict()[source]#

Returns a schema dictionary.

Examples

>>> value.getdict()
Returns the complete dictionary for the value
set(value, field='value')[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, key, salt=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

verify_signature(person, key)[source]#

Verify the signature of this value.

Parameters:
  • person (str) – Identification for this person signing this value

  • key (str) – Key to used to sign this value

class siliconcompiler.schema.parametervalue.PathNodeValue(type, value=None)[source]#

Bases: NodeValue

Holds the path data for a parameter.

Parameters:
  • type (str) – type of path

  • value (any) – default value for this parameter

add(value, field='value')[source]#

Not valid for this datatype, will raise a ValueError

copy()[source]#

Returns a copy of this value.

property fields#

Returns a list of valid fields for this value

classmethod from_dict(manifest, keypath, version, 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, package)[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

  • package (str) – name of package this file belongs to

get(field='value')[source]#

Returns the value in the specified field

Parameters:

field (str) – name of schema field.

get_hashed_filename()[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()[source]#

Returns a schema dictionary.

Examples

>>> value.getdict()
Returns the complete dictionary for the value
hash(function, **kwargs)[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, hashobj=None, hashfunction=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, hashobj=None, hashfunction=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

static resolve_env_vars(path, envvars=None)[source]#

Resolve environment variables in a path.

Returns the expended path.

Parameters:
  • path (str) – path to expand

  • envvars (dict) – environmental variables to use during resolution.

resolve_path(envvars=None, search=None, collection_dir=None)[source]#

Resolve the path of this value.

Returns the absolute path if found, otherwise raises a FileNotFoundError.

Parameters:
  • envvars (dict) – environmental variables to use during resolution.

  • search (list of paths) – list of paths to search to check for the path.

  • collection_dir (path) – path to collection directory.

set(value, field='value')[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, key, salt=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

verify_signature(person, key)[source]#

Verify the signature of this value.

Parameters:
  • person (str) – Identification for this person signing this value

  • key (str) – Key to used to sign this value

class siliconcompiler.schema.parametervalue.DirectoryNodeValue(value=None)[source]#

Bases: PathNodeValue

Holds the directory data for a parameter.

Parameters:

value (any) – default value for this parameter

add(value, field='value')[source]#

Not valid for this datatype, will raise a ValueError

copy()[source]#

Returns a copy of this value.

property fields#

Returns a list of valid fields for this value

classmethod from_dict(manifest, keypath, version, 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, package)[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

  • package (str) – name of package this file belongs to

get(field='value')[source]#

Returns the value in the specified field

Parameters:

field (str) – name of schema field.

get_hashed_filename()[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()[source]#

Returns a schema dictionary.

Examples

>>> value.getdict()
Returns the complete dictionary for the value
hash(function, **kwargs)[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, hashobj=None, hashfunction=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, hashobj=None, hashfunction=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

static resolve_env_vars(path, envvars=None)[source]#

Resolve environment variables in a path.

Returns the expended path.

Parameters:
  • path (str) – path to expand

  • envvars (dict) – environmental variables to use during resolution.

resolve_path(envvars=None, search=None, collection_dir=None)[source]#

Resolve the path of this value.

Returns the absolute path if found, otherwise raises a FileNotFoundError.

Parameters:
  • envvars (dict) – environmental variables to use during resolution.

  • search (list of paths) – list of paths to search to check for the path.

  • collection_dir (path) – path to collection directory.

set(value, field='value')[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, key, salt=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

verify_signature(person, key)[source]#

Verify the signature of this value.

Parameters:
  • person (str) – Identification for this person signing this value

  • key (str) – Key to used to sign this value

class siliconcompiler.schema.parametervalue.FileNodeValue(value=None)[source]#

Bases: PathNodeValue

Holds the file data for a parameter.

Parameters:

value (any) – default value for this parameter

add(value, field='value')[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

copy()[source]#

Returns a copy of this value.

property fields#

Returns a list of valid fields for this value

classmethod from_dict(manifest, keypath, version, 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, package)[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

  • package (str) – name of package this file belongs to

get(field='value')[source]#

Returns the value in the specified field

Parameters:

field (str) – name of schema field.

get_hashed_filename()[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()[source]#

Returns a schema dictionary.

Examples

>>> value.getdict()
Returns the complete dictionary for the value
hash(function, **kwargs)[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, hashobj=None, hashfunction=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, hashobj=None, hashfunction=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

static resolve_env_vars(path, envvars=None)[source]#

Resolve environment variables in a path.

Returns the expended path.

Parameters:
  • path (str) – path to expand

  • envvars (dict) – environmental variables to use during resolution.

resolve_path(envvars=None, search=None, collection_dir=None)[source]#

Resolve the path of this value.

Returns the absolute path if found, otherwise raises a FileNotFoundError.

Parameters:
  • envvars (dict) – environmental variables to use during resolution.

  • search (list of paths) – list of paths to search to check for the path.

  • collection_dir (path) – path to collection directory.

set(value, field='value')[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, key, salt=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

verify_signature(person, key)[source]#

Verify the signature of this value.

Parameters:
  • person (str) – Identification for this person signing this value

  • key (str) – Key to used to sign this value

class siliconcompiler.schema.parametertype.NodeType(sctype)[source]#

Schema type decoding and encoding class.

Parameters:

sctype (str or NodeType) – schema type

static contains(value, check)[source]#

Check if the type contains a specific type.

static encode(sctype)[source]#

Encodes a schema type into a string.

static normalize(value, sctype)[source]#

Normalizes a value into the appropriate datatype.

static parse(sctype)[source]#

Parses a schema type string.

static to_tcl(value, sctype)[source]#

Recursive helper function for converting Python values to safe TCL values, based on the SC type string.

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'#
is_never()[source]#

Returns true is this is ‘never’

class siliconcompiler.flowgraph.FlowgraphNodeSchema[source]#

Bases: BaseSchema

add(*args, field='value', step=None, index=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, include_default=True)[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=None)[source]#

Returns a copy of this schema.

Parameters:

key (list of str) – keypath to this schema

classmethod from_manifest(filepath=None, cfg=None)[source]#

Create a new schema based on the provided source files.

The two arguments to this class are mutually exclusive.

Parameters:
  • filepath (path) – Initial manifest.

  • cfg (dict) – Initial configuration dictionary.

get(*keypath, field='value', step=None, index=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 Parameter object 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, include_default=True)[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

Returns:

A schema dictionary

Examples

>>> pdk = schema.getdict('pdk')
Returns the complete dictionary found for the keypath [pdk]
getkeys(*keypath)[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 = chip.getkeys('pdk')
Returns all keys for the [pdk] keypath.
read_manifest(filepath)[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)[source]#

Remove a schema parameter and its subparameters.

Parameters:

keypath (list) – Parameter keypath to clear.

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'
unset(*keypath, step=None, index=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 to set() with clobber=False will 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, default_valid=False, check_complete=False)[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_manifest(filepath)[source]#

Writes the manifest to a file.

Parameters:

filename (filepath) – Output filepath.

Examples

>>> schema.write_manifest('mydump.json')
Dumps the current manifest into mydump.json
class siliconcompiler.flowgraph.RuntimeFlowgraph(base, args=None, from_steps=None, to_steps=None, prune_nodes=None)[source]#

Runtime representation of a flowgraph

Parameters:
  • base (FlowgraphSchema) – base flowgraph for this runtime

  • args (tuple of step, index) – specific node to apply runtime to

  • from_steps (list of steps) – steps to start the runtime from

  • to_steps (list of steps) – step to end the runtime at

  • prune_nodes (list of nodes) – nodes to remove from execution

get_entry_nodes()[source]#

Returns the entry nodes for this graph

get_execution_order()[source]#

Returns the execution order of the nodes

get_exit_nodes()[source]#

Returns the exit nodes for this graph

get_nodes()[source]#

Returns the nodes available in this graph

get_nodes_starting_at(step, index)[source]#

Returns all the nodes that the given step, index connect to

Parameters:
  • step (str) – step to start from

  • index (str/int) – index to start from

class siliconcompiler.tool.TaskSchema(name=None)[source]#

Bases: NamedSchema

add(*args, field='value', step=None, index=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, include_default=True)[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=None)[source]#

Returns a copy of this schema.

Parameters:

key (list of str) – keypath to this schema

classmethod from_manifest(filepath=None, cfg=None)[source]#

Create a new schema based on the provided source files.

The two arguments to this class are mutually exclusive.

Parameters:
  • filepath (path) – Initial manifest.

  • cfg (dict) – Initial configuration dictionary.

get(*keypath, field='value', step=None, index=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 Parameter object 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, include_default=True)[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

Returns:

A schema dictionary

Examples

>>> pdk = schema.getdict('pdk')
Returns the complete dictionary found for the keypath [pdk]
getkeys(*keypath)[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 = chip.getkeys('pdk')
Returns all keys for the [pdk] keypath.
name()[source]#

Returns the name of the schema

read_manifest(filepath)[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)[source]#

Remove a schema parameter and its subparameters.

Parameters:

keypath (list) – Parameter keypath to clear.

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'
unset(*keypath, step=None, index=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 to set() with clobber=False will 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, default_valid=False, check_complete=False)[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_manifest(filepath)[source]#

Writes the manifest to a file.

Parameters:

filename (filepath) – Output filepath.

Examples

>>> schema.write_manifest('mydump.json')
Dumps the current manifest into mydump.json
class siliconcompiler.tool.TaskError[source]#

Bases: Exception

Error indicates 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: TaskError

Error indicates a timeout has occurred

Parameters:

timeout (float) – execution time at timeout

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: TaskError

Executable not 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.