npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

d3-hwschematic

v0.1.6

Published

D3.js and ELK based schematic visualizer

Downloads

134

Readme

d3-hwschematic

Travis-ci Build Status Windows Build Status npm versionCoverage StatusDocumentation Status

D3.js and ELK based schematic visualizer.

Use npm install d3-hwschematic --save to install this library and save it to your package.json file.

Features:

  • automatic layout (layered graph with orthogonal routing, created by elkjs) with caching
  • hierarchical components expandable on click
  • net selection on click, highligh and tooltip on mouse over
  • zoom, drag
  • css style/class specifiable in input json, d3.js querey as a query language in javascript
  • support for user node renderers and user CSS
  • input is ELK json with hwMeta propoperty (described in this document)

cdc_pulse_gen

Typical usecase

How to use examples

Online

  • Documentation of hwtLib. (Look for scheme href under component name.)

  • jupyter_widget_hwt - Jupyter widgets for hw developement.

From this git

  1. download dependencies and build this library
npm install
npm install --only=dev
npm run build
  1. Then you can open examples, but current web browsers does not allow to load files from local disk (because of security). It has multiple solution
  • You can run chrome with --allow-file-access-from-files option
  • (prefered) Or use webserver. One webserver implementation is part of standard python distribution.
# (in root directory of this git)
python3 -m http.server 8888

Now you should be able to view the example application on http://0.0.0.0:8888/examples/example.html?schematic=/examples/schemes/Cdc.json. Where part after schematic= is path to json file where schematic is stored.

ELK json format for d3-hwschematic

This libarary uses ELK json, ELK options. This format is basically a component tree stored in json. The json specifies not just the structure of circuit but also how the circuit should be rendered. It contains 3 object types LNode, LPort and LEdge.

ELK LNode (component instance)

{
  "id": "0",
  "hwMeta": { // [d3-hwschematic specific]
    "name": "compoent instance name", // optional str
    "cls": "compoent (module) name", // optional str
    "bodyText": "", // optional str
    "maxId": 2, // max id of any object in this node used to avoid re-counting object if new object is generated
    "isExternalPort": true // optional flag which set component style to external port
    "cssClass": "node-style0", // optional string, css classes separated by space
    "cssStyle": "fill:red", // css style specification separated by ;
  },
  "hideChildren": true, // [d3-hwschematic specific] optional flag, if true the body of component is collapsed
  "properties": { // recommended renderer settings
    "org.eclipse.elk.portConstraints": "FIXED_ORDER", // can be also "FREE" or other value accepted by ELK
    "org.eclipse.elk.layered.mergeEdges": 1
  },
  "ports": [],    // list of LPort
  "edges": [],    // list of LEdge
  "children": [], // list of LNode, if the node should be collapsed rename this property
                  // to "_children" and "edges" to "_edges"
}

If the children should be collapsed by default, the children children and edges property should be renamed to _children and _edges.

ELK LPort

{
  "id": "1",
  "hwMeta": { // [d3-hwschematic specific]
    "name": "port name",
    "cssClass": "node-style0", // optional string, css classes separated by space
    "cssStyle": "fill:red", // css style specification separated by ;
    "connectedAsParent": true, // an optional flag that notes that this port
                               // has no connections but it is connected as its parent port
  },
  "direction": "OUTPUT", // [d3-hwschematic specific] controlls direction marker
  "properties": {
    "portSide": "EAST",
    "portIndex": 0 // The order is assumed as clockwise, starting with the leftmost port on the top side.
                   // Required only for components with "org.eclipse.elk.portConstraints": "FIXED_ORDER"
  },
  "children": [], // list of LPort, if the port should be collapsed rename this property to "_children"
}

ELK LEdge

{ // simple LEdge
  "id": "62",
  "source": "2", // id of component
  "sourcePort": "23", // id of component port
  "target": "4", // id of component
  "targetPort": "29", // id of component port
  "hwMeta": { // [d3-hwschematic specific]
    "name": null // optional string, displayed on mouse over
    "cssClass": "link-style0", // optional string, css classes separated by space
    "cssStyle": "stroke:red", // css style specification separated by ;
  }
}
{ // hyper LEdge
  "id": "1119",
  "sources": [
    ["17", "343"]  // id of component, id of port
  ],
  "targets": [
    [ "18", "346"],  // id of component, id of port
    [ "21", "354"],
  ],
  "hwMeta": { // [d3-hwschematic specific]
    "name": "wr_ptr",
    "cssClass": "link-style0", // optional string, css classes separated by space
    "cssStyle": "stroke:red", // css style specification separated by ;
  }
}

LEdge souce destination has to always be directly visible from the LNode where the LEdge is instanciated. That means that LEdge may connect only to ports of current LNode or to ports of this LNode direct children LNodes. LNode represents all types of components. Top component ports are also represented as LNode because it looks better.

Component shapes

The style and shape is determined by node renderers. Node renderers are defined in src/node_renderers. Renderer classes can be registered using HwSchematic.nodeRenderers.registerRenderer() function on HwSchematic object. The node renderer has function select which is used to determine if renderer should be used for for selected LNode.

Similar opensource projects

  • netlistsvg - draws an SVG schematic from a JSON netlist
  • pyVhdl2Sch - Python based VHDL to (pdf) schematic converter
  • verilog-dot - Python, A simple dot file / graph generator for Verilog syntax trees.
  • diagrammer - Scala, Very simple visualizer for chisel3.
  • hwstudio - GDScript, GUI editor for hardware description designs
  • Spyce - Python, Simple circuit editor, MyHDL output (only prototype)
  • circuitsandbox - Java, Boolean network editor and simulator
  • BreadboardSim - C#, Circuit Simulator with Breadboard UI
  • hneemann/Digital - Java, Circut simulator and editor
  • adaptagrams - C++, Libraries for constraint-based layout and connector routing for diagrams.
  • sphinxcontrib-verilog-diagrams - Python, Sphinx Extension which generates various types of diagrams from Verilog code.
  • logidrom - JS, Digital circuit renderer for some specific circuits
  • dkilfoyle/logic - JS, IDE for digital circuit simulation
  • Eclipse Layout Kernel (ELK) - Java, Libary focused on automatic graph drawing.
  • elkjs - JS, ELK transpiled to JS, (used in this project)
  • ogdf - C++, Libary focused on automatic graph drawing.
  • hdelk - Web-based HDL diagramming tool
  • Siva - Python, Qt based scheme editor