File size: 12,335 Bytes
ce57c19 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | Installation
------------
This document will guide you through the process of installing Yosys.
CAD suite(s)
~~~~~~~~~~~~
Yosys is part of the `Tabby CAD Suite
<https://www.yosyshq.com/tabby-cad-datasheet>`_ and the `OSS CAD Suite
<https://github.com/YosysHQ/oss-cad-suite-build>`_! The easiest way to use yosys
is to install the binary software suite, which contains all required
dependencies and related tools.
* `Contact YosysHQ <https://www.yosyshq.com/contact>`_ for a `Tabby CAD Suite
<https://www.yosyshq.com/tabby-cad-datasheet>`_ Evaluation License and
download link
* OR go to https://github.com/YosysHQ/oss-cad-suite-build/releases to download
the free OSS CAD Suite
* Follow the `Install Instructions on GitHub
<https://github.com/YosysHQ/oss-cad-suite-build#installation>`_
Make sure to get a Tabby CAD Suite Evaluation License if you need features such
as industry-grade SystemVerilog and VHDL parsers!
For more information about the difference between Tabby CAD Suite and the OSS
CAD Suite, please visit https://www.yosyshq.com/tabby-cad-datasheet
Many Linux distributions also provide Yosys binaries, some more up to date than
others. Check with your package manager!
Targeted architectures
^^^^^^^^^^^^^^^^^^^^^^
The `OSS CAD Suite`_ releases `nightly builds`_ for the following architectures:
- **linux-x64** - Most personal Linux based computers
- **darwin-x64** - macOS 12 or later with Intel CPU
- **darwin-arm64** - macOS 12 or later with M1/M2 CPU
- **windows-x64** - Targeted for Windows 10 and 11
- **linux-arm64** - Devices such as Raspberry Pi with 64bit OS
For more information about the targeted architectures, and the current build
status, check the `OSS CAD Suite`_ git repository.
.. _OSS CAD Suite: https://github.com/YosysHQ/oss-cad-suite-build
.. _nightly builds: https://github.com/YosysHQ/oss-cad-suite-build/releases/latest
Building from source
~~~~~~~~~~~~~~~~~~~~
The Yosys source files can be obtained from the `YosysHQ/Yosys git repository`_.
`ABC`_ and some of the other libraries used are included as git submodules. To
clone these submodules at the same time, use e.g.:
.. code:: console
git clone --recurse-submodules https://github.com/YosysHQ/yosys.git # ..or..
git clone https://github.com/YosysHQ/yosys.git
cd yosys
git submodule update --init --recursive
.. _YosysHQ/Yosys git repository: https://github.com/yosyshq/yosys/
.. _ABC: https://github.com/berkeley-abc/abc
.. note::
As of Yosys v0.47, releases include a ``yosys.tar.gz`` file which includes
all source code and all sub-modules in a single archive. This can be used as
an alternative which does not rely on :program:`git`.
Supported platforms
^^^^^^^^^^^^^^^^^^^
The following platforms are supported and regularly tested:
- Linux
- macOS
Other platforms which may work, but instructions may not be up to date and are
not regularly tested:
- FreeBSD
- WSL
- Windows with (e.g.) Cygwin
Build prerequisites
^^^^^^^^^^^^^^^^^^^
A C++ compiler with C++20 support is required as well as some standard tools
such as GNU Flex, GNU Bison (>=3.8), CMake (>=3.28), Make (or other CMake
generator such as Ninja), and Python (>=3.11). Some additional tools: readline,
libffi, Tcl and zlib; will be used if available but are optional. Graphviz and
Xdot are used by the `show` command to display schematics.
Installing all prerequisites:
.. tab:: Ubuntu 22.04
.. code:: console
sudo apt-get install gawk git make python3 lld bison clang flex \
libffi-dev libfl-dev libreadline-dev pkg-config tcl-dev zlib1g-dev \
graphviz xdot
sudo snap install cmake --classic
.. tab:: Ubuntu 24.04
.. code:: console
sudo apt-get install gawk git cmake make python3 lld bison clang flex \
libffi-dev libfl-dev libreadline-dev pkg-config tcl-dev zlib1g-dev \
graphviz xdot
.. tab:: macOS 13 (with Homebrew)
.. code:: console
brew tap Homebrew/bundle && brew bundle
.. tab:: MacPorts
.. code:: console
sudo port install bison cmake flex readline gawk libffi graphviz \
pkgconfig python311 zlib tcl
.. tab:: FreeBSD
.. code:: console
pkg install bison cmake-core flex readline gawk libffi graphviz \
pkgconf python311 tcl-wrapper
.. tab:: Nix
.. code:: console
nix-shell
enters a shell with all prerequisites, using the nixpkgs revision pinned in
``flake.lock``. To have direnv load it automatically, put ``use nix`` in
``.envrc``. ``nix develop`` gives the same shell, but first copies the source
tree including all submodules into the Nix store.
.. tab:: Cygwin
Use the following command to install all prerequisites, or select these
additional packages:
.. code:: console
setup-x86_64.exe -q --packages=bison,flex,gcc-core,gcc-g++,git,libffi-devel,libreadline-devel,cmake,make,pkg-config,python3,tcl-devel,zlib-devel
.. warning::
As of this writing, Cygwin only supports up to Python 3.9.16 while the
minimum required version of Python is 3.11. This means that Cygwin is not
compatible with many of the Python-based frontends. While this does not
currently prevent Yosys itself from working, no guarantees are made for
continued support. You may also need to specify ``CXXSTD=gnu++20`` to
resolve missing ``strdup`` function when using gcc. It is instead
recommended to use Windows Subsystem for Linux (WSL) and follow the
instructions for Ubuntu.
..
tab:: MSYS2 (MINGW64)
.. code:: console
pacman -S bison flex mingw-w64-x86_64-gcc git libffi-devel libreadline-devel make pkg-config python3 tcl-devel zlib-devel
Not that I can get this to work; it's failing during ld with what looks like
math library issues: ``multiple definition of `tanh'`` and
``undefined reference to `__imp_acosh'``, as well as issues in `aiger2` with
``seekg`` et al not being available.
.. note::
The ``config-msys2-64`` target uses the ``mingw-w64-x86_64-`` prefixed
compiler in order to allow compiled exe files to be run without an MSYS2
shell.
Build configuration
^^^^^^^^^^^^^^^^^^^
The Yosys build is configured via CMake, and uses a number of variables which
influence the build process. When setting one-off variables, CMake provides the
``-D <var>=<value>`` command line option. For example, disabling zlib support:
.. code:: console
cmake -B build . -DYOSYS_WITHOUT_ZLIB=ON
.. warning::
Yosys does not support in-tree builds. If calling :program:`cmake` from the
root ``yosys`` directory the ``-B`` option must be provided.
For a more persistent configuration, we recommend creating and using a
``CMakeUserPresets.json`` file in the root ``yosys`` directory. Below is an
example file which has two configurations, one enables ccache and sets the default compiler to clang when
calling ``cmake --preset clang``, and the other disables zlib support when calling ``cmake --preset without_zlib``
This can be used instead of manually specifying ``-DYOSYS_WITHOUT_ZLIB=ON``:
.. code-block:: json
:caption: CMakeUserPresets.json
{
"version": 1,
"configurePresets": [
{
"name": "clang",
"inherits": "default",
"generator": "Unix Makefiles",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"YOSYS_COMPILER_LAUNCHER": "ccache"
}
},
{
"name": "without_zlib",
"inherits": "clang",
"cacheVariables": {
"YOSYS_WITHOUT_ZLIB": "ON"
}
}
]
}
Once generated, available build variables can be inspected and modified with
:program:`ccmake` or opening the generated ``build/CMakeCache.txt`` file:
.. code:: console
ccmake build #..or..
vi build/CMakeCache.txt
If you have clang, and (a compatible version of) ``ld.lld`` available in PATH,
it's recommended to speed up incremental builds with lld by enabling LTO with
``CMAKE_INTERPROCEDURAL_OPTIMIZATION=ON``. On macOS, LTO requires using clang
from homebrew rather than clang from xcode. For example:
.. code:: console
cmake -B build . -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-DCMAKE_C_COMPILER=$(brew --prefix)/opt/llvm/bin/clang \
-DCMAKE_CXX_COMPILER=$(brew --prefix)/opt/llvm/bin/clang++
This is also available with a preset:
.. code:: console
cmake --preset lto
By default, building (and installing) Yosys will build (and install) `ABC`_,
using :program:`yosys-abc` as the executable name. To use an existing ABC
executable instead, set the :makevar:`YOSYS_ABC_EXECUTABLE` CMake variable to
point to the desired executable.
Running the build system
^^^^^^^^^^^^^^^^^^^^^^^^
To quickly install Yosys with default settings, call the following commands from
the root ``yosys`` directory:
.. code:: console
cmake --preset release --fresh
cmake --build build-rel --config Release --parallel $(nproc)
sudo cmake --install build-rel --strip
To use an existing configuration, use the ``--build`` option, e.g:
.. code:: console
cmake --preset default
ccmake build # modify configuration
cmake --build build
.. seealso::
Refer to :doc:`/yosys_internals/extending_yosys/test_suites` for details on
testing Yosys once compiled.
Source tree and build system
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Yosys source tree is organized into the following top-level
directories:
``backends/``
This directory contains a subdirectory for each of the backend modules.
``cmake/``
Additional ``.cmake`` files used by CMake during build generation.
``docs/``
Contains the source for this documentation, including images and sample code.
``examples/``
Contains example code for using Yosys with some other tools including a demo
of the Yosys Python api, and synthesizing for various toolchains such as
Intel and Anlogic.
``frontends/``
This directory contains a subdirectory for each of the frontend modules.
``kernel/``
This directory contains all the core functionality of Yosys. This includes
the functions and definitions for working with the RTLIL data structures
(:file:`rtlil.{h|cc}`), the ``main()`` function (:file:`driver.cc`), the
internal framework for generating log messages (:file:`log.{h|cc}`), the
internal framework for registering and calling passes
(:file:`register.{h|cc}`), some core commands that are not really passes
(:file:`select.cc`, :file:`show.cc`, …) and a couple of other small utility
libraries.
``libs/``
Libraries packaged with Yosys builds are contained in this folder. See
:doc:`/appendix/auxlibs`.
``misc/``
Other miscellany which doesn't fit anywhere else.
``passes/``
This directory contains a subdirectory for each pass or group of passes. For
example as of this writing the directory :file:`passes/hierarchy/` contains
the code for three passes: `hierarchy`, `submod`, and `uniquify`.
``pyosys/``
Contains the scripts and wrappers necessary for building :doc:`Pyosys
</using_yosys/pyosys>`.
``techlibs/``
This directory contains simulation models and standard implementations for
the cells from the internal cell library.
``tests/``
This directory contains the suite of unit tests and regression tests used by
Yosys. See :doc:`/yosys_internals/extending_yosys/test_suites`.
.. TODO:: CMAKE_TODO
- ``yosys_<pass|test_pass|frontend|backend>(<name>)`` for each pass
- see :file:`cmake/YosysComponent.cmake`
- if using a sub folder, add it to the parent's ``CMakeLists.txt`` with
``add_subdirectory(<name>)``
- previous:
The Yosys kernel automatically detects all commands linked
with Yosys. So it is not needed to add additional commands to a central list of
commands.
Good starting points for reading example source code to learn how to write
passes are :file:`passes/opt/dff/opt_dff.cc` and :file:`passes/opt/opt_merge.cc`.
Users of the Qt Creator IDE can generate a QT Creator project file using make
qtcreator. Users of the Eclipse IDE can use the "Makefile Project with Existing
Code" project type in the Eclipse "New Project" dialog (only available after the
CDT plugin has been installed) to create an Eclipse project in order to
programming extensions to Yosys or just browse the Yosys code base.
|