Documentation on Analyzing Circuits with Python Bindings
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 524
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 46
Description
Following up from a discussion in today's Dev Meeting (cc @mikeurbach).
I'm trying to do some analysis of circuits (starting from Chisel in my case), and am having trouble getting started with the [CIRCT Python Bindings](https://pypi.org/project/circt/). One use-case I have in mind is finding all of the modules (as well as the output files) associated with a Public module. Once I have an instance graph of my circuit, I'm hoping that this would be reasonably straightforward.
There's currently a [`docs/PythonBindings.md`](https://github.com/llvm/circt/blob/main/docs/PythonBindings.md) file with some getting-started information for the Python Bindings, but after reading it, I'm left with a few questions:
- What dialect should I use to do this analysis? `firtool` has the `--output-final-mlir=` option for creating another `.mlir` output file in addition to the `-o` output (SystemVerilog in my case). Should I be using that? Or should I be invoking `firtool` once to generate SystemVerilog, and another time to emit HW dialect (`--ir-hw`)?
- Once I have one of these `.mlir` files, what entry point should I use in the Python Bindings to parse those files? Is something like this the right direction?
```python
import circt
from circt.ir import Context, Module
if __name__ == "__main__":
ctx = Context()
circt.register_dialects(ctx)
with open("path/to/my/circuit.mlir") as f:
module = Module.parse(f.read(), ctx)
# ...
```
- Once I have a Module loaded, what are some of the primitives that I should use to walk the Module's operations?
I really appreciate any help with getting started on all of this! If someone points me in the right direction with answering these questions, I'm happy to contribute additions to the docs.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with docs/PythonBindings.md and review the firtool options and Python parsing example named in the issue. Determine which dialect and entry points support the requested module and output-file analysis, and document how to walk loaded operations. Done means the getting-started documentation answers these three questions for a newcomer.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers, documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100