Problems

26. UART transmitter

HardWrite the moduleAbout 40 min
fsmserialuartcounters

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

Module uart_tx

PortDirBitsWhat it is
clkin1Clock.
rstin1Synchronous reset, active high.
startin1Send data (ignored while busy).
datain8Byte to send.
txout1Serial line, idle high.
busyout11 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.

Stuck? . Sign in to save your progress. You can solve the free problems without an account.

Veriloguart_tx.v
14px
Loading the editor…

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.

UART transmitter: Verilog interview question | breadboardhub