aboutsummaryrefslogtreecommitdiffstats
path: root/guidelines/CodingStyle
diff options
context:
space:
mode:
authorN. Engelhardt <nak@symbioticeda.com>2021-03-23 17:41:13 +0100
committerGitHub <noreply@github.com>2021-03-23 17:41:13 +0100
commit049e3abf9baf795e69b9ecb9c4f19de6131f8418 (patch)
tree7a25547cc993ab7039827639543cdb21b7117a13 /guidelines/CodingStyle
parent4a35f244aa6ac187610cae0014d261e38cbab550 (diff)
parentd9ec35a526b9583727ef484ec68bc288dcddb0c8 (diff)
downloadyosys-049e3abf9baf795e69b9ecb9c4f19de6131f8418.tar.gz
yosys-049e3abf9baf795e69b9ecb9c4f19de6131f8418.tar.bz2
yosys-049e3abf9baf795e69b9ecb9c4f19de6131f8418.zip
Merge pull request #2696 from nakengelhardt/guidelines
split CodingReadme into multiple files
Diffstat (limited to 'guidelines/CodingStyle')
-rw-r--r--guidelines/CodingStyle35
1 files changed, 35 insertions, 0 deletions
diff --git a/guidelines/CodingStyle b/guidelines/CodingStyle
new file mode 100644
index 000000000..d3d3a7134
--- /dev/null
+++ b/guidelines/CodingStyle
@@ -0,0 +1,35 @@
+Coding Style
+============
+
+
+Formatting of code
+------------------
+
+- Yosys code is using tabs for indentation. Tabs are 8 characters.
+
+- A continuation of a statement in the following line is indented by
+ two additional tabs.
+
+- Lines are as long as you want them to be. A good rule of thumb is
+ to break lines at about column 150.
+
+- 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.
+
+- Otherwise stick to the Linux Kernel Coding Style:
+ https://www.kernel.org/doc/Documentation/CodingStyle
+
+
+C++ Language
+-------------
+
+Yosys is written in C++11. At the moment only constructs supported by
+gcc 4.8 are allowed in Yosys code. This will change in future releases.
+
+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 kernel/yosys.h)
+
+Use range-based for loops whenever applicable. \ No newline at end of file