Back to features

Gate Synthesis

Automatic lowering to primitive gates with full netlist generation. AND, OR, XOR, NOT, MUX, and DFF primitives form the foundation of every digital circuit.

AND OR XOR NOT MUX DFF

Gate Primitives

CIRCT synthesizes down to six fundamental gate types. Every digital circuit, no matter how complex, is built from these primitives.

GateInputsFunctionUse Case
AND2+Output high when all inputs highMasking, enable logic
OR2+Output high when any input highFlag combining, priority logic
XOR2+Output high when odd number of inputs highParity, comparison, arithmetic
NOT1Output is complement of inputInversion, active-low signals
MUX2 data + 1 selectSelect between inputs based on controlData routing, conditionals
DFFD + CLKCapture input on clock edgeState storage, registers, pipelines

Lowering Pipeline

The synthesis pipeline transforms high-level RTL through multiple passes, progressively lowering abstractions until only primitive gates remain.

RTL

High-level operators, case statements

Boolean

AND/OR/NOT/XOR expressions

Netlist

Gate instances, wire connections

A simple 2-to-1 multiplexer at the RTL level uses a mux call.

mux_rtl.rb
class Mux2 < RHDL::Sim::Component
  input  :a, :b, :sel
  output :y

  behavior do
    y <= mux(sel, a, b)
  end
end

After synthesis: y = (a AND NOT sel) OR (b AND sel).

gate_netlist Synthesized
# NOT  g0 (.in(sel), .out(sel_n))
# AND  g1 (.in(a, sel_n), .out(t0))
# AND  g2 (.in(b, sel), .out(t1))
# OR   g3 (.in(t0, t1), .out(y))
#
# Total: 4 gates, 1 level of logic

Netlist Generation

synthesis_example.rb
alu = SimpleALU.new
netlist = alu.synthesize(target: :gates)

netlist.stats
# => { and: 24, or: 16, xor: 8, not: 12, mux: 4, dff: 0 }
# => Total: 64 gates

netlist.to_verilog("alu_gates.v")
netlist.to_dot("alu_gates.dot")