Unit 1: Signals
On, off, and one little gate.
Unit 1 of 8 in Digital logic for kids. Its 5 lessons are On or Off, The One Gate, Drawing a Chip, Flip It and Two Flips — below is everything each one explains, and a question or two from it to try.
Every chip on this page was wired up and run on the gate-level simulator before it shipped, and prints exactly the table shown.
This unit is free for ever, because the first two units of every track are. Try it in the app.
💡 On or Off
A computer only knows two things
Inside a computer there are no words, no pictures and no numbers. There is only electricity in a wire — and it is either flowing or it is not.
We write 1 for on and 0 for off. That is it. Everything else you have ever seen a computer do is built out of those two.
Where does the thinking happen?
A wire on its own is just a wire. The interesting part is a gate: a tiny thing that looks at the wires coming in and decides what goes out.
A computer is millions of gates. And here is the surprise you are going to prove for yourself: they can all be the same kind of gate.
Try it yourself
How many different things can one wire carry?
- Two: on or off
- Ten: 0 to 9
- As many as you like
- One
A wire is switched on. What do we write?
- 1
- 0
- yes
- on
Answer them in the app
🚪 The One Gate
Meet Nand
Nand has two wires going in, called a and b, and one coming out, called out.
The rule is short: out is 0 only when a and b are both 1. Every other time, out is 1.
TABLE shows you every possible input and what comes out — that is called a truth table.
HDL
TABLE Nand;
It prints
a b | out 0 0 | 1 0 1 | 1 1 0 | 1 1 1 | 0
Why this one?
Nand is not special because it is clever. It is special because everything else can be made out of it.
Real factories like it for the same reason: one gate to design, one gate to test, printed millions of times over. In this track you are going to start with exactly one Nand and end with a working calculator and a memory.
Try it yourself
Both wires going in are 1. What comes out?
- 0
- 1
- Nothing
- Both
a is 1 and b is 0. What comes out?
- 1
- 0
- It depends
- 2
Answer them in the app
📐 Drawing a Chip
How to describe wiring
You do not write instructions here — there is nothing to run. You describe what is connected to what, and the wires do the rest, all at once.
IN lists the wires coming in, OUT the wires going out, and under PARTS: you name a gate and say where each of its pins is wired.
HDL
CHIP Not {
IN in;
OUT out;
PARTS:
Nand(a=in, b=in, out=out);
}
Try it yourself
In Nand(a=in, b=in, out=out);, what is on the left of each =?
HDL
Nand(a=in, b=in, out=out);
- A pin on the Nand gate
- A wire in our chip
- A number
- The name of the chip
Why does every chip need OUT?
- Otherwise nothing ever comes out of it
- To make it run faster
- To give it a name
- It does not — OUT is optional
Answer them in the app
🔄 Flip It
One gate, one trick
Feed the same wire into both inputs of a Nand. Now the only way to get 0 out is for that wire to be 1.
So the answer always comes out the opposite of what went in. That chip is called Not, and it is your first one.
HDL
CHIP Not {
IN in;
OUT out;
PARTS:
Nand(a=in, b=in, out=out);
}
TABLE Not;
It prints
in | out 0 | 1 1 | 0
Testing one row at a time
A truth table shows every row at once. Sometimes you want just one.
USE picks the chip, SET holds a wire at a value, and SHOW prints what is coming out right now.
HDL
CHIP Not {
IN in;
OUT out;
PARTS:
Nand(a=in, b=in, out=out);
}
USE Not;
SET in=1;
SHOW out;
It prints
out=0
Try it yourself
What does this print?
HDL
CHIP Not {
IN in;
OUT out;
PARTS:
Nand(a=in, b=in, out=out);
}
USE Not;
SET in=0;
SHOW out;
Answer it in the app
🏆 Two Flips
Chips are parts too
Once you have built a chip you can use it inside the next one, exactly like a Nand. That is the whole game: small pieces become parts of bigger pieces.
Here Same uses Not twice. The wire between them is called flipped — a name we made up, because we needed somewhere for the middle answer to sit.
HDL
CHIP Not {
IN in;
OUT out;
PARTS:
Nand(a=in, b=in, out=out);
}
CHIP Same {
IN in;
OUT out;
PARTS:
Not(in=in, out=flipped);
Not(in=flipped, out=out);
}
TABLE Same;
It prints
in | out 0 | 0 1 | 1
Try it yourself
Why does flipping twice give you back what you started with?
- Because there are only two values, so flipping twice lands where it began
- Because the second Not is ignored
- Because 0 and 1 are the same thing
- It does not — it gives the opposite
Answer it in the app