在结构声明中添加函数时出现vcs编译错误。IEEE文档没有提到是否允许在struct中使用函数。
在尝试将默认值赋值给字段时,我还得到了vcs编译错误。但在IEEE-1800-2012 7.2.2中是允许的。
typedef struct {
int a = 1; //compile error here
int b;
function void func();
b = a;
endfunction
} a_struct;因此,我按照建议添加命令行和错误信息:
vcs -sverilog a.sv
Error-[V2KIIAD] Invalid initialization at declaration
....
Struct or union member field 'a' cannot be initialized at declaration.
Error-[SE] Syntax error
Following verilog source has syntax error :
"a.sv", 4: token is 'function'
function void func();
^我的vcs版本是2013.06-SP1-10。
发布于 2018-01-04 00:03:12
我们知道结构是静态的,类是动态数据类型。因此,在SV中,当我们使用类时,我们可以在内部或其他条件下分配值。但是对于结构,我们不能初始化声明中的任何变量。
https://stackoverflow.com/questions/27561704
复制相似问题