无法为模块创建符号文件,因为端口具有不受支持的类型

Can't create symbole file for module because port has unsupported type

我遇到了一个奇怪的问题,Quartus 不会为以下代码生成符号文件:

module bin_to_bcd #(parameter N_DIGITS = 4) (count, bcd_output);

input wire [$clog2(9999)-1:0] count;
output reg [(N_DIGITS<<2)-1:0] bcd_output;

integer i;
integer decade;

always @ (count) begin
    bcd_output = 'b0;
    for(i = $clog2(9999) - 1; i >= 0; i = i - 1) begin
        for(decade = 1; decade < N_DIGITS + 1; decade = decade + 1) begin
            if(bcd_output[(decade<<2) - 1 -: 4] >= 5) begin
                bcd_output[(decade<<2) - 1 -: 4] = bcd_output[(decade<<2) - 1 -: 4] + 3;
            end
        end

        bcd_output = bcd_output << 1;
        bcd_output[0] = count[i];
    end
end

endmodule

抛出的错误是:

10016 Can't create symbol/include/instantiation/component file for module "bin_to_bcd" because port "count" has an unsupported type

但是 "count" 是一个 "input wire",因为它应该是,我还有其他类似的代码可以正常工作。 也许我遗漏了一些明显的东西,但我将不胜感激我能得到的任何帮助。

我还应该提到这段代码在 ModelSim-Altera 中的仿真中运行得非常好。

谢谢。

编辑:如果有人知道如何实现它,我还希望能够为输出指定一些数字作为参数。 注意:$clog2({N_DIGITS{9}}) 不起作用...

编辑 #2 :很抱歉,如果我反应缓慢,我正在做其他事情。所以问题仍然存在,我还没有弄清楚为什么......这里有一些可能有用的见解。下面的代码工作得很好,并且使用与 $clog2 相同类型的寄存器大小调整。如果有人看到我发布的代码和这个有什么不同,请上前大喊 "I FOUND IT!",因为这让我抓狂 :P

module multiplexer #(parameter N_INPUTS = 2, parameter N_OUTPUTS = 1) (in, out, select);

generate
    if (N_INPUTS % N_OUTPUTS != 0) begin
        illegal_parameter_cant_divide_inputs_by_outputs non_existing_module();
    end
endgenerate

input wire [N_INPUTS-1:0] in;
input wire [$clog2(N_INPUTS/N_OUTPUTS) - 1:0] select; //THIS LINE WORKS FINE
output wire [N_OUTPUTS-1:0] out;

assign out = in[(select + 1) * N_OUTPUTS - 1 -: N_OUTPUTS];

endmodule

编辑 #3:我实际上只是注意到多路复用器代码没有正确合成为符号(select 端口丢失...我应用了相同的修复程序,现在没问题了)。

再一次,我们将不胜感激。

我不确定标准是怎么说的,但好的做法是始终使用 ANSI 样式的端口,尤其是与 ANSI 样式的参数结合使用。

这看起来像:

module bin_to_bcd #(parameter N_DIGITS = 4) (input wire [$clog2(9999)-1:0] count, output reg [(N_DIGITS<<2)-1:0] bcd_output);

通过将 $clog2 表达式设置为参数,然后使用该参数绑定总线,我解决了您的错误。

module test #(
    parameter N_DIGITS = 4,
    parameter int M = $clog2(9999) // see here
)(
    count, 
    bcd_output
);

input wire [M-1:0] count; // and here
output reg [(N_DIGITS<<2)-1:0] bcd_output;

integer i;
integer decade;

always @ (count) begin
    bcd_output = 'b0;
    for(i = $clog2(9999) - 1; i >= 0; i = i - 1) begin
        for(decade = 1; decade < N_DIGITS + 1; decade = decade + 1) begin
            if(bcd_output[(decade<<2) - 1 -: 4] >= 5) begin
                bcd_output[(decade<<2) - 1 -: 4] = bcd_output[(decade<<2) - 1 -: 4] + 3;
            end
        end

        bcd_output = bcd_output << 1;
        bcd_output[0] = count[i];
    end
end

endmodule

Can't create symbol/include/instantiation/component file for module "<name>" because port "<name>" has an unsupported type (ID: 10016)

CAUSE:

You attempted to create a symbol/include/instantiation/component file for the specified module in a Verilog Design File (.vhd). However, the specified port on the module has a type that cannot be represented by a symbol/include/instantiation/component file. Unsupported port types include SystemVerilog structs, interfaces, or modports. Most array or vector types are generally supported, but the their bounds must be defined by constant expressions or by simple arithmetic expressions involving module parameters and integer literals. Because the specified port has an unsupported type, the Quartus II software cannot create a symbol/include/instantiation/component file for the module.

ACTION:

Omit the port from the module declaration or change its type.

https://www.intel.com/content/www/us/en/programmable/quartushelp/13.0/mergedProjects/msgs/msgs/evrfx_symbol_cant_handle_verilog_port.htm

根据 Verilog-2005 和 SystemVerilog 语法,我无法发现您的代码有任何问题。它 运行 在 EDAplayground 上使用各种模拟器都很好。如果 bin_to_bcd.v 文件中并且 multiplexer 有一个 .sv 文件,那么它可能是文件被解析的方式。 $clog2 不是 Verilog-2001 的 build-in 类型,您可能希望确保 Verilog 文件被解析为 2005 而不是 2001。尽管我建议使用 SystemVerilog .sv 文件类型.

至于根据 N_DIGITS 制作 $clog2(9999) 比例,使用 $clog2(10**N_DIGITS-1).

您可能还想将 $clog2(...) 分配给参数。 ANSI header 样式示例:

module bin_to_bcd #(
  parameter N_DIGITS = 4,
  parameter IN_BITS = $clog2(10**N_DIGITS-1)
) (
  input wire [IN_BITS-1:0] count,
  output reg [(N_DIGITS<<2)-1:0] bcd_output );