-
Notifications
You must be signed in to change notification settings - Fork 3
/
style_commaleading.sv
138 lines (125 loc) · 2.93 KB
/
style_commaleading.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/* Comma-Leading Style
<https://gist.github.com/isaacs/357981>
<https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md#list-declarations>
*/
/* Module declaration without parameter ports.
*/
module Mod_A
( input var logic i_abc // comment
, inout tri logic b_def /* comment */
, output var logic o_ghi
);
endmodule
/* Module declaration with parameter ports.
*/
module Mod_B
#(int FOO = 1 // comment
, bit BAR = 2 /* comment */
, bit [31:0] BAZ = 2
, parameter int BUZZ = 4
)
( input var logic i_abc // comment
, inout tri logic b_def /* comment */
, output var logic o_ghi
);
/* Each item on its own line.
- Short lines.
- Every list indented to same level.
- Single-line LHS can be any length without indent issue.
*/
assign {foo, bar} =
{ i_abc
, 12'h345
, b_def // comment
, 16'h3456 /* comment */
};
/* First item on same line (less nice style).
*/
assign lessnice_A = { i_abc // No indent alignment issue.
, 12'h345
, b_def
, 16'h3456
};
assign lessnice_B_ = { i_abc // Extra space after `=` to align with indent.
, 12'h345
, b_def
, 16'h3456
};
/* Everything fits on one line.
- No space after opening parenthesis/bracket/brace.
*/
assign singleline1D = {i_abc, 12'h345, b_def, 16'h3456};
assign singleline2D = {{foo, bar}, {foo, bar}, {foo, bar}};
/* Multi-dimensional concatenation with innermost array on one line.
*/
assign matrix2D_A =
{ {elem21, elem20}
, {elem11, elem10} // comment
, {elem01, elem00} /* comment */
};
assign matrix3D_A =
{ { {elem211, elem210}
, {elem201, elem200}
}
, { {elem111, elem110} // comment
, {elem101, elem100} /* comment */
}
, { {elem011, elem010}
, {elem001, elem000}
}
};
/* Multi-dimensional concatenation with innermost array on multiple lines.
*/
assign matrix2D_B =
{ { elem21
, elem20
}
, { elem11 // comment
, elem10 /* comment */
}
, { elem01
, elem00
}
};
assign matrix3D_B =
{ { { elem211
, elem210
}
, { elem201 // comment
, elem200 /* comment */
}
}
, { { elem110
, elem110
}
, { elem100
, elem100
}
}
, { { elem010
, elem010
}
, { elem000
, elem000
}
}
};
/* Module instance without parameter ports.
*/
Mod_A u_instanceA
( .i_abc(foo) // comment
, .b_def({bar, bar}) /* comment */
, .o_ghi
);
/* Module instance with parameter ports.
*/
Mod_B
#(.FOO(1) // comment
, .BAR(2) /* comment */
, .BUZZ(2)
) u_instanceB
( .i_abc(foo) // comment
, .b_def({bar, bar}) /* comment */
, .o_ghi
);
endmodule