Added $alu support to test_cell
[yosys.git] / CodingStyle
1
2
3 Section 0: Notes on the existing codebase
4 -----------------------------------------
5
6 Not all parts of Yosys adhere to this coding styles for historical
7 reasons. When adding code to existing parts of the system, adhere
8 to this guide for the new code instead of trying to mimic to style
9 of the surrounding code.
10
11
12
13 Section 1: Formatting of code
14 -----------------------------
15
16 - Yosys code is using tabs for indentation. Tabs are 8 characters.
17
18 - A continuation of a statement in the following line is indented by
19 two additional tabs.
20
21 - Lines are as long as you want them to be. A good rule of thumb is
22 to break lines at about column 150.
23
24 - Opening braces can be put on the same or next line as the statement
25 opening the block (if, switch, for, while, do). Put the opening brace
26 on its own line for larger blocks.
27
28 - Otherwise stick to the Linux Kernel Coding Stlye:
29 https://www.kernel.org/doc/Documentation/CodingStyle
30
31
32 Section 2: C++ Langugage
33 ------------------------
34
35 Yosys is written in C++11. At the moment only constructs supported by
36 gcc 4.6 is allowed in Yosys code. This will change in future releases.
37
38 In general Yosys uses "int" instead of "size_t". To avoid compiler
39 warnings for implicit type casts, always use "SIZE(foobar)" instead
40 of "foobar.size()". (the macro SIZE() is defined by kernel/yosys.h)
41
42 Use range-based for loops whenever applicable.
43