26. UART transmitter
Send bytes on a serial line in the common 8N1 format: one start bit (0), eight data bits with the least significant bit first, one stop bit (1). Each bit lasts exactly 4 clock cycles. Between frames the line idles at 1.
When start = 1 at a rising clock edge and the transmitter is not busy, it captures data on that edge and the start bit begins at once (tx is 0 after that edge). busy goes to 1 on the same edge and stays 1 for the whole frame: 10 bits of 4 cycles, 40 cycles in all. On the 40th edge after the one that captured the byte, tx returns to idle and busy drops to 0; a new start can be accepted from the next edge. start while busy is ignored, and data may change freely once captured.
tx must come straight from a flip-flop. rst (synchronous, active high) puts the line in idle (tx = 1) and clears busy.
Ports
| Port | Dir | Bits | What it is |
|---|---|---|---|
clk | in | 1 | Clock. |
rst | in | 1 | Synchronous reset, active high. |
start | in | 1 | Send data (ignored while busy). |
data | in | 8 | Byte to send. |
tx | out | 1 | Serial line, idle high. |
busy | out | 1 | 1 while a frame is being sent. |
Example
Sending 0xB2 (1011_0010): after the capturing edge the line reads 0 (start) for 4 cycles, then 0, 1, 0, 0, 1, 1, 0, 1 (bit 0 first), 4 cycles each, then 1 (stop) for 4 cycles.
Written hints
AI hint
Submissions
No submissions yet. Submit your answer and it shows here. Sign in to keep them.
Submit your answer to have it graded. The hidden test runs on the server; you see whether it passes and, if not, the first case it gets wrong.
Press Build to check your code with Yosys. Errors and warnings show here, and a clean build draws the logic diagram.
Build your design to drive it by hand and see its signals here.