结构体类型的本地参数 – 使用默认值 – 仍然需要初始化器吗?

huangapple go评论73阅读模式
英文:

localparam of struct type - using default values - still requires initializer?

问题

应该是这样吗:如果一个struct类型的localparam有默认初始值,是否仍然需要一个初始化器?

例如:

typedef struct {
 int a = 1;
} my_struct;

localparam my_struct m;
英文:

Should a localparam of a struct type still require an initializer if it has default initial values?

Eg

typedef struct {
 int a = 1;
} my_struct;

localparam my_struct m;

答案1

得分: 0

你的代码在3个主要的Verilog模拟器上生成了语法错误。根据IEEE Std 1800-2017,第6.20.1节“参数声明语法”:

> 只有在parameter_port_list内,才可以在param_assignment中省略constant_param_expression或在type_assignment中省略data_type。

英文:

Your code generates a syntax error on 3 major Verilog simulators. From IEEE Std 1800-2017, section 6.20.1 Parameter declaration syntax:

> It shall be legal to omit the constant_param_expression from a
> param_assignment or the data_type from a type_assignment only within
> a parameter_port_list
.

答案2

得分: 0

SystemVerilog的语法/语义要求对于任何localparam声明都需要一个声明赋值,或者一个parameter声明位于模块头之外(即在模块体内)。

英文:

SystemVerilog syntax/semantics requires a declaration assignment for any localparam declaration, or a parameter declaration outside the module header (i.e. inside the module body).

huangapple
  • 本文由 发表于 2023年6月8日 06:53:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76427560.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定