The problem is with your `define
statement. `define
is similar to #define
in C/C++. The statements do literal substitution and the terminator is end of line, not a semi-colon. repeat (`delay)
means repeat ( 20; )
. Remove the ;
and it will simulate.
Even with with the correction it will not synthesize. Blocking statements (i.e. @
,#
, and wait
) are not allowed inside combinational logic. To be synthesizable, you'll need to add some flip-flops for a counter. Your next state and next counter combinational logic should look something like the following:
always @* begin
// default value
ns = cs;
next_counter = counter + 1;
// update value
case(cs)
s0: begin
if (counter >= `delay) begin
ns = s1;
next_counter = 0;
end
end
/* ... */
endcase
end
Also, remember to assign flops with non-blocking (<=
). Blocking (=
) for assigning combinational logic.