GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - rohaansch/sdf-parser: A pure-Python parser for Standard Delay Format (SDF) files used in EDA timing flows.

BranchesTags
Open more actions menu

Latest commit

 

History

10 Commits
10 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
examples
examples
 
 
sdf_parser
sdf_parser
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pyproject.toml
pyproject.toml
 
 

Repository files navigation

sdf-parser

A pure-Python parser for Standard Delay Format (SDF) files — the industry-standard format used by EDA tools to back-annotate timing delays and constraints onto digital designs.

CI Python License: MIT

Building a Python SDF Parser for EDA Flow Automation — Closing a tooling gap that every EDA engineer eventually runs into.

Features

  • Parses IOPATH, COND, CONDELSE, WIDTH, SETUPHOLD, and RECREM
  • Single file or directory of SDF files (with cross-file consistency checks)
  • Single-cell extraction mode — stops early once the target cell is found
  • Zero required dependencies — only the Python standard library
  • Optional colored warnings via termcolor
  • CLI included: sdf-parser timing.sdf --cell INV_X1

Installation

pip install eda-sdf-parser                  # no extra dependencies
pip install "eda-sdf-parser[color]"         # adds termcolor for colored warnings

PyPI Python

Or for development:

git clone https://github.com/rohaansch/sdf-parser
cd sdf-parser
pip install -e ".[dev]"

Quick start

from sdf_parser import SDFParser

parser = SDFParser()
sdf = parser.read("timing.sdf")

print(repr(sdf))
# SDF(cells=142, files=1, header=['SDFVERSION', 'DESIGN', 'TIMESCALE'])

for entry in sdf.cells["INV_X1"]:
    print(entry)
# ['IOPATH', 'A', 'ZN', 2]
# ['COND', "A==1'b0", 'A', 'ZN', 1]
# ['WIDTH', None, 'posedge', 'A', 1]

Parsed entry format

Each entry in sdf.cells["CELLNAME"] is a list whose first element is the construct keyword:

Construct Entry format
IOPATH [IOPATH, pin_1, pin_2, n]
COND [COND, condition, pin_1, pin_2, n]
CONDELSE [CONDELSE, pin_1, pin_2, n]
WIDTH [WIDTH, condition, edge, port, n]
SETUPHOLD [SETUPHOLD, cond_1, edge_1, port_1, cond_2, edge_2, port_2, n]
RECREM [RECREM, cond_1, edge_1, port_1, cond_2, edge_2, port_2, n]

condition is None when no COND qualifier is present. n is the number of delay value tuples (e.g. 3 for min/typ/max).

Full example

SDF input:

(CELL
  (CELLTYPE "DFFS_X2")
  (INSTANCE FF1)
  (TIMINGCHECK
    (SETUPHOLD (posedge D) (posedge CK) (0.1:0.1:0.1) (0.05:0.05:0.05))
    (RECREM   (negedge SN) (posedge CK) (0.2:0.2:0.2) (0.1:0.1:0.1))
    (WIDTH    (posedge CK) (0.3:0.3:0.3))
  )
)

Python output:

sdf.cells["DFFS_X2"]
# [
#   ['SETUPHOLD', None, 'posedge', 'D', None, 'posedge', 'CK', 2],
#   ['RECREM',    None, 'negedge', 'SN', None, 'posedge', 'CK', 2],
#   ['WIDTH',     None, 'posedge', 'CK', 1],
# ]

API reference

SDFParser(path=None)

Create a parser. path sets the default file/directory used by read().

SDFParser.read(path=None, given_cell=None) → SDF

Argument Type Description
path str .sdf file or directory. Falls back to the constructor path.
given_cell str Extract only this cell (case-insensitive).

Raises ValueError / FileNotFoundError / IOError on bad input.

SDFParser.reset()

Clear internal state to reuse the parser for a different file:

sdf_fast = parser.read("fast.sdf")
parser.reset()
sdf_slow = parser.read("slow.sdf")

SDF object

Attribute Type Description
header_data dict Header fields (SDFVERSION, DESIGN, TIMESCALE, …)
cells dict[str, list] Cell name → list of parsed entries
files list[str] All files that contributed to this object

format_entries(cell) → str

Format a cell's entries as a human-readable multi-line string:

from sdf_parser import format_entries
print(format_entries(sdf.cells["INV_X1"]))

Parsing a directory

When path is a directory every .sdf file inside it is parsed and merged. Cells found in multiple files are compared; mismatches produce a warning:

sdf = SDFParser().read("sdf_corners/")
print(repr(sdf))
# SDF(cells=142, files=3, header=['SDFVERSION', 'DESIGN', 'TIMESCALE'])

Command-line usage

sdf-parser timing.sdf
sdf-parser timing.sdf --cell INV_X1
sdf-parser timing.sdf --cell INV_X1 --header
sdf-parser sdf_corners/ --header
sdf-parser --version

Or without installing:

python -m sdf_parser timing.sdf --cell INV_X1

Limitations

  • Delay values are not parsed — only the count of value tuples is stored.
  • Only the constructs listed above are extracted; other SDF keywords are skipped.
  • OASIS and binary SDF formats are not supported.

Running the tests

pip install -e ".[dev]"
pytest -v

License

MIT

About

A pure-Python parser for Standard Delay Format (SDF) files used in EDA timing flows.

Topics

cadencelibertyparsersdftimingtiming-analysisverilogverilog-hdlvlsivlsi-design

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.