Download chips/yosys/tests/pyosys/test_pass.py from STAR-future/Trinity-SciData: direct link, hf CLI and curl.
- Browser
- Download file 881 Bytes
-
https://huggingface.co/datasets/STAR-future/Trinity-SciData/resolve/main/chips/yosys/tests/pyosys/test_pass.py
- Command line
-
hf download hf://datasets/STAR-future/Trinity-SciData/chips/yosys/tests/pyosys/test_pass.py
-
curl -L -o test_pass.py https://huggingface.co/datasets/STAR-future/Trinity-SciData/resolve/main/chips/yosys/tests/pyosys/test_pass.py
881 Bytes
| from pyosys import libyosys as ys | |
| import json | |
| from pathlib import Path | |
| __file_dir__ = Path(__file__).absolute().parent | |
| class CellStatsPass(ys.Pass): | |
| def __init__(self): | |
| super().__init__( | |
| "cell_stats", | |
| "dumps cell statistics in JSON format" | |
| ) | |
| def execute(self, args, design): | |
| ys.log_header(design, "Dumping cell stats\n") | |
| ys.log_push() | |
| cell_stats = {} | |
| for module in design.all_selected_whole_modules(): | |
| for cell in module.selected_cells(): | |
| if cell.type.str() in cell_stats: | |
| cell_stats[cell.type.str()] += 1 | |
| else: | |
| cell_stats[cell.type.str()] = 1 | |
| ys.log(json.dumps(cell_stats)) | |
| ys.log_pop() | |
| p = CellStatsPass() # registration | |
| design = ys.Design() | |
| ys.run_pass(f"read_verilog {__file_dir__.parent / 'simple' / 'fiedler-cooley.v'}", design) | |
| ys.run_pass("prep", design) | |
| ys.run_pass("opt -full", design) | |
| ys.run_pass("cell_stats", design) | |