Altera_Forum
Honored Contributor
10 years agoConverting Aynchronous UART to Synchronous USART
OpenCores has a very stable uart (attached) that integrates easily to altera/qsys.
My goal is to tweak it just enough so that it transmits on the rising edge and receives on the falling edge of a separate dedicated 1mhz clock. Looking at the tx state machine, it looks to run off the system clock, but gets enabled via a 16x baud clock:
module uart_transmitter (wb_clk, wb_rst_i, baud_16x_enable...
always @(posedge wb_clk or posedge wb_rst_i)
begin
if (baud_16x_enable)
begin
case (tstate)
s_idle : if (~|tf_count) // if tf_count==0
...
Where the baud_16x_enable is generated from a divided system clock:
// Enable signal generation logic
always @(posedge wb_clk or posedge wb_rst_i)
begin
if (wb_rst_i)
baud_16x_enable <=# 1 1'b0;
else
if (|dl & ~(|dlc)) // dl>0 & dlc==0
baud_16x_enable <=# 1 1'b1;
else
baud_16x_enable <=# 1 1'b0;
end
I was thinking to make it synchronous all I'd have to do is keep it enabled (baud_16x_enable <= 1'b1), and replace the wb_clk driving the transmitter, by my sync_clk in order for the state machine to clock out synchrounsly from the dedicated clock. Would it be this easy, or would this not work?