RTL Problems / Level 6 · Advanced RTL & Protocol Design
What You Will Learn
By solving Configurable APB Memory-Mapped Register Bank with Masking, 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
Design a production-grade APB register bank featuring control, status, scratchpad, and interrupt-enable registers with read-only protections.
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.
Prerequisites: AMBA APB protocol, memory-mapped I/O, address decoding, register banks.
Port List & Interface Timing
The hidden testbench instantiates top_module. Module port names and bit-widths must match the interface contract exactly:
| Port | Dir | Width | Description |
|---|---|---|---|
PCLK, PRESETn | input | 1 | Clock and active-low reset |
PSEL, PENABLE, PWRITE | input | 1 | Standard APB control |
PADDR[7:0] | input | 8 | Register address (0x00=CTRL, 0x04=STATUS, 0x08=SCRATCH, 0x0C=IEN) |
PWDATA[31:0] | input | 32 | Incoming write data |
PRDATA[31:0] | output | 32 | Outgoing read data |
PREADY, PSLVERR | output | 1 | Ready and error indicator |
ext_status[31:0] | input | 32 | Hardware status wired to Read-Only 0x04 |
ctrl_out[31:0] | output | 32 | Current content of Control Register (0x00) |
ien_out[31:0] | output | 32 | Current content of Interrupt Enable Register (0x0C) |
Timing Constraints & Synthesizable RTL Rules
Timing Contract: Clocked on PCLK with active-low PRESETn. All registers update on posedge PCLK during active ACCESS phase (PSEL && PENABLE && PWRITE && PREADY).
Synthesis Constraints: Synthesizable Verilog-2001. No latches. Clean default address decode multiplexing.
Architectural Deep Dive & Implementation Walkthrough
Memory-Mapped Register Banks in Modern SoCs
Every peripheral core in an SoC (timers, UARTs, I2C controllers, GPU dispatchers) exposes an addressable register bank over APB or AXI-Lite.
Key Architecture Rules
- Read-Only Registers: Registers reflecting hardware conditions (status, FIFO levels, error flags) ignore CPU writes.
- Reset Value Management: Certain registers (like scratchpads or hardware IDs) must wake up with nonzero values to allow software drivers to identify the IP version.
- Address Decoding: Word-aligned addresses step in multiples of 4 bytes (0x00, 0x04, 0x08, 0x0C). Unmapped accesses must flag
PSLVERRto trap rogue firmware pointers.
Common RTL Designer Pitfalls
Allowing writes to modify read-only status registers or failing to clear PSLVERR on valid transfers.
Silicon & Hardware Engineering Notes
Registers can consume significant gate count. For wide register sets, register sharing or RAM-based register files are employed.
Starter RTL Code
module top_module (
input wire PCLK,
input wire PRESETn,
input wire PSEL,
input wire PENABLE,
input wire PWRITE,
input wire [7:0] PADDR,
input wire [31:0] PWDATA,
output reg [31:0] PRDATA,
output wire PREADY,
output reg PSLVERR,
input wire [31:0] ext_status,
output reg [31:0] ctrl_out,
output reg [31:0] ien_out
);
// Address Map:
// 0x00: CTRL (R/W, reset=0x00000000) -> drives ctrl_out
Verified Reference Solution
🔒 Reveal Verified Reference RTL Solution
module top_module (
input wire PCLK,
input wire PRESETn,
input wire PSEL,
input wire PENABLE,
input wire PWRITE,
input wire [7:0] PADDR,
input wire [31:0] PWDATA,
output reg [31:0] PRDATA,
output wire PREADY,
output reg PSLVERR,
input wire [31:0] ext_status,
output reg [31:0] ctrl_out,
output reg [31:0] ien_out
);
assign PREADY = 1'b1;
reg [31:0] scratch_reg;
wire wr_en = PSEL && PENABLE && PWRITE;
wire rd_en = PSEL && PENABLE && !PWRITE;
always @(posedge PCLK or negedge PRESETn) begin
if (!PRESETn) begin
ctrl_out <= 32'h00000000;
ien_out <= 32'h00000000;
scratch_reg <= 32'hA5A50001;
PRDATA <= 32'h00000000;
PSLVERR <= 1'b0;
end else begin
PSLVERR <= 1'b0;
if (wr_en) begin
case (PADDR)
8'h00: ctrl_out <= PWDATA;
8'h04: ; // Status register is Read-Only; writes ignored without error or with error per design
8'h08: scratch_reg <= PWDATA;
8'h0C: ien_out <= PWDATA;
default: PSLVERR <= 1'b1;
endcase
end
if (rd_en) begin
case (PADDR)
8'h00: PRDATA <= ctrl_out;
8'h04: PRDATA <= ext_status;
8'h08: PRDATA <= scratch_reg;
8'h0C: PRDATA <= ien_out;
default: begin
PRDATA <= 32'h00000000;
PSLVERR <= 1'b1;
end
endcase
end
end
end
endmodule
Related RTL Problems in Level 6
- Manchester Encoder — Combine a data bit with the clock to produce a Manchester-encoded line signal — the self-clocking encoding used in classic Ethernet and RFID.
- Manchester Decoder — Recover the original data bit from a Manchester-encoded line signal — the exact inverse of the Manchester Encoder problem.
- Quadrature Rotary Encoder Decoder — Decode the two-phase A/B signal from a real rotary knob or mouse wheel into a direction and position count — sample B on every rising edge of A.
Connected EcrioniX Learning Resources
Accelerate your VLSI engineering knowledge with these curated learning materials:
Progress through step-by-step verified modules from fundamentals to advanced silicon design.
Benchmark your hardware knowledge across 10 semiconductor domains and receive study roadmaps.
Explore foundational circuit theory, waveform timing, and physical hardware implementation.
Frequently Asked Questions
What does Configurable APB Memory-Mapped Register Bank with Masking require?
Design a production-grade APB register bank featuring control, status, scratchpad, and interrupt-enable registers with read-only protections. Implement it as Verilog module top_module matching the listed ports.
Is this design combinational or sequential?
Tags: advanced-rtl, apb-protocol, systemverilog, asic, fpga. 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 Configurable APB Memory-Mapped Register Bank with Masking to assess real-world synthesizability and race-condition awareness.