Driver implementation using statemachine, getting extra delay in driving command./data on bus

Hello All,

I am implementing a driver for the bus protocol using statemachine flow,
the statemachine has the following states,

IDLE, COMMAND, RESPONSE, READ_DATA, WRITE_DATA.
IDLE - reset
COMMAND - my actual command frame should be driven on bus
RESPONSE - receive response from the slave or DUT
READ_DATA - if the operation is a read after the bus turn around time i start receiving the data(just for parity calculation and retry if any error is there)
WRITE_DATA - if the operation is write, the driver starts sending the data on the bus io.

the difficulty am having is,
the transition from one state to another takes one clock,
so for eg - if first clock is IDLE and next clock if it moves to COMMAND, i immediately want to send the command on bus,but my present implementation is in the COMMAND state i call a task drive_command and it looks for posedge and then drives the data, so what happens is only in the third clock my data is being driven outside, how do i avoid this?

also my implementation is in COMMAND state i do a “get_next_item” and in end of READ_DATA/WRITE_DATA i do a “item_done”, is this fine?
i also have scenarios like i may have to perform a write transaction immediately after a read transaction, so all i have is just one IDLE clock inbetween the end of READ data phase and next WRITE command.

my requirement is as soon as i enter COMMAND i want the command to be driven onto bus immediately.

please help guys…

maximus…

In reply to maximus:

Hi maximus,

what you are describing is mor or less a SV problem. You should consider each clock ha a falling and a rrising egde. If you get an extra clock cycle delay you might avoid this by dealing with the falling edge.

There has to be always a pair of get_next_item and item_done. item_done should be executed always at the end of the protocol.

In reply to chr_sue:

Agreed, yes its kind of SV related issue, sure, let me consider your tip and try to fix my issue. Thanks for the tip…