I have a 50Mhz master clock clk and from that I have a derived baudClock clock which runs at 9600bps.
I have a transmitter module that I want to follow a state machine flow every baudClock.
The transmitter module receives strings from an external module/testbench and puts them into a queue. I want the state machine to take an item from the queue and then reduce queueCount by one.
On the other hand, I would like to be able to add an item to the queue on a clk cycle.
I cannot implement something such as that below because I would then be assigning queueCount from 2 always processes (resulting in multiple driver errors).
always_ff @(posedge clk ) begin if( addToQueue ) begin if( queueCount < MAX_ELEMENTS ) begin textQueue[ queueCount ] = myString; queueCount ++; end end end always_ff @(posedge baudClock ) begin unique case( state ) IDLE : HandleIdle(); GETNEXT : HandleGetNextString(); // Decreases queueCount SENDSTART : HandleSendStart(); SENDDATA : HandleSendData(); SENDBYTEDONE : HandleSendByteDone(); endcase end
How would I go about doing this? ie. What's the best way to share variables in reading/writing or producer/consumer scenarios?
baudTickis not really a variable ... it is a signal \$\endgroup\$