2023-08-02 16:20:29 -05:00
|
|
|
Scripting in Yosys
|
|
|
|
------------------
|
|
|
|
|
2023-12-11 17:05:45 -06:00
|
|
|
.. TODO:: logical consistency, esp with example_synth
|
2023-08-02 16:20:29 -05:00
|
|
|
|
|
|
|
Yosys reads and processes commands from synthesis scripts, command line
|
|
|
|
arguments and an interactive command prompt. Yosys commands consist of a command
|
|
|
|
name and an optional whitespace separated list of arguments. Commands are
|
|
|
|
terminated using the newline character or a semicolon (;). Empty lines and lines
|
2023-12-06 18:04:46 -06:00
|
|
|
starting with the hash sign (#) are ignored. Also see :doc:`example_synth`.
|
2023-08-02 16:20:29 -05:00
|
|
|
|
2023-08-07 19:45:18 -05:00
|
|
|
The command :cmd:ref:`help` can be used to access the command reference manual,
|
|
|
|
with ``help <command>`` providing details for a specific command. ``yosys -H``
|
|
|
|
or ``yosys -h <command>`` will do the same outside of an interactive prompt.
|
|
|
|
The entire reference manual is also available here at :doc:`/cmd_ref`.
|
2023-08-02 16:20:30 -05:00
|
|
|
|
|
|
|
Example commands
|
|
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Commands for design navigation and investigation:
|
|
|
|
|
|
|
|
.. code-block:: yoscrypt
|
|
|
|
|
|
|
|
cd # a shortcut for 'select -module <name>'
|
|
|
|
ls # list modules or objects in modules
|
|
|
|
dump # print parts of the design in RTLIL format
|
|
|
|
show # generate schematics using graphviz
|
|
|
|
select # modify and view the list of selected objects
|
|
|
|
|
|
|
|
Commands for executing scripts or entering interactive mode:
|
|
|
|
|
|
|
|
.. code-block:: yoscrypt
|
|
|
|
|
|
|
|
shell # enter interactive command mode
|
|
|
|
history # show last interactive commands
|
|
|
|
script # execute commands from script file
|
|
|
|
tcl # execute a TCL script file
|
|
|
|
|
|
|
|
Commands for reading and elaborating the design:
|
|
|
|
|
|
|
|
.. code-block:: yoscrypt
|
|
|
|
|
|
|
|
read_rtlil # read modules from RTLIL file
|
|
|
|
read_verilog # read modules from Verilog file
|
|
|
|
hierarchy # check, expand and clean up design hierarchy
|
|
|
|
|
|
|
|
|
|
|
|
Commands for high-level synthesis:
|
|
|
|
|
|
|
|
.. code-block:: yoscrypt
|
|
|
|
|
|
|
|
proc # translate processes to netlists
|
|
|
|
fsm # extract and optimize finite state machines
|
|
|
|
memory # translate memories to basic cells
|
|
|
|
opt # perform simple optimizations
|
|
|
|
|
|
|
|
|
|
|
|
Commands for technology mapping:
|
|
|
|
|
|
|
|
.. code-block:: yoscrypt
|
|
|
|
|
|
|
|
techmap # generic technology mapper
|
|
|
|
abc # use ABC for technology mapping
|
|
|
|
dfflibmap # technology mapping of flip-flops
|
|
|
|
hilomap # technology mapping of constant hi- and/or lo-drivers
|
|
|
|
iopadmap # technology mapping of i/o pads (or buffers)
|
|
|
|
flatten # flatten design
|
|
|
|
|
|
|
|
Commands for writing the results:
|
|
|
|
|
|
|
|
.. code-block:: yoscrypt
|
|
|
|
|
|
|
|
write_blif # write design to BLIF file
|
|
|
|
write_btor # write design to BTOR file
|
|
|
|
write_edif # write design to EDIF netlist file
|
|
|
|
write_rtlil # write design to RTLIL file
|
|
|
|
write_spice # write design to SPICE netlist file
|
|
|
|
write_verilog # write design to Verilog file
|
|
|
|
|
|
|
|
|
|
|
|
Script-Commands for standard synthesis tasks:
|
|
|
|
|
|
|
|
.. code-block:: yoscrypt
|
|
|
|
|
|
|
|
synth # generic synthesis script
|
|
|
|
synth_xilinx # synthesis for Xilinx FPGAs
|
|
|
|
|
|
|
|
|
|
|
|
Commands for model checking:
|
|
|
|
|
|
|
|
.. code-block:: yoscrypt
|
|
|
|
|
|
|
|
sat # solve a SAT problem in the circuit
|
|
|
|
miter # automatically create a miter circuit
|
|
|
|
scc # detect strongly connected components (logic loops)
|
|
|
|
|
|
|
|
Selections intro
|
|
|
|
~~~~~~~~~~~~~~~~
|
2023-08-02 16:20:29 -05:00
|
|
|
|
2023-10-09 18:27:00 -05:00
|
|
|
.. todo:: reorder text for logical consistency
|
|
|
|
|
2023-08-02 16:20:29 -05:00
|
|
|
Most commands can operate not only on the entire design but also specifically on
|
2023-08-07 19:45:18 -05:00
|
|
|
selected parts of the design. For example the command :cmd:ref:`dump` will print
|
|
|
|
all selected objects in the current design while ``dump foobar`` will only print
|
|
|
|
the module ``foobar`` and ``dump *`` will print the entire design regardless of
|
|
|
|
the current selection.
|
2023-08-02 16:20:29 -05:00
|
|
|
|
|
|
|
.. code:: yoscrypt
|
|
|
|
|
2023-08-02 17:23:39 -05:00
|
|
|
dump */t:$add %x:+[A] */w:* %i
|
2023-08-02 16:20:29 -05:00
|
|
|
|
|
|
|
The selection mechanism is very powerful. For example the command above will
|
|
|
|
print all wires that are connected to the ``\A`` port of a ``$add`` cell.
|
2023-08-02 16:20:30 -05:00
|
|
|
Detailed documentation of the select framework can be found under
|
|
|
|
:doc:`/using_yosys/more_scripting/selections` or in the command reference at
|
|
|
|
:doc:`/cmd/select`.
|
2023-10-09 18:27:00 -05:00
|
|
|
|
|
|
|
The show command
|
|
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
The :cmd:ref:`show` command requires a working installation of `GraphViz`_ and
|
|
|
|
`xdot`_ for generating the actual circuit diagrams. Below is an example of how
|
|
|
|
this command can be used, showing the changes in the generated circuit at
|
|
|
|
different stages of the yosys tool flow.
|
|
|
|
|
|
|
|
.. _GraphViz: http://www.graphviz.org/
|
|
|
|
|
|
|
|
.. _xdot: https://github.com/jrfonseca/xdot.py
|
|
|
|
|
2023-11-13 23:54:16 -06:00
|
|
|
.. literalinclude:: /code_examples/show/example.ys
|
|
|
|
:language: yoscrypt
|
|
|
|
:caption: docs/source/code_examples/show/example.ys
|
|
|
|
|
|
|
|
.. literalinclude:: /code_examples/show/example.v
|
|
|
|
:language: Verilog
|
|
|
|
:caption: docs/source/code_examples/show/example.v
|
|
|
|
|
|
|
|
.. role:: yoscrypt(code)
|
|
|
|
:language: yoscrypt
|
|
|
|
|
|
|
|
.. figure:: /_images/code_examples/show/example_00.*
|
|
|
|
:class: width-helper
|
|
|
|
|
|
|
|
``example_00`` - shown after :yoscrypt:`read_verilog example.v`
|
|
|
|
|
|
|
|
.. figure:: /_images/code_examples/show/example_01.*
|
|
|
|
:class: width-helper
|
|
|
|
|
|
|
|
``example_01`` - shown after :yoscrypt:`proc`
|
|
|
|
|
|
|
|
.. figure:: /_images/code_examples/show/example_02.*
|
2023-10-09 18:27:00 -05:00
|
|
|
:class: width-helper
|
|
|
|
|
2023-11-13 23:54:16 -06:00
|
|
|
``example_02`` - shown after :yoscrypt:`opt`
|
2023-10-09 18:27:00 -05:00
|
|
|
|
|
|
|
A circuit diagram is generated for the design in its current state. Various
|
|
|
|
options can be used to change the appearance of the circuit diagram, set the
|
|
|
|
name and format for the output file, and so forth. When called without any
|
|
|
|
special options, it saves the circuit diagram in a temporary file and launches
|
|
|
|
``xdot`` to display the diagram. Subsequent calls to show re-use the ``xdot``
|
|
|
|
instance (if still running).
|
|
|
|
|
|
|
|
For more information on the :cmd:ref:`show` command, including a guide on what
|
|
|
|
the different symbols represent, see :ref:`interactive_show` and the
|
|
|
|
:doc:`/using_yosys/more_scripting/interactive_investigation` page.
|