Verilog代码可移植性设计

1.       参数定义

localparam,实例代码如下:

module tm1(

            clk,rst_n,

            pout

        );

input clk;

input rst_n;

output[M:0] pout;  

 

localparam N = 4;

localparam M = N-1;

 

reg[M:0] cnt;  

 

always @(posedge clk or negedge rst_n)

    if(!rst_n) cnt <= 0;

    else cnt <= cnt+1'b1;

   

assign pout = cnt;

 

endmodule

    &n