Clock

The clock is a circuit that oscillates at a particular frequency; its purpose is to turn its output wire HIGH or LOW periodically. A very famous example is the 555 Timer. In its core, you guessed it, an infinite loop.

https://en.wikipedia.org/wiki/555_timer_IC

There are other kinds of timers that use oscillating crystals that can oscillate in the MHz range, and then there are circuits that are frequency multipliers, so MHz can turn into GHz. For reference, most modern CPUs are operating with clocks in the GHz range. The frequency multipliers usually are Phase-locked loops or PLLs. Names are not important, ideas are important. The 555 timer can achieve stable frequency from 0.1 Hz to 500 kHz.

The clock circuit can be outside or inside the CPU itself. Z80 has it outside, meaning that one of Z80's pins is connected to the output of the clock circuit.

The signal clock looks like this:

     _____       _____       _____
CLK       |_____|     |_____|     |_____

It is really just a heartbeat, HIGH, LOW, HIGH, LOW... 1 0 1 0 1 0.

In the book 'But How Do It Know?' by J. Clark Scott, and in The Art of Electronics, there is an example of a very simple pulse generator circuit.

Imagine a NOT gate: HIGH comes in, LOW comes out, but now we also connect its output to its input, so just as 1 comes out, it feeds into its input and very shortly after, it will output 0, but then 0 will be its input, so it will output 1, and so on. In this case the pulse will be very very short, but you get the idea.

When you buy a computer it says 'the CPU is at 3ghz' this is what they mean, it beats 3,000,000,000 times per second. The speed of light is about 300,000,000 meters per second, in various materials depending on their structure electrons move at speeds between 50 and 99% of the speed of light, so lets say in your computer they move at 150,000,000 m/s. That means that in 1 nanosecond an electron can travel about 15cm. Your computer ticks about 3 times per nanosecond, that means that in 1 clock pulse an electro can travel 5cm. Open up your computer and see, take a ruler and measure the distance between the RAM and the CPU, between the GPU and the RAM, and think about it.

AMD's Ryzen 7 can reach up to 5.6GHz, and and some of Intel's i9 can reach 5.8GHz. Imagine, 6 beats per nanosecond, the electrons can travel barely 3cm. Thats just about the width of 2 of your fingers.

This is how far we have gotten.

Why do we need a clock? Why can't things just be continous?

For our digital computers clocks make things easier to design and to make, because the clock allows us to orchestrate many components, and physically each one of them have some error, also you see how electrons will reach one before the other, just a tiny tiny bit, but that is enough to cause confusion if we want to disable one component and enable the other in the "same" time. There are clockless processors, but I have never programmed one. One example is the AMULET processor.

But I think the bigger question is: Why is it so natural for us to break things into steps, enable this, disable that..?

How would you sort the rings on this baby toy? You will immediately make a plan, first you would take all pieces out, then you look for the biggest one, then you place it first, then look for the second biggest. You can't do it all in the same time, cant even do it 2 at a time, and you have 2 hands.

Even as I am writing this, I can imagine a machine with many levers I pull one and this happens, then pull the other and that happens, then the next one.. I can control the machine. I can think like it. It is much harder to me to think like water.

Look at a wave.

It scares me and excites me in the same time, my thoughts run out. The interference between crests and troughs, how they collapse on themselves, how they interract with each other. Just look at it.

Have you seen boiling water? What do you think the bubbles are made of? Do you think its air? It is water vapour, water molecules so excited that they create a bubble, thrashing agains the rest of the water, the bubble has no air, it is just vacuum and water molecules 3-4 nanometers apart. But what happens as the bubble goes up, from the bottom of the pan?. It is an amazing question, first why does it even want to go up? Why doesn't all the water become gas in the same time? How come the bubbles from at the bottom when they are under the pressure of all the water above, they must hit other molecules so hard to break free.

Since we are babies we split things into chunks, make plans, stack cubes, do steps, one at a time. Even as I type this very text on my keyboard, I type one character at a time. It is quite strange to have 10 fingers and type one at a time, but here we are. This is our limitation and we have to work hard to break through it. The limitation of thinking sequentially. One word at a time, one character at a time, It takes great deal of practice and experience to be able to see a canvas and follow multiple threads, and see how they interract. To think as multiple things at once.

There is a story, about two generals (A1 and A2). They were at war with general B, and were about to attack their city.

The only way they can win is if they attack together. They must agree on the time of attack. You will play general A1, I will be A2. So you send me a message with a messanger on a horse, that says 'tomorrow at 12:00 we attack'. Now, you won't actually know if I received the message, because maybe the messanger got captured by B. So you decide to send a message asking me to confirm 'tomorrow at 12:00 we attack; confirm that you received this message'. I safely receive the message, and I send 'confirmed, tomorrow at 12:00 we go!', but how do I know that you received my confirmation? Anxiety creeps up, maybe its better I ask for your confirmation that you received my confirmation? This way we will never attack, we will keep asking for the confirmation of the confirmation of the confirmation.

Maybe a week before we attack, we see how good is B's at detecting our messangers, you send 20 messages and ask for confirmation, and we measure that 1 get lost, then on the day of the battle we can just send 3 messangers and don't wait for confirmation?

Or we just send 20 messangers at the day of the battle hope for the best.

Thinking about the components interracting with each other, allows you to think from everyone's perspective. You are the generals, but you are also the messanger, you are also the defender. You still break things into pieces, you are the messanger traveling, how much time it takes, which route you take? Rewind the time, now you are the second general A2, waiting for message, did the A1 even sent it? Should you attack? Maybe all 20 messangers were killed. Rewind the time, you are A1 and are anxiously waiting for the confirmation, and so on.

I can't think as multiple things at once, but I can freeze time and rewind and imagine as if I am each of the things, and I see their world, take pencil and paper and draw what is going on. For me this is much more difficult with continous systems, like waves, its just too much going on at once. Even in the AMULET processor it is not exactly continous, it does have instructions and they are split into micro messages between the components, similar to our generals. We are far from water.