Compare commits
197 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
c5bdeb4a68 | 20 hours ago |
|
|
67db64611b | 20 hours ago |
|
|
7a9ed1e536 | 2 days ago |
|
|
fcd9b78c24 | 3 days ago |
|
|
f975765bbb | 3 days ago |
|
|
3cb1b2bc86 | 3 days ago |
|
|
c4aecbd6c9 | 2 weeks ago |
|
|
25ff1fb2dc | 2 weeks ago |
|
|
f0b55eed27 | 5 months ago |
|
|
3700ae9b33 | 5 months ago |
|
|
df695e0aa1 | 5 months ago |
|
|
a28128830d | 5 months ago |
|
|
20cf441abb | 6 months ago |
|
|
5ac21edbb1 | 6 months ago |
|
|
f0d74777af | 6 months ago |
|
|
3848665533 | 6 months ago |
|
|
541cccd756 | 6 months ago |
|
|
fed66f85cb | 6 months ago |
|
|
2eb10f83b0 | 6 months ago |
|
|
dd4e5c861a | 6 months ago |
|
|
9cebbcce8f | 6 months ago |
|
|
31434cfd51 | 6 months ago |
|
|
ce94210b52 | 6 months ago |
|
|
09420fd72c | 6 months ago |
|
|
5bcc1c1d77 | 6 months ago |
|
|
df8a58f57b | 6 months ago |
|
|
3dfd0cb60d | 6 months ago |
|
|
21439e3595 | 6 months ago |
|
|
88a5c79161 | 7 months ago |
|
|
9ca437fe47 | 7 months ago |
|
|
0cdaf71963 | 7 months ago |
|
|
75972d7bb2 | 7 months ago |
|
|
469dc18aa9 | 7 months ago |
|
|
33addab141 | 7 months ago |
|
|
674f3dea4a | 11 months ago |
|
|
187d176cfd | 11 months ago |
|
|
ba1de0bea9 | 1 year ago |
|
|
5769aa3716 | 1 year ago |
|
|
e97c370d39 | 1 year ago |
|
|
3b7106be80 | 2 years ago |
|
|
d2357859f6 | 2 years ago |
|
|
53629c5c28 | 2 years ago |
|
|
e64845e8c0 | 2 years ago |
|
|
da98ca2db7 | 2 years ago |
|
|
deb4599206 | 2 years ago |
|
|
c1c9ec9aae | 2 years ago |
|
|
4c55dcec60 | 2 years ago |
|
|
a4b7364478 | 2 years ago |
|
|
f59e97afa9 | 2 years ago |
|
|
f6baf9cb5e | 2 years ago |
|
|
fc030c6708 | 2 years ago |
|
|
795cac0716 | 2 years ago |
|
|
3a8777e0a3 | 2 years ago |
|
|
68e8cb844a | 2 years ago |
|
|
1a3b91c1c0 | 2 years ago |
|
|
aa7536b8b0 | 2 years ago |
|
|
fccf5e0d84 | 2 years ago |
|
|
a6d1e4099c | 3 years ago |
|
|
1654915ed6 | 3 years ago |
|
|
d2a2484efa | 3 years ago |
|
|
de79393dfc | 3 years ago |
|
|
4bb3f3424a | 3 years ago |
|
|
a6243b43f6 | 3 years ago |
|
|
baeb759824 | 3 years ago |
|
|
967a232b1c | 3 years ago |
|
|
8096416b0e | 3 years ago |
|
|
a4cce9f8c0 | 3 years ago |
|
|
4f6b733eb4 | 3 years ago |
|
|
371bc906b3 | 3 years ago |
|
|
0ade89defa | 3 years ago |
|
|
7f4026f504 | 3 years ago |
|
|
e6a0d59d44 | 3 years ago |
|
|
63e5f32e21 | 3 years ago |
|
|
35e727e714 | 3 years ago |
|
|
83445e2bbd | 3 years ago |
|
|
c67148c0ee | 3 years ago |
|
|
280c425486 | 3 years ago |
|
|
5be82da49a | 3 years ago |
|
|
b3dbe9765a | 3 years ago |
|
|
5e573b0408 | 3 years ago |
|
|
08d9f5a9bf | 3 years ago |
|
|
b098fb219d | 3 years ago |
|
|
97387e962b | 3 years ago |
|
|
f4d875f7e5 | 3 years ago |
|
|
cf9a98b5ce | 3 years ago |
|
|
d8f605a47a | 3 years ago |
|
|
ec5626b8ca | 3 years ago |
|
|
5a693f7b9b | 3 years ago |
|
|
19bbe2c260 | 3 years ago |
|
|
d3897246c5 | 3 years ago |
|
|
9bda7a4c57 | 3 years ago |
|
|
2270a9eee7 | 3 years ago |
|
|
ea45a326ec | 3 years ago |
|
|
1e9fe7707b | 3 years ago |
|
|
50a5d8a290 | 3 years ago |
|
|
d97555e9e9 | 3 years ago |
|
|
47ee8d5878 | 3 years ago |
|
|
c32584fc76 | 3 years ago |
|
|
39b8c1695b | 3 years ago |
|
|
80d26b6f0b | 3 years ago |
|
|
f7ef78e58d | 3 years ago |
|
|
7afb13b33b | 3 years ago |
|
|
153442a10a | 3 years ago |
|
|
afb0a64953 | 3 years ago |
|
|
c49667edc1 | 3 years ago |
|
|
d921eb5048 | 3 years ago |
|
|
670fb0b3fc | 3 years ago |
|
|
f8bf579be2 | 3 years ago |
|
|
f61e2b42e8 | 3 years ago |
|
|
4aec335abb | 3 years ago |
|
|
1a9cb396bf | 3 years ago |
|
|
3875dc38f9 | 3 years ago |
|
|
ecb7171c37 | 3 years ago |
|
|
8957db48ab | 3 years ago |
|
|
0b15f9fa18 | 3 years ago |
|
|
dc76a9f517 | 3 years ago |
|
|
0968cb451e | 3 years ago |
|
|
947df89434 | 3 years ago |
|
|
f17e461fdd | 3 years ago |
|
|
d6d981a351 | 3 years ago |
|
|
7a060b1831 | 3 years ago |
|
|
03802ac9f8 | 3 years ago |
|
|
70caea065e | 3 years ago |
|
|
f04f1b0012 | 3 years ago |
|
|
44b0c887d7 | 3 years ago |
|
|
4e2022291e | 3 years ago |
|
|
5566b80e52 | 3 years ago |
|
|
63c0b48537 | 3 years ago |
|
|
6520ee23ef | 3 years ago |
|
|
1810d40959 | 3 years ago |
|
|
7430ebb068 | 3 years ago |
|
|
89f317b463 | 3 years ago |
|
|
753ce566e4 | 3 years ago |
|
|
1eb8d87884 | 3 years ago |
|
|
02f3a0e1b2 | 3 years ago |
|
|
fc8e65e788 | 3 years ago |
|
|
d80a3ae2b1 | 3 years ago |
|
|
7bfc02e683 | 3 years ago |
|
|
8da4a62bce | 3 years ago |
|
|
3497bfdc75 | 3 years ago |
|
|
f1ebe1487c | 3 years ago |
|
|
f0dac36ac7 | 3 years ago |
|
|
b2953aef25 | 3 years ago |
|
|
3774b14286 | 3 years ago |
|
|
4847ad9c40 | 3 years ago |
|
|
6801606dca | 3 years ago |
|
|
faf41f0863 | 3 years ago |
|
|
6430f10f73 | 3 years ago |
|
|
fa19af8c31 | 3 years ago |
|
|
93a0858d2f | 3 years ago |
|
|
1f2808ee31 | 4 years ago |
|
|
163b348a0c | 4 years ago |
|
|
ecfc692edc | 4 years ago |
|
|
afb7e745a1 | 4 years ago |
|
|
6a8841c3c6 | 4 years ago |
|
|
c530983afa | 4 years ago |
|
|
775b13c694 | 4 years ago |
|
|
584445f3b1 | 5 years ago |
|
|
85dd02d4d7 | 5 years ago |
|
|
7c03271048 | 5 years ago |
|
|
8bbaaf8fae | 5 years ago |
|
|
d59d6401c8 | 5 years ago |
|
|
387c436207 | 5 years ago |
|
|
b981b1153c | 5 years ago |
|
|
87d93afb44 | 5 years ago |
|
|
c3e4090f31 | 5 years ago |
|
|
0251d66d28 | 5 years ago |
|
|
864230b883 | 5 years ago |
|
|
d05841a6a2 | 5 years ago |
|
|
c5be32d7e5 | 5 years ago |
|
|
8434f5e694 | 5 years ago |
|
|
9ff2369a55 | 5 years ago |
|
|
82a53e0171 | 5 years ago |
|
|
a2df0e5682 | 5 years ago |
|
|
ec37e11fef | 5 years ago |
|
|
3a5a3c128b | 5 years ago |
|
|
ee30898cef | 5 years ago |
|
|
62cf56e98a | 5 years ago |
|
|
dc003fa624 | 5 years ago |
|
|
8b5a71f498 | 5 years ago |
|
|
9c8dee31b9 | 5 years ago |
|
|
2bbdf3ee5d | 5 years ago |
|
|
35cf63cf38 | 5 years ago |
|
|
ff4de6d782 | 5 years ago |
|
|
c12a30328c | 5 years ago |
|
|
7e6660002b | 5 years ago |
|
|
dfbc35eeb9 | 5 years ago |
|
|
4f531fe4cb | 5 years ago |
|
|
18c17b5f76 | 5 years ago |
|
|
0bad95e94e | 5 years ago |
|
|
7501613951 | 5 years ago |
|
|
5084f1dd8c | 5 years ago |
|
|
7f035c1ac5 | 5 years ago |
|
|
7bcfbf502b | 5 years ago |
|
|
5830608527 | 5 years ago |
|
|
cff18e0915 | 5 years ago |
|
|
a77ac4a397 | 5 years ago |
32 changed files with 2430 additions and 910 deletions
@ -1,12 +1,14 @@ |
|||||||
__pycache__ |
__pycache__/ |
||||||
.ipynb_checkpoints |
.ipynb_checkpoints |
||||||
.pytest_cache |
.pytest_cache |
||||||
.DS_Store |
.DS_Store |
||||||
*.pyc |
|
||||||
docs/_build |
|
||||||
build |
|
||||||
dist |
|
||||||
.idea |
.idea |
||||||
.vscode |
.vscode |
||||||
src/kyupy.egg-info |
.venv |
||||||
|
*.py[oc] |
||||||
|
docs/_build |
||||||
|
build/ |
||||||
|
dist/ |
||||||
|
wheels/ |
||||||
|
*.egg-info |
||||||
*nogit* |
*nogit* |
||||||
|
|||||||
@ -0,0 +1,32 @@ |
|||||||
|
KyuPy - Pythonic Processing of VLSI Circuits |
||||||
|
============================================ |
||||||
|
|
||||||
|
KyuPy is a Python package for processing and analysis of non-hierarchical gate-level VLSI designs. |
||||||
|
It contains fundamental building blocks for research software in the fields of VLSI test, diagnosis and reliability: |
||||||
|
|
||||||
|
* Efficient data structures for gate-level circuits and related design data. |
||||||
|
* Partial [lark](https://github.com/lark-parser/lark) parsers for common design files like |
||||||
|
bench, gate-level Verilog, standard delay format (SDF), standard test interface language (STIL), design exchange format (DEF). |
||||||
|
* Bit-parallel gate-level 2-, 4-, and 8-valued logic simulation. |
||||||
|
* GPU-accelerated high-throughput gate-level timing simulation. |
||||||
|
* High-performance through the use of [numpy](https://numpy.org) and [numba](https://numba.pydata.org). |
||||||
|
|
||||||
|
|
||||||
|
Getting Started |
||||||
|
--------------- |
||||||
|
|
||||||
|
KyuPy is available in [PyPI](https://pypi.org/project/kyupy). |
||||||
|
It requires Python 3.10 or newer, [lark](https://pypi.org/project/lark), and [numpy](https://numpy.org). |
||||||
|
Although optional, [numba](https://numba.pydata.org) should be installed for best performance. [numba-cuda](https://nvidia.github.io/numba-cuda/) is required for GPU/CUDA acceleration. |
||||||
|
If numba is not available, KyuPy will automatically fall back to slow, pure Python execution. |
||||||
|
|
||||||
|
The Jupyter Notebook [Introduction.ipynb](https://github.com/s-holst/kyupy/blob/main/examples/Introduction.ipynb) contains some useful examples to get familiar with the API. |
||||||
|
|
||||||
|
|
||||||
|
Development |
||||||
|
----------- |
||||||
|
|
||||||
|
To work with the latest pre-release source code, clone the [KyuPy GitHub repository](https://github.com/s-holst/kyupy). |
||||||
|
|
||||||
|
* Using ``pip``: Run ``pip install -e .`` within your local checkout to make the package available in your Python environment. The source code comes with tests that can be run with ``pytest``. |
||||||
|
* Using ``uv``: Run ``uv run pytest`` within your local checkout to get started. |
||||||
@ -1,32 +0,0 @@ |
|||||||
KyuPy - Pythonic Processing of VLSI Circuits |
|
||||||
============================================ |
|
||||||
|
|
||||||
KyuPy is a Python package for processing and analysis of non-hierarchical gate-level VLSI designs. |
|
||||||
It contains fundamental building blocks for research software in the fields of VLSI test, diagnosis and reliability: |
|
||||||
|
|
||||||
* Efficient data structures for gate-level circuits and related design data. |
|
||||||
* Partial `lark <https://github.com/lark-parser/lark>`_ parsers for common design files like |
|
||||||
bench, gate-level Verilog, standard delay format (SDF), standard test interface language (STIL), design exchange format (DEF). |
|
||||||
* Bit-parallel gate-level 2-, 4-, and 8-valued logic simulation. |
|
||||||
* GPU-accelerated high-throughput gate-level timing simulation. |
|
||||||
* High-performance through the use of `numpy <https://numpy.org>`_ and `numba <https://numba.pydata.org>`_. |
|
||||||
|
|
||||||
|
|
||||||
Getting Started |
|
||||||
--------------- |
|
||||||
|
|
||||||
KyuPy is available in `PyPI <https://pypi.org/project/kyupy>`_. |
|
||||||
It requires Python 3.8 or newer, `lark-parser <https://pypi.org/project/lark-parser>`_, and `numpy`_. |
|
||||||
Although optional, `numba`_ should be installed for best performance. |
|
||||||
GPU/CUDA support in numba may `require some additional setup <https://numba.readthedocs.io/en/stable/cuda/index.html>`_. |
|
||||||
If numba is not available, KyuPy will automatically fall back to slow, pure Python execution. |
|
||||||
|
|
||||||
The Jupyter Notebook `Introduction.ipynb <https://github.com/s-holst/kyupy/blob/main/examples/Introduction.ipynb>`_ contains some useful examples to get familiar with the API. |
|
||||||
|
|
||||||
|
|
||||||
Development |
|
||||||
----------- |
|
||||||
|
|
||||||
To work with the latest pre-release source code, clone the `KyuPy GitHub repository <https://github.com/s-holst/kyupy>`_. |
|
||||||
Run ``pip install -e .`` within your local checkout to make the package available in your Python environment. |
|
||||||
The source code comes with tests that can be run with ``pytest``. |
|
||||||
@ -0,0 +1,211 @@ |
|||||||
|
"""A simple parser for Verilog Change Dump (VCD) files. |
||||||
|
|
||||||
|
This parser loads the changes into a ndarray of logic values. |
||||||
|
Axis 0 is the time step, axis 1 is the variable data. |
||||||
|
All variable values are flattened. Offsets are stored in each variable metadata. |
||||||
|
""" |
||||||
|
|
||||||
|
from collections import namedtuple |
||||||
|
from dataclasses import dataclass, field |
||||||
|
|
||||||
|
from lark import Lark, Transformer |
||||||
|
import numpy as np |
||||||
|
|
||||||
|
from . import readtext, logic |
||||||
|
|
||||||
|
|
||||||
|
@dataclass |
||||||
|
class Var: |
||||||
|
type: str |
||||||
|
width: int |
||||||
|
idcode: str |
||||||
|
reference: str |
||||||
|
scope: 'Scope' |
||||||
|
locs: list[int] = field(default_factory=list) |
||||||
|
|
||||||
|
|
||||||
|
class Scope: |
||||||
|
def __init__(self, parent, name='', type='module') -> None: |
||||||
|
self.name = name |
||||||
|
self.type = type |
||||||
|
self.parent_scope = parent |
||||||
|
self.sub_scopes : list[Scope] = [] |
||||||
|
self.vars : list = [] |
||||||
|
|
||||||
|
@property |
||||||
|
def path(self) -> str: |
||||||
|
parts = [] |
||||||
|
s = self |
||||||
|
while s is not None and s.name: |
||||||
|
parts.append(s.name) |
||||||
|
s = s.parent_scope |
||||||
|
return '/'.join(reversed(parts)) |
||||||
|
|
||||||
|
|
||||||
|
class VcdHeader: |
||||||
|
def __init__(self) -> None: |
||||||
|
self.comment: str = '' |
||||||
|
self.date: str = '' |
||||||
|
self.timescale: str = '' |
||||||
|
self.version: str = '' |
||||||
|
self.root_scope = Scope(None) |
||||||
|
self.current_scope = self.root_scope |
||||||
|
|
||||||
|
def scope(self, name, type): |
||||||
|
new_scope = Scope(self.current_scope, name, type) |
||||||
|
self.current_scope.sub_scopes.append(new_scope) |
||||||
|
self.current_scope = new_scope |
||||||
|
|
||||||
|
def upscope(self): |
||||||
|
assert self.current_scope.parent_scope is not None, "root scope has no parent" |
||||||
|
self.current_scope = self.current_scope.parent_scope |
||||||
|
|
||||||
|
def add_var(self, type: str, width: int, idcode: str, reference: str): |
||||||
|
self.current_scope.vars.append(Var(type, width, idcode, reference, self.current_scope)) |
||||||
|
|
||||||
|
def __repr__(self): |
||||||
|
lines = [ |
||||||
|
'VcdHeader(', |
||||||
|
f' comment = {self.comment!r}', |
||||||
|
f' date = {self.date!r}', |
||||||
|
f' timescale = {self.timescale!r}', |
||||||
|
f' version = {self.version!r}', |
||||||
|
' scopes:', |
||||||
|
] |
||||||
|
def fmt_scope(scope, indent=4): |
||||||
|
lines.append(f'{" " * (indent // 2)}{scope.type}:{scope.name} ({len(scope.vars)} vars)') |
||||||
|
for sub in scope.sub_scopes: |
||||||
|
fmt_scope(sub, indent + 2) |
||||||
|
for sub in self.root_scope.sub_scopes: |
||||||
|
fmt_scope(sub) |
||||||
|
lines.append(')') |
||||||
|
return '\n'.join(lines) |
||||||
|
|
||||||
|
|
||||||
|
class VcdVarMap: |
||||||
|
def __init__(self, header: VcdHeader, var_locs = lambda _: []) -> None: |
||||||
|
self.var_list: list[Var] = [] |
||||||
|
def collect(scope): |
||||||
|
for v in scope.vars: |
||||||
|
v.locs = var_locs(v) |
||||||
|
if v.locs is not None and len(v.locs) > 0: |
||||||
|
assert len(v.locs) == v.width, f'{v.reference}: len(locs)={len(v.locs)} != width={v.width}' |
||||||
|
self.var_list.append(v) |
||||||
|
for sub in scope.sub_scopes: |
||||||
|
collect(sub) |
||||||
|
collect(header.root_scope) |
||||||
|
self.total_width = max((max(v.locs) for v in self.var_list), default=-1) + 1 |
||||||
|
self.idcode2var = {var.idcode: var for var in self.var_list} |
||||||
|
|
||||||
|
|
||||||
|
class VcdData: |
||||||
|
def __init__(self, var_map, steps, data): |
||||||
|
self.var_map = var_map |
||||||
|
self.steps = steps |
||||||
|
self.data = data |
||||||
|
|
||||||
|
|
||||||
|
class VcdHeaderTransformer(Transformer): |
||||||
|
def __init__(self): |
||||||
|
super().__init__() |
||||||
|
self.header = VcdHeader() |
||||||
|
|
||||||
|
def comment(self, args): self.header.comment = args[0].value.strip() |
||||||
|
def date(self, args): self.header.date = args[0].value.strip() |
||||||
|
def timescale(self, args): self.header.timescale = args[0].value.strip() |
||||||
|
def version(self, args): self.header.version = args[0].value.strip() |
||||||
|
|
||||||
|
def scope(self, args): |
||||||
|
type, name = args |
||||||
|
self.header.scope(name.value, type.value) |
||||||
|
|
||||||
|
def upscope(self, args): |
||||||
|
self.header.upscope() |
||||||
|
|
||||||
|
def var(self, args): |
||||||
|
type, width, idcode, reference = args |
||||||
|
reference = reference.strip() |
||||||
|
width = int(width) |
||||||
|
self.header.add_var(type, width, idcode, reference) |
||||||
|
|
||||||
|
def start(self, args): |
||||||
|
return self.header |
||||||
|
#return tuple(args) if len(args) > 1 else (args[0], None) |
||||||
|
|
||||||
|
|
||||||
|
GRAMMAR = r""" |
||||||
|
start: (_declaration_command)* |
||||||
|
_declaration_command: ( comment | date | scope | timescale | upscope | var | version ) "$end" |
||||||
|
comment: "$comment" TEXT? |
||||||
|
date: "$date" TEXT |
||||||
|
scope: "$scope" /[^\s]+/ /[^\s]+/ |
||||||
|
timescale: "$timescale" TEXT |
||||||
|
upscope: "$upscope" |
||||||
|
var: "$var" /[^\s]+/ /[^\s]+/ /[^\s]+/ TEXT |
||||||
|
version: "$version" TEXT |
||||||
|
TEXT: /(?:(?!\$end)[\s\S])+/ |
||||||
|
%ignore ( /\r?\n/ )+ |
||||||
|
%ignore /[\t \f]+/ |
||||||
|
""" |
||||||
|
|
||||||
|
|
||||||
|
def load(file, var_locs = lambda _: [], step_filter = lambda *_: True): |
||||||
|
"""Parses the contents of ``file`` as Verilog Change Dump (VCD). |
||||||
|
|
||||||
|
:param file: A file name or a file handle. Files with `.gz`-suffix are decompressed on-the-fly. |
||||||
|
:param var_locs: A callback ``(var) -> list[int]`` mapping each variable to ndarray column indices. Empty list drops the variable. |
||||||
|
:param step_filter: A callback ``(time, values, var_map) -> bool`` to select which timesteps to include. |
||||||
|
:return: A VcdData object with metadata and an ndarray with all values. |
||||||
|
""" |
||||||
|
vcd = readtext(file) |
||||||
|
header_size = vcd.find('$enddefinitions') |
||||||
|
assert header_size > 0, "invalid VCD file: end of header not found" |
||||||
|
vcd_header_str = vcd[:header_size] |
||||||
|
vcd_header : VcdHeader = Lark(GRAMMAR, parser="lalr", lexer='contextual', transformer=VcdHeaderTransformer()).parse(vcd_header_str) # type: ignore |
||||||
|
vcd_data = vcd[header_size:].splitlines() |
||||||
|
var_map = VcdVarMap(vcd_header, var_locs) |
||||||
|
|
||||||
|
chunk_size = 10240 |
||||||
|
chunks = [] |
||||||
|
chunk = np.full((chunk_size, var_map.total_width), logic.UNASSIGNED, dtype=np.uint8) |
||||||
|
|
||||||
|
_val_map = {'0': logic.ZERO, '1': logic.ONE, |
||||||
|
'x': logic.UNKNOWN, 'X': logic.UNKNOWN, |
||||||
|
'z': logic.UNASSIGNED, 'Z': logic.UNASSIGNED} |
||||||
|
_pad_char = {'0': '0', '1': '0', 'x': 'x', 'X': 'x', 'z': 'z', 'Z': 'z'} |
||||||
|
|
||||||
|
current_time = None |
||||||
|
steps = [] |
||||||
|
step_idx = 0 |
||||||
|
for line in vcd_data: |
||||||
|
if not line or line[0] == '$': |
||||||
|
continue |
||||||
|
if line[0] == '#': |
||||||
|
if step_filter(current_time, chunk[step_idx], var_map): |
||||||
|
step_idx += 1 |
||||||
|
steps.append(current_time) |
||||||
|
if step_idx >= chunk_size: |
||||||
|
chunks.append(chunk) |
||||||
|
chunk = np.empty((chunk_size, var_map.total_width), dtype=np.uint8) |
||||||
|
chunk[0] = chunks[-1][-1] |
||||||
|
step_idx = 0 |
||||||
|
else: |
||||||
|
chunk[step_idx] = chunk[step_idx - 1] |
||||||
|
current_time = int(line[1:]) |
||||||
|
continue |
||||||
|
if line[0] in ('b', 'B'): |
||||||
|
value_str, idcode = line[1:].split(None, 1) |
||||||
|
else: |
||||||
|
value_str, idcode = line[0], line[1:] |
||||||
|
var = var_map.idcode2var.get(idcode) |
||||||
|
if var is None: |
||||||
|
continue |
||||||
|
if len(value_str) < var.width: |
||||||
|
value_str = _pad_char.get(value_str[0], '0') * (var.width - len(value_str)) + value_str |
||||||
|
for i, c in enumerate(value_str): |
||||||
|
if var.locs[i] >= 0: |
||||||
|
chunk[step_idx, var.locs[i]] = _val_map.get(c, logic.UNKNOWN) |
||||||
|
|
||||||
|
chunks.append(chunk[:step_idx]) |
||||||
|
data = np.concatenate(chunks, axis=0).T |
||||||
|
return VcdData(var_map, steps, data) |
||||||
@ -0,0 +1,91 @@ |
|||||||
|
// Benchmark "all_kyupy_primitives" written by ABC on Thu Nov 6 13:13:21 2025 |
||||||
|
|
||||||
|
module all_kyupy_primitives ( |
||||||
|
i0, i1, i2, i3, |
||||||
|
\o[0] , \o[1] , \o[2] , \o[3] , \o[4] , \o[5] , \o[6] , \o[7] , \o[8] , |
||||||
|
\o[9] , \o[10] , \o[11] , \o[12] , \o[13] , \o[14] , \o[15] , \o[16] , |
||||||
|
\o[17] , \o[18] , \o[19] , \o[20] , \o[21] , \o[22] , \o[23] , \o[24] , |
||||||
|
\o[25] , \o[26] , \o[27] , \o[28] , \o[29] , \o[30] , \o[31] , \o[32] ); |
||||||
|
input i0, i1, i2, i3; |
||||||
|
output \o[0] , \o[1] , \o[2] , \o[3] , \o[4] , \o[5] , \o[6] , \o[7] , |
||||||
|
\o[8] , \o[9] , \o[10] , \o[11] , \o[12] , \o[13] , \o[14] , \o[15] , |
||||||
|
\o[16] , \o[17] , \o[18] , \o[19] , \o[20] , \o[21] , \o[22] , \o[23] , |
||||||
|
\o[24] , \o[25] , \o[26] , \o[27] , \o[28] , \o[29] , \o[30] , \o[31] , |
||||||
|
\o[32] ; |
||||||
|
wire new_n45, new_n48, new_n51, new_n54, new_n55, new_n56, new_n57, |
||||||
|
new_n60, new_n61, new_n62, new_n63, new_n64, new_n65, new_n66, new_n67, |
||||||
|
new_n68, new_n69, new_n72, new_n73, new_n74, new_n75, new_n76, new_n77, |
||||||
|
new_n78, new_n79, new_n80, new_n81, new_n86, new_n87, new_n91, new_n92, |
||||||
|
new_n96, new_n99, new_n102, new_n103, new_n104; |
||||||
|
INV1 g00(.i0(i1), .o(\o[1] )); |
||||||
|
AND2 g01(.i0(i1), .i1(i0), .o(\o[2] )); |
||||||
|
AND2 g02(.i0(\o[2] ), .i1(i2), .o(\o[3] )); |
||||||
|
AND2 g03(.i0(\o[3] ), .i1(i3), .o(\o[4] )); |
||||||
|
INV1 g04(.i0(\o[2] ), .o(\o[5] )); |
||||||
|
INV1 g05(.i0(\o[3] ), .o(\o[6] )); |
||||||
|
INV1 g06(.i0(\o[4] ), .o(\o[7] )); |
||||||
|
INV1 g07(.i0(i0), .o(new_n45)); |
||||||
|
AND2 g08(.i0(\o[1] ), .i1(new_n45), .o(\o[11] )); |
||||||
|
INV1 g09(.i0(\o[11] ), .o(\o[8] )); |
||||||
|
INV1 g10(.i0(i2), .o(new_n48)); |
||||||
|
AND2 g11(.i0(\o[11] ), .i1(new_n48), .o(\o[12] )); |
||||||
|
INV1 g12(.i0(\o[12] ), .o(\o[9] )); |
||||||
|
INV1 g13(.i0(i3), .o(new_n51)); |
||||||
|
AND2 g14(.i0(\o[12] ), .i1(new_n51), .o(\o[13] )); |
||||||
|
INV1 g15(.i0(\o[13] ), .o(\o[10] )); |
||||||
|
AND2 g16(.i0(\o[1] ), .i1(i0), .o(new_n54)); |
||||||
|
INV1 g17(.i0(new_n54), .o(new_n55)); |
||||||
|
AND2 g18(.i0(i1), .i1(new_n45), .o(new_n56)); |
||||||
|
INV1 g19(.i0(new_n56), .o(new_n57)); |
||||||
|
AND2 g20(.i0(new_n57), .i1(new_n55), .o(\o[17] )); |
||||||
|
INV1 g21(.i0(\o[17] ), .o(\o[14] )); |
||||||
|
AND2 g22(.i0(i2), .i1(i1), .o(new_n60)); |
||||||
|
INV1 g23(.i0(new_n60), .o(new_n61)); |
||||||
|
AND2 g24(.i0(new_n48), .i1(\o[1] ), .o(new_n62)); |
||||||
|
INV1 g25(.i0(new_n62), .o(new_n63)); |
||||||
|
AND2 g26(.i0(new_n63), .i1(new_n61), .o(new_n64)); |
||||||
|
INV1 g27(.i0(new_n64), .o(new_n65)); |
||||||
|
AND2 g28(.i0(new_n65), .i1(i0), .o(new_n66)); |
||||||
|
INV1 g29(.i0(new_n66), .o(new_n67)); |
||||||
|
AND2 g30(.i0(new_n64), .i1(new_n45), .o(new_n68)); |
||||||
|
INV1 g31(.i0(new_n68), .o(new_n69)); |
||||||
|
AND2 g32(.i0(new_n69), .i1(new_n67), .o(\o[18] )); |
||||||
|
INV1 g33(.i0(\o[18] ), .o(\o[15] )); |
||||||
|
AND2 g34(.i0(i3), .i1(new_n48), .o(new_n72)); |
||||||
|
INV1 g35(.i0(new_n72), .o(new_n73)); |
||||||
|
AND2 g36(.i0(new_n51), .i1(i2), .o(new_n74)); |
||||||
|
INV1 g37(.i0(new_n74), .o(new_n75)); |
||||||
|
AND2 g38(.i0(new_n75), .i1(new_n73), .o(new_n76)); |
||||||
|
INV1 g39(.i0(new_n76), .o(new_n77)); |
||||||
|
AND2 g40(.i0(new_n77), .i1(\o[17] ), .o(new_n78)); |
||||||
|
INV1 g41(.i0(new_n78), .o(new_n79)); |
||||||
|
AND2 g42(.i0(new_n76), .i1(\o[14] ), .o(new_n80)); |
||||||
|
INV1 g43(.i0(new_n80), .o(new_n81)); |
||||||
|
AND2 g44(.i0(new_n81), .i1(new_n79), .o(\o[19] )); |
||||||
|
INV1 g45(.i0(\o[19] ), .o(\o[16] )); |
||||||
|
AND2 g46(.i0(\o[5] ), .i1(new_n48), .o(\o[24] )); |
||||||
|
INV1 g47(.i0(\o[24] ), .o(\o[20] )); |
||||||
|
AND2 g48(.i0(i3), .i1(i2), .o(new_n86)); |
||||||
|
INV1 g49(.i0(new_n86), .o(new_n87)); |
||||||
|
AND2 g50(.i0(new_n87), .i1(\o[5] ), .o(\o[25] )); |
||||||
|
INV1 g51(.i0(\o[25] ), .o(\o[21] )); |
||||||
|
AND2 g52(.i0(\o[8] ), .i1(i2), .o(\o[22] )); |
||||||
|
AND2 g53(.i0(new_n51), .i1(new_n48), .o(new_n91)); |
||||||
|
INV1 g54(.i0(new_n91), .o(new_n92)); |
||||||
|
AND2 g55(.i0(new_n92), .i1(\o[8] ), .o(\o[23] )); |
||||||
|
INV1 g56(.i0(\o[22] ), .o(\o[26] )); |
||||||
|
INV1 g57(.i0(\o[23] ), .o(\o[27] )); |
||||||
|
AND2 g58(.i0(\o[5] ), .i1(new_n51), .o(new_n96)); |
||||||
|
AND2 g59(.i0(new_n96), .i1(new_n48), .o(\o[30] )); |
||||||
|
INV1 g60(.i0(\o[30] ), .o(\o[28] )); |
||||||
|
AND2 g61(.i0(\o[8] ), .i1(i3), .o(new_n99)); |
||||||
|
AND2 g62(.i0(new_n99), .i1(i2), .o(\o[29] )); |
||||||
|
INV1 g63(.i0(\o[29] ), .o(\o[31] )); |
||||||
|
AND2 g64(.i0(new_n48), .i1(i0), .o(new_n102)); |
||||||
|
INV1 g65(.i0(new_n102), .o(new_n103)); |
||||||
|
AND2 g66(.i0(new_n103), .i1(new_n61), .o(new_n104)); |
||||||
|
INV1 g67(.i0(new_n104), .o(\o[32] )); |
||||||
|
BUF1 g68(.i0(i0), .o(\o[0] )); |
||||||
|
endmodule |
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,53 @@ |
|||||||
|
module all_kyupy_primitives (i0, i1, i2, i3, o); |
||||||
|
input i0; |
||||||
|
input i1; |
||||||
|
input i2; |
||||||
|
input i3; |
||||||
|
output [32:0] o; |
||||||
|
|
||||||
|
BUF1 buf1_0 (.i0(i0), .o(o[0])); |
||||||
|
INV1 inv1_0 (.i0(i1), .o(o[1])); |
||||||
|
|
||||||
|
AND2 and2_0 (.i0(i0), .i1(i1), .o(o[2])); |
||||||
|
AND3 and3_0 (.i0(i0), .i1(i1), .i2(i2), .o(o[3])); |
||||||
|
AND4 and4_0 (.i0(i0), .i1(i1), .i2(i2), .i3(i3), .o(o[4])); |
||||||
|
|
||||||
|
NAND2 nand2_0 (.i0(i0), .i1(i1), .o(o[5])); |
||||||
|
NAND3 nand3_0 (.i0(i0), .i1(i1), .i2(i2), .o(o[6])); |
||||||
|
NAND4 nand4_0 (.i0(i0), .i1(i1), .i2(i2), .i3(i3), .o(o[7])); |
||||||
|
|
||||||
|
OR2 or2_0 (.i0(i0), .i1(i1), .o(o[8])); |
||||||
|
OR3 or3_0 (.i0(i0), .i1(i1), .i2(i2), .o(o[9])); |
||||||
|
OR4 or4_0 (.i0(i0), .i1(i1), .i2(i2), .i3(i3), .o(o[10])); |
||||||
|
|
||||||
|
NOR2 nor2_0 (.i0(i0), .i1(i1), .o(o[11])); |
||||||
|
NOR3 nor3_0 (.i0(i0), .i1(i1), .i2(i2), .o(o[12])); |
||||||
|
NOR4 nor4_0 (.i0(i0), .i1(i1), .i2(i2), .i3(i3), .o(o[13])); |
||||||
|
|
||||||
|
XOR2 xor2_0 (.i0(i0), .i1(i1), .o(o[14])); |
||||||
|
XOR3 xor3_0 (.i0(i0), .i1(i1), .i2(i2), .o(o[15])); |
||||||
|
XOR4 xor4_0 (.i0(i0), .i1(i1), .i2(i2), .i3(i3), .o(o[16])); |
||||||
|
|
||||||
|
XNOR2 xnor2_0 (.i0(i0), .i1(i1), .o(o[17])); |
||||||
|
XNOR3 xnor3_0 (.i0(i0), .i1(i1), .i2(i2), .o(o[18])); |
||||||
|
XNOR4 xnor4_0 (.i0(i0), .i1(i1), .i2(i2), .i3(i3), .o(o[19])); |
||||||
|
|
||||||
|
AO21 ao21_0 (.i0(i0), .i1(i1), .i2(i2), .o(o[20])); |
||||||
|
AO22 ao22_0 (.i0(i0), .i1(i1), .i2(i2), .i3(i3), .o(o[21])); |
||||||
|
OA21 oa21_0 (.i0(i0), .i1(i1), .i2(i2), .o(o[22])); |
||||||
|
OA22 oa22_0 (.i0(i0), .i1(i1), .i2(i2), .i3(i3), .o(o[23])); |
||||||
|
|
||||||
|
AOI21 aoi21_0 (.i0(i0), .i1(i1), .i2(i2), .o(o[24])); |
||||||
|
AOI22 aoi22_0 (.i0(i0), .i1(i1), .i2(i2), .i3(i3), .o(o[25])); |
||||||
|
OAI21 oai21_0 (.i0(i0), .i1(i1), .i2(i2), .o(o[26])); |
||||||
|
OAI22 oai22_0 (.i0(i0), .i1(i1), .i2(i2), .i3(i3), .o(o[27])); |
||||||
|
|
||||||
|
AO211 ao211_0 (.i0(i0), .i1(i1), .i2(i2), .i3(i3), .o(o[28])); |
||||||
|
OA211 oa211_0 (.i0(i0), .i1(i1), .i2(i2), .i3(i3), .o(o[29])); |
||||||
|
|
||||||
|
AOI211 aoi211_0 (.i0(i0), .i1(i1), .i2(i2), .i3(i3), .o(o[30])); |
||||||
|
OAI211 oai211_0 (.i0(i0), .i1(i1), .i2(i2), .i3(i3), .o(o[31])); |
||||||
|
|
||||||
|
MUX21 mux21_0 (.i0(i0), .i1(i1), .i2(i2), .o(o[32])); |
||||||
|
|
||||||
|
endmodule |
||||||
@ -0,0 +1,34 @@ |
|||||||
|
# library of all KyuPy simulation primitives defined in kyupy.sim |
||||||
|
GATE BUF1 1 o=i0; PIN * NONINV 1 999 1 0 1 0 |
||||||
|
GATE INV1 1 o=!i0; PIN * INV 1 999 1 0 1 0 |
||||||
|
GATE AND2 1 o=i0*i1; PIN * NONINV 1 999 1 0 1 0 |
||||||
|
GATE AND3 1 o=i0*i1*i2; PIN * NONINV 1 999 1 0 1 0 |
||||||
|
GATE AND4 1 o=i0*i1*i2*i3; PIN * NONINV 1 999 1 0 1 0 |
||||||
|
GATE NAND2 1 o=!(i0*i1); PIN * INV 1 999 1 0 1 0 |
||||||
|
GATE NAND3 1 o=!(i0*i1*i2); PIN * INV 1 999 1 0 1 0 |
||||||
|
GATE NAND4 1 o=!(i0*i1*i2*i3); PIN * INV 1 999 1 0 1 0 |
||||||
|
GATE OR2 1 o=i0+i1; PIN * NONINV 1 999 1 0 1 0 |
||||||
|
GATE OR3 1 o=i0+i1+i2; PIN * NONINV 1 999 1 0 1 0 |
||||||
|
GATE OR4 1 o=i0+i1+i2+i3; PIN * NONINV 1 999 1 0 1 0 |
||||||
|
GATE NOR2 1 o=!(i0+i1); PIN * INV 1 999 1 0 1 0 |
||||||
|
GATE NOR3 1 o=!(i0+i1+i2); PIN * INV 1 999 1 0 1 0 |
||||||
|
GATE NOR4 1 o=!(i0+i1+i2+i3); PIN * INV 1 999 1 0 1 0 |
||||||
|
GATE XOR2 1 o=i0^i1; PIN * UNKNOWN 1 999 1 0 1 0 |
||||||
|
GATE XOR3 1 o=i0^i1^i2; PIN * UNKNOWN 1 999 1 0 1 0 |
||||||
|
GATE XOR4 1 o=i0^i1^i2^i3; PIN * UNKNOWN 1 999 1 0 1 0 |
||||||
|
GATE XNOR2 1 o=!(i0^i1); PIN * UNKNOWN 1 999 1 0 1 0 |
||||||
|
GATE XNOR3 1 o=!(i0^i1^i2); PIN * UNKNOWN 1 999 1 0 1 0 |
||||||
|
GATE XNOR4 1 o=!(i0^i1^i2^i3); PIN * UNKNOWN 1 999 1 0 1 0 |
||||||
|
GATE AO21 1 o=(i0*i1)+i2; PIN * NONINV 1 999 1 0 1 0 |
||||||
|
GATE AO22 1 o=(i0*i1)+(i2*i3); PIN * NONINV 1 999 1 0 1 0 |
||||||
|
GATE OA21 1 o=(i0+i1)*i2; PIN * NONINV 1 999 1 0 1 0 |
||||||
|
GATE OA22 1 o=(i0+i1)*(i2+i3); PIN * NONINV 1 999 1 0 1 0 |
||||||
|
GATE AOI21 1 o=!( (i0*i1)+i2 ); PIN * INV 1 999 1 0 1 0 |
||||||
|
GATE AOI22 1 o=!( (i0*i1)+(i2*i3) ); PIN * INV 1 999 1 0 1 0 |
||||||
|
GATE OAI21 1 o=!( (i0+i1)*i2 ); PIN * INV 1 999 1 0 1 0 |
||||||
|
GATE OAI22 1 o=!( (i0+i1)*(i2+i3) ); PIN * INV 1 999 1 0 1 0 |
||||||
|
GATE AO211 1 o=(i0*i1)+i2+i3; PIN * NONINV 1 999 1 0 1 0 |
||||||
|
GATE OA211 1 o=(i0+i1)*i2*i3; PIN * NONINV 1 999 1 0 1 0 |
||||||
|
GATE AOI211 1 o=!( (i0*i1)+i2+i3 ); PIN * INV 1 999 1 0 1 0 |
||||||
|
GATE OAI211 1 o=!( (i0+i1)*i2*i3 ); PIN * INV 1 999 1 0 1 0 |
||||||
|
GATE MUX21 1 o=(i0*!i2)+(i1*i2); PIN * UNKNOWN 1 999 1 0 1 0 |
||||||
@ -0,0 +1,8 @@ |
|||||||
|
# abc -f map_to_minimal.abc |
||||||
|
|
||||||
|
read kyupy_simprims.genlib |
||||||
|
read -m all_kyupy_simprims.v |
||||||
|
fraig |
||||||
|
read minimal.genlib |
||||||
|
map |
||||||
|
write all_kyupy_simprims.minimal.v |
||||||
@ -0,0 +1,5 @@ |
|||||||
|
# A minimal library for generating logically equivalent circuits with |
||||||
|
# minimum number of gate types. |
||||||
|
GATE BUF1 1 o=i0; PIN * NONINV 1 999 1 0 1 0 |
||||||
|
GATE INV1 1 o=!i0; PIN * INV 1 999 1 0 1 0 |
||||||
|
GATE AND2 1 o=i0*i1; PIN * NONINV 1 999 1 0 1 0 |
||||||
Loading…
Reference in new issue