You are on page 1of 29

# Computing with Switches and Circuits

Part 2

1004QBT
Foundations of Computing
Systems

Lecture Objective
This week, well continue to look at
electrical circuits that would be used

Mwahahaha

QUIZ TIME!

Revision

LAST WEEK

Last Week
Boolean logic gates

AND
OR
NOT
NOR
NAND
XOR

Electromechanical
and logical circuits

Binary
mathematics
Decimal to binary
Binary to decimal
subtraction,
multiplication,
division

Mathematical
circuits
Multiplexor

## How does a von Neumann machine

use Boolean and Arithmetic circuits?

Computer memory

STORAGE CIRCUITS

Storage in a von
Neumann Machine

## The CPU registers are made up

of a series of flip-flops.
Well look at how to build flipflops and how they work.
Before we get there, we need
to look at some of the
components.

Feedback
To store information, circuits must
feedback into each other.
A set/reset (SR) latch does this using
two NOR gates

Nor gates: relay diagram of de Morgan variant, and both versions of logical

SR Latches in Operation
An SR latch with the reset line
moving from off to on

## An SR latch with the reset line

moving from on to off

SR Latches in Operation
An SR latch with the reset line
moving from off to on

## An SR latch with the reset line

moving from on to off

SR Latches in Operation
An SR latch with the set line
moving from off to on

## An SR latch with the set line

moving from on to off

SR Latches in Operation
An SR latch with the set line
moving from off to on

## An SR latch with the set line

moving from on to off

## Latches and Fetch-Execute

We can now make our computer remember
one bit per SR Latch.
In a von Neumann machine, we want to be
able to update all latches at the same time.
In the Fetch-Execute cycle, we used the
clock to synchronise actions. We can do the
same thing here.
We call the new latch a data-type (D-type)
latch

D-type Latch
NOT
switch

## The System Clock

The clock sends an oscillating signal. The D-type latch
can only update when the clock signal is high.
Otherwise, the AND circuit will not be closed and
current cant flow to the SET or RESET inputs of the SR
latch.

D-type Latch
There is one special
case where this D-type
latch wont work as we
expect.
Remember that in a
von Neumann
machine, calculations
specified the register/s
to get data from, and
the register to store
data in.
NOT

Register

## If we had data in a Dtype latch, perform a

NOT on the data, and
store it into the same
latch again, the latch
would oscillate
unpredictably.
The clock cannot help
here, because we
wont know when the
circuit will be in the
right state.
Register

Unused

## The D-type Flip Flop

A flip-flop uses two latches, one to hold the current state,
and the other to overwrite when the NOT instruction is
completed.

## The D-type Flip Flop

A flip-flop uses two latches, one to hold the current state,
and the other to overwrite when the NOT instruction is
completed.

CPU Registers
We have now seen how to build CPU
registers.
To store 8 bits, you would use 8 Dtype flip-flops in parallel.

## How to make the Instructions work

BOOLEAN SELECTION

Performing Computations
In a von Neumann machine, the instruction
register is connected to the other registers
and the ALU in such a way that entering
the instruction causes a cascade that
updates all relevant registers every clocktick.
During the fetch of the fetch-execute cycle,
an instruction is loaded into the instruction
register.
It then gets decoded.

The Decoder
Instructions are
entered as a binary
number.
Operations are built
circuits.
The decoder is a
circuit which takes
the input number and
uses it to activate a
particular output line.

Multiplexing
Once the decoder
has selected an
output, we can use
a multiplexor to
select one set of
data.
This data can come
from a register, or
be the output of an
operation.

Demultiplexing
We can also go the
opposite way,
using a
demultiplexor to
decide where to
send one bit of
data.

ALU

Multiplexor

## We can put all our

arithmetic and logic
circuits together to
create an ALU.
We can have multiple
ALUs in parallel to do
multiple bits of
calculation.
Note that a multiplexor
is used to select one
output from the ALU.

Instruction Register
The op-code of the instruction
register is used to select an output
from an operations available on the
ALU.
The operands of the ALU are used to
select an input from the CPU
registers, to be fed into the ALU.
You now have everything you need to
build a CPU or a calculator!