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

问题描述 投票:-1回答:1

我有一个奇怪的问题,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”应该是“输入线”,我还有其他类似的代码也可以正常工作。也许我缺少明显的东西,但我将不胜感激,我将为您提供任何帮助。

我还要提到的是,该代码在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

再次,将不胜感激。

verilog fpga system-verilog quartus
1个回答
0
投票

我不确定标准怎么说,但是好的做法是始终使用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);
© www.soinside.com 2019 - 2024. All rights reserved.