Handshake

I have two agents, one master, one slave.

protocol supports pipe-lining. when slave captures command it sends response, if its free it sends it next clock cycle, if it’s not it might take more clock cycles. My question is how can I emulate this latency in code to be random in range of 5 wait cycles or less.