Skip to content

Commit 4be1daf

Browse files
committed
2 parents 8ff57de + ac98250 commit 4be1daf

File tree

1 file changed

+13
-58
lines changed

1 file changed

+13
-58
lines changed

README.md

+13-58
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
[![Build Status](https://travis-ci.org/nturley/netlistsvg.svg?branch=master)](https://travis-ci.org/nturley/netlistsvg)
1+
[![Linux Build Status](https://travis-ci.org/nturley/netlistsvg.svg?branch=master)](https://travis-ci.org/nturley/netlistsvg)
2+
[![Windows Build status](https://ci.appveyor.com/api/projects/status/heijuq5nhw9m7rib/branch/master?svg=true)](https://ci.appveyor.com/project/nturley/netlistsvg/branch/master)
23
[![Gitter chat](https://badges.gitter.im/nturley/netlistsvg.png)](https://gitter.im/netlistsvg)
34
[![npm version](https://badge.fury.io/js/netlistsvg.svg)](https://badge.fury.io/js/netlistsvg)
5+
![npm](https://img.shields.io/npm/dm/netlistsvg.svg)
6+
47
# netlistsvg
5-
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.
69

710
You can see an online demo [here](https://nturley.github.io/netlistsvg)
811

12+
Here's an digital netlist produced by Yosys along with the diagram that netlistsvg created from it.
913
<details>
1014
<summary>JSON Source</summary>
1115

@@ -225,7 +229,7 @@ You can see an online demo [here](https://nturley.github.io/netlistsvg)
225229
</details>
226230
<img src="https://cdn.rawgit.com/nturley/netlistsvg/d01285946e05ee5ce99dc5d0f8025be58b5936a3/doc/up3down5.svg" />
227231

228-
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.
229233

230234
<details>
231235
<summary>JSON Source</summary>
@@ -360,57 +364,12 @@ The elkjs layout properties are also defined in the skin file.
360364
org.eclipse.elk.direction="DOWN"
361365
/>
362366
```
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.
369-
370-
<details>
371-
<summary>JSON Source</summary>
372-
373-
```json
374-
{
375-
"modules": {
376-
"simple": {
377-
"ports": {
378-
"inthing": {
379-
"direction": "input",
380-
"bits": [ 2, 3, 4, 5 ]
381-
},
382-
"outthing": {
383-
"direction": "output",
384-
"bits": [ 2, 3 ]
385-
},
386-
"outthing2": {
387-
"direction": "output",
388-
"bits": [ 2, 3, 5 ]
389-
},
390-
"outthing3": {
391-
"direction": "output",
392-
"bits": [ 2, 3, 5 ]
393-
},
394-
"outthing4": {
395-
"direction": "output",
396-
"bits": [ 2 ]
397-
}
398-
},
399-
"cells": {}
400-
}
401-
}
402-
}
403-
```
404-
</details>
405-
<img src="https://cdn.rawgit.com/nturley/netlistsvg/d01285946e05ee5ce99dc5d0f8025be58b5936a3/doc/ports_splitjoin.svg" >
406-
407-
* 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).
411368

412369
## 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.
414373
```json
415374
{
416375
"modules": {
@@ -441,14 +400,10 @@ This is designed to handle Yosys netlist format but we ignore most of it. This i
441400
```
442401

443402
## 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-
448403
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
449404

450405
# 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.
452407

453408
# Installation/Usage Instructions
454409

@@ -463,7 +418,7 @@ netlistsvg input_json_file [-o output_svg_file] [--skin skin_file]
463418
```
464419
The default value for the output file is out.svg.
465420

466-
Should work on Linux, OSX, and Windows. Running the build scripts (examples makefiles and the web demo) is easiest on Linux and OSX.
421+
Should work on Linux, OSX, and Windows. Running the build scripts (makefiles and the web demo) is easiest on Linux and OSX.
467422

468423
## Generating `input_json_file` with Yosys
469424

0 commit comments

Comments
 (0)