当我在 Xilinx Vivado 2016.4 中模拟顶级模块时,我收到了奇怪的错误:
ERROR: [VRFC 10-1342] root scope declaration is not allowed in verilog 95/2K mode [<...>/header.vh]
我正在使用指定了 Verilog 2001 的内置 Vivado 模拟器。我的 header.vh 如下所示:
`ifndef _header_vh_
`define _header_vh_
function integer clog2;
input integer value;
begin
value = value - 1;
for (clog2 = 0; value > 0; clog2 = clog2 + 1)
value = value >> 1;
end
endfunction
`endif
最佳答案
当函数 clog2
的作用域被有效设置为根(因为它没有在模块内声明)时,就会出现此错误; Verilog 2001 中不允许此范围声明,但在更高版本中(例如 SystemVerilog)允许。切换到 SystemVerilog 可以解决该问题(但不推荐),但为该函数引入模块包装器就足够了。
`ifndef _header_vh_
`define _header_vh_
module header();
function integer clog2;
input integer value;
begin
value = value - 1;
for (clog2 = 0; value > 0; clog2 = clog2 + 1)
value = value >> 1;
end
endfunction
endmodule
`endif
关于verilog - Vivado模拟错误: "root scope declaration is not allowed in verilog 95/2K mode",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44979043/