RTL Studio Open IDE

2.3 · SOC CLASS

UART CSR hook (lite)

Implement a lightweight UART CSR hook to expose TX data and busy status via AXI-Lite, verifying functionality with a testbench.

Video coming soon. This lesson page stays at the same URL when the lecture publishes.

What you practice

UART CSR hook (lite) (2.3). Implement a lightweight UART CSR hook to expose TX data and busy status via AXI-Lite, verifying functionality with a testbench. It is in UART CSR Hook — Part 2 · Peripheral Islands of the SoC Masterclass. Build GPIO, timer, UART, and IRQ islands, then wrap them as a peripheral subsystem.

SoC lessons simulate the fabric and the peripheral together in the IDE. Verilator is the simulator; the waveform is where address and response show up.

What you will learn

This lesson teaches you how to implement a lightweight UART Control and Status Register (CSR) hook. You will expose the UART TX data register and the busy status bit via an AXI-Lite interface. This is a fundamental skill for integrating peripherals into a System-on-Chip (SoC). Proper CSR mapping allows software to control hardware behavior through memory-mapped I/O.

Learning objectives

  • Define the correct address offsets for UART TX data and status registers.
  • Implement the AXI-Lite write logic to capture TX data and assert TX valid.
  • Implement the AXI-Lite read logic to return the TX busy status.
  • Verify the CSR hook functionality using the provided testbench.

Theory

The UART CSR hook acts as a bridge between the AXI-Lite bus and the UART transmitter logic. It must decode specific memory addresses to determine whether the bus master is writing to the TX data register or reading the status register. The AXI-Lite protocol uses separate address channels for writes (AW) and reads (AR), followed by data channels (W/R) and response channels (B). The state machine in the CSR hook must handle these phases correctly to ensure data integrity.

SignalDirectionDescription
axi_bus.awaddrInputAddress for write transaction
axi_bus.araddrInputAddress for read transaction
axi_bus.wdataInputData written to the peripheral
axi_bus.rdataOutputData read from the peripheral
tx_dataOutputData to be transmitted by UART
tx_validOutputValid signal for UART TX
tx_busyInputStatus indicating if UART is busy

The design uses a simple state machine with four states: IDLE, WRITE, READ, and RESP. In the IDLE state, the module waits for an incoming AXI transaction. When an AWVALID signal is detected, it transitions to the WRITE state to capture the address. Similarly, an ARVALID signal triggers the READ state. The actual data transfer occurs in subsequent cycles when WVALID or RREADY signals are asserted. The module compares the latched address against predefined register offsets to determine which internal signal to update or return.

Practice

  1. Open RtlStudio and select this chapter from the Examples or Lecture list.
  2. Confirm that the file tree appears in the Explore panel with student/ and golden/ directories.
  3. Open student/rtl/ip/soc/uart_csr_hook.sv in the editor.
  4. Locate the __TODO__ comments in the code.
  5. Define REG_TX as 32'h00 to map the TX data register to address 0x00.
  6. Initialize tx_data to '0 and tx_valid to 1'b0 in the reset block.
  7. Ensure the write logic updates tx_data and asserts tx_valid when lat_addr matches REG_TX.
  8. Open student/tb/tb_top.sv to verify the testbench structure.

Summary

In this lesson, you practiced exposing UART TX data and busy status CSRs to integrate peripheral islands effectively. You modified the design to bridge the UART module with the system-on-chip interconnect for proper register access. The verification step confirmed that the simulation passes with the new CSR hooks in place. This exercise solidified your understanding of how to expose peripheral status and data registers in a modular SoC design.

© 2026 RtlStudio. Licensed under CC BY-NC-ND 4.0. Commercial use and modifications by third parties are not permitted.

Run it in the Verilog IDE

  1. Open the lesson workspace in the IDE. The fabric and the peripheral are one simulation.
  2. Run Verilator and follow the address, write data, and read response on the waveform.
  3. A passing log is not enough when decode or an IRQ line is the point of the lesson — those show up on the VCD.
  4. Run Yosys on the RTL island you just integrated when you want the mapped cells.

The lesson is done when the simulation matches UART CSR hook (lite). Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.