Skip to content

Commit

Permalink
Use yowasp-yosys for syntheses
Browse files Browse the repository at this point in the history
  • Loading branch information
freand76 committed Dec 16, 2023
1 parent 50d81fc commit aa8f3b5
Show file tree
Hide file tree
Showing 9 changed files with 4,272 additions and 4,017 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CHANGELOG

## vx.x.x
- Use yowasp-yoysys fir synthesis

## v0.1.0
* Fix bug when detecting number of modules with yosys 0.9
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ Then the following package must be installed:

## Yosys synthesis helper tool

**Yosys** must be installed and in your path
```
> python3 -m digsim.synth synth -i <verilog file 1> <optional verilog file 2> -o <output_file.json> -t <verilog top_module>
```
Expand Down
11 changes: 2 additions & 9 deletions docs/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ See chapter about [Yosys Synthesis](#yosys-synthesis).

When adding a Yosys component the application will bring up a file dialog where you can choose a **verilog file** or a **Yosys netlist** in json format.

If a verilog file is chosen **Yosys** must be installed and in your path.
Currently there is a limitation that the verilog file must not contain more than one module.

When the yosys component has been added to the circuit it is possible to reload the verilog file or netlist by right-clicking on the component and
Expand All @@ -176,7 +175,7 @@ A test cycle for a verilog file could be like this:
* Update verilog
* Right-click component and select **Reload**

***Important: The interface, input and output ports in the netlist must not change between load and reload.***
***Importants: The interface, input and output ports in the netlist must not change between load and reload.***

### Notes
* Notes with (or without) informative text can be added to the circuit.
Expand Down Expand Up @@ -212,16 +211,10 @@ The VCD File that later can be loaded into [GTKWave](https://gtkwave.sourceforge
[Yosys](https://github.com/YosysHQ/yosys) is an open-source verilog synthesis tool.
It can be used to create a [netlist](https://en.wikipedia.org/wiki/Netlist), a list of gates and of they are connected, from [verilog](https://en.wikipedia.org/wiki/Verilog).

Yosys can be installed with your favorite packet manager, such as aptitude in Ubuntu.
```
shell> apt install yosys
```
If you want the latest and greatest version it can be fetched from [github](https://github.com/YosysHQ/yosys).
DigSim uses a portable WebAssembly version of Yosys, [YoWASP](https://github.com/YoWASP/yosys).

More information and documentation can be found [here](https://yosyshq.net/yosys/documentation.html).

When Yosys is installed it can be started, verilog can be loaded and the synthesis process can begin.

### Synthesis with command line interface

* Start application
Expand Down
8 changes: 5 additions & 3 deletions examples/synthesis/example_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from digsim.circuit import Circuit
from digsim.circuit.components import YosysComponent
from digsim.synth import Synthesis
from digsim.synth import Synthesis, SynthesisException


example_path = Path(__file__).parent
Expand All @@ -25,8 +25,10 @@
yosys_json_output_path = str(example_path / "fibonacci.json")

print(f"Start synthesis of '{input_verilog_path}'")
synthesis = Synthesis(input_verilog_path, yosys_json_output_path, "fibonacci")
if not synthesis.execute(silent=True):
synthesis = Synthesis(input_verilog_path, "fibonacci")
try:
synthesis.synth_to_json_file(yosys_json_output_path, silent=True)
except SynthesisException:
# print log and exit if error occurs
print("\n======== Yosys Log ========")
log = synthesis.get_log()
Expand Down
Loading

0 comments on commit aa8f3b5

Please sign in to comment.