APB Protocol 1738772935
APB Protocol 1738772935
Prasanthi Chanda
1. Write a Verilog module for an APB Slave interface.
module apb_slave (
input logic PCLK, // APB Clock
input logic PRESETn, // Active low reset
input logic PSEL, // Slave select
input logic PENABLE, // Enable signal
input logic PWRITE, // Write enable
input logic [7:0] PADDR, // Address bus
input logic [31:0] PWDATA, // Write data
output logic [31:0] PRDATA, // Read data
output logic PREADY, // Ready signal
output logic PSLVERR // Error signal
);
module apb_master (
input logic PCLK, // Clock
input logic PRESETn, // Active low reset
output logic PSEL, // Slave select
output logic PENABLE, // Enable signal
output logic PWRITE, // Write enable
output logic [7:0] PADDR, // Address bus
output logic [31:0] PWDATA, // Write data
input logic [31:0] PRDATA, // Read data
input logic PREADY, // Ready signal
input logic PSLVERR // Error signal
);
typedef enum logic [1:0] {IDLE, SETUP, ACCESS} state_t;
state_t state, next_state;
always_ff @(posedge PCLK or negedge PRESETn) begin
if (!PRESETn)
state <= IDLE;
else
state <= next_state;
end
always_comb begin
case (state)
IDLE: next_state = PSEL ? SETUP : IDLE;
SETUP: next_state = ACCESS;
ACCESS: next_state = PREADY ? IDLE : ACCESS;
default: next_state = IDLE;
endcase
end
always_ff @(posedge PCLK) begin
if (state == IDLE) begin
PSEL <= 1'b0;
PENABLE <= 1'b0;
end else if (state == SETUP) begin
PSEL <= 1'b1;
PENABLE <= 1'b0;
end else if (state == ACCESS) begin
PENABLE <= 1'b1;
end
end
endmodule
Uses PSEL,
Uses Uses AWVALID,
Handshake PENABLE,
HREADY WVALID, BVALID
PREADY
Medium- High-
Usage Peripherals speed performance
memory memory
endmodule
EXPLANATION OF ASSERTIONS:
PREADY should be LOW during the setup phase.
PREADY should be HIGH during the access phase for a
successful transfer.
PWDATA must remain stable when writing during the access
phase.
PRDATA must remain stable when reading during the access
phase.
PENABLE should remain HIGH if PREADY is LOW (ensures
transfer completion).
PENABLE should be LOW in the setup phase (ensures correct
handshake).
A valid APB transaction should have PSEL=1, PENABLE=1, and
PREADY=1.
PSLVERR should only be HIGH when PREADY is HIGH (ensures
proper error handling).
8. What are the main challenges in verifying an APB interface in a
complex SoC?
Ensuring timing correctness with various slave latencies.
Handling corner cases like unexpected PSEL deassertion.
Debugging protocol violations using assertions (SVA).
Managing multiple masters in multi-layer APB systems.
// Write Transaction
txn = apb_transaction::type_id::create("write_txn");
txn.addr = 8'h20;
txn.wdata = 32'h12345678;
txn.write = 1;
start_item(txn);
finish_item(txn);
// Read Transaction
txn = apb_transaction::type_id::create("read_txn");
txn.addr = 8'h20;
txn.write = 0;
start_item(txn);
finish_item(txn);
endtask
endclass
13. Implement an APB Error-Handling Slave Model.
module apb_err_slave (
input logic PCLK,
input logic PRESETn,
input logic PSEL,
input logic PENABLE,
input logic PWRITE,
input logic [7:0] PADDR,
input logic [31:0] PWDATA,
output logic [31:0] PRDATA,
output logic PREADY,
output logic PSLVERR
);
logic [31:0] mem [0:255];
if (!PWRITE)
PRDATA <= mem[PADDR];
end
end
endmodule
14. How would you handle APB bus contention in a multi-master
environment?
APB is inherently a single-master bus, so direct contention is
not possible.
In a multi-master system, an arbiter must select which master
gets control of the APB bridge.
Arbitration mechanisms include fixed priority, round-robin, and
time-sliced scheduling.
15. How does APB handle clock domain crossing (CDC) issues?
PENABLE asserted
Master design issue (state machine bug).
before PSEL
DEBUGGING
VIOLATION POSSIBLE CAUSE
STEPS
PREADY never
Slave not responding Verify slave logic
asserts
INTERVIEW TIPS:
✅ Understand APB’s role as a simple peripheral bus in AMBA
architecture.
✅ Explain timing diagrams clearly with signal transitions.
✅ Know the handshake mechanism using PSEL, PENABLE, and
PREADY.
✅ Compare APB with AHB and AXI in terms of performance and
use cases.
✅ Demonstrate debugging techniques for APB protocol violations.
CONTACT DETAILS:
For the interview guidance, or any additional support, feel free to
contact ProV Logic :
Email : [email protected]
Phone : +91 91822 80927
LinkedIn : @ProV Logic
Excellence in World class
VLSI Training & Placements
+91- 9182280927