1
0
Fork
You've already forked liberty-parser
0
forked from tok/liberty-parser
Liberty parser for Python.
  • Python 99.6%
  • Shell 0.4%
Find a file
2022年03月25日 16:25:35 +01:00
examples Example: Find propagation time of a cell. 2021年05月20日 11:55:45 +02:00
liberty Parsing version numbers and unary operators 2022年03月25日 16:25:35 +01:00
test_data Add test liberty from FreePDK45. 2019年02月08日 12:16:35 +01:00
.gitignore Ignore dist folder. 2019年02月08日 12:18:25 +01:00
.woodpecker.yml CI: Install numpy with apt. 2022年02月21日 22:15:59 +01:00
LICENSE 📜 Add GPLv3 license. 2019年03月08日 12:45:14 +01:00
README.md Add comment on installing in development mode. 2022年02月21日 18:58:08 +01:00
setup.py Bump version. 2022年02月21日 22:11:33 +01:00
test.sh Note on running tests with specific Python version. 2022年02月21日 19:03:39 +01:00

Liberty Parser

This library provides functions to parse, manipulate and format 'Liberty' files. The liberty format is a common standard to describe certain aspects of standard-cell libraries such as timing, power, cell pin types, etc.

Example

from liberty.parser import parse_liberty
# Read and parse a library.
library = parse_liberty(open(liberty_file).read())
}
# Format the library.
print(str(library))
# Loop through all cells.
for cell_group in library.get_groups('cell'):
 name = cell_group.args[0]
 print(cell_name)
 # Loop through all pins of the cell.
 for pin_group in library.get_groups('pin'):
 pin_name = pin_gropu.args[0]
 print(pin_name)
 # Access a pin attribute.
 some_attribute = pin_group['some_attribute']

Library structure.

The liberty library is made of Group objects. The library itself is a Group object. A Group contains other nested Groups, has a name, a list of arguments and attributes.

group_name(args) {
 simple_attribute: 1.23;
 other_group_name(args) {
 other_simple_attribute: 2.34;
 complex_attribute (1.23, 2.34);
 }
}

Reading arrays and timing tables.

Timing tables are stored in the liberty format as attributes which holds a string with comma-separated values.

This string can be converted into a Numpy array with get_array:

some_group.get_array('attribute_name')

More examples

Example scripts can be found under ./examples.

Install for development

Run the following command to install the liberty parser using symlinks. This allows to edit the parser with immediate effect on the installed package.

pip install --upgrade --editable .