J
Jeepster
Guest
This has been driving me nuts!
I'm compiling and simulating using quartus. The state machine is
supposed to loop forever in 100->101->110->111. But based on
simulation results, it sometimes skips 100 in some loop iterations.
Any ideas? Thanks!
always @(posedge FIFO_CLK)
case(state)
3'b000: if( FIFO2_data_available) state <= 3'b001; // wait for data
packet in FIFO2
3'b001: if(~FIFO2_data_available) state <= 3'b010; // wait until end
of data packet
3'b010: begin
start <= 1'b1;
if (state_31==3'b101) state<=3'b100;
end
3'b100: begin //0 - 511
if((read_pos==511)) state<=3'b101;
else if(1) read_pos <= read_pos+1'b1;
end
3'b101: if((state_31==3'b110)) // wait
begin
state<=3'b110;
read_pos <= 512;
end
3'b110: begin // 512 - 1023
if((read_pos==1023)) state<=3'b111;
else if(1) read_pos <= read_pos+1'b1;
end
3'b111: if((state_31==3'b101)) //wait
begin
state<=3'b100;
read_pos <= 0;
end
default: state <= 3'b000;
endcase
I'm compiling and simulating using quartus. The state machine is
supposed to loop forever in 100->101->110->111. But based on
simulation results, it sometimes skips 100 in some loop iterations.
Any ideas? Thanks!
always @(posedge FIFO_CLK)
case(state)
3'b000: if( FIFO2_data_available) state <= 3'b001; // wait for data
packet in FIFO2
3'b001: if(~FIFO2_data_available) state <= 3'b010; // wait until end
of data packet
3'b010: begin
start <= 1'b1;
if (state_31==3'b101) state<=3'b100;
end
3'b100: begin //0 - 511
if((read_pos==511)) state<=3'b101;
else if(1) read_pos <= read_pos+1'b1;
end
3'b101: if((state_31==3'b110)) // wait
begin
state<=3'b110;
read_pos <= 512;
end
3'b110: begin // 512 - 1023
if((read_pos==1023)) state<=3'b111;
else if(1) read_pos <= read_pos+1'b1;
end
3'b111: if((state_31==3'b101)) //wait
begin
state<=3'b100;
read_pos <= 0;
end
default: state <= 3'b000;
endcase