Defining a Library#
In hardware design, a library is a collection of reusable components.
SiliconCompiler generalizes this concept with the Design object, which acts as a standardized “manifest” for any piece of IP (Intellectual Property) you want to include in your design.
This could be a hard macro with pre-defined physical layouts (GDS, LEF), a standard cell library from a foundry, or a soft IP delivered as RTL source code (Verilog, VHDL).
By packaging IP into a Design, you make it easy to manage, version, and reuse across different projects.
Libraries are loaded into a project using the Project.add_dep() method.
Types of Libraries#
There are two primary categories of libraries you can define:
Hard Libraries (StdCellLibrary): These represent foundational, physical IP. This includes standard cell libraries, I/O cells, or hard macros (like SRAMs or SERDES) that have fixed layouts. They are defined using the specialized
StdCellLibraryclass, which has extra features for handling physical and timing models.Soft Libraries (Design): These represent synthesizable IP delivered as source code. This is common for digital IP cores that you want to integrate into your design before synthesis. They are defined using the base
Designclass.
Example 1: Hard IP Library#
This example demonstrates how to define a library for a hard macro. This macro is a pre-designed block with its own physical layout (LEF, GDS) and timing models (.lib).
We will use the StdCellLibrary because it is a physical, foundational component.
from pathlib import Path
from siliconcompiler import StdCellLibrary
from my_pdk import FakePDK # Assuming a PDK is defined elsewhere
class FakeHardIPLibrary(StdCellLibrary):
def __init__(self):
# 1. Call the parent constructor with a unique name for the library.
super().__init__("fakeip")
# 2. Associate this library with a specific PDK.
# This tells SiliconCompiler that this IP is designed for this technology.
self.add_asic_pdk(FakePDK())
# 3. Define the location of the library's source files.
# Here, we point to a local directory.
path_base = Path("fakeip")
self.set_dataroot("fakedata", "python://fakedata_module")
# 4. Organize the library's files into standardized filesets.
with self.active_dataroot("fakedata"):
# Define the physical view files (LEF and GDS).
with self.active_fileset("models.physical"):
self.add_file(path_base / "lef" / "fakeip.lef")
self.add_file(path_base / "gds" / "fakeip.gds")
# Helper function to add standard APR tech files.
self.add_asic_aprfileset()
# Define the timing models. This library provides an NLDM model
# for the "typical" corner.
with self.active_fileset("models.timing.nldm"):
self.add_file(path_base / "nldm" / "fakeip.lib")
# Helper to associate the file with a specific corner.
self.add_asic_libcornerfileset("typical", "nldm")
Using the Library#
To use either of these libraries in your design, you would instantiate the class and add it as a dependency to your project.
import siliconcompiler
project = siliconcompiler.ASIC()
# Instantiate and add the hard IP library.
hard_ip_lib = FakeHardIPLibrary()
project.add_asiclib(hard_ip_lib)
# Now, the 'fakeip' will be included during compilation.
# project.run()
Example 2: Soft IP Library#
This example shows how to define a library for a soft IP core, which is just a reusable block of RTL code. Since there are no physical or timing views, we use the Design.
from siliconcompiler import Design
class FakeSoftIP(Design):
def __init__(self):
# 1. Call the parent constructor with a unique name.
super().__init__("fakesoftip")
# 2. Set metadata for the library.
self.set_version("v1.0")
# 3. Define the location of the source files.
self.set_dataroot("fakedata", "python://fakedata_module")
# 4. Add the RTL source code to the 'rtl' fileset.
# When this library is included in a project, this Verilog file
# will be passed to the synthesis tool.
with self.active_dataroot("fakedata"), self.active_fileset("rtl"):
self.add_file("rtl/fakeip.v")
Using the Library#
To use either of these libraries in your design, you would instantiate the class and add it as a dependency to your project.
import siliconcompiler
project = siliconcompiler.Project()
# Instantiate and add the soft IP library.
soft_ip_lib = FakeSoftIP()
project.add_dep(soft_ip_lib)
# Now, the 'fakeip.v' source file will be included during compilation.
# project.run()
Useful APIs#
Core Configuration#
Adds files to a fileset. |
|
Registers a data source by name, path, and optional version tag. |
PDK and Physical Views#
Adds files to a fileset. |
|
Registers a data source by name, path, and optional version tag. |
|
Adds the PDK associated with this library. |
|
Adds a mapping between filesets defined in the library. |
|
Adds a mapping between filesets a corners defined in the library. |
Class Reference#
For a complete list of all available methods, please see the full class documentation.
Design#
Class siliconcompiler.Design
Use this context to set the dataroot parameter on files and directory parameters. |
|
Provides a context to temporarily set an active design fileset. |
|
Adds preprocessor macro definitions to a fileset. |
|
Adds a module dependency to this design. |
|
Record a reference to an imported dependency's fileset. |
|
Adds files to a fileset. |
|
Adds include directories to a fileset. |
|
Adds dynamic libraries to a fileset. |
|
Adds dynamic library directories to a fileset. |
|
Adds preprocessor macro (un)definitions to a fileset. |
|
Verifies that paths to all files in manifest are valid. |
|
Creates a new copy of a source fileset. |
|
Returns absolute paths to files or directories based on the keypath provided. |
|
Returns absolute path to the data directory. |
|
Returns defined macros for a fileset. |
|
Returns all dependencies associated with this object or a specific one if requested. |
|
Returns list of dependency filesets. |
|
Returns a list of files from one or more filesets. |
|
Computes the full, recursive list of (design, fileset) tuples required for a given set of top-level filesets. |
|
Returns include directories for a fileset. |
|
Returns list of dynamic libraries for a fileset. |
|
Returns dynamic library directories for a fileset. |
|
Returns value of a named fileset parameter. |
|
Returns the topmodule of a fileset. |
|
Returns undefined macros for a fileset. |
|
Checks if a specific dependency is present. |
|
Returns true if the fileset contains files. |
|
Checks if a fileset exists in the schema. |
|
Returns true if idirs are defined for the fileset |
|
Returns true if library directories are defined for the fileset |
|
Generates hash values for a list of parameter files. |
|
Imports filesets from a standard formatted text file. |
|
Removes a previously registered module. |
|
Registers a data source by name, path, and optional version tag. |
|
Sets a named parameter for a fileset. |
|
Sets the topmodule of a fileset. |
|
Renders and saves the dependency graph to a file. |
|
Exports filesets to a standard formatted text file. |
StdCellLibrary#
Class siliconcompiler.StdCellLibrary
Use this context to set the dataroot parameter on files and directory parameters. |
|
Provides a context to temporarily set an active design fileset. |
|
Adds a mapping between filesets defined in the library. |
|
Adds a standard cell library to the specified type. |
|
Adds a mapping between filesets a corners defined in the library. |
|
Adds the PDK associated with this library. |
|
Adds a mapping between filesets a corners defined in the library. |
|
Adds a standard site to the library. |
|
Set the stackups supported by this library. |
|
Adds preprocessor macro definitions to a fileset. |
|
Adds a module dependency to this design. |
|
Record a reference to an imported dependency's fileset. |
|
Adds files to a fileset. |
|
Adds include directories to a fileset. |
|
Adds dynamic libraries to a fileset. |
|
Adds dynamic library directories to a fileset. |
|
Adds preprocessor macro (un)definitions to a fileset. |
|
Verifies that paths to all files in manifest are valid. |
|
Creates a new copy of a source fileset. |
|
Define a new tool parameter for the library. |
|
Returns absolute paths to files or directories based on the keypath provided. |
|
Returns absolute path to the data directory. |
|
Returns defined macros for a fileset. |
|
Returns all dependencies associated with this object or a specific one if requested. |
|
Returns list of dependency filesets. |
|
Returns a list of files from one or more filesets. |
|
Computes the full, recursive list of (design, fileset) tuples required for a given set of top-level filesets. |
|
Returns include directories for a fileset. |
|
Returns list of dynamic libraries for a fileset. |
|
Returns dynamic library directories for a fileset. |
|
Returns value of a named fileset parameter. |
|
Returns the topmodule of a fileset. |
|
Returns undefined macros for a fileset. |
|
Checks if a specific dependency is present. |
|
Returns true if the fileset contains files. |
|
Checks if a fileset exists in the schema. |
|
Returns true if idirs are defined for the fileset |
|
Returns true if library directories are defined for the fileset |
|
Generates hash values for a list of parameter files. |
|
Imports filesets from a standard formatted text file. |
|
Removes a previously registered module. |
|
Registers a data source by name, path, and optional version tag. |
|
Sets a named parameter for a fileset. |
|
Sets the topmodule of a fileset. |
|
Renders and saves the dependency graph to a file. |
|
Exports filesets to a standard formatted text file. |