RTL Problems / Level 6 · Advanced RTL & Protocol Design
What You Will Learn
By solving 4-Channel Round-Robin AXI-Stream Arbiter with Packet Locking, 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 4-channel AXI-Stream arbiter featuring packet-boundary locking, starvation-free fair round-robin scheduling, and full backpressure propagation.
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: AXI-Stream packet framing, round-robin arbitration algorithms, fair resource sharing, packet locking.
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 |
|---|---|---|---|
aclk, aresetn | input | 1 | Clock and active-low synchronous reset |
s_tvalid[3:0] | input | 4 | Ingress valid signals for channels 0..3 |
s_tready[3:0] | output | 4 | Backpressure ready signals for channels 0..3 |
s_tdata[127:0] | input | 128 | Packed data: ch0=[31:0], ch1=[63:32], ch2=[95:64], ch3=[127:96] |
s_tlast[3:0] | input | 4 | End-of-packet indicators for channels 0..3 |
m_tvalid, m_tready | out/in | 1 | Downstream AXI-Stream valid and ready |
m_tdata[31:0], m_tlast | output | 32, 1 | Arbitrated egress data stream and end-of-packet flag |
Timing Constraints & Synthesizable RTL Rules
Timing Contract: Clocked on aclk with active-low aresetn. Arbitration decision occurs when unlocked and requesters are active. Priority advances only when packet completes.
Synthesis Constraints: No packet interleaving. Synthesizable Verilog-2001.
Architectural Deep Dive & Implementation Walkthrough
Packet Interleaving vs. Packet Locking
In streaming networking protocols (Ethernet, PCIe TLP, AXI-Stream), data beats belong to distinct packets bounded by TLAST. Arbitrating on a pure per-beat basis would cause packet fragmentation and interleaving, corrupting packet payloads at the receiver.
Arbiter Design Rules
- Arbitration Phase: When the arbiter is idle (unlocked), it inspects all requesting channels and grants access according to the current round-robin priority pointer.
- Locked Phase: The winner gains exclusive access to the egress bus. Even if downstream backpressure occurs (
m_tready = 0), the arbiter holds its grant. - Release & Rotation: When the final beat is transferred (
m_tvalid && m_tready && m_tlast), the lock releases and the priority pointer advances to prevent starvation.
Common RTL Designer Pitfalls
Switching channels on backpressure (m_tready=0) or breaking packet boundaries when higher-priority requesters arrive.
Silicon & Hardware Engineering Notes
In network-on-chip (NoC) routers, packet arbiters include aging counters to prevent low-bandwidth channels from starving under high-rate streaming flows.
Starter RTL Code
module top_module (
input wire aclk,
input wire aresetn,
input wire [3:0] s_tvalid,
output reg [3:0] s_tready,
input wire [127:0] s_tdata,
input wire [3:0] s_tlast,
output reg m_tvalid,
input wire m_tready,
output reg [31:0] m_tdata,
output reg m_tlast
);
// Implement 4-to-1 Round-Robin Arbiter:
// 1. Lock arbitration onto winning channel until (m_tvalid && m_tready && m_tlast).
// 2. Rotate priority to (winner + 1) % 4 only upon packet completion.
// 3. Forward s_tdata and s_tlast of selected channel to egress.
Verified Reference Solution
🔒 Reveal Verified Reference RTL Solution
module top_module (
input wire aclk,
input wire aresetn,
input wire [3:0] s_tvalid,
output reg [3:0] s_tready,
input wire [127:0] s_tdata,
input wire [3:0] s_tlast,
output reg m_tvalid,
input wire m_tready,
output reg [31:0] m_tdata,
output reg m_tlast
);
reg [1:0] winner;
reg [1:0] base_ptr;
reg locked;
wire [31:0] ch_data [0:3];
assign ch_data[0] = s_tdata[31:0];
assign ch_data[1] = s_tdata[63:32];
assign ch_data[2] = s_tdata[95:64];
assign ch_data[3] = s_tdata[127:96];
// Combinational round-robin priority picker
reg [1:0] next_grant;
reg any_req;
always @(*) begin
any_req = |s_tvalid;
next_grant = base_ptr;
if (s_tvalid[base_ptr]) begin
next_grant = base_ptr;
end else if (s_tvalid[(base_ptr + 2'd1) & 2'd3]) begin
next_grant = (base_ptr + 2'd1) & 2'd3;
end else if (s_tvalid[(base_ptr + 2'd2) & 2'd3]) begin
next_grant = (base_ptr + 2'd2) & 2'd3;
end else if (s_tvalid[(base_ptr + 2'd3) & 2'd3]) begin
next_grant = (base_ptr + 2'd3) & 2'd3;
end
end
// Mux selection
always @(*) begin
if (locked || any_req) begin
m_tvalid = s_tvalid[winner];
m_tdata = ch_data[winner];
m_tlast = s_tlast[winner];
end else begin
m_tvalid = 1'b0;
m_tdata = 32'h0;
m_tlast = 1'b0;
end
s_tready = 4'b0000;
if (locked || any_req) begin
s_tready[winner] = m_tready;
end
end
always @(posedge aclk or negedge aresetn) begin
if (!aresetn) begin
winner <= 2'd0;
base_ptr <= 2'd0;
locked <= 1'b0;
end else begin
if (!locked) begin
if (any_req) begin
winner <= next_grant;
locked <= 1'b1;
// Single-beat packet check
if (s_tvalid[next_grant] && m_tready && s_tlast[next_grant]) begin
locked <= 1'b0;
base_ptr <= (next_grant + 2'd1) & 2'd3;
end
end
end else begin
// Locked in transfer
if (m_tvalid && m_tready && m_tlast) begin
locked <= 1'b0;
base_ptr <= (winner + 2'd1) & 2'd3;
end
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 4-Channel Round-Robin AXI-Stream Arbiter with Packet Locking require?
Design a 4-channel AXI-Stream arbiter featuring packet-boundary locking, starvation-free fair round-robin scheduling, and full backpressure propagation. Implement it as Verilog module top_module matching the listed ports.
Is this design combinational or sequential?
Tags: advanced-rtl, axi-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 4-Channel Round-Robin AXI-Stream Arbiter with Packet Locking to assess real-world synthesizability and race-condition awareness.