RTL Problems / Level 4 · On-Chip Protocols
What You Will Learn
By solving Credit-Based Flow Control — Credit Management, 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
Implement a transmitter credit manager with initial credits MAX_CREDITS (default 4). Transmitter can send when credits > 0, decrementing credits; credits return via credit_return strobe.
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: Flow control, counters, latency-insensitive protocols.
Port List & Interface Timing
The hidden testbench instantiates top_module. Module port names and bit-widths must match the interface contract exactly:
| Name | Dir | Width | Description |
|---|---|---|---|
clk | input | 1 | Clock signal |
areset_n | input | 1 | Active-low reset |
tx_req | input | 1 | Transmit request from internal core |
credit_ret | input | 1 | Credit return strobe from remote receiver |
tx_send | output | 1 | Packet transmitted onto physical link |
credit_count | output | 4 | Current available credit balance |
Timing Constraints & Synthesizable RTL Rules
Timing Contract: Transmitter transmits (`tx_send=1`) only when `credit_count > 0`. Each returned credit (`credit_ret=1`) increments `credit_count`.
Synthesis Constraints: Total credits must never exceed `MAX_CREDITS`. Credit counter must not underflow or overflow.
Architectural Deep Dive & Implementation Walkthrough
Common RTL Designer Pitfalls
['Allowing `credit_count` to decrement below 0 (underflow) when `tx_req` is asserted with 0 credits.', 'Not accounting for simultaneous transmission and credit return in the same clock cycle.']
Silicon & Hardware Engineering Notes
PCI Express (PCIe) Transaction Layer Protocol (TLP) and high-speed Network-on-Chip (NoC) interconnects (ARM CoreLink NIC-400 / CMN-700) exclusively use credit-based flow control.
Starter RTL Code
module top_module #(
parameter MAX_CREDITS = 4
)(
input clk,
input areset_n,
input tx_req,
input credit_ret,
output tx_send,
output reg [3:0] credit_count
);
// Credit-based flow control manager
endmodule
Verified Reference Solution
🔒 Reveal Verified Reference RTL Solution
module top_module #(
parameter MAX_CREDITS = 4
)(
input clk,
input areset_n,
input tx_req,
input credit_ret,
output tx_send,
output reg [3:0] credit_count
);
// Can send if core requests and we have available credits
assign tx_send = tx_req && (credit_count > 4'd0);
always @(posedge clk or negedge areset_n) begin
if (!areset_n) begin
credit_count <= MAX_CREDITS[3:0];
end else begin
case ({tx_send, credit_ret})
2'b10: credit_count <= credit_count - 1'b1; // spent 1 credit
2'b01: credit_count <= (credit_count < MAX_CREDITS[3:0]) ? (credit_count + 1'b1) : credit_count; // returned 1
default: credit_count <= credit_count; // both 00 or 11 (send and return in same cycle)
endcase
end
end
endmodule
Related RTL Problems in Level 4
- Two-Flop Synchronizer — Single-Bit CDC — Design a 2-flip-flop synchronizer to safely pass a single-bit control signal from an asynchronous source into the destination clock domain clk_dst.
- Pulse Synchronizer — Clock-Domain Crossing — Design a Toggle-based Pulse Synchronizer to transfer a single-cycle pulse from a fast clock domain (clk_src) to a slow destination domain (clk_dst).
- Gray Code Counter — Gray Encoding — Implement a 4-bit Gray code counter that advances by exactly one bit per transition: 0000, 0001, 0011, 0010, 0110, 0111, 0101, 0100...
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 Credit-Based Flow Control — Credit Management require?
Implement a transmitter credit manager with initial credits MAX_CREDITS (default 4). Transmitter can send when credits > 0, decrementing credits; credits return via credit_return strobe. Implement it as Verilog module top_module matching the listed ports.
Is this design combinational or sequential?
Tags: cdc, industry-rtl, arbiters, clock-domain-crossing, hard, credit-flow-control. 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 Credit-Based Flow Control — Credit Management to assess real-world synthesizability and race-condition awareness.