Home / Learn Verilog / Inference: Latches and Flip-Flops

Inference: Latches and Flip-Flops

How the tool decides storage.

Bottom lineHow the tool decides storage.

Breaking it down

What you getalways @(posedge clk) -> flip-flopalways @(*) complete -> logicalways @(*) incomplete -> latchassign -> logic
What you get

The basic idea

A block with a clock edge infers flip-flops; a level-sensitive block with missing branches infers latches.

Why this comes up

You choose hardware by how you write code.

The mechanics

Clocked always = flip-flop; always @* complete = logic.

Where it is used

  • Everyday RTL design
  • FPGA and ASIC projects
  • Testbenches and debugging

Try it

Latch or not?Verilog: edit and run

The second block must remember a.

Quick check

1. Incomplete combinational block infers...