Part of Curriculum: Protocol RTL Design (Module 10: UART & SPI Serial Controllers)
View Full Roadmap →
Level 3 Hard ★ Flagship #30 50 pts ✓ Solved

UART Transmitter — Serial Communication

Serial Protocols · memory, fifo, protocols, apb, uart, hard, uart

Implement an 8N1 UART transmitter (1 Start bit (0), 8 Data bits (LSB first), 1 Stop bit (1)) with start strobe and busy flag. (Clocked with 1 cycle per bit for simulation simplicity).

Write a synthesizable Verilog module named top_module matching the ports below exactly.
📐 Circuit Schematic Diagram
tx_starttx_data[7:0]txbusy>clkrst_nUART TRANSMITTERPROTOCOL INTERFACE
⚡ Timing & Synthesizability Constraints

Timing Contract: When `tx_start=1` while `!busy`, frame serialization begins: 1 start bit, 8 data bits, 1 stop bit.

RTL Constraints: Idle line state must be 1 (MARK). Simplified 1 clock cycle per bit for fast educational simulation.

Objective: Master framing protocols, serializer shift registers, transmission state machines, and baud clocking.

Prerequisites: Shift registers, FSM design, serial communication framing.
NameDirWidthDescription
clkinput1Baud rate clock
areset_ninput1Active-low reset
tx_startinput1Strobe to begin transmission
tx_datainput88-bit byte to transmit
txoutput1Serial TX line (idle = 1)
busyoutput1High while transmitting frame
Expected Waveform (Golden Timing Contract)
💡 Need Guidance? Progressive Hints (3 Levels)
Hint 1: Conceptual Direction & Hardware Primitives
Use a bit counter `bit_cnt`: 0 = idle, 1..8 = data bits, 9 = stop bit.
Hint 2: Implementation Architecture & Approach
Frame format: Start bit is always `0`, followed by 8 data bits (LSB first: `sh_reg[0]`), ending with Stop bit `1`.
Hint 3: Edge Cases, Timing & Verilog Syntax
Idle state of `tx` must be `1`.
🔒 Reveal Verified Reference RTL Solution (Click to expand)
⚠️ Self-Discovery Warning: Try solving and simulating first! Viewing the verified reference implementation will bypass the real debugging experience.
Verified Synthesizable RTL
module top_module(
  input        clk,
  input        areset_n,
  input        tx_start,
  input  [7:0] tx_data,
  output reg   tx,
  output       busy
);
  reg [3:0] bit_cnt;
  reg [7:0] sh_reg;

  assign busy = (bit_cnt != 4'd0);

  always @(posedge clk or negedge areset_n) begin
    if (!areset_n) begin
      tx      <= 1'b1; // Idle line is HIGH
      bit_cnt <= 4'd0;
      sh_reg  <= 8'd0;
    end else if (bit_cnt == 4'd0) begin
      tx <= 1'b1;
      if (tx_start) begin
        tx      <= 1'b0; // Start bit (0)
        sh_reg  <= tx_data;
        bit_cnt <= 4'd1;
      end
    end else if (bit_cnt >= 4'd1 && bit_cnt <= 4'd8) begin
      tx      <= sh_reg[0]; // Data bits LSB first
      sh_reg  <= {1'b0, sh_reg[7:1]};
      bit_cnt <= bit_cnt + 1'b1;
    end else if (bit_cnt == 4'd9) begin
      tx      <= 1'b1; // Stop bit (1)
      bit_cnt <= 4'd0; // Complete
    end
  end
endmodule
Verilog-2001 / SV Saved
Font: |
// Click Run Tests (or press Ctrl+Enter) to compile your RTL and simulate against hidden testbenches.
Simulation Timing Diagram (VCD Waveform)
100%
No simulation waveform yet. Run tests to simulate and generate VCD traces.
No compilation run yet. Syntax warnings and elaboration messages will appear here.
No simulation output yet. Raw stdout from vvp will appear here.

RTL Problems / Level 3 · Serial Protocols

What You Will Learn

By solving UART Transmitter — Serial Communication, you will acquire core industry skills:

  • Synthesizable hardware modeling in standard Verilog-2001 / SystemVerilog.
  • Correct handling of interface port contracts, edge-triggered clocks, and active-low/high resets.
  • Simulation waveform interpretation and debugging using timing diagrams (VCD traces).
  • Architectural avoidance of timing violations, glitching hazards, and synthesis warnings.

Problem Statement & Requirements

Implement an 8N1 UART transmitter (1 Start bit (0), 8 Data bits (LSB first), 1 Stop bit (1)) with start strobe and busy flag. (Clocked with 1 cycle per bit for simulation simplicity).

Hardware design teams at leading semiconductor firms evaluate these exact port contracts, race-condition assertions, and corner cases during technical design reviews and ASIC engineer interviews.

Objective: Master framing protocols, serializer shift registers, transmission state machines, and baud clocking.

Prerequisites: Shift registers, FSM design, serial communication framing.

Port List & Interface Timing

The hidden testbench instantiates top_module. Module port names and bit-widths must match the interface contract exactly:

NameDirWidthDescription
clkinput1Baud rate clock
areset_ninput1Active-low reset
tx_startinput1Strobe to begin transmission
tx_datainput88-bit byte to transmit
txoutput1Serial TX line (idle = 1)
busyoutput1High while transmitting frame

Timing Constraints & Synthesizable RTL Rules

⚡ Synthesizable Implementation Guidelines

Timing Contract: When `tx_start=1` while `!busy`, frame serialization begins: 1 start bit, 8 data bits, 1 stop bit.

Synthesis Constraints: Idle line state must be 1 (MARK). Simplified 1 clock cycle per bit for fast educational simulation.

Architectural Deep Dive & Implementation Walkthrough

UART is an asynchronous serial protocol. The receiver detects the falling edge of the Start bit (0), samples data at the midpoint of each baud period, and validates the frame with the Stop bit (1). In real systems, a baud rate generator divides the system clock down to standard baud rates (115200 bps).

Common RTL Designer Pitfalls

⚠️ Common Mistakes to Avoid

['Sending MSB first instead of LSB first (standard UART transmits `tx_data[0]` first).', 'Leaving the TX line low in idle: UART idle line is active-high (MARK).']

Silicon & Hardware Engineering Notes

🛠️ ASIC vs FPGA Hardware Considerations

This educational design assumes 1 cycle per baud bit. Real UARTs include a 16x oversampling baud divider to align the receiver to the center of incoming bit pulses.

Starter RTL Code

module top_module(
  input        clk,
  input        areset_n,
  input        tx_start,
  input  [7:0] tx_data,
  output reg   tx,
  output       busy
);

  // 8N1 UART Transmitter (1 start bit, 8 data bits, 1 stop bit)

endmodule

Verified Reference Solution

🔒 Reveal Verified Reference RTL Solution
module top_module(
  input        clk,
  input        areset_n,
  input        tx_start,
  input  [7:0] tx_data,
  output reg   tx,
  output       busy
);
  reg [3:0] bit_cnt;
  reg [7:0] sh_reg;

  assign busy = (bit_cnt != 4'd0);

  always @(posedge clk or negedge areset_n) begin
    if (!areset_n) begin
      tx      <= 1'b1; // Idle line is HIGH
      bit_cnt <= 4'd0;
      sh_reg  <= 8'd0;
    end else if (bit_cnt == 4'd0) begin
      tx <= 1'b1;
      if (tx_start) begin
        tx      <= 1'b0; // Start bit (0)
        sh_reg  <= tx_data;
        bit_cnt <= 4'd1;
      end
    end else if (bit_cnt >= 4'd1 && bit_cnt <= 4'd8) begin
      tx      <= sh_reg[0]; // Data bits LSB first
      sh_reg  <= {1'b0, sh_reg[7:1]};
      bit_cnt <= bit_cnt + 1'b1;
    end else if (bit_cnt == 4'd9) begin
      tx      <= 1'b1; // Stop bit (1)
      bit_cnt <= 4'd0; // Complete
    end
  end
endmodule
Advertisement

Related RTL Problems in Level 3

Frequently Asked Questions

What does UART Transmitter — Serial Communication require?

Implement an 8N1 UART transmitter (1 Start bit (0), 8 Data bits (LSB first), 1 Stop bit (1)) with start strobe and busy flag. (Clocked with 1 cycle per bit for simulation simplicity). Implement it as Verilog module top_module matching the listed ports.

Is this design combinational or sequential?

Tags: memory, fifo, protocols, apb, uart, hard, uart. If a clock signal is present in the port table, implement it as sequential logic; otherwise, use continuous assignments or combinational blocks.

How is my solution graded?

A hidden SystemVerilog testbench simulates your module in the cloud judge. You pass when all directed corner cases match the golden model and the VCD timing waveform matches the contract.

How does this challenge help with semiconductor interviews?

Technical interviewers at NVIDIA, Qualcomm, Apple, and Intel routinely ask candidates to code, debug, and explain the timing waveforms of UART Transmitter — Serial Communication to assess real-world synthesizability and race-condition awareness.

Advertisement