【问题标题】:Verilog syntax error in module declaration模块声明中的 Verilog 语法错误
【发布时间】:2018-01-31 18:37:25
【问题描述】:

我收到声明第二个模块的语法错误,我已在 cmets.xml 中指出。我正在使用在线 Verilog 模拟器,所以它不会告诉我什么样的错误。我真的很困惑,因为我遵循了与第一个模块相同的设置,并且我没有收到错误。它与重用变量有关吗?我尝试更改它们,但似乎不起作用。

    module MagnitudeComparator4Bit(input [3:0] a, input [3:0] b, output eq, output lt, output gt); 
assign eq = a==b;
assign lt = a < b;
assign gt = a > b;
 endmodule

module 8bitMagCompare(input [7:0] a, input [7:0] b, output EQ, output LT, output GT); //SYNTAX ERROR
wire w1, w2, w3, w4;
MagnitudeComparator4Bit MagComp1(a[7:4], b[7:4], w1, LT, GT);
MagnitudeComparator4Bit MagComp2(a[3:0], b[3:0], w2, w3, w4);
assign EQ = w1 && w2;
endmodule

module MagCompareTB;
reg a, b;
wire EQ, LT, GT;

8bitMagCompare testcompare(a, b, EQ, LT, GT);

initial begin
$monitor("%d A=%a, B=%b, EQ=%b, LT=%b, GT=%b", $time, a, b, EQ, LT, GT);
    #10 a = 00000000;
        b = 00000000;
    #10 a = 10000000;
        b = 00000000;
    #10 a = 00000000;
        b = 10000000;
end
endmodule

【问题讨论】:

    标签: module syntax-error verilog


    【解决方案1】:

    很明显你错过了它:第二个模块名称以数字开头!

    但我也不满意您为第二个模块编写的代码。如果第一个 (MS) 实例报告相等,则应使用第二个 (LS) 实例的所有结果。

    尝试使用例如00010000 和 00010001。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多