verilog - Vivado模拟错误: "root scope declaration is not allowed in verilog 95/2K mode"

标签 verilog xilinx hdl vivado

当我在 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/

相关文章:

io - Xilinx 约束文件中的 IO 数组 [VHDL Spartan-6]

scala - 如何使用 chisel3 黑盒实例化 Xilinx 差分时钟缓冲器?

Python 和 UIO 设备 : Why does mmap. read() 工作而 os.read() 失败?

verilog - 如何在 verilog 中设计 16 位进位前瞻加法器

c - 将模块 2 的输出链接到模块 1 VERILOG 的 if else 语句

linux-kernel - 如何从 PCIe Verilog 内核实现 DMA?

scala - 在一个时钟周期内多次重新分配变量 - Chisel

vhdl - 如何在 VHDL 中初始化 std_logic_vector?

haskell - 冲突教程示例中 'pure' 关键字的用途是什么?

verilog - `在生成 if 语句中定义