Skip to content

Gate Library

SJulianS edited this page Feb 19, 2021 · 12 revisions

The gate library is a container for all gate types that are available within a selected standard cell library. Commonly, such standard cell libraries are proprietary. Hence, HAL only comes with a few selected libraries that mainly describe FPGAs. However, the reverse engineer is free to add any library he desires by either using the supplemented gate library parsers or writing new ones.

Gate Library Information

In HAL, a gate library comprises a name, the path to its underlying file, and the gate types it contains. It can be constructed giving just a name and the input path using its constructor GateLibrary. Access to its name and path are provided by the get_name and get_path functions.

gl = GateLibrary("path/to/example_library.lib", "example_library")   # construct a new (empty) gate library
name = gl.get_name()   # get the name of the gate library
path = gl.get_path()   # get the path to the gate library file

Managing Gate Types

To create a new gate type, the function create_gate_type can be called on the gate library. When creating a new gate type, its base type(s) need(s) to be specified at time of creation. For more on base types, see gate types. The functions contains_gate_type and contains_gate_type_by_name may be used to check whether a gate type is part of the gate library. While get_get_type_by_name may be utilized to retrieve a gate type of the specified name from the gate library (if available), the function get_gate_types returns all gate types available in the gate library.

new_gt = gl.create_gate_type("new_gt", set([hal_py.GateType.BaseType.combinational]))   # creates a new combinational gate type
gl.contains_gate_type(new_gt)                 # returns True
gl.contains_gate_type_by_name("new_gt")       # returns True
gl.contains_gate_type_by_name("invalid_gt")   # returns False
gt = gl.get_gate_type_by_name("new_gt")       # returns gate type 'new_gt'
gate_types = gl.get_gate_types()              # get all gate types of that library

Since the gate library keeps track of types that act as VCC or GND sources, the functions mark_vcc_gate_type and mark_gnd_gate_type may be used to declare a gate type to be such a VCC or GND type. Usually, this is automatically detected after parsing of the gate library, however manually manipulating the gate library may require additional gate types being marked accordingly. Hence, using get_vcc_gate_types and get_vcc_gate_types, the user can retrieve these special gate types separately. Each gate library needs to provide at least one VCC and one GND gate type. If no such type is present within the gate library file that is parsed by HAL, a new gate type fulfilling that purpose is created by HAL automatically.

Clone this wiki locally