【问题标题】:iverilog error: syntax in assignment statement l-valueiverilog 错误:赋值语句左值中的语法
【发布时间】:2021-02-08 20:04:39
【问题描述】:

我是 SystemVerilog 的新手,我使用的是 Icarus Verilog。 我正在尝试设计一个简单的 FSM 来练习,但我不断收到此错误:

错误:赋值语句左值中的语法

module primoex (input logic clk, reset, x,
               output logic y);
               
    enum reg [1:0] {S0, S1, S2} stati;
    reg [1:0] stato, statoprox;
     

     always_ff@(posedge clk, posedge reset) 
      if(reset) stato = S0; 
      else stato <= statoprox;

    always_comb 
    case (stato)
        S0: statoprox = x? S1 : S0;
        S1: statoprox = x? S2 : S0;
        S2: statoprox = x? S2 : S0;
        default= S0;
    endcase

    
    assign y = S1 & ~S0; 

endmodule

【问题讨论】:

    标签: verilog system-verilog digital-design


    【解决方案1】:

    case 语句中,default 关键字用于代替其他案例项值;你不能给它赋值。您仍然需要使用您分配的信号名称。

    变化:

        default= S0;
    

    到:

        default statoprox = S0;
    

    此代码在多个模拟器上的 edaplayground 上编译。您可以注册一个免费帐户。

    它无法在 Icarus 上编译,但您可能有不同的版本。我看到与您报告的编译错误不同。请记住,Icarus 并不支持所有 SystemVerilog 功能。

    【讨论】:

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