Combinational I
Half Adder
Two bits in, sum and carry out — the simplest adder there is.
Combinational I
Full Adder
Adds three bits — because a carry-in has to go somewhere.
Combinational I
Half Subtractor
The half adder's mirror image — difference and borrow instead of sum and carry.
Combinational I
Full Subtractor
Three-bit subtraction: A, B, and a borrow coming in.
Combinational I
4-bit Ripple Carry Adder
Four full adders, daisy-chained by their carry bits.
Combinational I
1-bit Magnitude Comparator
Which is bigger — A or B — for a single bit?
Combinational I
4-bit Magnitude Comparator
Same idea, scaled up to a real bus width.
Combinational I
Binary to Gray Code Converter
XOR each bit with its neighbor and the ambiguity disappears.
Combinational I
Gray to Binary Code Converter
Undoing the Gray-code conversion, one XOR chain at a time.
Combinational II
2:1 Multiplexer
One select bit picks between two inputs.
Combinational II
4:1 Multiplexer
Two select bits, four inputs, one output.
Combinational II
8:1 Multiplexer
Eight inputs, three select bits, one clean line of Verilog.
Combinational II
1:8 Demultiplexer
One input, routed to exactly one of eight outputs.
Combinational II
2:4 Decoder
Turn a 2-bit code into a one-hot 4-bit output.
Combinational II
3:8 Decoder
Same idea, one more address bit, twice the outputs.
Combinational II
8:3 Encoder
The reverse of a decoder — one active line becomes a binary code.
Combinational II
8:3 Priority Encoder
When more than one input is active, the highest-priority one wins.
Sequential
D Flip-Flop
Whatever is on D gets copied to Q on the next clock edge.
Sequential
T Flip-Flop
One input: toggle, or don't.
Sequential
JK Flip-Flop
Set, reset, hold, or toggle — all four combinations, no invalid state.
Sequential
N-bit Up/Down Counter
One control bit decides whether the count climbs or falls.
Sequential
Mod-N Counter
Counts 0 up to N-1, then wraps back to 0.
Sequential
Gray Code Counter
Counts in Gray code directly, one bit change per step.
Sequential
Ring Counter
A single 1 bit chases itself around a loop of flip-flops.
Sequential
Twisted Ring (Johnson) Counter
Feed back the inverted output, and the sequence doubles in length.
Sequential
LFSR (Linear Feedback Shift Register)
A shift register with just enough feedback to look random.