Altera_Forum
Honored Contributor
8 years agoFSM Caught in impossible State
Hey all,
So I've been developing an FPGA (Cyclone 3 Series) that basically sits between an FX3 USB 3 micro-controller and the HPI interface of a DSP. My problem lies withing my FSM, that is responsible for managing the timing of reading and writing to the DMA buffers in the FX3. After reading data from the FX3, I need to wait until I receive a signal "mult_done", before I can write back to the FX3 as that signals the data is ready. However when the state machine reaches the point where it waits for mult_done to go high and continue to the write state, the problem occurs. The state machine seems to go to the write state (HPI_FPGA_write_to_usb), but then returns to the previous state (HPI_FPGA_wait_read_mult_done), then continues to alternate between these two states on each positive clock edge, (I've checked this using a scope and test pins). The code for my state machine is more or less as follows, let me know if I can supply any further details as I'm still fairly new to quartus. --HPI_FPGA mode state machine combo HPI_FPGA_mode_fsm : process(clk_ddr, reset_n) begin if(reset_n = '0')then current_HPI_FPGA_state <= HPI_FPGA_idle; elsif(clk_ddr'event and clk_ddr = '1')then current_HPI_FPGA_state <= next_HPI_FPGA_state; case current_HPI_FPGA_state is . . . . when HPI_FPGA_wait_flagb => if(flagb_d = '1' and read_writeb_mode = '1')then next_HPI_FPGA_state <= HPI_FPGA_wait_read_mult_done; elsif(read_writeb_mode = '0' and flagb_d = '1') then next_HPI_FPGA_state <= HPI_FPGA_write_to_usb; else next_HPI_FPGA_state <= HPI_FPGA_wait_flagb; end if; when HPI_FPGA_wait_read_mult_done => if(mult_done_sig = '1')then next_HPI_FPGA_state <= HPI_FPGA_write_to_usb; else next_HPI_FPGA_state <= HPI_FPGA_wait_read_mult_done; end if; when HPI_FPGA_write_to_usb => if(flagb_d = '0' or pktend_sig = '0')then next_HPI_FPGA_state <= HPI_FPGA_write_wr_delay; else next_HPI_FPGA_state <= HPI_FPGA_write_to_usb; end if; . . . end case; end if; end process; I greatly appreciate any advice you can give me. Kind Regards Ricky