在 verilog 中替代 "can not set both range and type on function declaration"?
Alternative of "can not set both range and type on function declaration" in verilog?
我正在做一个计算variance
的verilog代码,在我的verilog代码中我调用了一个定义文件,定义文件如下
`define MAXIMUM_FUNC_WIDTH 64
function integer clog2(input reg [`MAXIMUM_FUNC_WIDTH-1:0] value);
begin
value = value-1;
for (clog2=0; value>0; clog2=clog2+1)
value = value>>1;
end
endfunction
function reg [`MAXIMUM_FUNC_WIDTH-1:0] pow(input integer base, input integer index);
begin
for (pow=1; index>=0; pow=pow*base)
index = index - 1;
end
endfunction
但在 function reg [MAXIMUM_FUNC_WIDTH-1:0] pow(input integer base, input integer index);
行中显示 can not set both range and type on function declaration
之类的错误。认为这与system verilog
有关。但是我怎样才能将同一行仅用于verilog。
Verilog 标准只允许一个简单的类型名称,或一个范围(假定为 reg
,但不能同时使用两者。SystemVerilog 允许将两者作为压缩数组。
我正在做一个计算variance
的verilog代码,在我的verilog代码中我调用了一个定义文件,定义文件如下
`define MAXIMUM_FUNC_WIDTH 64
function integer clog2(input reg [`MAXIMUM_FUNC_WIDTH-1:0] value);
begin
value = value-1;
for (clog2=0; value>0; clog2=clog2+1)
value = value>>1;
end
endfunction
function reg [`MAXIMUM_FUNC_WIDTH-1:0] pow(input integer base, input integer index);
begin
for (pow=1; index>=0; pow=pow*base)
index = index - 1;
end
endfunction
但在 function reg [MAXIMUM_FUNC_WIDTH-1:0] pow(input integer base, input integer index);
行中显示 can not set both range and type on function declaration
之类的错误。认为这与system verilog
有关。但是我怎样才能将同一行仅用于verilog。
Verilog 标准只允许一个简单的类型名称,或一个范围(假定为 reg
,但不能同时使用两者。SystemVerilog 允许将两者作为压缩数组。