Open tilk opened 4 years ago
Hi, can you explain how is JSON converted into digital circuits using yosys2digitaljs? A simple workflow describing which files are being used in the process would be great.
I don't really understand your question. Yosys2digitaljs takes Yosys-genereated JSON, and generates DigitalJS-compatible JSON. Yosys's JSON format describes connections using numbered, single bit nets, while DigitalJS's format describes connections of whole ports. The complex part is converting the single bit connections to whole port connections, adding adapter elements (bit extensions, bit vector splitting and concatenation, etc.) as needed. The code is currently a little bit messy, it's here: https://github.com/tilk/yosys2digitaljs/blob/master/index.js
I saw the mention of JointJS and BackboneJS being used. Would you please help me with their functionality also. Also, You mentioned, "Yosys's JSON format describes connections using numbered, single bit nets, while DigitalJS's format describes connections of whole ports." This is pretty vague as I wasn't able to understand "DigitalJS's JSON" part. Can you help me with an example?
JointJS and BackboneJS
JointJS is used to render the circuit as a graph in an SVG and JointJS already builds on top of BackboneJS. It also uses jQuery and lodash.
DigitalJS's JSON
Please refer to the README's section on the input format. Some examples to get you started are available under examples
, e.g. a (relatively simple) fulladder.
How would you like digitaljs to react in such a case? I would propose to show a warning/error (e.g. using a red shadow) on the affected wire (or port?), perhaps with a tooltip shown on mouseover stating the problem, and only allow circuit.start()
in case there are no errors in the whole graph.
This would then also be another step towards #2 by handling invalid connections introduced by changing bit lengths after initialization.
Your proposition is fine. The information about the circuit correctness should also be accessible by code, for example by a property on HeadlessCircuit. Also, I worry about complexity of the solution. It should be simple (so that it's easy to see it's correct), and should not impact the performance for error-free circuits.
If the input JSON has a connection between different-sized ports, DigitalJS will happily connect them, with disastrous results. For example, yosys2digitaljs currently generates such a bad JSON for: