Skip to main content

Python library for parsing, representing, and manipulating Liberty (.lib) files

Project description

liberty-tools

liberty-tools is a clean, robust, and lightweight Python library for parsing, representing, and manipulating Liberty (.lib) files, commonly used in Electronic Design Automation (EDA) workflows for standard cell and memory library characterization.

Features

  • Lexer & Parser: Full lexical analysis and parsing of Liberty syntax, including arrays, complex groups, bus structures, bundles, lookup tables (LUTs), operating conditions, and k-factors.
  • Pydantic Validation: Fully-typed data models validated via pydantic v2, allowing for robust IDE autocompletion and static type analysis.
  • Serialization (Writer): Write model hierarchies back to fully-compliant Liberty syntax format with controllable formatting and indentation.
  • PVT & Corner Management: Helper functions to generate, normalize, and manage operating conditions, temperatures, voltages, and process skews (e.g., typical/corner PVTs).

Installation

You can install liberty-tools from PyPI using pip:

pip install liberty-tools

Or add it to your Poetry project:

poetry add liberty-tools

Quick Start

Parsing a Liberty File

from liberty_tools import LibertyReader

liberty_text = """
library (my_typical_library) {
  comment : "Sample Library";
  delay_model : table_lookup;
  voltage_unit : "1V";

  cell (AND2_X1) {
    area : 1.064;
    pin (A) {
      direction : input;
      capacitance : 0.005;
    }
    pin (Y) {
      direction : output;
      function : "(A)";
    }
  }
}
"""

# Parse the text into a Library model
reader = LibertyReader(liberty_text)
library = reader.parse()

print(f"Parsed library: {library.name}")
print(f"Delay Model: {library.delay_model}")
print(f"Cells in library: {[cell.name for cell in library.cells]}")

Serializing back to Liberty Syntax

from liberty_tools import LibertyWriter

writer = LibertyWriter(indent_size=2)
output_text = writer.write(library)
print(output_text)

PVT Corner Generation

from liberty_tools import create_corners

process_info = {
    "process_names": ["tt", "ss", "ff"],
    "io_voltage": [1.8],
    "core_voltage": [0.9],
    "temperature": [25, 125]
}

corners = create_corners(process_info)
for corner in corners:
    print(f"Corner: {corner.core_name} (Core: {corner.v_core}V, IO: {corner.v_io}V, Temp: {corner.temp}C)")

Development and Testing

Setup

Clone the repository and install development dependencies using Poetry:

git clone https://github.com/your-username/liberty-tools.git
cd liberty-tools
poetry install

Running Tests

Run the full test suite with coverage:

poetry run pytest

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

liberty_tools-0.1.1.tar.gz (25.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

liberty_tools-0.1.1-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file liberty_tools-0.1.1.tar.gz.

File metadata

  • Download URL: liberty_tools-0.1.1.tar.gz
  • Upload date:
  • Size: 25.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for liberty_tools-0.1.1.tar.gz
Algorithm Hash digest
SHA256 103dccd62ad83f081776d1125f4942b426019058d78c4e44c748474c2de8efdd
MD5 b7a907f12b19ffe3a7bed6ee0d797ed0
BLAKE2b-256 1a112b6051ad6b5142bbe9415269e7014fad0c6ffcb05b37e12597862fd95181

See more details on using hashes here.

Provenance

The following attestation bundles were made for liberty_tools-0.1.1.tar.gz:

Publisher: publish.yml on AidenDawn/liberty-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file liberty_tools-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: liberty_tools-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for liberty_tools-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6402520a37ad73429103ec0ca1d1e6a539ff8ef15d5b99873eb1e2021107c70a
MD5 c976ab61f7f8eb63575f72999868b8cd
BLAKE2b-256 5c770df3aa339042e3111d45558bf91e83fe45b4965654fb57a06ccf48f15f0f

See more details on using hashes here.

Provenance

The following attestation bundles were made for liberty_tools-0.1.1-py3-none-any.whl:

Publisher: publish.yml on AidenDawn/liberty-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page