Reset & CDC Design
Master reset strategies, clock domain crossing techniques, and synchronization for reliable digital systems.
π― Essential Concepts
Reset Strategies
FundamentalDifferent approaches to resetting digital systems reliably.
Key Topics:
- β’Synchronous vs asynchronous reset
- β’Reset assertion and deassertion
- β’Power-on reset circuits
- β’Reset synchronization
- β’Reset tree distribution
Implementation:
// Asynchronous reset, synchronous deassertion
module reset_sync (
input logic clk,
input logic async_rst_n,
output logic sync_rst_n
);
logic [1:0] sync_reg;
always_ff @(posedge clk or negedge async_rst_n) begin
if (!async_rst_n)
sync_reg <= 2'b00;
else
sync_reg <= {sync_reg[0], 1'b1};
end
assign sync_rst_n = sync_reg[1];
endmoduleClock Domain Crossing (CDC)
AdvancedSafe techniques for transferring data between different clock domains.
Key Topics:
- β’Metastability fundamentals
- β’Two-flop synchronizers
- β’Pulse synchronizers
- β’Handshake protocols
- β’Gray code techniques
Implementation:
// Handshake-based CDC
module handshake_cdc #(parameter WIDTH = 8) (
// Source domain
input logic src_clk, src_rst_n,
input logic [WIDTH-1:0] src_data,
input logic src_valid,
output logic src_ready,
// Destination domain
input logic dst_clk, dst_rst_n,
output logic [WIDTH-1:0] dst_data,
output logic dst_valid,
input logic dst_ready
);
// Source domain logic
logic src_req, src_ack_sync;
logic [WIDTH-1:0] data_reg;
always_ff @(posedge src_clk or negedge src_rst_n) begin
if (!src_rst_n) begin
src_req <= 1'b0;
data_reg <= '0;
end else if (src_valid && src_ready) begin
src_req <= ~src_req;
data_reg <= src_data;
end
end
assign src_ready = (src_req == src_ack_sync);
// Destination domain logic
logic dst_req_sync, dst_ack;
logic dst_req_sync_d1;
always_ff @(posedge dst_clk or negedge dst_rst_n) begin
if (!dst_rst_n) begin
dst_req_sync_d1 <= 1'b0;
dst_ack <= 1'b0;
end else begin
dst_req_sync_d1 <= dst_req_sync;
if (dst_req_sync != dst_req_sync_d1)
dst_ack <= dst_req_sync;
end
end
assign dst_valid = (dst_req_sync != dst_req_sync_d1);
assign dst_data = data_reg;
// Synchronizers
sync_2ff u_req_sync (.clk(dst_clk), .rst_n(dst_rst_n),
.async_in(src_req), .sync_out(dst_req_sync));
sync_2ff u_ack_sync (.clk(src_clk), .rst_n(src_rst_n),
.async_in(dst_ack), .sync_out(src_ack_sync));
endmoduleSynchronizer Design
IntermediateBuilding robust synchronizers to prevent metastability.
Key Topics:
- β’MTBF calculations
- β’Synchronizer depth selection
- β’Fast vs safe synchronizers
- β’Synchronizer failure modes
- β’Temperature and voltage effects
Implementation:
// Configurable depth synchronizer
module sync_nff #(
parameter WIDTH = 1,
parameter STAGES = 2,
parameter RESET_VAL = 0
) (
input logic clk,
input logic rst_n,
input logic [WIDTH-1:0] async_in,
output logic [WIDTH-1:0] sync_out
);
logic [WIDTH-1:0] sync_ff [STAGES];
always_ff @(posedge clk or negedge rst_n) begin
if (!rst_n) begin
for (int i = 0; i < STAGES; i++)
sync_ff[i] <= RESET_VAL;
end else begin
sync_ff[0] <= async_in;
for (int i = 1; i < STAGES; i++)
sync_ff[i] <= sync_ff[i-1];
end
end
assign sync_out = sync_ff[STAGES-1];
// Synthesis attributes to prevent optimization
(* ASYNC_REG = "TRUE" *) logic [WIDTH-1:0] sync_ff [STAGES];
endmoduleπ CDC Techniques Comparison
Two-Flop Synchronizer
Use Case:
Single bit control signals
Pros:
- +Simple
- +Low latency
- +Well understood
Cons:
- -Single bit only
- -Pulse can be lost
Gray Code Counter
Use Case:
Multi-bit counters/addresses
Pros:
- +Multi-bit safe
- +No decode errors
- +Atomic updates
Cons:
- -Counter values only
- -Complex decode
Handshake Protocol
Use Case:
Data buses and control
Pros:
- +Any data width
- +No loss
- +Flow control
Cons:
- -Higher latency
- -More complex
- -More resources
Async FIFO
Use Case:
Data streaming
Pros:
- +High throughput
- +Buffering
- +Rate adaptation
Cons:
- -Most complex
- -Higher power
- -Area overhead
π Reset Design Strategies
Synchronous Reset
Reset signal is synchronized to clock edge
Advantages:
- βTiming predictable
- βNo reset removal issues
- βBetter for synthesis
Disadvantages:
- βRequires clock
- βWider reset distribution
- βPower consumption
Asynchronous Reset
Reset takes effect immediately, independent of clock
Advantages:
- βWorks without clock
- βImmediate effect
- βLower power
Disadvantages:
- βReset removal issues
- βMetastability risk
- βTiming complexity
Mixed Reset
Asynchronous assertion, synchronous deassertion
Advantages:
- βBest of both
- βSafe removal
- βImmediate assertion
Disadvantages:
- βMore complex
- βRequires careful design
- βAdditional logic
π Common CDC Issues & Debugging
Missing Synchronizers
CriticalSymptom:
Intermittent functional failures
Debug:
Look for control signals crossing domains
Fix:
Add two-flop synchronizers
Multi-bit Bus CDC
CriticalSymptom:
Corrupted data transfers
Debug:
Check for wide buses crossing domains
Fix:
Use Gray code or handshake protocol
Reset Synchronization
HighSymptom:
Startup failures or glitches
Debug:
Check reset deassertion timing
Fix:
Implement proper reset synchronizers
False Path Constraints
MediumSymptom:
Timing violations on async signals
Debug:
Review timing reports for CDC paths
Fix:
Add false path constraints
β CDC Design Checklist
Ready to Master Reset & CDC Design?
Practice with real-world scenarios and learn advanced synchronization techniques for robust systems.