verilog - 无法为模块创建符号文件,因为端口的类型不受支持
问题描述
我遇到了这个奇怪的问题,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:我实际上只是注意到多路复用器代码没有正确合成为符号(选择端口丢失......我应用了相同的修复程序,现在可以了)。
再次,任何帮助将不胜感激。
解决方案
从 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 );
推荐阅读
- ember.js - 将带有源映射的 ember-cli 生产构建配置到不同的域
- python - 神经网络不接受灰度图像
- version - 32 位处理器的 LoadRunner 版本
- haskell - 如何为具有存在量化类型变量的复合类型编写类型实例?
- python - 包控制:当前未安装依赖项“markupsafe”
- parse-platform - 从 android studio 在 bitnami Parse 服务器上设置电子邮件验证
- ios - 在 AKPlayer.buffer 上播放
- html - 获取动态输入字段的值
- datetime - 如何在多个键上使用 pandas Grouper?
- javascript - 无法使用 v2 api 在对话流中正确创建 Intent