【问题标题】:How can I fix the Expected a constant as index error?如何修复 Expected a constant as index 错误?
【发布时间】:2022-01-07 07:14:45
【问题描述】:

我正在尝试在 Verilog 上做一些项目,但遇到了持续索引错误的问题。

integer k=32;
reg[k-1:0] inputs;

在这段代码中,Verilog 编译器给了我这样的信息:

在 Verilog 中期望一个常量作为索引错误

我必须在这个项目中使用整数k。我该如何解决这个问题?

【问题讨论】:

    标签: verilog system-verilog


    【解决方案1】:

    integer 是一个变量类型。如错误消息所述,您需要一个 constant 类型,例如 parameter:

    parameter k=32;
    reg[k-1:0] inputs;
    

    【讨论】:

      猜你喜欢
      • 2020-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-28
      • 2016-09-10
      • 2011-02-27
      相关资源
      最近更新 更多