💬 Engineering Q&A Community

Technical Discussions & Solutions

Get peer-reviewed engineering answers from practicing RTL, verification, and physical design engineers. Debug synthesizable Verilog, resolve CDC race conditions, and discuss silicon signoff.

🔍
42
CDC & RDC ✓ Verified Solution Posted by RTL_Specialist · 2 days ago

Why does synchronizing a 4-bit binary counter with two separate 2-FF synchronizers cause intermittent silicon glitches?

We have a write counter running at 200 MHz being sampled into a 66 MHz clock domain. We passed each bit of wptr[3:0] through its own two-stage flip-flop synchronizer. In simulation it works fine, but on FPGA hardware we intermittently observe invalid jump values (e.g. jumping from 7 to 0 then back to 8). What is the root cause?

// Buggy RTL: Bit-by-bit synchronization of binary counter
genvar i;
generate
  for (i = 0; i < 4; i = i + 1) begin : sync_bits
    (* ASYNC_REG = "TRUE" *) reg [1:0] sync_reg;
    always @(posedge rclk) sync_reg <= {sync_reg[0], wptr_bin[i]};
    assign rclk_wptr[i] = sync_reg[1];
  end
endgenerate
#cdc #metastability #gray-code #wire-skew
✓ Accepted Answer by Staff Engineer

The root cause is asynchronous wire skew across multi-bit transitions. When transitioning from 7 (0111) to 8 (1000), all 4 bits toggle at the same time. Because of slight differences in physical routing delays and standard-cell threshold variations, the destination clock rclk may sample bit 3 after it changed, but sample bits 2, 1, and 0 before they finished propagating!

This results in sampling intermediate phantom codes such as 1111 (15) or 0000 (0). To fix this, you must convert to reflected Gray code before crossing, ensuring that strictly 1 bit changes per clock cycle.

// Verified Fix: Convert to Gray code in source domain, then sync
wire [3:0] wptr_gray = wptr_bin ^ (wptr_bin >> 1);
// Synchronize wptr_gray, then convert back to binary in rclk domain!
35
Bus Protocols ✓ Verified Solution Posted by DV_Lead · 4 days ago

How to write an SVA property to prove a slave never waits for TVALID before asserting TREADY?

According to ARM AMBA AXI4 specification section A3.2.1, TREADY can depend on TVALID, but TVALID must NEVER wait for TREADY. However, to achieve maximum throughput, our architecture requires the slave to assert default ready. How do we formalize this in concurrent SystemVerilog Assertions?

#sva #axi4 #deadlock #formal
✓ Accepted Answer by Protocol Architect

To verify handshake non-deadlock formally, you assert that once tvalid rises, it stays asserted until tready arrives, and that tready assertion does not have a combinational dependency path from tvalid:

// SVA: Master must not drop TVALID prematurely
property p_valid_stability;
  @(posedge aclk) disable iff (!aresetn)
  tvalid && !tready |=> tvalid && $stable(tdata);
endproperty
assert_valid_stability: assert property (p_valid_stability);

// SVA: Handshake completion bound (slave must respond within 16 cycles)
property p_slave_liveness;
  @(posedge aclk) disable iff (!aresetn)
  tvalid |=> ##[1:16] (tvalid && tready);
endproperty
assert_slave_liveness: assert property (p_slave_liveness);
28
RTL Architecture ✓ Verified Solution Posted by ECE_Student · 5 days ago

Yosys reports "Inferred latch for signal next_state" in my Moore FSM. How to fix?

I am synthesizing a 4-state sequence detector in Yosys. During synthesis, the log emits Latch inferred for variable 'next_state'. My simulation matches test vectors, but timing signoff fails with huge propagation delays. Why does Yosys think it's a latch?

✓ Accepted Answer by EDA Synthesis Engineer

In Verilog, combinational always @(*) blocks infer memory latches whenever a variable is not assigned in every possible execution branch (e.g. missing else or missing default: in a case statement).

The standard industry remedy is to specify a default assignment at the very top of the combinational block:

always @(*) begin
  next_state = state; // Default prevents latch inference on unhandled branches!
  case (state)
    S0: if (in) next_state = S1;
    S1: if (!in) next_state = S2;
    // ...
    default: next_state = S0;
  endcase
end
31
Static Timing (STA) ✓ Verified Solution Posted by Timing_Engineer · 1 week ago

Negative setup slack (-0.85ns) on 32-bit comparator path in OpenROAD at 250 MHz. Should I buffer or size gates?

Our datapath has a 32-bit equality and magnitude comparison driving an enable pin. In OpenSTA, the arrival time is 4.85ns against a 4.00ns period. Adding buffers increases cell delay. What is the standard physical design methodology to close timing here?

✓ Accepted Answer by Physical Design Lead

Buffers fix hold violations, not setup violations. Adding buffers increases combinational delay and makes setup slack worse!

To close a -0.85ns setup violation on a comparator path:
1. Upsize driving cells: Replace X1 cells with X2 or X4 drive strength standard cells along the critical path to reduce transition (slew) and cell delay.
2. Swap to Low-Vt (LVT) library: LVT transistors switch faster at the cost of higher subthreshold leakage.
3. RTL Retiming / Pipelining: If physical optimization cannot recover 0.85ns, insert a pipeline register to break the 32-bit comparison into two 16-bit stages.