Skip to content

Commit faf2ca6

Browse files
committed
[Docs]: Add Yosys documentation
Signed-off-by: Seyed Alireza Damghani <[email protected]>
1 parent 3054751 commit faf2ca6

File tree

7 files changed

+267
-2
lines changed

7 files changed

+267
-2
lines changed

doc/src/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ For more specific documentation about VPR see :ref:`vpr`.
3838
vpr/index
3939
odin/index
4040
yosys+odin/index
41+
yosys/index
4142
abc/index
4243
tutorials/index
4344
utils/index

doc/src/yosys+odin/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ As a result, hard/soft logic trade-off decisions and heterogeneous logic inferen
4040
:maxdepth: 2
4141
:Caption: Verilog Support
4242

43-
verilog_support
43+
../yosys/verilog_support
4444

4545
.. toctree::
4646
:glob:

doc/src/yosys/dev_guide.rst

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
.. _dev_guide:
2+
3+
Developers Guide
4+
================
5+
6+
The approach of utilizing Yosys in VTR is mainly driven by what Eddie Hung proposed
7+
for the `VTR-to-Bitstream <http://eddiehung.github.io/vtb.html>`_ (VTB), based upon VTR 7.
8+
Although some files, such as `yosys_models.v <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vtr_flow/misc/yosyslib/yosys_models.v>`_
9+
and `multiply.v <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vtr_flow/misc/yosyslib/multiply.v>`_, are directly
10+
copied from the VTB project, the other files have been subjected to a few changes due to significant
11+
alterations from VTR 7 to the current version of VTR. Additionally, Hung's approach was specifically
12+
proposed for Xilinx Vertix-6 architecture. As a result, relevant changes to the remainder
13+
of Yosys library files have been applied to make them compatible with the current VTR version and support routine architectures
14+
used in the VTR regression tests.
15+
16+
What is new compared to the VTB files?
17+
--------------------------------------
18+
19+
Changes applied to the VTB files are outlined as follows:
20+
21+
1. Replacing Vertix-6 adder black-box (`xadder`) with the conventional adder used in the current version of VTR.
22+
2. If required, performing a recursive depth splitting for memory hard blocks, i.e., `single_port_ram` and `dual_port_ram`, to make them adaptable with the VTR flow configurations.
23+
3. Converting DFFs with asynchronous reset to synchronous form using `adff2dffe.v <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/ODIN_II/techlib/adff2dff.v>`_ and `adffe2dffe.v <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/ODIN_II/techlib/adffe2dff.v>`_.
24+
4. Adding the `dffunmap` command to Yosys synthesis script to transform complex DFF sub-circuits, such as SDFFE (DFF with synchronous reset and enable), to their soft logic implementation, i.e., the combination of multiplexers and latches.
25+
5. Removing the ABC commands from the Yosys synthesis script and letting the VTR flow's ABC stage performs the technology mapping.
26+
27+
.. note::
28+
The LUT size is considered the one defined in the architecture file as the same as the regular VTR flow
29+
30+
31+
How to add new changes?
32+
-----------------------
33+
34+
The Yosys synthesis commands, including the generic synthesis and additional VTR specific configurations, are provided
35+
in `synthesis.ys <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vtr_flow/misc/yosyslib/synthesis.ys>`_. To make changes in the overall Yosys synthesis flow, the `synthesis.ys <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vtr_flow/misc/yosyslib/synthesis.ys>`_
36+
script is perhaps the first file developers may require to change.
37+
38+
Moreover, the `yosys_models.v <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vtr_flow/misc/yosyslib/yosys_models.v>`_ file includes the required definitions for Yosys to how it should infer implicit
39+
memories and instantiate arithmetic operations, such as addition, subtraction, and multiplication. Therefore, to alter these
40+
behaviours or add more regulations such as how Yosys should behave when facing other arithmetic operations, for example modulo and division,
41+
the `yosys_models.v <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vtr_flow/misc/yosyslib/yosys_models.v>`_ Verilog file is required to be modified.
42+
43+
Except for `single_port_ram.v <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vtr_flow/misc/yosyslib/single_port_ram.v>`_ and `dual_port_ram.v <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vtr_flow/misc/yosyslib/dual_port_ram.v>`_ Verilog files that perform the depth splitting
44+
process, the other files are defined as black-box, i.e., their declarations are required while no definition is needed. To add new black-box
45+
components, developers should first provide the corresponding Verilog files similar to the `adder.v <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vtr_flow/misc/yosyslib/adder.v>`_. Then, a new `read_verilog -lib TTT/NEW_BB.v`
46+
command should be added to the Yosys synthesis script. If there is an implicit inference of the new black-box component, the `yosys_models.v <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vtr_flow/misc/yosyslib/yosys_models.v>`_
47+
Verilog file must also be modified, as mentioned earlier.
48+
49+
50+
Yosys Synthesis Script File
51+
---------------------------
52+
53+
.. code-block:: tcl
54+
55+
# XXX (input circuit) is replaced with filename by the run_vtr_flow script
56+
read_verilog -nolatches XXX
57+
58+
# These commands follow the generic `synth`
59+
# command script inside Yosys
60+
# The -libdir argument allows Yosys to search the current
61+
# directory for any definitions to modules it doesn't know
62+
# about, such as hand-instantiated (not inferred) memories
63+
hierarchy -check -auto-top -libdir .
64+
proc
65+
66+
# Check that there are no combinational loops
67+
scc -select
68+
select -assert-none %
69+
select -clear
70+
71+
72+
opt_expr
73+
opt_clean
74+
check
75+
opt -nodffe -nosdff
76+
fsm
77+
opt
78+
wreduce
79+
peepopt
80+
opt_clean
81+
share
82+
opt
83+
memory -nomap
84+
opt -full
85+
86+
# Transform all async FFs into synchronous ones
87+
techmap -map +/adff2dff.v
88+
techmap -map TTT/../../../ODIN_II/techlib/adffe2dff.v
89+
90+
# Map multipliers, DSPs, and add/subtracts according to yosys_models.v
91+
techmap -map YYY */t:$mul */t:$mem */t:$sub */t:$add
92+
opt -fast -full
93+
94+
memory_map
95+
# Taking care to remove any undefined muxes that
96+
# are introduced to promote resource sharing
97+
opt -full
98+
99+
# Then techmap all other `complex` blocks into basic
100+
# (lookup table) logic
101+
techmap
102+
opt -fast
103+
104+
# We read the definitions for all the VTR primitives
105+
# as blackboxes
106+
read_verilog -lib TTT/adder.v
107+
read_verilog -lib TTT/multiply.v
108+
read_verilog -lib SSS #(SSS) will be replaced by single_port_ram.v by python script
109+
read_verilog -lib DDD #(DDD) will be replaced by dual_port_ram.v by python script
110+
111+
# Rename singlePortRam to single_port_ram
112+
# Rename dualPortRam to dualZ_port_ram
113+
# rename function of Yosys not work here
114+
# since it may outcome hierarchy error
115+
read_verilog SSR #(SSR) will be replaced by spram_rename.v by python script
116+
read_verilog DDR #(DDR) will be replaced by dpram_rename.v by python script
117+
118+
# Flatten the netlist
119+
flatten
120+
# Turn all DFFs into simple latches
121+
dffunmap
122+
opt -fast -noff
123+
124+
# Lastly, check the hierarchy for any unknown modules,
125+
# and purge all modules (including blackboxes) that
126+
# aren't used
127+
hierarchy -check -purge_lib
128+
tee -o /dev/stdout stat
129+
130+
autoname
131+
132+
# Then write it out as a blif file, remembering to call
133+
# the internal `$true`/`$false` signals vcc/gnd, but
134+
# switch `-impltf` doesn't output them
135+
# ZZZ will be replaced by run_vtr_flow.pl
136+
write_blif -true + vcc -false + gnd -undef + unconn -blackbox ZZZ
137+
138+
**Algorithm 1** - The Yosys Tcl Script File

doc/src/yosys/index.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.. _Yosys:
2+
3+
#####
4+
Yosys
5+
#####
6+
7+
Yosys is a framework for Verilog RTL synthesis, used as one of three VTR front-ends to perform logic synthesis, elaboration,
8+
and converting a subset of the Verilog Hardware Description Language (HDL) into a BLIF netlist.
9+
10+
.. image:: ../yosys+odin/dev_guide/YosysOdinFlow.png
11+
:width: 100%
12+
:alt: The Odin-II, Yosys, and Yosys+Odin-II Synthesis Flows
13+
14+
.. toctree::
15+
:glob:
16+
:maxdepth: 2
17+
:Caption: Quickstart
18+
19+
quickstart
20+
21+
22+
.. toctree::
23+
:glob:
24+
:maxdepth: 2
25+
:Caption: Developer Guide
26+
27+
dev_guide
28+
29+
.. toctree::
30+
:glob:
31+
:maxdepth: 2
32+
:Caption: Verilog Support
33+
34+
verilog_support
35+
36+
.. toctree::
37+
:glob:
38+
:maxdepth: 2
39+
:Caption: Structure
40+
41+
structure

doc/src/yosys/quickstart.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.. _quickstart:
2+
3+
Quickstart
4+
==========
5+
6+
Prerequisites
7+
-------------
8+
9+
* ctags
10+
* bison
11+
* flex
12+
* gcc 5.x
13+
* cmake 3.9 (minimum version)
14+
* time
15+
* cairo
16+
* gawk
17+
* xdot
18+
* tcl-dev
19+
* graphviz
20+
* pkg-config
21+
* python3
22+
* libffi-dev
23+
* libreadline-dev
24+
* libboost-system-dev
25+
* libboost-python-dev
26+
* libboost-filesystem-dev
27+
* zlib1g-dev
28+
29+
Building
30+
--------
31+
32+
To build the VTR flow with the Yosys front-end you may use the VTR Makefile wrapper, by calling the ``make CMAKE_PARAMS="-DWITH_YOSYS=ON"`` command in the `$VTR_ROOT` directory.
33+
The compile flag ``-DWITH_YOSYS=ON`` should be passed to the CMake parameters to enable Yosys compilation process.
34+
35+
.. note::
36+
37+
Yosys uses Makefile as its build system. Since CMake provides portable, cross-platform build systems with many useful features, we provide a CMake wrapper to successfully embeds the Yosys library into the VTR flow.
38+
39+
40+
Basic Usage
41+
-----------
42+
43+
To run the VTR flow with the Yosys front-end, you would need to run the `run_vtr_flow.py <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vtr_flow/scripts/run_vtr_flow.py>`_ script with the start stage specified as `Yosys`.
44+
45+
.. code-block:: bash
46+
47+
./run_vtr_flow `PATH_TO_VERILOG_FILE.v` `PATH_TO_ARCH_FILE.xml` -start yosys

doc/src/yosys/structure.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.. _structure:
2+
3+
Structure
4+
=========
5+
6+
Structure of Yosys Synthesis Files and the Yosys External Library Library
7+
-------------------------------------------------------------------------
8+
9+
.. code-block:: bash
10+
11+
└── $VTR_ROOT
12+
├── vtr_flow
13+
│ └── misc
14+
│ └── yosyslib
15+
│ ├── adder.v
16+
│ ├── dpram_rename.v
17+
│ ├── dual_port_ram.v
18+
│ ├── multiply.v
19+
│ ├── single_port_ram.v
20+
│ ├── spram_rename.v
21+
│ ├── synthesis.ys
22+
│ └── yosys_models.v
23+
└── libs
24+
└── EXTERNAL
25+
└── libyosys
26+
├── backends
27+
├── examples
28+
├── frontends
29+
├── guidelines
30+
├── kernel
31+
├── libs
32+
├── manual
33+
├── misc
34+
├── passes
35+
├── techlibs
36+
└── tests

doc/src/yosys+odin/verilog_support.rst renamed to doc/src/yosys/verilog_support.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
.. _verilog_support:
2+
13
Verilog Support
24
===============
35

4-
Yosys+Odin-II, with Yosys as the front-end elaborator, has extensive Verilog IEEE-2005 support. Please see the `Yosys GitHub <https://github.com/YosysHQ/yosys#unsupported-verilog-2005-features>`_ repository for more information on a few unsupported Verilog-2005 features.
6+
Yosys RTL framework has extensive Verilog IEEE-2005 support. Please see the `Yosys GitHub <https://github.com/YosysHQ/yosys#unsupported-verilog-2005-features>`_ repository for more information on a few unsupported Verilog-2005 features.
57

68
Unsupported Verilog-2005 features by Yosys
79
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)