2

我是 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
4

1 回答 1

0

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

改变:

    default= S0;

至:

    default statoprox = S0;

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

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

于 2021-02-08T20:08:58.783 回答