How does it work? GATES!!!

Ok, it’s time to start this. Of course… I have already made some progress, and I will do this in parallel with the actual build, so, it will take a while until the blog reaches the actual status of the computer… but… I have to start writing at some point.

I’ll start with GATES!. Why? First, because I want to. Second, because it’s the smallest piece of hardware with some logic and actual application in programming. Yes… we can go with smallest pieces, but trust me, gates will do. Also we need to start talking about, what a computer actually does, and how fast.

REGARDING SPEED

The main goal of a computer is… to compute things… and do it fast… but, how fast? Well, really fast, but the problem is not just showing a text in a millisecond, but it goes way beyond that.
Usually you use a programming language, which is a “human” readable way of programming. A computer does not understand that, instead it moves 1s and 0s really fast. Showing just a simple character on display may take just one line in your programming language of choice… around 10 in assembly language… and maybe a hundred in microcode.
Just showing “Hello World” in screen may take one thousand microinstructions… that will be executed… FAST.

One quick example, simplified of course : loading a byte from RAM into the Accumulator : LDA in assembly.

In “microcode” it would look something like this assuming we just booted our computer, assuming it starts from location $00

  • READ FROM LOCATION $00, LDA
  • READ FROM LOCATION $01 THE DESIRED RAM ADDRESS AND STORE IT IN MEMORY ADDRESS REGISTER (MAR)
  • ENABLE MEMORY OUTPUT FROM STORED LOCATION IN MAR
  • ENABLE ACCUMULATOR INPUT
  • INCREASE PROGRAM COUNTER

So… at least 5 microcode steps, for loading a single value from RAM, assuming just 8 bit addressing. The amount of microcode steps will be increased if the address is larger, and obviously… I’m ignoring a couple of steps, a CPU has dozens of components that must be in sync, and turned on and off in perfect harmony.

We will discuss assembly and microcode in a future post, but you can get a small idea regarding speed.

REGARDING GATES

We have a door, with locks… we need to be secure that the door is well shut, you know… you have the door open… insects come in… some stray dogs… maybe a moose… the mailman… You need to close your door!.
This are tricky locks, because… you have to combine them in a specific way to actually close your door.  In our case… only when both locks are in OPEN position, the door will be closed.

LOCK 1 LOCK 2 DOOR
CLOSED CLOSED OPEN
CLOSED OPEN OPEN
OPEN CLOSED OPEN
OPEN OPEN CLOSED

Again… only when both locks are in OPEN position… the door is CLOSED

This is a type of GATE called NAND, or Not AND. Some thing like “When 1 is NOT open AND, 2 is NOT open… then… open”. If we change OPEN for 1 and CLOSED for 0 the table will look like :

A B Y (OUTPUT)
0 0 1
0 1 1
1 0 1
1 1 0

All GATES have a symbol, for NAND gate this is the one :

The small circle at the end is the “NOT” part, so each time you see that small symbol you can safely assume it’s a NOT kind of gate

But… why I’m showing this GATE first and not one of the others. Because you can create ANY kind of gate with this one.

Let’s create another one… just a NOT GATE. This is a gate that has only one input, and just inverts it, that’s why is also called an INVERTER.
How can we create a NOT gate with a NAND ? Well, simple, just send the same value to both inputs.

A Q
0 1
1 0

Simple!, and this NOT gate has a symbol:

See ? the small circle at the end?

Ok… this is a long post so I’ll just add one more gate. The AND gate, in which when if only both inputs are 1, the output will be one.
Again… we can build it with NAND gates…

You can see… it’s a NAND gate… and the output goes to both inputs of a 2nd NAND gate… or an NOT gate as we saw before.
Let’s look at the value table (truth table from now on)

A B OUPUT 1 Q
0 0 1 0
0 1 1 0
1 0 1 0
1 1 0 1

So that’s all for today. Next time I’ll introduce to you the 7400 chip series that I will use for building my homemade computer. And of course, will show to you some diagrams about building the NOT and AND gates, with one of those chips.

See you next time!!!!

Leave a Reply

Your email address will not be published. Required fields are marked *