My FPGA has 50Mhz clock (clk). From this clock I have a module that generates a 9600 baud clock (baudTick).
UART_BaudRate_generator #(baudRate) BaudGen1(
.Clk( clk ),
.Tick( baudTick ) );
Every 50000000 clk cycles (every second) I want to transmit some text to my PC.
always_ff @( posedge clk )
begin
counter ++;
if( counter > 50000000 ) // 1Hz
begin
counter = 0;
secondCount ++;
myString = getStr();
addStringToQueue = 1;
end
end
I have a CharacterTransmitter module which adds a copy of myString to an internal queue when addStringToQueue is high.
CharacterTransmitter charTransmitter( myString, addStringToQueue, baudTick, o101 );
CharacterTransmitter runs off the baudTick clock.
What I want to do is reset addStringToQueue after one baudTick clock cycle has passed.
My problem is that I cannot set it inside the always_ff @( posedge clk ) block/process and within another always_ff @( negedge baudTick ) process because of the “mulitple constant drivers” error I receive. I understand that only one always block should be setting an output.
So how would I go about setting and clearing my addStringToQueue flag in this scenario? I know I could use the clk block to keep it high for a number of clk cycles but I’d prefer to clear the flag when an actual baudTick has elapsed.
The only way I can think of doing this is to get the CharacterTransmitter to return a gotString output that is high for one baudTick upon consumption. Is this the way I should be going?
My software brain is longing for something like a shared semaphore in this case.