File tree 1 file changed +65
-0
lines changed
1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change 2
2
Coding Style
3
3
=============
4
4
5
+ Naming Conventions
6
+ ~~~~~~~~~~~~~
7
+
8
+ Consistent naming makes code easier to read, search, and maintain.
9
+ The following rules help enforce a uniform naming style throughout the codebase:
10
+
11
+ General Rules
12
+ -------------
13
+
14
+ - Use descriptive and unambiguous names.
15
+ - Avoid abbreviations unless they are widely understood (e.g., `id `, `ctx `, `cfg `).
16
+ - Prefer clarity over brevity.
17
+
18
+ Specific Conventions
19
+ --------------------
20
+
21
+ - **Class names ** use `PascalCase `.
22
+
23
+ .. code-block :: cpp
24
+
25
+ class DecompNetlistRouter {
26
+ };
27
+
28
+ - **Variable and function names ** use `snake_case `.
29
+
30
+ .. code-block :: cpp
31
+
32
+ int net_count;
33
+ void estimate_wirelength();
34
+
35
+ - **Private member variables and private methods ** should end with an underscore `_ `.
36
+
37
+ .. code-block :: cpp
38
+
39
+ class Example {
40
+ private:
41
+ int count_;
42
+ void update_state_();
43
+ };
44
+
45
+ - **Enums ** should use `enum class ` instead of traditional enums. Enum names should start with `e_ `.
46
+
47
+ .. code-block :: cpp
48
+
49
+ enum class e_heap_type {
50
+ INVALID_HEAP = 0,
51
+ BINARY_HEAP,
52
+ FOUR_ARY_HEAP,
53
+ };
54
+
55
+ - **Trivial structs ** that primarily store data without behavior should be prefixed with `t_ `.
56
+
57
+ .. code-block :: cpp
58
+
59
+ struct t_dijkstra_data {
60
+ vtr::vector<RRNodeId, bool> node_expanded;
61
+ vtr::vector<RRNodeId, float> node_visited_costs;
62
+ std::priority_queue<PQ_Entry> pq;
63
+ };
64
+
65
+ - **Source and header file names ** use `snake_case ` and should be short but descriptive.
66
+
67
+ Example: `router_lookahead_map.cpp `, `netlist_walker.h `
68
+
69
+
5
70
Use of `auto `
6
71
~~~~~~~~~~~~~
7
72
You can’t perform that action at this time.
0 commit comments