diff options
author | Clifford Wolf <clifford@clifford.at> | 2014-07-30 14:10:49 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2014-07-30 14:10:49 +0200 |
commit | e2a029b5d583c3268df4d798f8e79874919eb601 (patch) | |
tree | c6d128f00c7fafb6c8ede532f273dbc1e896e089 | |
parent | a7c6b37abf3e4628dd921bb12f77987d1f94c45f (diff) | |
download | yosys-e2a029b5d583c3268df4d798f8e79874919eb601.tar.gz yosys-e2a029b5d583c3268df4d798f8e79874919eb601.tar.bz2 yosys-e2a029b5d583c3268df4d798f8e79874919eb601.zip |
Added CodingStyle document
-rw-r--r-- | CodingStyle | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/CodingStyle b/CodingStyle new file mode 100644 index 000000000..e076cbd89 --- /dev/null +++ b/CodingStyle @@ -0,0 +1,43 @@ + + +Section 0: Notes on the existing codebase +----------------------------------------- + +Not all parts of Yosys adhere to this coding styles for historical +reasons. When adding code to existing parts of the system, adhere +to this guide for the new code instead of trying to mimic to style +of the surrounding code. + + + +Section 1: 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. + +- Otherwise stick to the Linux Kernel Coding Stlye: + https://www.kernel.org/doc/Documentation/CodingStyle + + +Section 2: C++ Langugage +------------------------ + +Yosys is written in C++11. At the moment only constructs supported by +gcc 4.6 is 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 "SIZE(foobar)" instead +of "foobar.size()". (the macro SIZE() is defined by kernel/yosys.h) + +Use range-based for loops whenever applicable. + |