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.
Combinational
Sequential
Memory
None
Yes (flip-flops, latches)
Output depends on
Current inputs
Current inputs and stored state
Clock
Not needed
Usually clocked
Examples
Gates, adders, multiplexers, decoders
Registers, 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…
How real designs combine them
Nearly every synchronous design is registers connected by combinational logic. On each clock edge the registers capture the results of the logic between them. The clock period has to be long enough for the slowest path of gates to settle, which is what limits how fast a design can run.
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.