Altera_Forum
Honored Contributor
9 years agoQuartus not synthesizing my FSM right?
I made a FSM in verilog that is working in simulation.
I found a strange behaviour however, when I synthesize it in Quartus 2. The state WRITE should immediately go to WRITE_DONE, which it does. But when in state WRITE_DONE, it should wait for the trigger of "ye" going low before moving on to the next state. But when I synthesize and put this on FPGA, the WRITE_DONE is immediately passing to YE_PROG2 state on the next clock cycle, without waiting for the 'if condition'. Does anyone have any suggestion why this might be happening? is there an error in my code I'm missing that's causing the synthesis to not do what I want? The code seems straightforward to me. I did pull out the 'ye' signal in SignalTap to make sure it's high. always@(posedge clk or negedge resetn)
begin
if (!resetn)
begin
state <= IDLE;
end
else
begin
state <= next_state;
end
end
always@(*)
begin
//next_state = IDLE;
case(state)
IDLE: begin
if (read_start | read_next)//(xe & se & ye & yadr_change)) //(xe & ye & se)
next_state = XYS;
else if (xe & prog & !se)
next_state = XPS;
else
next_state = IDLE;
end
// READ
XYS: begin
if ((xe & ye & se) == 0)
next_state = IDLE;
else if (xys_count >= 2)//(xys_count == 2)
next_state = READ;
end
READ: next_state = READ_READY;
READ_READY: begin
if (hreadyout_rise)
next_state = READ2;
end
READ2: next_state = READ_READY2;
READ_READY2: begin
if (hreadyout_rise)
next_state = IDLE;
end
// WRITE
XPS: begin
if ((xe & prog & !se) == 0)
next_state = IDLE;
else if (ye_rise)
next_state = YE_PROG;
end
YE_PROG: begin
if ((xe & prog & !se) == 0)
next_state = IDLE;
else if (prog_count == 5'd31)//(prog_count > 30)
next_state = WRITE;
end
WRITE: next_state = WRITE_DONE;
WRITE_DONE: begin
if (!ye)
next_state = YE_PROG2;
end
YE_PROG2: begin
if ((xe & prog & !se) == 0)
next_state = IDLE;
else if (prog_count == 5'd31)
next_state = WRITE2;
end
WRITE2: next_state = WRITE_DONE2;
WRITE_DONE2: begin
if ((xe & prog & !se) == 0)
next_state = IDLE;
else if (ye_fall)//(hreadyout_rise)
next_state = IDLE;
end
default: next_state = IDLE;
endcase // case (state)
end // always@ (*)