首页 > 解决方案 > 无法为模块创建符号文件,因为端口的类型不受支持

问题描述

我遇到了这个奇怪的问题,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

但是“计数”应该是“输入线”,而且我还有其他类似的代码可以正常工作。也许我遗漏了一些明显的东西,但我将非常感谢我能得到的任何帮助。

我还应该提到,这段代码在 ModelSim-Altera 的模拟中运行良好。

谢谢。

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

编辑#2:如果我反应缓慢,我很抱歉我正在做其他事情。所以问题仍然存在,我还没有弄清楚为什么......这里有一些可能有用的见解。以下代码运行良好,并使用与 $clog2 相同类型的寄存器大小。如果有人看到我发布的代码和这个代码之间有任何差异,请上前大喊“我找到了!”,因为这让我发疯: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:我实际上只是注意到多路复用器代码没有正确合成为符号(选择端口丢失......我应用了相同的修复程序,现在可以了)。

再次,任何帮助将不胜感激。

标签: verilogfpgasystem-verilogquartus

解决方案


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

至于制作$clog2(9999)规模的依据N_DIGITS,使用$clog2(10**N_DIGITS-1).

您可能还想分配$clog2(...)给一个参数。ANSI 标头样式示例:

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 );

推荐阅读