我试图合成一个参数化函数,其中结构作为参数给出。我在参数化函数的开头出现以下错误 "令牌'虚拟'处于或附近的语法错误。"
我正在尝试编译这个简单的包。
package def;
typedef struct packed {
logic[10:0] SIZE1;
logic[10:0] SIZE2;
} my_struct;
endpackage
import def::*;
virtual class my_class #(parameter my_struct new_struct = '{10,11});
static function [new_struct.SIZE2-1:0] adder (input [new_struct.SIZE1-1:0] a, b);
return a+b;
endfunction
endclass
module top
#(parameter my_struct new_struct2 = '{63,64})
(input logic [new_struct2.SIZE1-1:0] a, b,
output logic [new_struct2.SIZE2-1:0] y) ;
assign y = my_class #(.new_struct(new_struct2))::adder(a,b);
endmodule
我做错了吗?或者Synopsys DC不支持此功能?
(更新:代码已更新,此代码可与Synopsys DC合成)
答案 0 :(得分:3)
根据http://www.sutherland-hdl.com/papers/2013-SNUG-SV_Synthesizable-SystemVerilog_paper.pdf§5.6.7使用静态类的参数化任务/函数参数,该类必须为virtual
并在$unit
声明空间中定义。这意味着无法在包内定义类。正如文章指出的那样,这是一个奇怪的要求。
尝试将类移出包。您也可以尝试将函数导入$unit
范围,但不确定这是否有效。
...
endpackage : def
import def::my_class; // or def::*;
...