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.0.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.0-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: liberty_tools-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 a7e605bcacf39e1ea2b999a9ec61d4d6565333699dd643aad02daa21fc073937
MD5 ece324cb36bf33b5f87a02643aeebafb
BLAKE2b-256 e622aed7fd3ba931d0053502962b989fb938ddcfa2276ec3a590fecad7ff533c

See more details on using hashes here.

Provenance

The following attestation bundles were made for liberty_tools-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: liberty_tools-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 828e052e368871b50edbcee38e7d42e9b8360dd1c5e2f101a3f9246bc4a1db19
MD5 37df5a91c94304bb272a37f39a7b7f9f
BLAKE2b-256 6be0ec3971a3abcfedca7095a224a9f3b1228e466a673c27a3adb99b552a0723

See more details on using hashes here.

Provenance

The following attestation bundles were made for liberty_tools-0.1.0-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