When Synthesis Goes Wrong: Debugging and Solutions
Synthesis is powerful, but it's not magic. The tool faithfully translates your RTL into gates, which means it will also faithfully translate your mistakes into hardware problems. Unlike software bugs that crash at runtime, hardware synthesis issues can create chips that behave unpredictably, fail timing closure, or simply don't work at all. The good news? Most synthesis problems fall into predictable categories with well-known solutions.
This module explores the most common synthesis issues you'll encounter: unintended latches, unmapped cells, combinational loops, unconnected ports, and constant tie cells. You'll learn to recognize these problems in synthesis reports and warnings, understand why they occur, and most importantly, fix them in your RTL. These debugging skills will save you countless hours and prevent expensive tape-out mistakes.
Latch Inference: The Accidental State
What Are Latches?
A latch is a level-sensitive storage element—it's transparent (passes input to output) when the enable is high, and holds its value when enable is low. Unlike flip-flops (edge-triggered), latches are level-triggered.
D-Latch Behavior
When EN = 1: Q follows D (transparent)
When EN = 0: Q holds previous value (latched)
Why Latches Are Usually Bad
Problems with Latches:
- Timing analysis nightmare: Level-sensitive timing is complex
- Race conditions: Glitches can cause incorrect latching
- Testability issues: Difficult to control and observe in testing
- Clock domain crossing: Complications with multiple clocks
- Technology mapping: Not all libraries have efficient latch cells
When Latches Are Intentional:
- Low-power designs (less switching than flip-flops)
- Asynchronous interfaces
- Specific architectural requirements
- But these are rare—99% of the time, latch inference is a bug
How Latches Get Inferred
Classic Mistake: Incomplete Combinational Logic
// BAD: Infers latch
always @(*) begin
if (select)
out = a;
// Missing else - what happens when select = 0?
// Synthesis infers latch to hold previous value
end
Why a Latch?
The always @(*) block describes combinational logic, but the output isn't defined for all input conditions. The synthesis tool assumes you want to retain the previous value, creating a latch.
More Examples of Latch Inference
Incomplete Case Statement
// BAD: Infers latch
always @(*) begin
case (opcode)
2'b00: result = a + b;
2'b01: result = a - b;
2'b10: result = a & b;
// Missing 2'b11 case - latch inferred for result
endcase
end
Conditional Assignment
// BAD: Infers latch
always @(*) begin
if (condition)
data_out = data_in;
// No else - latch inferred
end
Partially Assigned Multi-Bit Signal
// BAD: Infers latches for upper bits
always @(*) begin
case (sel)
2'b00: out[1:0] = 2'b00; // What about out[7:2]?
2'b01: out[3:0] = 4'b1111;
2'b10: out = 8'hFF;
2'b11: out[5:0] = 6'h3F;
endcase
end
Detecting Latch Inference
Yosys Warning
Latch inferred for signal `\my_module.\out' from process `\my_module.$proc$design.v:2$1': $auto$proc_dlatch.cc:432:proc_dlatch$15
Synthesis Statistics
For a module with an 8-bit out assigned in always @(*) only when en is 1, next to an 8-bit clocked register, stat after synth shows one latch per bit:
yosys> stat
=== my_module ===
5 wires
26 wire bits
5 public wires
26 public wire bits
5 ports
26 port bits
16 cells
8 $_DFF_P_
8 $_DLATCH_P_
Any cell with "LATCH" in the name indicates latch inference.
Visual Detection
yosys> show
Look for feedback loops with enable signals—characteristic of latches.
Fixing Latch Inference
Solution 1: Add Default Case
// GOOD: No latch
always @(*) begin
case (opcode)
2'b00: result = a + b;
2'b01: result = a - b;
2'b10: result = a & b;
2'b11: result = a ^ b; // Now all cases covered
endcase
end
Or use default:
// GOOD: Default handles all other cases
always @(*) begin
case (opcode)
2'b00: result = a + b;
2'b01: result = a - b;
2'b10: result = a & b;
default: result = 8'h00; // Explicit default
endcase
end
Solution 2: Add Else Clause
// GOOD: Complete specification
always @(*) begin
if (select)
out = a;
else
out = b; // Explicit else
end
Solution 3: Initialize Before Conditionals
// GOOD: Default value for all paths
always @(*) begin
out = 8'h00; // Default assignment
case (opcode)
2'b00: out = a + b;
2'b01: out = a - b;
2'b10: out = a & b;
// 2'b11 uses default value
endcase
end
This is the most robust approach—guarantees no latches.
Best Practice Pattern
always @(*) begin
// Default assignments first
result = 0;
valid = 0;
error = 0;
// Then conditional logic
case (state)
IDLE: begin
valid = 1;
end
ACTIVE: begin
result = data;
valid = 1;
end
ERROR: begin
error = 1;
end
// No default needed - all signals initialized
endcase
end
Unmapped Cells: Lost in Translation
What Are Unmapped Cells?
Unmapped cells are Yosys's generic internal cells (names starting with $, such as $_XOR_, $_MUX_ or $_DFF_P_) that are still in the netlist after technology mapping. They do not exist in silicon, so a netlist that contains them cannot be built.
Example
This counter was synthesized and its flip-flops mapped with dfflibmap, but abc was never run:
yosys> stat
=== counter ===
22 wires
43 wire bits
4 public wires
11 public wire bits
4 ports
11 port bits
32 cells
2 $_ANDNOT_
5 $_AND_
8 $_MUX_
1 $_NAND_
1 $_NOT_
1 $_XNOR_
6 $_XOR_
8 sky130_fd_sc_hd__dfrtp_1
The flip-flops are real dfrtp_1 cells, but the logic is still generic.
Why Cells Don't Map
Cause 1: A Mapping Step Was Not Run
This is by far the most common cause. synth breaks arithmetic and multiplexers down into generic gates, dfflibmap maps flip-flops, and abc maps the gates. Leave out dfflibmap and the flip-flops stay generic; leave out abc and the gates do, as above.
Cause 2: The Library Lacks a Needed Cell
The library must offer every kind of storage element the design needs. Combinational logic always maps, because any function can be built from basic gates: an 8-by-8 multiply and an arithmetic shift $signed(a) >>> 3 mapped completely to 258 SkyWater 130 gates, with no multiplier or shifter cell in the library. Flip-flops and latches are different: a register type with no suitable library cell, and no way for dfflibmap to build it from one, stays generic.
Detecting Unmapped Cells
yosys> select -assert-none t:$*
The command stops the script with an error listing the generic cells if any are left, so put it at the end of every synthesis script. Cell names starting with $ in stat output tell you the same thing.
Fixing Unmapped Cells
Solution 1: Run the Mapping Steps in Order
synth -top counter
dfflibmap -liberty cells.lib
abc -liberty cells.lib
opt_clean -purge
select -assert-none t:$*
Solution 2: Check the Library's Sequential Cells
If flip-flops or latches stay generic, look for a cell of the right kind in the Liberty file (reset polarity, set and reset, enable). Changing the RTL to a register style the library supports, for example an active-low reset, is often simpler than finding another library.
Solution 3: Keep RTL Changes Exactly Equivalent
If you rewrite RTL to work around a mapping problem, make sure the new code computes the same thing. A tempting example is replacing $signed(a) >>> 3 with $signed(a) / 8: they differ for negative numbers, because the shift rounds down and the division rounds toward zero. In a simulation, a = -1 gives -1 for the shift and 0 for the division, and a = -12 gives -2 and -1.
Solution 4: Use FPGA Synthesis for FPGA Targets
If the target is an FPGA, use the FPGA-specific command, such as synth_ice40 or synth_ecp5, which maps to FPGA primitives instead of ASIC standard cells.
Combinational Loops: The Feedback Problem
What Are Combinational Loops?
A combinational loop is a path through combinational logic that feeds back to itself—creating a cycle with no registers to break it.
Example
assign a = b & c;
assign b = a | d; // Loop! a depends on b, b depends on a
Why Combinational Loops Are Bad
Problems:
- Unstable behavior: Output oscillates or settles unpredictably
- Timing analysis impossible: No well-defined delay
- Simulation-hardware mismatch: Simulators may not catch the issue
- Synthesis tool confusion: May produce warnings or errors
Intentional Combinational Loops: Very rare—only in specialized circuits like:
- Arbiters
- Metastability resolvers
- Analog-style circuits
How Combinational Loops Occur
Mistake 1: Unintentional Feedback
// BAD: Combinational loop
always @(*) begin
temp = a & b;
out = temp | out; // out depends on itself!
end
Mistake 2: Circular Dependencies
// BAD: Module A uses Module B, Module B uses Module A output
module A (input x, output y);
assign y = x & b_out;
endmodule
module B (input p, output q);
assign q = p | a_out; // Circular!
endmodule
Mistake 3: Incorrect Latch Modeling
// BAD: Trying to model latch, created loop
assign q = enable ? d : q; // q depends on q combinationally
Detecting Combinational Loops
Yosys Warning
Warning: found logic loop in module top:
cell $ternary$design.v:2$1 ($mux) source: design.v:2.14-2.28
A[0] --> Y[0]
Visual Detection
yosys> show
Look for cycles in the graph that don't pass through flip-flops.
Check Command
yosys> check
Warning: found logic loop in module top:
cell $ternary$design.v:2$1 ($mux) source: design.v:2.14-2.28
A[0] --> Y[0]
Found and reported 1 problems.
Fixing Combinational Loops
Solution 1: Add Registers
// GOOD: Break loop with register
always @(posedge clk) begin
temp <= a & b;
out <= temp | out_reg;
end
Solution 2: Restructure Logic
// BAD: Loop
always @(*) begin
temp = a & b;
out = temp | out;
end
// GOOD: No feedback
always @(*) begin
temp = a & b;
out = temp | c; // Use different signal
end
Solution 3: Use Proper Latch Syntax
// Instead of combinational feedback for latch
// Use proper level-sensitive always block
always @(enable or d) begin
if (enable)
q <= d;
// Synthesizes to latch correctly
end
Solution 4: Fix Module Interconnections
Break circular module dependencies:
// Redesign so data flows in one direction
// Use registers at module boundaries if needed
Unconnected Ports: The Floating Signal
What Are Unconnected Ports?
Unconnected ports are module inputs that aren't driven or outputs that aren't used.
Example
module counter (
input clk,
input rst,
input enable, // Never connected
output [7:0] count
);
// ...
endmodule
// Instantiation
counter u_cnt (
.clk(clk),
.rst(rst),
// .enable missing!
.count(count)
);
Why Unconnected Ports Are Problematic
Unconnected Inputs:
- May synthesize to undefined values (X in simulation)
- Could float in actual hardware (unpredictable behavior)
- Synthesis tool may tie to 0 or 1 (but which?)
Unconnected Outputs:
- Wasted logic (synthesis may not remove it)
- Confusion about design intent
- Could indicate a bug (forgot to use the signal?)
Detecting Unconnected Ports
What Yosys Reports
hierarchy -check does not complain about an unconnected port: it only checks that every instantiated module exists. An unconnected input shows up later as an undriven wire once the design is flattened and checked:
yosys> hierarchy -check -top top
yosys> proc; flatten; check
Warning: Wire top.\u_cnt.enable is used but has no driver.
An unconnected output is not reported at all; the logic behind it is simply removed if nothing else uses it. Review instantiations for missing outputs by reading them, or lint the RTL first.
Fixing Unconnected Ports
Solution 1: Connect the Port
// If port should be used, connect it
counter u_cnt (
.clk(clk),
.rst(rst),
.enable(1'b1), // Connect to constant or signal
.count(count)
);
Solution 2: Remove Unused Ports
// If truly unused, remove from module definition
module counter (
input clk,
input rst,
// enable removed
output [7:0] count
);
Solution 3: Explicit Unused Indication
// Document that port is intentionally unused
counter u_cnt (
.clk(clk),
.rst(rst),
.enable(), // Explicitly left unconnected
.count(count)
);
// Or in Verilog-2001
counter u_cnt (
.clk(clk),
.rst(rst),
// .enable not mentioned - implicitly unconnected
.count(count)
);
Solution 4: Default Port Values
// In module definition, provide defaults
module counter (
input clk,
input rst,
input enable = 1'b1, // Default value
output [7:0] count
);
Now if enable isn't connected, it defaults to 1.
Tie-High/Tie-Low Cells: Constant Connections
What Are Tie Cells?
Tie cells are library cells that output a constant 0 or 1. In SkyWater 130 the cell is sky130_fd_sc_hd__conb_1, which has both a HI and a LO output.
Why Not Just Connect to Vdd/Gnd?
A gate input wired straight to a supply rail has its thin gate oxide exposed to every spike on that rail and to electrostatic discharge. A tie cell drives the input through a transistor instead, and gives place and route a normal cell to connect the constant from. Foundry rules usually require it.
When Tie Cells Appear
Synthesis first propagates constants: logic that always produces the same value is removed. What is left are constant bits that still reach an output or a cell input, such as:
module consts (input [7:0] data, output [7:0] result, output [3:0] flags);
assign result = data & 8'hF0; // lower bits always 0
assign flags = 4'b1010; // constant output
endmodule
In Yosys these constants become tie cells only when you ask for it, with the hilomap pass:
yosys> hilomap -hicell sky130_fd_sc_hd__conb_1 HI -locell sky130_fd_sc_hd__conb_1 LO
Detecting Tie Cells
yosys> stat -liberty cells.lib
=== consts ===
3 - wires
20 - wire bits
3 - public wires
20 - public wire bits
3 - ports
20 - port bits
8 30.029 cells
8 30.029 sky130_fd_sc_hd__conb_1
Chip area for module '\consts': 30.028800
of which used for sequential elements: 0.000000 (0.00%)
Eight constant bits (the four low bits of result and the four bits of flags) produced eight conb_1 cells. select t:sky130_fd_sc_hd__conb_1 lists them.
Managing Tie Cells
One Cell or Many
By default hilomap gives each constant bit its own cell. With -singleton it uses one cell for all 1s and one for all 0s:
=== consts ===
3 - wires
20 - wire bits
3 - public wires
20 - public wire bits
3 - ports
20 - port bits
2 7.507 cells
2 7.507 sky130_fd_sc_hd__conb_1
Chip area for module '\consts': 7.507200
of which used for sequential elements: 0.000000 (0.00%)
One cell saves area, but its output then runs to every constant in the design, which can mean long wires; one cell per bit keeps each tie close to its load. Flows choose per design.
Review Constants in RTL
A large number of tie cells usually means a wide bus that is mostly constant, or ports that are tied off. Check that the constants are intended:
// Many tie cells: is the wide bus really needed?
assign wide_bus = {16'h0000, data[15:0]};
Accept the Ones You Need
If the design genuinely needs constants, tie cells are the correct way to provide them; do not try to remove them artificially.
Debugging Workflow for Synthesis Issues
Systematic Approach
Step 1: Check Synthesis Log
$ yosys -s synthesis.ys 2>&1 | tee synthesis.log
$ grep -i "warning\|error" synthesis.log
Step 2: Examine Statistics
yosys> stat
Look for:
- Generic cells (unmapped)
- Latch cells
- Excessive tie cells
Step 3: Run Checks
yosys> check
yosys> select -assert-none t:$* # No unmapped cells
Step 4: Visual Inspection
yosys> show
Look for:
- Feedback loops (combinational loops)
- Latch structures (unintended state)
- Dangling connections
Step 5: Fix RTL
Address issues in source Verilog, not synthesized netlist.
Step 6: Re-synthesize and Verify
$ yosys -s synthesis.ys
$ # Check that issues are resolved
Prevention Checklist
Before Synthesis:
- [ ] All combinational blocks have complete assignments
- [ ] All case statements have default cases
- [ ] All if statements have else clauses
- [ ] No circular module dependencies
- [ ] All instantiated ports connected or explicitly left unconnected
During Synthesis:
- [ ] Read synthesis warnings carefully
- [ ] Check statistics for generic cells
- [ ] Verify no latches (unless intentional)
- [ ] Run
checkcommand
After Synthesis:
- [ ] Review cell type distribution
- [ ] Verify no combinational loops
- [ ] Check for excessive tie cells
- [ ] Compare against expected results
Summary
Common synthesis issues have predictable causes and solutions:
- Latch inference: Incomplete combinational logic → Add defaults, else clauses, or full case coverage
- Unmapped cells: Missing technology mapping or library cells → Run
abc, use complete library, or change RTL - Combinational loops: Unintentional feedback paths → Add registers or restructure logic
- Unconnected ports: Missing connections → Connect ports, remove unused ports, or document intent
- Tie-high/tie-low cells: Constant generation → Normal in moderation; review if excessive
Key debugging skills you've developed:
- Recognizing warning patterns in synthesis logs
- Using
stat,check, andshowto diagnose issues - Tracing problems back to RTL source
- Applying systematic fixes
- Preventing issues with good coding practices
These debugging skills are invaluable throughout your career. Every designer encounters these issues, but experienced designers fix them quickly because they recognize the patterns. With practice, you'll spot potential problems in RTL before synthesis, write cleaner code, and spend less time debugging synthesis issues. The patterns you've learned here apply across all synthesis tools—commercial or open-source—making you a more effective hardware designer.