【问题标题】:Verilog error in modelsim- near "=": syntax error, unexpected '=', expecting IDENTIFIER or TYPE_IDENTIFIER or NETTYPE_IDENTIFIERmodelsim 中的 Verilog 错误-“=”附近:语法错误,意外 '=',需要 IDENTIFIER 或 TYPE_IDENTIFIER 或 NETTYPE_IDENTIFIER
【发布时间】:2018-07-17 16:43:33
【问题描述】:

我在 modelsim 10.4 中遇到以下错误:

错误:(vlog-13069) D:/divya/verilog/pipelined alu/alu.v(5): near "=": 语法错误,意外 '=',需要 IDENTIFIER 或 TYPE_IDENTIFIER 或 NETTYPE_IDENTIFIER。

代码:

module func(output reg[15:0] out,input[15:0] a,b,input[3:0] select);


case(select)

0:out=a+b;

1:out=a-b;

2:out=a*b;

3:out=a;

4:out=b;

5:out=a&b;

6:out=a|b;

7:out=a^b;

8:out=~a;

9:out=~b;

10:out=a>>1;
11:out=a<<1;

default:out=16'hxxxx;

endcase

endmodule

【问题讨论】:

    标签: verilog simulation hdl modelsim


    【解决方案1】:

    在实现上述组合逻辑时,您需要确保将功能描述放在一个程序块中,如 always @(*)assign 语句(您使用哪个语句取决于逻辑的长度和其他次要因素)。下面是带有一些格式的代码(请记住,编码风格不仅仅关乎美观;它还有助​​于发现错误并使阅读代码更容易!):

    module func(output reg [15:0] out,
                input [15:0] a, b,
                input [3:0] select); // I like to break up io on multiple lines to make it easier to read
    
      always @(*) begin // Need to put logic in a procedural block!
        case(select)
        0: out = a + b;
        1: out = a - b;
        2: out = a * b; // Note that this would take quite a bit of logic compared to all the other operations here, combinational multiply take alot of gates
        3: out = a;
        4: out = b;
        5: out = a & b;
        6: out = a | b;
        7: out = a ^ b;
        8: out = ~a;
        9: out = ~b;
        10: out = a >> 1;
        11: out = a << 1;
        default: out = 16'hxxxx;
        endcase
      end
    endmodule
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-09
      相关资源
      最近更新 更多