RTL Problems / Level 6 · Advanced RTL & Protocol Design
What You Will Learn
By solving AMBA APB Slave Controller with Wait States & Error Response, 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 compliant AMBA 3/4 APB slave supporting IDLE, SETUP, and ACCESS phases with dynamic wait states and slave error signaling.
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 specification, synchronous FSM design, bus handshaking, address decoding.
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 | input | 1 | APB clock |
PRESETn | input | 1 | Active-low reset |
PSEL | input | 1 | Slave select |
PENABLE | input | 1 | Enable strobe (asserted in ACCESS phase) |
PWRITE | input | 1 | 1 = Write transfer, 0 = Read transfer |
PADDR[7:0] | input | 8 | 8-bit memory address |
PWDATA[31:0] | input | 32 | Incoming 32-bit write data |
PRDATA[31:0] | output | 32 | Outgoing 32-bit read data |
PREADY | output | 1 | 1 when transfer complete; 0 extends wait state |
PSLVERR | output | 1 | 1 on address out of bounds (PADDR > 8'h0C) during completed access |
Timing Constraints & Synthesizable RTL Rules
Timing Contract: Clocked on rising edge of PCLK with active-low synchronous reset PRESETn. PREADY must assert during ACCESS phase; PSLVERR is valid only when PSEL && PENABLE && PREADY.
Synthesis Constraints: Fully synthesizable Verilog-2001. No # delays. Registered read data and PREADY control.
Architectural Deep Dive & Implementation Walkthrough
AMBA APB Protocol Fundamentals
The Advanced Peripheral Bus (APB) is part of the Arm AMBA protocol family optimized for minimal power and reduced interface complexity. Unlike high-performance burst protocols (such as AXI), APB is designed for non-pipelined, register-mapped control transfers.
The APB Transfer Cycle
- IDLE State: Normal default state.
PSELandPENABLEare deasserted. - SETUP Phase: When a transfer is requested, the bus master drives
PADDR,PWRITE, andPWDATA(if writing), and assertsPSEL = 1while keepingPENABLE = 0. - ACCESS Phase: On the next clock edge, the master asserts
PENABLE = 1. The slave assertsPREADY = 1to complete the transaction, or holdsPREADY = 0to insert wait states.
If an invalid address is targeted, the slave asserts PSLVERR = 1 during the completed ACCESS phase to report a transfer error to the master.
Common RTL Designer Pitfalls
Updating internal registers during the SETUP phase (when PENABLE=0) instead of the ACCESS phase (when PSEL && PENABLE && PREADY). Inverting PENABLE or letting PREADY float.
Silicon & Hardware Engineering Notes
In high-frequency SoC architectures, PREADY and PRDATA paths should be registered to avoid combinational feedback loops across chip partition boundaries.
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 wire [31:0] PRDATA,
output wire PREADY,
output wire PSLVERR
);
// Implement 4 internal 32-bit registers at addresses 8'h00, 8'h04, 8'h08, 8'h0C.
// Addresses > 8'h0C should assert PSLVERR = 1 when transfer completes.
// PREADY = 1 completes the transfer.
endmodule
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 wire [31:0] PRDATA,
output wire PREADY,
output wire PSLVERR
);
reg [31:0] mem [0:3];
wire addr_valid = (PADDR <= 8'h0C) && (PADDR[1:0] == 2'b00);
wire [1:0] reg_idx = PADDR[3:2];
assign PREADY = 1'b1;
assign PSLVERR = (PSEL && PENABLE && !addr_valid);
assign PRDATA = (PSEL && !PWRITE) ? (addr_valid ? mem[reg_idx] : 32'hDEADBEEF) : 32'h0;
always @(posedge PCLK or negedge PRESETn) begin
if (!PRESETn) begin
mem[0] <= 32'h0;
mem[1] <= 32'h0;
mem[2] <= 32'h0;
mem[3] <= 32'h0;
end else begin
if (PSEL && PENABLE && PWRITE && addr_valid) begin
mem[reg_idx] <= PWDATA;
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 AMBA APB Slave Controller with Wait States & Error Response require?
Design a compliant AMBA 3/4 APB slave supporting IDLE, SETUP, and ACCESS phases with dynamic wait states and slave error signaling. 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 AMBA APB Slave Controller with Wait States & Error Response to assess real-world synthesizability and race-condition awareness.