Quartus Prime 在 $error 命令中抛出错误

Quartus Prime throwing an error at a $error command

我遇到了以下代码的问题,它应该只是在编译时抛出一个错误 如果我的输入数量不能被我的输出数量整除。

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

    generate
        if (N_INPUTS % N_OUTPUTS != 0) begin
            $error("%m ** Illegal Parameter ** NUMBER OF INPUTS(%d) does not divide into NUMBER OF OUTPUTS(%d)", N_INPUTS, N_OUTPUTS);
        end
    endgenerate

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

    always @ (select, in) begin
        out = in[(select + 1) * N_OUTPUTS - 1:(select + 1) * N_OUTPUTS - N_OUTPUTS];
    end

endmodule

但是当我进行分析时,Quartus 一直向我抛出这个错误:

Error (10170): Verilog HDL syntax error at multiplexer.v(5) near text: "$error";  expecting "end". Check for and fix any syntax errors that appear immediately before or at the specified keyword. The Intel FPGA Knowledge Database contains many articles with specific details on how to resolve this error. Visit the Knowledge Database at https://www.altera.com/support/support-resources/knowledge-base/search.html and search for this specific error message number.

开始怀疑Quartus的编译器是否支持$error命令(第一次用)

我将不胜感激任何有关该主题的帮助,因为我仍然是该领域的初学者:)

我看到其他错误:

  • 您正在从程序块中驱动电线 out(您的 always 堵塞)。你不能那样做,你只能驱动一个变量。即out 必须是变量。

  • 你方括号内的代码是非法的。你将需要使用 +:-: 运算符之一。见 this answer here.

关闭您的 Quartus 项目并在 .qsf 文件中,更改指向您的 multiplexer 模块 verilog 文件的行:

set_global_assignment -name VERILOG_FILE multiplexer.v

收件人:

set_global_assignment -name SYSTEMVERILOG_FILE multiplexer.v

编辑:

同时设置:

set_global_assignment -name VERILOG_INPUT_VERSION SYSTEMVERILOG_2009

编辑 2:

这是 SystemVerilog 2009 的一个特性,Quartus Prime Standard 和 Quartus Prime Lite 不支持 VHDL 2008 或 SystemVerilog 2009。

Quartus Prime Pro 19.4:

Quartus Prime 标准版 19.1:

我找到了问题...钱... 如果你看下面的图片,你会发现如果你很穷,你就不能使用 Quartus Prime 精简版和标准版中最新版本的 SystemVerilog。

好吧,这就说明了一切。 如果有人作为另一种在编译时抛出错误的解决方案看起来比这更好,请告诉我:

generate
if (CONDITION > MAX_ALLOWED /* your condition check */ ) begin
    illegal_parameter_condition_triggered_will_instantiate_an non_existing_module();
end
endgenerate

注意:这取自https://electronics.stackexchange.com/a/71226