Reading Code by Charles Petzold? Build its circuits yourself
Code: The Hidden Language of Computer Hardware and Software, by Charles Petzold, walks from switches and relays through logic gates, adders, flip-flops and memory to a working CPU and assembly language. The 2nd edition was published by Pearson Education in August 2022, and Petzold's free companion site, codehiddenlanguage.com, has interactive illustrations of the book's most important circuits. This page maps those chapters to circuits you can build yourself, part by part, in digiwleea's free browser lab.
What Code does best
Code explains each idea in plain language and builds it up one small step at a time, so a reader with no background can follow the whole path from a light switch to a processor. The companion site lets you click the switches of each finished circuit and watch it work, and it is free, with no paywall, cookies or tracking. (digiwleea is an independent project, not affiliated with Charles Petzold or his publishers.)
Building the circuits yourself
Reading about a circuit and clicking a finished one is not the same as wiring it yourself and finding out why your first try does not work. In digiwleea you build the book's circuits on a live simulator: gates from CMOS transistors (the modern version of Code's relays), then adders, flip-flops, memory, an ALU and a CPU that you program in assembly, with every part checked against its truth table, and a 40+ level course and an AI tutor (Wleea) for when you get stuck. The table further down lists, for each chapter with an interactive illustration, the matching builds and lessons.
| Code (book and site) | digiwleea | |
|---|---|---|
| Format | A book, plus a free site of interactive illustrations | A browser lab and a guided course |
| The basic switch | Relays | CMOS transistors |
| What you do | Read, then toggle switches in finished circuits | Place every part and wire yourself |
| Checks your circuit | No (illustrations) | Yes, every part against its truth table |
| Price | The book is paid; the site is free | Free lab and Act I; Premium for the full course |
Chapter by chapter: build what you read
Every chapter with interactive illustrations on the companion site, the circuits it shows, and where to build or read the same thing on digiwleea:
- 6. Logic with Switches. In Code: switches in series and in parallel. On digiwleea: logic as switches, the MOSFET simulator.
- 8. Relays and Gates. In Code: AND, OR, NOR and NAND from relays; De Morgan's laws. On digiwleea: gates from transistors, NAND, NOR, AND, OR; De Morgan's laws.
- 10. Alternative 10s. In Code: 3-to-8 decoder, 8-to-3 encoder. On digiwleea: 3-to-8 decoder, 8-to-3 encoder.
- 14. Adding with Logic Gates. In Code: half adder, full adder, 8-bit adder. On digiwleea: half adder, full adder, 8-bit ripple carry adder.
- 16. But What About Subtraction? In Code: 8-bit adder/subtractor, two's complement. On digiwleea: adder-subtractor, two's complement calculator.
- 17. Feedback and Flip-Flops. In Code: relay oscillator, NOR flip-flop, level- and edge-triggered D flip-flops, accumulating adder, ripple counter. On digiwleea: SR latch, D latch, D flip-flop, ripple counter.
- 18. Let's Build a Clock! In Code: binary clock, seven-segment display. On digiwleea: decade counter, BCD to 7-segment decoder.
- 19. An Assemblage of Memory. In Code: 1-bit and 8-bit memory, 8 × 1 and 16 × 8 RAM. On digiwleea: one-bit register, RAM, the memory simulator.
- 20. Automating Arithmetic. In Code: automated accumulating adder. On digiwleea: the accumulator, the program counter.
- 21. The Arithmetic Logic Unit. In Code: add/subtract unit, logic unit, ALU. On digiwleea: 1-bit ALU, 4-bit ALU.
- 22. Registers and Busses. In Code: register array, incrementer/decrementer. On digiwleea: 4-bit register, register file, buses.
- 23. CPU Control Signals. In Code: instruction decoder, the CPU. On digiwleea: control signals, the CPU simulator.
- 24. Loops, Jumps, and Calls. In Code: a CPU with jump instructions. On digiwleea: branching and loops.
- 27. Coding. In Code: assembly language. On digiwleea: assembly language.
No sign-up is needed to start: open the lab and place your first transistor, or read the free theory course. The account (and the AI tutor) are optional.
See for yourself: build a logic gate from transistors in the simulator, then follow the path from sand to an 8-bit CPU.
Open the digiwleea lab →Frequently asked
Is there an online simulator for the circuits in Code by Charles Petzold?
Petzold's own companion site, codehiddenlanguage.com, has free interactive illustrations of the book's main circuits, where you toggle the switches of finished circuits. To build the circuits yourself, part by part, use a logic simulator such as digiwleea, which runs free in the browser.
Which chapters of Code have interactive circuits?
On codehiddenlanguage.com: chapters 6, 8, 10 and 14 to 24, plus chapter 27 on assembly language and JavaScript.
Do I need to read Code before using digiwleea?
No. digiwleea's free theory lessons and course start from a single switch, so either works on its own. They make a good pair: read a chapter, then build its circuits.
Does digiwleea use relays like the book?
No. Code starts with relays because they are easy to picture; digiwleea uses CMOS transistors, the switches inside modern chips. The logic is the same: switches in series make AND, and switches in parallel make OR.