|
| 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 |
0 commit comments