Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Then
```bash
python test.py
```
The script uses the example LEF and DEF files provided in the `test` directory:
`NanGate_15nm_UTDA.tech.lef` and `simple.def`.
## Usage

To use the LEF reader, you can follow the example provided in the `test.py` file:
Expand Down
34 changes: 29 additions & 5 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
from lefdef import C_LefReader
from lefdef import C_DefReader
#change the file address below

import sys
from contextlib import redirect_stdout


class Tee:
"""Helper class to duplicate output to stdout and a file."""

def __init__(self, *files):
self.files = files

def write(self, data):
for f in self.files:
f.write(data)

def flush(self):
for f in self.files:
f.flush()


# Example usage with the sample files shipped in the ``test`` directory
lef_reader = C_LefReader()
_lef = lef_reader.read("external/def/TEST/complete.5.8.def")
_lef.print()
_lef = lef_reader.read("test/NanGate_15nm_UTDA.tech.lef")

def_reader = C_DefReader()
_def = def_reader.read("external/lef/TEST/complete.5.8.lef")
_def.print()
_def = def_reader.read("test/simple.def")

# Export the printed output of the LEF and DEF objects to ``output.txt``
with open("output.txt", "w") as f:
with redirect_stdout(Tee(sys.stdout, f)):
_lef.print()
_def.print()