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.
| Signal | Direction | Description |
|---|---|---|
axi_bus.awaddr | Input | Address for write transaction |
axi_bus.araddr | Input | Address for read transaction |
axi_bus.wdata | Input | Data written to the peripheral |
axi_bus.rdata | Output | Data read from the peripheral |
tx_data | Output | Data to be transmitted by UART |
tx_valid | Output | Valid signal for UART TX |
tx_busy | Input | Status 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
- Open RtlStudio and select this chapter from the Examples or Lecture list.
- Confirm that the file tree appears in the Explore panel with
student/andgolden/directories. - Open
student/rtl/ip/soc/uart_csr_hook.svin the editor. - Locate the
__TODO__comments in the code. - Define
REG_TXas32'h00to map the TX data register to address 0x00. - Initialize
tx_datato'0andtx_validto1'b0in the reset block. - Ensure the write logic updates
tx_dataand assertstx_validwhenlat_addrmatchesREG_TX. - Open
student/tb/tb_top.svto 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
- Open the lesson workspace in the IDE. The fabric and the peripheral are one simulation.
- Run Verilator and follow the address, write data, and read response on the waveform.
- A passing log is not enough when decode or an IRQ line is the point of the lesson — those show up on the VCD.
- 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.