You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
draws an SVG schematic from a [yosys](https://github.com/cliffordwolf/yosys) JSON netlist. It uses [elkjs](https://github.com/OpenKieler/elkjs) for layout.
8
+
draws an SVG schematic from a [yosys](https://github.com/cliffordwolf/yosys) JSON netlist. This can be generated [the `write_json` command](http://www.clifford.at/yosys/cmd_json.html). It uses [elkjs](https://github.com/OpenKieler/elkjs) for layout.
6
9
7
10
You can see an online demo [here](https://nturley.github.io/netlistsvg)
8
11
12
+
Here's an digital netlist produced by Yosys along with the diagram that netlistsvg created from it.
9
13
<details>
10
14
<summary>JSON Source</summary>
11
15
@@ -225,7 +229,7 @@ You can see an online demo [here](https://nturley.github.io/netlistsvg)
The JSON doesn't need to be produced by Yosys, of course. We can process arbitrary block diagrams.
232
+
You can also write out the JSON by hand, of course. We support [JSON5](https://json5.org) syntax.
229
233
230
234
<details>
231
235
<summary>JSON Source</summary>
@@ -360,57 +364,12 @@ The elkjs layout properties are also defined in the skin file.
360
364
org.eclipse.elk.direction="DOWN"
361
365
/>
362
366
```
363
-
Any properties specified here will get passed along to the layout engine. Node and edge properties aren't configurable (yet). Right now I'm setting the priority of $dff.Q to be lower than everything else so that feedback edges on flip flops will go from right to left.
364
-
365
-
I'm also setting the ports to be fixed position right now, until I figure out a plan for swappable ports.
366
-
367
-
## Split/Join Wires
368
-
It does it's best to be smart about how to split and join buses. I spent a lot of time thinking about it and hacked something together using javascript strings (because I was too lazy to write my own library for processing sequences). At some point I will rewrite it with a sane implementation that doesn't use strings. I think I'm happy with the core algorithm, just the implementation is wonky.
* There should only exist one wire for each unique sequence of signals
408
-
* Always prefer using an existing signal over adding a new split or join
409
-
410
-
ElkJS handles all of the wire junctions. Sometimes it does some odd things.
367
+
Any properties specified here will get passed along to the layout engine. Node and edge properties aren't configurable (yet).
411
368
412
369
## Input JSON
413
-
This is designed to handle Yosys netlist format but we ignore most of it. This is what we are looking at. Currently, we only draw the first module in the modules object.
370
+
Yosys JSON includes more information than we need. We only render one module (either the first or the module with an attribute "top"). If the cell name matches one of the aliases of a template from the skin, then it will use it as a template for the SVG file. Port directions are optional for cells that are defined in the skin (not generic cells).
371
+
372
+
So it should look something like this.
414
373
```json
415
374
{
416
375
"modules": {
@@ -441,14 +400,10 @@ This is designed to handle Yosys netlist format but we ignore most of it. This i
441
400
```
442
401
443
402
## ElkJS
444
-
I'm super impressed with this. Layout is a non-trivial problem and this tool is amazing. ELK is written in Java and transpiled to javascript.
445
-
446
-
This tool is really powerful and I'm still learning the ins and outs of how to use it. ELK is capable of port positioning for instance. This means that potentially I could flag certain ports as being able to be swapped or repositioned and ELK could reorder them to reduce crossings. That's obviously a win for labeled ports on the generic, and split/join, but also a win for cells whose operation is commutative.
447
-
448
403
ELK is using a layered approach (Sugiyama, Ganser), similar to dot in the Graphviz package. You can read about their algorithm here: https://rtsys.informatik.uni-kiel.de/%7Ebiblio/downloads/papers/jvlc13.pdf
449
404
450
405
# Status
451
-
Still early stages. But it's usable. Skin definition format is still changing.
406
+
We are getting close to the 1.0 release. At that point, the skin file format will be considered specified and breaking changes will only happen on major version bumps.
0 commit comments