Chisel / Firrtl to ELK Graph
This project can generate ELK Graph files, which can be layout by ELK and rendered by icviewer as an interactive diagram to represent Chisel generated Firrtl circuits.
If you want to see the ELK Graph directly, you can use this online service, it's open source https://github.com/kieler/elk-live . But there may be some bugs, which are not suitable for circuit diagrams.
It is highly recommended to using the IntelliJ plugin to view your circuit. It supports interactive viewing of the sub-modules by double-click. In addition, it supports back navigation, zoom view, export SVG format and other functions.
The main idea is that the layout of graph use a layer-based algorithm provided by the Eclipse Layout Kernel, and the graph rendering is implemented by Sprotty diagramming framework. The combination of the two gives us a very intuitive circuit schematics.
The logic of circuit format conversion comes from diagrammer project and adapted to elk data generation with some optimizations.
Example
Purple Theme View this example interactively Solid Theme(--flatten 2)
Using
Install
Maven
https://search.maven.org/artifact/org.easysoc/layered-firrtl_2.12
for SBT
// "org.easysoc" %% "layered-firrtl" % "1.1-SNAPSHOT"
"org.easysoc" %% "layered-firrtl" % "1.1.+"
Source
git clone https://github.com/easysoc/layered-firrtl
cd layered-firrtl
Creating graph from Chisel code
val targetDir = "test_run_dir/gcd"
(new ElkStage).execute(
Array("-td", targetDir),
Seq(ChiselGeneratorAnnotation(() => new GCD))
)
Creating graph from Firrtl file
To create a set of graphs of a Firrtl Circuit all you need is this project and a Firrtl file (typically a file generated by Chisel with a .fir extension). Let's say you have a Firrtl file ~/projects/output/circuit.fir. From the command line you while in this directory for this project
./elk.sh -i ~/projects/output/circuit.fir
or run through fat jar
sbt assembly
./utils/bin/elk -i ~/projects/output/circuit.fir
This will create a number of files in the test_run_dir/${circuit.main} directory that representing the firrtl circuit. Each file will be a ELK Graph for each module contained in the firrtl file.
Options
-i, set the source firrtl to work on-td,--target-dirwork directory (default: "./test_run_dir")--topthe module in the hierarchy to start, default is the circuit top--flattenthe maxDepth of the flatten levels- It is not recommended to exceed 2, otherwise the generated graph is too complicated
--lowFirgenerate the corresponding lo.fir file