2024-12-04 14:21:12 -06:00
|
|
|
Contributing to Yosys
|
|
|
|
=====================
|
2021-03-22 13:16:25 -05:00
|
|
|
|
2024-12-04 14:21:12 -06:00
|
|
|
Coding Style
|
|
|
|
------------
|
2021-03-22 13:16:25 -05:00
|
|
|
|
|
|
|
Formatting of code
|
2024-12-04 14:21:12 -06:00
|
|
|
~~~~~~~~~~~~~~~~~~
|
2021-03-22 13:16:25 -05:00
|
|
|
|
|
|
|
- Yosys code is using tabs for indentation. Tabs are 8 characters.
|
|
|
|
|
2024-12-04 14:21:12 -06:00
|
|
|
- A continuation of a statement in the following line is indented by two
|
|
|
|
additional tabs.
|
2021-03-22 13:16:25 -05:00
|
|
|
|
2024-12-04 14:21:12 -06:00
|
|
|
- Lines are as long as you want them to be. A good rule of thumb is to break
|
|
|
|
lines at about column 150.
|
2021-03-22 13:16:25 -05:00
|
|
|
|
2024-12-04 14:21:12 -06:00
|
|
|
- Opening braces can be put on the same or next line as the statement opening
|
|
|
|
the block (if, switch, for, while, do). Put the opening brace on its own line
|
|
|
|
for larger blocks, especially blocks that contains blank lines.
|
2021-03-22 13:16:25 -05:00
|
|
|
|
2024-12-04 14:21:12 -06:00
|
|
|
- Otherwise stick to the `Linux Kernel Coding Style`_.
|
|
|
|
|
|
|
|
.. _Linux Kernel Coding Style: https://www.kernel.org/doc/Documentation/process/coding-style.rst
|
2021-03-22 13:16:25 -05:00
|
|
|
|
|
|
|
|
|
|
|
C++ Language
|
2024-12-04 14:21:12 -06:00
|
|
|
~~~~~~~~~~~~
|
2021-03-22 13:16:25 -05:00
|
|
|
|
2024-06-17 10:08:13 -05:00
|
|
|
Yosys is written in C++17.
|
2021-03-22 13:16:25 -05:00
|
|
|
|
2024-12-04 14:21:12 -06:00
|
|
|
In general Yosys uses ``int`` instead of ``size_t``. To avoid compiler warnings
|
|
|
|
for implicit type casts, always use ``GetSize(foobar)`` instead of
|
|
|
|
``foobar.size()``. (``GetSize()`` is defined in :file:`kernel/yosys.h`)
|
2021-03-22 13:16:25 -05:00
|
|
|
|
2024-12-04 14:21:12 -06:00
|
|
|
Use range-based for loops whenever applicable.
|