Build it from logic gates
Short, hands-on guides to building the core building blocks of digital logic from gates, each with a live circuit you can toggle right on the page and open in the lab.
Every part below is realized and verified by the same simulator that powers the digiwleea lab, so the embedded circuit is the exact one the walkthrough describes. They are grouped roughly in the order a computer is built: arithmetic, then choosing and routing signals, then comparing, then memory, then registers and counters.
Gates from transistors (CMOS)
Where every gate starts: NMOS and PMOS switches wired into CMOS inverter, NAND and NOR gates, then AND, OR and XOR, plus the switches with a third, floating state: transmission gates and tri-state buffers.
- Build a CMOS inverter →
- Build a CMOS NAND gate →
- Build a CMOS NOR gate →
- Build a CMOS AND gate →
- Build a CMOS OR gate →
- Build a CMOS XOR gate →
- Build a CMOS XNOR gate →
- Build a CMOS transmission gate →
- Build a tri-state buffer (CMOS) →
- Build a 2-to-1 mux from transmission gates →
- Build an XOR gate from transmission gates →
- Build a 4-to-1 mux from transmission gates →
- Build a CMOS AOI21 gate from transistors →
- Build a CMOS 3-input majority gate from transistors →
- Build a CMOS half adder (16 transistors) →
- Build a 28-transistor CMOS mirror full adder →
Arithmetic
From one column of binary addition to whole 4-bit adders, plus subtractors, multipliers and a 4-bit ALU.
- Build a half adder →
- Build a full adder →
- Build a full adder using two half adders →
- Build a Full adder using a decoder →
- Build a Full subtractor using a decoder →
- Build a 2-bit adder →
- Build a 3-bit binary adder →
- Build a 4-bit incrementer →
- Build a 4-bit decrementer →
- Build a 4-bit ripple carry adder →
- Build a 4-bit carry lookahead adder →
- Build a 4-bit carry lookahead generator →
- Build a 4-bit carry-select adder →
- Build a 4-bit carry-skip adder →
- Build a 4-bit Kogge-Stone adder →
- Build an 8-bit Brent-Kung adder →
- Build a 4-bit carry-save adder →
- Build a half adder using a decoder →
- Build a half adder using 2:1 multiplexers →
- Build a full adder using 4:1 multiplexers →
- Build a full adder using 8:1 multiplexers →
- Build a full subtractor using 4:1 multiplexers →
- Build a serial adder →
- Build a half subtractor →
- Build a full subtractor →
- Build a 4-bit subtractor →
- Build a 4-bit adder/subtractor →
- Build a BCD adder →
- Build a BCD subtractor →
- Build a 2-bit multiplier →
- Build a binary divider →
- Build a 4-bit array multiplier →
- Build a 4x4 Wallace tree multiplier →
- Build a 4x4 Dadda multiplier →
- Build an 8-bit adder →
- Build a 1-bit ALU →
- Build a 4-bit ALU →
- Build an 8-bit ALU →
Universal gates: NAND only, NOR only
One gate type is enough to build every other gate, and from them whole adders.
- Build NOT, AND, OR and NOR gates from NAND gates only →
- Build NOT, OR, AND and XOR gates from NOR gates only →
- Build an XOR and XNOR from AND, OR and NOT gates →
- Build a logic gates using 2:1 multiplexers →
- Build a 2-to-4 decoder from NOR gates →
- Build a Toffoli gate →
- Build a CNOT gate →
- Build an XOR gate from NAND gates →
- Build an XNOR gate from NAND gates →
- Build a NOT gate from a NAND gate →
- Build a NOT gate from a NOR gate →
- Build an AND gate from NAND gates →
- Build an OR gate from NAND gates →
- Build a NOR gate from NAND gates →
- Build an OR gate from NOR gates →
- Build an AND gate from NOR gates →
- Build an XOR gate from NOR gates →
- Build an XNOR gate from NOR gates →
- Build a half adder from NAND gates →
- Build a full adder from NAND gates →
- Build a half subtractor from NAND gates →
- Build a full subtractor from NAND gates →
- Build a half adder from NOR gates →
- Build a half subtractor from NOR gates →
- Build a full adder from NOR gates →
- Build a full subtractor from NOR gates →
- Build a SOP vs POS circuits →
- Build a 2-to-1 multiplexer from NAND gates →
Selecting, routing and decoding
Multiplexers pick a signal, demultiplexers and decoders steer one, encoders and display decoders translate codes.
- Build a 2:1 multiplexer →
- Build a 4:1 multiplexer →
- Build a 4-to-1 mux from 2-to-1 muxes →
- Build an 8-to-1 multiplexer from 2-to-1 muxes →
- Build an 8-to-1 multiplexer from 4-to-1 muxes →
- Build a 16-to-1 multiplexer from 8-to-1 muxes →
- Build a 32-to-1 multiplexer from 8-to-1 muxes →
- Build a BCD to Gray code converter using 8:1 multiplexers →
- Build an 8-to-1 multiplexer →
- Build a 16-to-1 multiplexer →
- Build a 1-to-2 demultiplexer →
- Build a 1-to-4 demultiplexer →
- Build a 1-to-8 demultiplexer →
- Build a 1-to-16 demultiplexer →
- Build a 1-to-32 demultiplexer from 1-to-8 demuxes →
- Build a 2-to-4 decoder →
- Build a 2-to-4 decoder with enable →
- Build a 3-to-8 decoder →
- Build a 3-to-8 decoder from two 2-to-4 decoders →
- Build a 4-to-16 decoder from 2-to-4 decoders →
- Build a programmable logic array (PLA) →
- Build a 4-to-16 decoder →
- Build a 4-to-2 encoder →
- Build an 8-to-3 encoder →
- Build a 4-to-2 priority encoder →
- Build an 8-to-3 priority encoder →
- Build a BCD to 7-segment decoder →
- Build a Hex to 7-segment decoder →
- Build a binary to Gray code converter →
- Build a Gray to binary converter →
- Build a BCD to Gray code converter →
- Build a binary to BCD converter →
- Build a BCD to binary converter →
- Build a BCD to excess-3 code converter →
- Build an excess-3 to BCD code converter →
- Build a decimal to BCD encoder →
- Build a BCD to decimal decoder →
- Build a parity generator and checker →
- Build an Odd parity generator and checker →
- Build a Hamming (7,4) code encoder and corrector →
- Build a 4-bit barrel shifter →
Logic chips: 74xx and 4000 series
Classic logic chips, each a live circuit with its datasheet pinout: the quad gate chips, a dual flip-flop, a bus buffer, decoders, multiplexers, 7-segment drivers, an adder, shift registers, counters and an ALU.
- Wire the 7400 NAND gate chip →
- Wire the 7402 NOR gate chip →
- Wire the 7404 NOT gate chip →
- Wire the 7408 AND gate chip →
- Wire the 7432 OR gate chip →
- Wire the 7486 XOR gate chip →
- Wire the 7410 3-input NAND gate chip →
- Wire the 7411 3-input AND gate chip →
- Wire the 7420 4-input NAND gate chip →
- Wire the CD4011 2-input NAND gate chip →
- Wire the CD4001 2-input NOR gate chip →
- Wire the CD4081 2-input AND gate chip →
- Wire the CD4069 NOT gate chip →
- Build the 7474 dual D flip-flop from NAND gates →
- Build the CD4013 dual D flip-flop from logic →
- Build the 74LS76 dual JK flip-flop from logic →
- Build the 74HC139 dual decoder from logic gates →
- Build the 74LS138 3-to-8 decoder from logic gates →
- Build the 74HC151 multiplexer from logic gates →
- Build the 74HC157 quad multiplexer from logic gates →
- Build the 74LS47 BCD to 7-segment decoder from logic gates →
- Build the CD4511 BCD to 7-segment decoder from logic →
- Build the 74LS283 4-bit adder from logic gates →
- Build the 7485 4-bit magnitude comparator from logic gates →
- Build the 74HC125 quad tri-state buffer →
- Build the 74HC244 tri-state buffer from transistors →
- Build the 74HC373 octal latch from logic →
- Build the 74HC374 octal register from logic →
- Build the 74HC595 shift register from logic →
- Build the 74HC164 shift register from logic →
- Build the 74HC165 shift register from logic →
- Build the 7490 decade counter from logic →
- Build the 7492 divide-by-12 counter from logic →
- Build the 7493 4-bit binary counter from logic →
- Build the 74HC161 synchronous counter from logic →
- Build the 74LS193 up/down counter from flip-flops and gates →
- Build the CD4017 decade counter from logic →
- Build the CD4040 12-stage ripple counter from flip-flops →
- Build the CD4060's 14-stage ripple counter from flip-flops →
- Build the 74181 4-bit ALU from logic gates →
Comparing numbers
Greater than, equal or less than, decided from the top bit down.
- Build a 1-bit magnitude comparator →
- Build a 2-bit comparator →
- Build a 3-bit magnitude comparator →
- Build a 4-bit magnitude comparator →
- Build an 8-bit magnitude comparator →
Memory: latches and flip-flops
Feedback that holds a bit, then clocked versions that update on an edge.
- Build an SR latch →
- Build an SR latch from NAND gates →
- Build an SR flip-flop from NAND gates →
- Build an SR flip-flop from NOR gates →
- Build a D latch →
- Build a D latch from NAND gates →
- Build a D flip-flop →
- Compare a D latch and a D flip-flop on one clock →
- Build a D flip-flop from NAND gates →
- Build a D flip-flop from NOR gates →
- Build a D latch and D flip-flop using 2:1 muxes →
- Build a D flip-flop with enable →
- Build a JK flip-flop →
- Build a JK latch and watch the race-around condition →
- Build a master-slave JK flip-flop (NAND) →
- Build a JK flip-flop from NOR gates →
- Build a T flip-flop →
- Build a T flip-flop from a JK flip-flop →
- Build a T flip-flop from NAND gates →
- Build an SR flip-flop from a D flip-flop →
- Build a D flip-flop from an SR flip-flop →
- Build a JK flip-flop from an SR flip-flop →
- Build a JK flip-flop from a D flip-flop →
- Build a flip-flop conversion (JK to D) →
- Build a D flip-flop from a T flip-flop →
- Build a switch debouncer (SR latch) →
Registers and counters
Flip-flops working together: loading a word, shifting, circulating and counting.
- Build a 4-bit register with parallel load →
- Build an 8-bit register with load →
- Build a 4-bit program counter →
- Build a 4-bit accumulator →
- Build an Instruction register and decoder →
- Build a Hardwired control unit →
- Build a Microprogrammed control unit →
- Build a 4 x 4-bit register file from registers, a decoder and multiplexers →
- Build a 4 x 4-bit content-addressable memory from registers and comparators →
- Build a memory address register, a small memory and an MDR →
- Build a hardware stack with a stack pointer →
- Build a 4-line direct-mapped cache from registers and multiplexers →
- Build a 4-bit shift register →
- Build a PISO shift register →
- Build a 4-bit universal shift register →
- Build a 4-bit bidirectional shift register →
- Build a 4-bit ring counter →
- Build a 4-bit Johnson counter →
- Build a ring and Johnson counter from JK flip-flops →
- Build a 4-bit ripple counter →
- Build a 4-bit ripple down counter →
- Build a 4-bit asynchronous up/down counter →
- Build a 4-bit synchronous counter →
- Build a 3-bit synchronous counter (JK) →
- Build a 3-bit synchronous down counter →
- Build a 2-bit up/down counter →
- Build a 3-bit synchronous up/down counter using JK flip-flops →
- Build a 4-bit up/down counter →
- Build a decade counter →
- Build a 7-segment display counter →
- Build a mod-6 counter →
- Build a mod-6 synchronous counter using JK flip-flops →
- Build a Mod-7 counter →
- Build a Mod-9 counter →
- Build a Mod-12 counter →
- Build a Mod-60 counter →
- Build a Mod-4 counter →
- Build a Mod-3 counter →
- Build a mod-5 counter →
- Build a 3-bit Gray code counter →
- Build a frequency divider (by 2, 4 and 3) →
- Build a digital PWM generator from a counter and a comparator →
- Build an electronic dice from a counter and a pip decoder →
- Build a binary clock from BCD counters →
- Build a 4-bit LFSR →
State machines
Flip-flops plus next-state logic that react to the bits arriving on an input.
- Build a turnstile finite state machine from a flip-flop and gates →
- Build a 1011 sequence detector →
- Build a 101 sequence detector →
- Build a Sequence generator →
- Build a Mealy machine (1011 detector) →
- Build a traffic light controller →
- Build a vending machine FSM →
- Build an edge detector →
These parts are rungs on the ladder from a single transistor to a working 8-bit CPU. Explore the concepts in the free theory reference, or begin the guided course with Act I for free.
Open the digiwleea lab →