BitFlow

Combinational vs sequential logic

Combinational logic depends only on its current inputs; sequential logic also remembers. How to tell them apart, how each is written in Verilog, and why it matters.

By BitFlow · · 6 min read

The difference in one sentence

Combinational logic has outputs that depend only on the inputs right now. Sequential logic has outputs that also depend on what happened before, because it contains memory. If the same inputs can give different outputs at different times, the circuit is sequential.

CombinationalSequential
MemoryNoneYes (flip-flops, latches)
Output depends onCurrent inputsCurrent inputs and stored state
ClockNot neededUsually clocked
ExamplesGates, adders, multiplexers, decodersRegisters, counters, state machines, memories

Combinational logic in Verilog

Use assign, or an always @(*) block with blocking assignments. The output follows the inputs. Step through this multiplexer: every change to an input wakes the block again.

Loading the animation…

Watch outIn an always @(*) block, give every output a value on every path (an else branch, a default in case). If one path leaves an output unassigned, the output has to remember its old value, and the tool builds a latch you did not intend.

Sequential logic in Verilog

Use always @(posedge clk) with nonblocking assignments. The value is stored at each rising edge and held until the next one. This counter remembers where it is, and the output depends on the history of edges.

Loading the animation…

The difference between a latch and a flip-flop matters too: a latch follows its input while enabled, a flip-flop captures it at an edge.

Loading the animation…

Questions

Is a multiplexer combinational or sequential?

Combinational. Its output depends only on its data and select inputs at that moment, and it has no memory.

Is a counter combinational or sequential?

Sequential. It stores its current count in flip-flops and changes it at each clock edge, so its next output depends on its past.

What is an inferred latch?

An unintended memory element created when a combinational always block does not assign an output on every path. Add an else branch or a default to avoid it.

Was this article helpful?

Keep going