// DEFINEOUTPUT //
//******************************
output [m:0] a_dout ; // *****
output [i:0] b_dout ; // *****
//******************************
// OUTPUTATRRIBUTE //
//******************************
// REGS
reg [m:0] a_dout ; // *****
//WIRES
wire [i:0] b_dout ; // *****
//******************************
// INSTSNCEMODULE //
//******************************
MODULE_NAME_A U_MODULE_NAME_A(
.A (A ),
.B (B ),
.C (C ),
); …
//******************************
//MAIN CODE //
//******************************
… …
… …
… …
//****************************** //
Endmodule
3.一致的排版
A. 一致的缩排
l 统一的缩排取4个空格宽度
l 输入输出信号的宽度定义与关键字之间,信号名与宽度之间要用空格分开;所有宽度定义对所有信号名对齐,代码风格统一如下:
input [3:0] input_a ; // *****
input input_b ; // *****
…
output [128:0] output_a ;
output [15:0] output_b ;
output output_c ;
B. 一致的 begin end 书写方式
always 中,一定要用begin end 区分,格式和代码风格统一如下:
always @ (postedge clk or negedge rst_n)
begin
if(rst_n==1’b0)
syn_rst<= ‘DLY 1’b0;
else
begin
if (a==b)
syn_rst<= ‘DLY 1’b1;
else
syn_rst<= ‘DLY 1’b0;
end
end
if else 中仅有一个语句行时,不要使用begin end; 如果有多个语句行时,begin end和if ()或else ()空四个格。
格式如下:
if (…)
…
else if (…)
else
********************************************************************
if (…)
…
else if (…)
begin
…
…(
end
else |