简体   繁体   English

电线声明后的localparam

[英]localparam after wire declaration

For a very strange reason (scripts we use) I need to be able to declare a localparam AFTER I declare wires and regs in a module: 出于一个非常奇怪的原因(我们使用的脚本),我需要能够在模块中声明wires和regs之后声明一个localparam:

module blah (clk, rst, in, out);

  input        clk;
  input        rst;
  input  [2:0] in;
  output [3:0] out;

  wire         res;

  localparam NUMBER=5;


...

is this legal verilog code? 这是合法的Verilog代码吗? I would also appreciate a link to the relevant seciton in the documentation. 我也希望在文档中链接到相关章节。 Thanks! 谢谢!

This is valid Verilog (2001). 这是有效的Verilog(2001)。 Verilog 2001 saw the introduction of localparam , for all versions it is still syntactically valid to use parameter in this context. Verilog 2001看到了localparam的引入,对于所有版本,在这种情况下使用参数在语法上仍然有效。 localparam indicates that it can not be overridden. localparam指示它不能被覆盖。

Usage can be seen in section 23.10 Overriding module parameters of SystemVerilog IEEE Std 1800-2012 . 用法可以在SystemVerilog IEEE Std 1800-2012的 23.10覆盖模块参数一节中看到。

From IEEE 1800-2012: 从IEEE 1800-2012:

For example: 例如:

module generic_fifo
    #(MSB=3, LSB=0)        // parameter port list parameters
    (input  wire  [MSB:LSB] in,
     input  wire            clk, read, write, reset,
     output logic [MSB:LSB] out,
     output logic           full, empty );

  parameter   DEPTH=4; // module item parameter

  localparam FIFO_MSB = DEPTH*MSB;
  localparam FIFO_LSB = LSB;
    // These constants are local, and cannot be overridden.
    // They can be affected by altering the value parameters above

  logic [FIFO_MSB:FIFO_LSB] fifo;
  logic [LOG2(DEPTH):0] depth;

  always @(posedge clk or posedge reset) begin
    casez ({read,write,reset})
      // implementation of fifo
    endcase
  end
endmodule

Exactly. 究竟。 As per the Verilog IEEE Std 1364-2001 , you can use localparam in your Verilog code. 根据Verilog IEEE Std 1364-2001 ,您可以在Verilog代码中使用localparam。 It can be declared after wire declaration, no problem for that. 可以在电线声明之后声明它,这没问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM