2023-12-06 18:04:46 -06:00
|
|
|
Synthesis starter
|
|
|
|
-----------------
|
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
This page will be a guided walkthrough of the prepackaged iCE40 FPGA synthesis
|
|
|
|
script - :cmd:ref:`synth_ice40`. We will take a simple design through each
|
|
|
|
step, looking at the commands being called and what they do to the design. While
|
|
|
|
:cmd:ref:`synth_ice40` is specific to the iCE40 platform, most of the operations
|
|
|
|
we will be discussing are common across the majority of FPGA synthesis scripts.
|
|
|
|
Thus, this document will provide a good foundational understanding of how
|
|
|
|
synthesis in Yosys is performed, regardless of the actual architecture being
|
|
|
|
used.
|
|
|
|
|
|
|
|
.. seealso:: Advanced usage docs for
|
|
|
|
:doc:`/using_yosys/synthesis/synth`
|
2023-12-06 22:14:21 -06:00
|
|
|
|
2023-12-13 21:21:52 -06:00
|
|
|
Demo design
|
|
|
|
~~~~~~~~~~~
|
2023-12-06 18:04:46 -06:00
|
|
|
|
|
|
|
.. role:: yoscrypt(code)
|
|
|
|
:language: yoscrypt
|
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
First, let's quickly look at the design we'll be synthesizing:
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 21:21:52 -06:00
|
|
|
.. todo:: reconsider including the whole (~77 line) design like this
|
|
|
|
|
2023-12-17 18:19:01 -06:00
|
|
|
.. literalinclude:: /code_examples/fifo/fifo.v
|
2023-12-06 18:04:46 -06:00
|
|
|
:language: Verilog
|
|
|
|
:linenos:
|
2023-12-17 18:19:01 -06:00
|
|
|
:caption: ``fifo.v``
|
|
|
|
:name: fifo-v
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-17 18:19:01 -06:00
|
|
|
.. todo:: fifo.v description
|
2023-12-06 18:04:46 -06:00
|
|
|
|
|
|
|
Loading the design
|
|
|
|
~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Let's load the design into Yosys. From the command line, we can call ``yosys
|
2023-12-17 18:19:01 -06:00
|
|
|
fifo.v``. This will open an interactive Yosys shell session and immediately
|
|
|
|
parse the code from ``fifo.v`` and convert it into an Abstract Syntax Tree
|
2023-12-06 18:04:46 -06:00
|
|
|
(AST). If you are interested in how this happens, there is more information in
|
|
|
|
the document, :doc:`/yosys_internals/flow/verilog_frontend`. For now, suffice
|
|
|
|
it to say that we do this to simplify further processing of the design. You
|
|
|
|
should see something like the following:
|
|
|
|
|
2023-12-17 18:19:01 -06:00
|
|
|
.. literalinclude:: /code_examples/fifo/fifo.out
|
|
|
|
:language: console
|
|
|
|
:start-at: $ yosys fifo.v
|
|
|
|
:end-before: echo on
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
.. seealso:: Advanced usage docs for
|
|
|
|
:doc:`/using_yosys/more_scripting/load_design`
|
|
|
|
|
|
|
|
Elaboration
|
|
|
|
~~~~~~~~~~~
|
|
|
|
|
2023-12-06 18:04:46 -06:00
|
|
|
Now that we are in the interactive shell, we can call Yosys commands directly.
|
2023-12-17 18:19:01 -06:00
|
|
|
Our overall goal is to call :yoscrypt:`synth_ice40 -top fifo`, but for now we
|
2023-12-13 16:30:51 -06:00
|
|
|
can run each of the commands individually for a better sense of how each part
|
2023-12-13 21:21:52 -06:00
|
|
|
contributes to the flow. We will also start with just a single module;
|
2023-12-17 18:19:01 -06:00
|
|
|
``addr_gen``.
|
2023-12-13 21:21:52 -06:00
|
|
|
|
|
|
|
At the bottom of the :cmd:ref:`help` output for
|
2023-12-13 16:30:51 -06:00
|
|
|
:cmd:ref:`synth_ice40` is the complete list of commands called by this script.
|
|
|
|
Let's start with the section labeled ``begin``:
|
|
|
|
|
|
|
|
.. literalinclude:: /cmd/synth_ice40.rst
|
|
|
|
:language: yoscrypt
|
|
|
|
:start-after: begin:
|
|
|
|
:end-before: flatten:
|
|
|
|
:dedent:
|
|
|
|
:caption: ``begin`` section
|
2023-12-13 21:21:52 -06:00
|
|
|
:name: synth_begin
|
2023-12-13 16:30:51 -06:00
|
|
|
|
|
|
|
:yoscrypt:`read_verilog -D ICE40_HX -lib -specify +/ice40/cells_sim.v` loads the
|
|
|
|
iCE40 cell models which allows us to include platform specific IP blocks in our
|
|
|
|
design. PLLs are a common example of this, where we might need to reference
|
|
|
|
``SB_PLL40_CORE`` directly rather than being able to rely on mapping passes
|
|
|
|
later. Since our simple design doesn't use any of these IP blocks, we can safely
|
|
|
|
skip this command.
|
|
|
|
|
2023-12-17 18:19:01 -06:00
|
|
|
The addr_gen module
|
|
|
|
^^^^^^^^^^^^^^^^^^^
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 21:21:52 -06:00
|
|
|
Since we're just getting started, let's instead begin with :yoscrypt:`hierarchy
|
2023-12-17 18:19:01 -06:00
|
|
|
-top addr_gen`. This command declares that the top level module is ``addr_gen``,
|
2023-12-13 21:21:52 -06:00
|
|
|
and everything else can be discarded.
|
|
|
|
|
2023-12-17 18:19:01 -06:00
|
|
|
.. literalinclude:: /code_examples/fifo/fifo.v
|
2023-12-13 21:21:52 -06:00
|
|
|
:language: Verilog
|
2023-12-17 18:19:01 -06:00
|
|
|
:start-at: module addr_gen
|
|
|
|
:end-at: endmodule //addr_gen
|
2023-12-13 21:21:52 -06:00
|
|
|
:lineno-match:
|
2023-12-17 18:19:01 -06:00
|
|
|
:caption: ``addr_gen`` module source
|
|
|
|
:name: addr_gen-v
|
2023-12-06 18:04:46 -06:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
:cmd:ref:`hierarchy` should always be the first command after the design has
|
|
|
|
been read.
|
|
|
|
|
|
|
|
.. use doscon for a console-like display that supports the `yosys> [command]` format.
|
|
|
|
|
2023-12-17 18:19:01 -06:00
|
|
|
.. literalinclude:: /code_examples/fifo/fifo.out
|
2023-12-13 21:21:52 -06:00
|
|
|
:language: doscon
|
2023-12-17 18:19:01 -06:00
|
|
|
:start-at: yosys> hierarchy -top addr_gen
|
2023-12-17 22:49:15 -06:00
|
|
|
:end-before: yosys> select
|
2023-12-17 18:19:01 -06:00
|
|
|
:caption: :yoscrypt:`hierarchy -top addr_gen` output
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-17 18:19:01 -06:00
|
|
|
Our ``addr_gen`` circuit now looks like this:
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-17 18:19:01 -06:00
|
|
|
.. figure:: /_images/code_examples/fifo/addr_gen_hier.*
|
2023-12-06 18:04:46 -06:00
|
|
|
:class: width-helper
|
2023-12-17 18:19:01 -06:00
|
|
|
:name: addr_gen_hier
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-17 18:19:01 -06:00
|
|
|
``addr_gen`` module after :cmd:ref:`hierarchy`
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-17 22:49:15 -06:00
|
|
|
.. todo:: how to highlight PROC blocks?
|
|
|
|
They seem to be replaced in ``show``, so the selection never matches
|
|
|
|
|
|
|
|
Simple operations like ``addr + 1`` and ``addr == MAX_DATA-1`` can be extracted
|
|
|
|
from our ``always @`` block in :ref:`addr_gen-v`. This gives us the highlighted
|
|
|
|
``$add`` and ``$eq`` cells we see. But control logic (like the ``if .. else``)
|
|
|
|
and memory elements (like the ``addr <= 0``) are not so straightforward. These
|
|
|
|
get put into "processes", shown in the schematic as ``PROC``. Note how the
|
|
|
|
second line refers to the line numbers of the start/end of the corresponding
|
|
|
|
``always @`` block. In the case of an ``initial`` block, we instead see the
|
|
|
|
``PROC`` referring to line 0.
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-17 22:49:15 -06:00
|
|
|
To handle these, let us now introduce the next command: :doc:`/cmd/proc`.
|
2023-12-13 16:30:51 -06:00
|
|
|
:cmd:ref:`proc` is a macro command like :cmd:ref:`synth_ice40`. Rather than
|
2023-12-13 21:21:52 -06:00
|
|
|
modifying the design directly, it instead calls a series of other commands. In
|
2023-12-13 16:30:51 -06:00
|
|
|
the case of :cmd:ref:`proc`, these sub-commands work to convert the behavioral
|
2023-12-13 21:21:52 -06:00
|
|
|
logic of processes into multiplexers and registers. Let's see what happens when
|
|
|
|
we run it.
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-17 18:19:01 -06:00
|
|
|
.. figure:: /_images/code_examples/fifo/addr_gen_proc.*
|
2023-12-06 18:04:46 -06:00
|
|
|
:class: width-helper
|
2023-12-17 18:19:01 -06:00
|
|
|
:name: addr_gen_proc
|
|
|
|
|
|
|
|
``addr_gen`` module after :cmd:ref:`proc`
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-17 22:49:15 -06:00
|
|
|
There are now a few new cells from our ``always @``, which have been
|
|
|
|
highlighted. The ``if`` statements are now modeled with ``$mux`` cells, while
|
|
|
|
the register uses an ``$adff`` cell. If we look at the terminal output we can
|
|
|
|
also see all of the different ``proc_*`` commands being called. We will look at
|
|
|
|
each of these in more detail in :doc:`/using_yosys/synthesis/proc`.
|
|
|
|
|
|
|
|
.. TODO:: intro ``opt_expr``
|
|
|
|
:doc:`/cmd/opt_expr`
|
|
|
|
|
|
|
|
- by default called at the end of :cmd:ref:`proc`
|
|
|
|
|
|
|
|
Notice how in the top left of :ref:`addr_gen_proc` we have a floating wire,
|
|
|
|
generated from the initial assignment of 0 to the ``addr`` wire. However, this
|
|
|
|
initial assignment is not synthesizable, so this will need to be cleaned up
|
|
|
|
before we can generate the physical hardware. We can do this now by calling
|
|
|
|
:cmd:ref:`opt_clean`:
|
|
|
|
|
|
|
|
.. figure:: /_images/code_examples/fifo/addr_gen_clean.*
|
|
|
|
:class: width-helper
|
|
|
|
:name: addr_gen_clean
|
|
|
|
|
|
|
|
``addr_gen`` module after :cmd:ref:`opt_clean`
|
|
|
|
|
|
|
|
.. TODO:: more on opt_clean
|
|
|
|
:doc:`/cmd/opt_clean`
|
|
|
|
|
|
|
|
- :cmd:ref:`clean` for short, ``;;`` for even shorter
|
|
|
|
- final command of :cmd:ref:`opt`
|
|
|
|
- can run at any time
|
2023-12-13 21:21:52 -06:00
|
|
|
|
2023-12-17 18:19:01 -06:00
|
|
|
.. todo:: consider a brief glossary for terms like adff
|
2023-12-13 21:21:52 -06:00
|
|
|
|
|
|
|
The full example
|
|
|
|
^^^^^^^^^^^^^^^^
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 21:21:52 -06:00
|
|
|
Let's now go back and check on our full design by using :yoscrypt:`hierarchy
|
2023-12-17 18:19:01 -06:00
|
|
|
-check -top fifo`. By passing the ``-check`` option there we are also
|
2023-12-13 21:21:52 -06:00
|
|
|
telling the :cmd:ref:`hierarchy` command that if the design includes any
|
|
|
|
non-blackbox modules without an implementation it should return an error.
|
|
|
|
|
|
|
|
Note that if we tried to run this command now then we would get an error. This
|
2023-12-17 18:19:01 -06:00
|
|
|
is because we already removed all of the modules other than ``addr_gen``. We
|
2023-12-13 21:21:52 -06:00
|
|
|
could restart our shell session, but instead let's use two new commands:
|
|
|
|
|
|
|
|
- :doc:`/cmd/design`, and
|
|
|
|
- :doc:`/cmd/read_verilog`.
|
|
|
|
|
2023-12-17 18:19:01 -06:00
|
|
|
.. literalinclude:: /code_examples/fifo/fifo.out
|
2023-12-13 21:21:52 -06:00
|
|
|
:language: doscon
|
|
|
|
:start-at: design -reset
|
2023-12-17 18:19:01 -06:00
|
|
|
:end-before: yosys> proc
|
|
|
|
:caption: reloading ``fifo.v`` and running :yoscrypt:`hierarchy -check -top fifo`
|
2023-12-13 21:21:52 -06:00
|
|
|
|
|
|
|
Notice how this time we didn't see any of those `$abstract` modules? That's
|
2023-12-17 18:19:01 -06:00
|
|
|
because when we ran ``yosys fifo.v``, the first command Yosys called was
|
|
|
|
:yoscrypt:`read_verilog -defer fifo.v`. The ``-defer`` option there tells
|
2023-12-13 21:21:52 -06:00
|
|
|
:cmd:ref:`read_verilog` only read the abstract syntax tree and defer actual
|
|
|
|
compilation to a later :cmd:ref:`hierarchy` command. This is useful in cases
|
2023-12-17 18:19:01 -06:00
|
|
|
where the default parameters of modules yield invalid code which is not
|
|
|
|
synthesizable. This is why Yosys defers compilation automatically and is one of
|
|
|
|
the reasons why hierarchy should always be the first command after loading the
|
|
|
|
design. If we know that our design won't run into this issue, we can skip the
|
|
|
|
``-defer``.
|
|
|
|
|
|
|
|
.. TODO:: more on why :cmd:ref:`hierarchy` is important
|
2023-12-13 21:21:52 -06:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
The number before a command's output increments with each command run. Don't
|
|
|
|
worry if your numbers don't match ours! The output you are seeing comes from
|
|
|
|
the same script that was used to generate the images in this document,
|
2023-12-17 18:19:01 -06:00
|
|
|
included in the source as ``fifo.ys``. There are extra commands being run
|
2023-12-13 21:21:52 -06:00
|
|
|
which you don't see, but feel free to try them yourself, or play around with
|
|
|
|
different commands. You can always start over with a clean slate by calling
|
|
|
|
``exit`` or hitting ``ctrl+c`` (i.e. SIGINT) and re-launching the Yosys
|
|
|
|
interactive terminal.
|
|
|
|
|
2023-12-17 18:19:01 -06:00
|
|
|
We can also run :cmd:ref:`proc` now to finish off the full :ref:`synth_begin`.
|
|
|
|
Because the design schematic is quite large, we will be showing just the data
|
|
|
|
path for the ``rdata`` output. If you would like to see the entire design for
|
|
|
|
yourself, you can do so with :doc:`/cmd/show`. Note that the :cmd:ref:`show`
|
|
|
|
command only works with a single module, so you may need to call it with
|
|
|
|
:yoscrypt:`show fifo`.
|
|
|
|
|
|
|
|
.. figure:: /_images/code_examples/fifo/rdata_proc.*
|
2023-12-13 21:21:52 -06:00
|
|
|
:class: width-helper
|
2023-12-17 18:19:01 -06:00
|
|
|
:name: rdata_proc
|
2023-12-13 21:21:52 -06:00
|
|
|
|
2023-12-17 18:19:01 -06:00
|
|
|
``rdata`` output after :cmd:ref:`proc`
|
2023-12-13 21:21:52 -06:00
|
|
|
|
2023-12-17 22:49:15 -06:00
|
|
|
The highlighted ``fifo_reader`` block contains an instance of the
|
|
|
|
:ref:`addr_gen_proc` that we looked at earlier. Notice how the type is shown as
|
|
|
|
``$paramod\\addr_gen\\MAX_DATA=s32'...``. This is a "parametric module"; an
|
|
|
|
instance of the ``addr_gen`` module with the ``MAX_DATA`` set to the given
|
|
|
|
value.
|
2023-12-13 21:21:52 -06:00
|
|
|
|
2023-12-17 18:19:01 -06:00
|
|
|
.. TODO:: comment on ``$memrd``
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
.. seealso:: Advanced usage docs for
|
|
|
|
:doc:`/using_yosys/synthesis/proc`
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
Flattening
|
|
|
|
~~~~~~~~~~
|
2023-12-06 18:04:46 -06:00
|
|
|
|
|
|
|
At this stage of a synthesis flow there are a few other commands we could run.
|
2023-12-13 21:21:52 -06:00
|
|
|
In :cmd:ref:`synth_ice40` we get these:
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
.. literalinclude:: /cmd/synth_ice40.rst
|
|
|
|
:language: yoscrypt
|
|
|
|
:start-after: flatten:
|
|
|
|
:end-before: coarse:
|
|
|
|
:dedent:
|
2023-12-13 21:21:52 -06:00
|
|
|
:name: synth_flatten
|
2023-12-13 16:30:51 -06:00
|
|
|
:caption: ``flatten`` section
|
|
|
|
|
2023-12-17 22:49:15 -06:00
|
|
|
First off is :cmd:ref:`flatten`. Flattening the design like this can allow for
|
|
|
|
optimizations between modules which would otherwise be missed. Let's run
|
|
|
|
:yoscrypt:`flatten;;` on our design.
|
|
|
|
|
|
|
|
.. literalinclude:: /code_examples/fifo/fifo.out
|
|
|
|
:language: doscon
|
|
|
|
:start-at: yosys> flatten
|
|
|
|
:end-before: yosys> show
|
|
|
|
:name: flat_clean
|
|
|
|
:caption: output of :yoscrypt:`flatten;;`
|
2023-12-17 18:19:01 -06:00
|
|
|
|
|
|
|
.. figure:: /_images/code_examples/fifo/rdata_flat.*
|
|
|
|
:class: width-helper
|
|
|
|
:name: rdata_flat
|
|
|
|
|
2023-12-17 22:49:15 -06:00
|
|
|
``rdata`` output after :yoscrypt:`flatten;;`
|
|
|
|
|
|
|
|
We can now see both :ref:`rdata_proc` and :ref:`addr_gen_proc` together. Note
|
|
|
|
that in the :ref:`flat_clean` we see above has two separate calls: one to
|
|
|
|
:cmd:ref:`flatten` and one to :cmd:ref:`clean`. In an interactive terminal the
|
|
|
|
output of both commands will be combined into the single `yosys> flatten;;`
|
|
|
|
output.
|
2023-12-13 21:21:52 -06:00
|
|
|
|
|
|
|
Depending on the target architecture, we might also see commands such as
|
|
|
|
:cmd:ref:`tribuf` with the ``-logic`` option and :cmd:ref:`deminout`. These
|
|
|
|
remove tristate and inout constructs respectively, replacing them with logic
|
|
|
|
suitable for mapping to an FPGA.
|
2023-12-07 16:19:12 -06:00
|
|
|
|
2023-12-06 18:04:46 -06:00
|
|
|
The coarse-grain representation
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
At this stage, the design is in coarse-grain representation. It still looks
|
2023-12-13 16:30:51 -06:00
|
|
|
recognizable, and cells are word-level operators with parametrizable width. This
|
|
|
|
is the stage of synthesis where we do things like const propagation, expression
|
2023-12-06 18:04:46 -06:00
|
|
|
rewriting, and trimming unused parts of wires.
|
|
|
|
|
|
|
|
This is also where we convert our FSMs and hard blocks like DSPs or memories.
|
|
|
|
Such elements have to be inferred from patterns in the design and there are
|
|
|
|
special passes for each. Detection of these patterns can also be affected by
|
|
|
|
optimizations and other transformations done previously.
|
|
|
|
|
2023-12-17 22:49:15 -06:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
While the iCE40 flow had a :ref:`synth_flatten` and put :cmd:ref:`proc` in
|
|
|
|
the :ref:`synth_begin`, some synthesis scripts will instead include these in
|
|
|
|
the :ref:`synth_coarse`.
|
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
In the iCE40 flow we get all the following commands:
|
|
|
|
|
|
|
|
.. literalinclude:: /cmd/synth_ice40.rst
|
|
|
|
:language: yoscrypt
|
2023-12-17 18:19:01 -06:00
|
|
|
:linenos:
|
2023-12-13 16:30:51 -06:00
|
|
|
:start-after: coarse:
|
|
|
|
:end-before: map_ram:
|
|
|
|
:dedent:
|
|
|
|
:caption: ``coarse`` section
|
2023-12-13 21:21:52 -06:00
|
|
|
:name: synth_coarse
|
|
|
|
|
2023-12-17 22:49:15 -06:00
|
|
|
The first few commands are relatively straightforward. We've already come
|
|
|
|
across :cmd:ref:`opt_clean` and :cmd:ref:`opt_expr`. The :cmd:ref:`check` pass
|
|
|
|
identifies a few obvious problems which will cause errors later. Calling it
|
|
|
|
here lets us fail faster rather than wasting time on something we know is
|
|
|
|
impossible.
|
|
|
|
|
|
|
|
Next up is :yoscrypt:`opt -nodffe -nosdff` performing a set of simple
|
|
|
|
optimizations on the design. This command also ensures that only a specific
|
|
|
|
subset of FF types are included, in preparation for the next command:
|
|
|
|
:doc:`/cmd/fsm`. Both :cmd:ref:`opt` and :cmd:ref:`fsm` are macro commands
|
|
|
|
which are explored in more detail in :doc:`/using_yosys/synthesis/fsm` and
|
|
|
|
:doc:`/using_yosys/synthesis/opt` respectively.
|
|
|
|
|
|
|
|
Up until now, the data path for ``rdata`` has remained the same since
|
|
|
|
:ref:`rdata_flat`. However the next call to :cmd:ref:`opt` does cause a change.
|
|
|
|
Specifically, the call to :cmd:ref:`opt_dff` without the ``-nodffe -nosdff``
|
|
|
|
options is able to fold one of the ``$mux`` cells into the ``$adff`` to form an
|
|
|
|
``$adffe`` cell; highlighted below:
|
2023-12-13 21:21:52 -06:00
|
|
|
|
2023-12-17 22:49:15 -06:00
|
|
|
.. literalinclude:: /code_examples/fifo/fifo.out
|
|
|
|
:language: doscon
|
|
|
|
:start-at: yosys> opt_dff
|
|
|
|
:end-before: yosys> select
|
|
|
|
:caption: output of :cmd:ref:`opt_dff`
|
2023-12-13 16:30:51 -06:00
|
|
|
|
2023-12-17 22:49:15 -06:00
|
|
|
.. figure:: /_images/code_examples/fifo/rdata_adffe.*
|
|
|
|
:class: width-helper
|
|
|
|
:name: rdata_adffe
|
|
|
|
|
|
|
|
``rdata`` output after :cmd:ref:`opt_dff`
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-17 22:49:15 -06:00
|
|
|
The next three (new) commands are :doc:`/cmd/wreduce`, :doc:`/cmd/peepopt`, and
|
|
|
|
:doc:`/cmd/share`. None of these affect our design either, so let's skip over
|
|
|
|
them. :yoscrypt:`techmap -map +/cmp2lut.v -D LUT_WIDTH=4` optimizes certain
|
|
|
|
comparison operators by converting them to LUTs instead. The usage of
|
|
|
|
:cmd:ref:`techmap` is explored more in
|
|
|
|
:doc:`/using_yosys/synthesis/techmap_synth`. Our next command to run is
|
|
|
|
:doc:`/cmd/memory_dff`.
|
|
|
|
|
|
|
|
.. literalinclude:: /code_examples/fifo/fifo.out
|
|
|
|
:language: doscon
|
|
|
|
:start-at: yosys> memory_dff
|
|
|
|
:end-before: yosys> select
|
|
|
|
:caption: output of :cmd:ref:`memory_dff`
|
|
|
|
|
|
|
|
.. figure:: /_images/code_examples/fifo/rdata_memrdv2.*
|
|
|
|
:class: width-helper
|
|
|
|
:name: rdata_memrdv2
|
|
|
|
|
|
|
|
``rdata`` output after :cmd:ref:`memory_dff`
|
|
|
|
|
|
|
|
As the title suggests, :cmd:ref:`memory_dff` has merged the output ``$dff`` into
|
|
|
|
the ``$memrd`` cell and converted it to a ``$memrd_v2`` (highlighted).
|
|
|
|
Following this is a series of commands for mapping to DSPs.
|
|
|
|
|
|
|
|
.. TODO:: more on DSP mapping
|
|
|
|
|
|
|
|
Where before each type of arithmetic operation had its own cell, e.g. ``$add``,
|
|
|
|
we now want to extract these into ``$alu`` and ``$macc`` cells which can be
|
|
|
|
mapped to hard blocks. We do this by running :cmd:ref:`alumacc`, which we can
|
|
|
|
see produce the following changes in our example design:
|
|
|
|
|
|
|
|
.. literalinclude:: /code_examples/fifo/fifo.out
|
|
|
|
:language: doscon
|
|
|
|
:start-at: yosys> alumacc
|
|
|
|
:end-before: yosys> select
|
|
|
|
:caption: output of :cmd:ref:`alumacc`
|
|
|
|
|
|
|
|
.. figure:: /_images/code_examples/fifo/rdata_alumacc.*
|
|
|
|
:class: width-helper
|
|
|
|
:name: rdata_alumacc
|
|
|
|
|
|
|
|
``rdata`` output after :cmd:ref:`alumacc`
|
|
|
|
|
|
|
|
That brings us to the last commands, and a look at ``rdata`` at the end of the
|
|
|
|
:ref:`synth_coarse`. We could also have gotten here by running
|
|
|
|
:yoscrypt:`synth_ice40 -top fifo -run begin:map_ram` after loading the design.
|
|
|
|
|
|
|
|
.. literalinclude:: /cmd/synth_ice40.rst
|
|
|
|
:language: yoscrypt
|
|
|
|
:start-at: memory -nomap
|
|
|
|
:end-before: map_ram:
|
|
|
|
:dedent:
|
|
|
|
|
|
|
|
.. figure:: /_images/code_examples/fifo/rdata_coarse.*
|
|
|
|
:class: width-helper
|
|
|
|
:name: rdata_coarse
|
2023-12-13 16:30:51 -06:00
|
|
|
|
2023-12-17 22:49:15 -06:00
|
|
|
``rdata`` output after :yoscrypt:`memory -nomap`
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-17 22:49:15 -06:00
|
|
|
.. TODO:: discuss :cmd:ref:`memory_collect` and ``$mem_v2``
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
.. seealso:: Advanced usage docs for
|
2023-12-17 22:49:15 -06:00
|
|
|
:doc:`/using_yosys/synthesis/fsm`
|
2023-12-13 16:30:51 -06:00
|
|
|
:doc:`/using_yosys/synthesis/opt`
|
2023-12-17 22:49:15 -06:00
|
|
|
:doc:`/using_yosys/synthesis/techmap_synth`
|
|
|
|
:doc:`/using_yosys/synthesis/memory`
|
2023-12-07 14:46:02 -06:00
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
Hardware mapping
|
|
|
|
~~~~~~~~~~~~~~~~
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
.. TODO:: example_synth hardware mapping sections
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
.. literalinclude:: /cmd/synth_ice40.rst
|
|
|
|
:language: yoscrypt
|
|
|
|
:start-after: map_ram:
|
|
|
|
:end-before: map_ffram:
|
|
|
|
:dedent:
|
|
|
|
:name: map_ram
|
|
|
|
:caption: ``map_ram`` section
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
.. literalinclude:: /cmd/synth_ice40.rst
|
|
|
|
:language: yoscrypt
|
|
|
|
:start-after: map_ffram:
|
|
|
|
:end-before: map_gates:
|
|
|
|
:dedent:
|
|
|
|
:name: map_ffram
|
|
|
|
:caption: ``map_ffram`` section
|
2023-12-07 14:46:02 -06:00
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
.. literalinclude:: /cmd/synth_ice40.rst
|
|
|
|
:language: yoscrypt
|
|
|
|
:start-after: map_gates:
|
|
|
|
:end-before: map_ffs:
|
|
|
|
:dedent:
|
|
|
|
:name: map_gates
|
|
|
|
:caption: ``map_gates`` section
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
.. literalinclude:: /cmd/synth_ice40.rst
|
|
|
|
:language: yoscrypt
|
|
|
|
:start-after: map_ffs:
|
|
|
|
:end-before: map_luts:
|
|
|
|
:dedent:
|
|
|
|
:name: map_ffs
|
|
|
|
:caption: ``map_ffs`` section
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
.. literalinclude:: /cmd/synth_ice40.rst
|
|
|
|
:language: yoscrypt
|
|
|
|
:start-after: map_luts:
|
|
|
|
:end-before: map_cells:
|
|
|
|
:dedent:
|
|
|
|
:name: map_luts
|
|
|
|
:caption: ``map_luts`` section
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
.. literalinclude:: /cmd/synth_ice40.rst
|
|
|
|
:language: yoscrypt
|
|
|
|
:start-after: map_cells:
|
|
|
|
:end-before: check:
|
|
|
|
:dedent:
|
|
|
|
:name: map_cells
|
|
|
|
:caption: ``map_cells`` section
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-06 22:14:21 -06:00
|
|
|
:cmd:ref:`dfflibmap`
|
|
|
|
This command maps the internal register cell types to the register types
|
|
|
|
described in a liberty file.
|
|
|
|
|
|
|
|
:cmd:ref:`hilomap`
|
|
|
|
Some architectures require special driver cells for driving a constant hi or
|
|
|
|
lo value. This command replaces simple constants with instances of such
|
|
|
|
driver cells.
|
|
|
|
|
|
|
|
:cmd:ref:`iopadmap`
|
|
|
|
Top-level input/outputs must usually be implemented using special I/O-pad
|
|
|
|
cells. This command inserts such cells to the design.
|
|
|
|
|
|
|
|
:cmd:ref:`dfflegalize`
|
|
|
|
Specify a set of supported FF cells/cell groups and convert all FFs to them.
|
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
.. seealso:: Advanced usage docs for
|
|
|
|
:doc:`/yosys_internals/techmap`, and
|
|
|
|
:doc:`/using_yosys/synthesis/memory`.
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
Final steps
|
|
|
|
~~~~~~~~~~~~
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
.. TODO:: example_synth final steps (check section and outputting)
|
2023-12-06 18:04:46 -06:00
|
|
|
|
2023-12-13 16:30:51 -06:00
|
|
|
.. literalinclude:: /cmd/synth_ice40.rst
|
2023-12-06 18:04:46 -06:00
|
|
|
:language: yoscrypt
|
2023-12-13 16:30:51 -06:00
|
|
|
:start-after: check:
|
|
|
|
:end-before: blif:
|
|
|
|
:dedent:
|
|
|
|
:name: check
|
|
|
|
:caption: ``check`` section
|
|
|
|
|
|
|
|
- :doc:`/cmd/check`
|
|
|
|
- :doc:`/cmd/autoname`
|
|
|
|
- :doc:`/cmd/stat`
|