Not sure if this is correct implementation, although it works so far. I output the data on the rising edge of the FETCH signal (this is not a clock). The data should only be out in the OUTP state. This also counts how many words were output so far, and the state machine (not shown) transitions to a different state if the word count reaches some value.
always @(posedge FETCH) case(state) OUTP: begin OUT_DATA <= DATA[WordCounter]; WordCounter <= WordCounter + 1 ; end default:WordCounter <= 6'd0; endcase
The problem is that to reset the WordCounter, I must pulse FETCH signal when not in the OUTP state. Is there a better way to rewrite this code, so I can fetch the data on the edge, but the WordCounter can be reset in any state other than OUTP not requiring a rising edge?