1

I have about six errors but they are all the same. The error goes as such: near "?": syntax error, unexpected '?'

I've been trying to figure out how to fix this and I've looked at other problems in stackoverflow relating to this problem but to no avail. At first I thought it was how I was formatting my ternary statements but that wasn't it. So what could the prroblem be?

Code:

always_ff@(posedge clk, posedge reset)
   if (reset) state <= S0;
   else state <= nextstate;

always_comb
 case (state)
  S0: OpCode1 ? nextstate <= S2 : nextstate <= S1;
  S1: OpCode2 ? nextstate <= S8 : nextstate <= S4;
  S2: OpCode2 ? nextstate <= S3 : nextState <= S9;
  S3: nextstate <= S0;
  S4: A ? nextstate <= S5 : nextstate <= S13;
  S5: B ? nextstate <= S7 : nextstate <= S6;
  S6: Binv ? nextstate <= S14 : nextstate <= S13;
  S7: Binv ? nextstate <= S13 : nextstate <= S14;
endcase

Note S1 to S14 are part of an enum that holds 5 bits[4:0]. The rest are inputs.

Luis Averhoff
  • 887
  • 2
  • 11
  • 22

1 Answers1

1

I don't see the result of ternary operation being assigned to a register. Try rewriting it as below:

nextstate = (OpCode1) ? S2 : S1;
Greg
  • 18,111
  • 5
  • 46
  • 68
vim
  • 84
  • 1
  • 2
  • 9
  • Yes, that was the problem. Note that this is an enum so it is actually nextstate <= opCode1. – Luis Averhoff Feb 22 '16 at 01:14
  • FYI: combinational logic should be assigned with a blocking assignment (`=`), not non-blocking (`<=`). non-blocking should be used to assign flops (both edge-sensitive flip-flops and level-sensitive latches). Enums allow do not determine if it should be blocking or non-blocking, it all depends how it is intended to be used. – Greg Feb 22 '16 at 03:57