Logic Gates with NAND Gates (and the 7400 chip)

This will be a short post… but useful. You will learn how to build different logic gates with just one chip (or several… but the same kind).
Of course… I will not use just this chip in my project… but this will help you understand how to do it if you want.

In the previous posts I showed you how the NAND, NOT and AND gates works, and I promised to show you how to create the last two with just the first one.

Well, we are going to use a 7400 chip, in my case I usually use the 74LS00 chip, but it doesn’t matter for this example. The first 2 digits are the family (7400), the 2 letters are the subfamily (if none, they are the original ones), and the last digits are the actual component, in this case 00 is a quad 2-input NAND gate.

Yo already know the NAND symbol, you can see that there are 4 of them inside this chip. VCC is for positive voltage, and GND is for ground.

If we play a little with this pins, we can create the NOT and NAND Gates, as you can see in the following picture, in the bottom we connect the pins 1 and 2 (d3 and d4) which are the inputs of one of our NAND gates, and the 3rd pin (d4) which is our output, will become a NOT gate, our first INVERTER (line 5 at the bottom of our breadboard)

On top of that we are using 2 NAND gates, the inputs (lines 4 and 5 at the top) are not connected, but the output of this first NAND gate, pin 11 (g6), is connected to both inputs of the next one at pins 10 and 9 (g6 to h7 and h8) which we are using as an INVERTER too, and we know from our previous post that NAND + INVERTER = AND, which is our output at pin 8 of our chip (line 9 on top of our breadboard)

We can also use the output of the top NAND to the combined input of the first INVERTER too, but I wanted to show you both examples in the same breadboard :). These chips are less than 1USD a piece, we are not going to worry about using more NANDs than needed… at least for now.

We have more Logic Gates to learn…. OR, XOR, NOR and XNOR. Let’s see the tables for input and output for each one (and how to build it with NAND gates, just the diagram, I’ll let you play with the 7400 chip and figure it out).
Of course… there are 74?? chips with each one of this gates, we are just using the NAND as an exercise. But I promise… it will be easier in the future

OR Gate
A B A OR B
0 0 0
0 1 1
1 0 1
1 1 1

If ANY of the inputs are 1 (or both), the OUTPUT will be 1.

XOR Gate (Exclusive OR)
A B A XOR B
0 0 0
0 1 1
1 0 1
1 1 0

If A or B are 1 (but not both), the OUTPUT will be 1

We need all 4 gates of the 7400 to build a XOR gate
We need all 4 gates of the 7400 to build a XOR gate.
NOR Gate
A B A NOR B
0 0 1
0 1 0
1 0 0
1 1 0

ONLY when A and B are both 0 the OUTPUT will be 1

XNOR Gate (Exclusive NOR)
A B A XNOR B
0 0 1
0 1 0
1 0 0
1 1 1

When A and B are the same (0 or 1) the OUTPUT will be 1

Backplane !!! (Our primitive BUS)

Hello everyone! I know I promised a small tutorial on how to build some gates with TTL components, but since I have been working in the backplane of DUCK 1… I wanted to show it.

First of all… it’s a backplane… and it’s a bus… it’s everything.

I’m using 31 lanes or pure power!. 16 for each bus bit… a couple for power, others for the clock (+ and -) and a couple for the reset signals (+ and – too).
Some are reserved for future ideas.
Why 31 lanes? Just because I used 8 bit ISA Slots (no… I’m not using ISA standards). and I’m not using 62… just joined both front and back plates together (I don’t need more).

Trust me, it was a busy afternoon… designing it… deciding what to do, SOLDERING IT…. But it WORKS!!!. You can even upgrade the clock if you want… and of course… you can completely remove it and include it in a board if needed but… why do that if you can include it in the backplane?

Ok… this is supposed to be a short post, here it is! The Backplane!

Ready for soldering!
Ready for soldering!
A couple of components...
A couple of components… check out the rounded sockets!… future expansion!
The Clock in Place!
Here you can see the small 7555 that I’m using for clock… 1.6khz of pure power!. Rounded socket for easy removal and future upgrades (maybe a Crystal oscillator or similar). Also check out the USB port for powering!.
Final Product...
Final Product…. almost 600 soldering points…

And finally… (and subject for a future post). The Program Counter board running at 1.6khz in  free run mode!

I know… short post, but hopefully it will start generating some comments and interaction with curious people. Also it will give me some time to write the Gates Tutorials, the computer architecture, and the Program Counter explanation 🙂

See you soon!

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!!!!

Duck 1 “The Phantom Duck”. Yet another homemade computer!

I’ve always been a curious Duck, specially with computers and electronics. And in a cuack moment, I decided to build my own homemade computer… from scratch.

I now, that’s not a big deal for many people, so I will explain a little bit more. I have no formal training in electronics, so it’s going to be  a learning process, and probably will take a lot of shorcuts and bad practices, and yes, my idea is to build ALMOST everything, even the CPU will be homemade using logic gates and TTL chips.

I will explain things as I learn them, including how each chip works, the way I understand it. I will not worry about power consumption or performance, just about making it work.

It will be a big and probably useless project… at least for a duck.

  • Build a computer from scratch
  • Make it Turing-ish
  • Must be programmable
  • Must be interactive (Input / Output)
  • Easy to upgrade

I need to make decisions, speed, bus, RAM, etc…
Based on a couple of books like “Digital Computer Electronics” by Albert Malvino, or “But how do it know?” by J. Clark Scott, I have some ideas.

  • 8 bit ALU
  • 8 bit Registers (how many? don’t know yet)
  • 16 bit shared bus (Everything will go through here)
  • 32 kbyte RAM
  • 32 kbyte ROM (for pseudo OS… maybe a rudimentary BASIC?…. yes… it’s too soon to know)Plus the rest… Stack pointer, program counter, memory address register, instruction register, I/O controller… etc. I will write details as it gets planned and built.

I think that’s all for today… see you all soon!.