Upload
taqi-shah
View
218
Download
0
Embed Size (px)
Citation preview
8/3/2019 Hardware Slides 14
1/27
DOC 112: Computer Hardware Lecture 14 Slide 1
Lecture 14:
Let's Put together a Manual Processor
(part 1)
8/3/2019 Hardware Slides 14
2/27
DOC 112: Computer Hardware Lecture 14 Slide 2
Inside every computer there is at least one processor(CPU) which can take an instruction some operands andproduce a result.
Processors can be operated in various ways: As a peripheral of another computer
(array processor or graphics processor).
One instruction at a time (e.g. a calculator).
A Manual Processor
8/3/2019 Hardware Slides 14
3/27
DOC 112: Computer Hardware Lecture 14 Slide 3
Block Diagram of a Processor
Both the data and the instruction will be binary numbers.The processing will be a sequence of one or more stepscontrolled by a clock.
Manual
Processor
Data
Instruction
Result
Operate
8/3/2019 Hardware Slides 14
4/27
DOC 112: Computer Hardware Lecture 14 Slide 4
Block Diagram of the 8 bit Processor
Manual
Processor
Data or
Instructions
8 Result8
Carry (out)
Operate
We will build an 8-bit processor, and will have acommon input stream for data and instructions.
Both data and instructions will be organised in 8-bit
bytes
8/3/2019 Hardware Slides 14
5/27DOC 112: Computer Hardware Lecture 14 Slide 5
Example: Average of two numbers.
Result = (A+B)/2
The following steps must be carried out:
1. Set up the processor to receive the first number from theinput stream and save it in a register called A
2. Set up the processor to receive the second number from theinput stream and save it in a register called B
How does a simple processor work?
8/3/2019 Hardware Slides 14
6/27DOC 112: Computer Hardware Lecture 14 Slide 6
3. Set the processor to add register A to register B. andthen shift the result right by one bit. The operation isexecuted and the results may be stored internally in a resultsregister.
4. Set up the processor to load the results on the outputregister.
The processor is a sequential digital circuit
How does a simple processor work?
8/3/2019 Hardware Slides 14
7/27DOC 112: Computer Hardware Lecture 14 Slide 7
Designing a Processor
To design a general purpose processor, we need (at least):
Two data registers, A and B
A Results register
A register to hold the operation code (Instruction register(IR)).
Circuits to do arithmetic and shifting
The results register may be augmented with a one-bit registerwhich holds the carry out bit.
8/3/2019 Hardware Slides 14
8/27
DOC 112: Computer Hardware Lecture 14 Slide 8
The processor Data Paths
A (8 bits)
B (8 bits)
Res (8 bits)
Instruction (8 bits)
C bit
INPUT
OUTPUT
Arithmetic
and shiftoperations
8
8
8
8 8
8
8/3/2019 Hardware Slides 14
9/27
DOC 112: Computer Hardware Lecture 14 Slide 9
Internal Registers and the Data Paths
Notice that:
on the data paths diagram there is no information aboutwhen the data transfers occur. The diagram shows only thepossible paths where data can be transferred.
the arithmetic and shift operations are done bycombinational circuits without more registers. Thefunction that is computed is controlled by the bits in theinstruction register.
the processor is unable to execute further operations on theresults.
8/3/2019 Hardware Slides 14
10/27
DOC 112: Computer Hardware Lecture 14 Slide 10
The Arithmetic - Logic Unit (4 bits)
Hardware design packages provide us with Arithmetic-Logic Units of different precisions, for example 4 bit:
The select lines determine what function of A and Bappears on the output
8/3/2019 Hardware Slides 14
11/27
DOC 112: Computer Hardware Lecture 14 Slide 11
The Arithmetic - Logic Unit (operations)
This table assumes that Cin=0.
When Cin=1, three arithmetic operations become:
011 : results = A plus B plus 1 010 : results = A minus B minus 1
001 : results = B minus A minus 1
Selection Bits/Results
000 001 010 011 100 101 110 111
000 A - B A B 1111zero minus plus xor or and -1
A or B A BB - A A + Bminus
8/3/2019 Hardware Slides 14
12/27
DOC 112: Computer Hardware Lecture 14 Slide 12
Designing an ALU
An arithmetic logic unitis a simplecombinatorial circuitthat can be built fromcomponents that wehave already designed.
To provide thearithmetic functions weuse adders andsubtractors.
8/3/2019 Hardware Slides 14
13/27
DOC 112: Computer Hardware Lecture 14 Slide 13
Designing an ALU
The logic functionsare provided by simplegates.
We need a multiplexerfor each bit of the ALUwe are designing.
8/3/2019 Hardware Slides 14
14/27
DOC 112: Computer Hardware Lecture 14 Slide 14
Designing an ALU
To finish the job we needone more multiplexer toprovide the carry out.
8/3/2019 Hardware Slides 14
15/27
DOC 112: Computer Hardware Lecture 14 Slide 15
The Arithmetic - Logic Unit (8 bits)
We could design anALU for any bit sizewe want, but often it isuseful to proceedfunctionally.
For example we canbuild an 8 bit ALU outof two four bit
circuits.
8/3/2019 Hardware Slides 14
16/27
DOC 112: Computer Hardware Lecture 14 Slide 16
1
The Control of the C(in) Bit
We can use a 2-to-1 multiplexer to allow two different carryinput bits. The Carry(in) may come from Carry(out), this helpsmultiple precision.
It can also be set to logic 1 in order to use the extra threearithmetic functions. Clearing the C flip-flop will supply alogic 0.
Cin Cout
8 bitALU
3F/alu (3 bits)
A 8 8
B 8 8AB
Out8
Cy/outC
F/cy
MUX
8/3/2019 Hardware Slides 14
17/27
DOC 112: Computer Hardware Lecture 14 Slide 17
The Shifter Circuit
Earlier in the course we discussed a specialisedregister, called the shift register, which could shiftits contents let or right depending on a multiplexerselection.
We could incorporate such a shift register in ourdesign, but, to save on circuitry, we will make use ofa simpler shifter which does not store the result.
8/3/2019 Hardware Slides 14
18/27
DOC 112: Computer Hardware Lecture 14 Slide 18
The Binary Shifter
The Binary Shifter circuit is a combinational circuit. It has eight input data bits plus a carry in, and 2
function selection bits which determine the data out.
Shifter8
Data in
CYin
Data out
8
F/shift
2
8/3/2019 Hardware Slides 14
19/27
DOC 112: Computer Hardware Lecture 14 Slide 19
Important Shifting Functions
ROTATE RIGHT
ARITHMETIC RIGHT SHIFT
ARITHMETIC LEFT SHIFT MSB LSB Cy
MSB LSB
MSB LSB
8/3/2019 Hardware Slides 14
20/27
DOC 112: Computer Hardware Lecture 14 Slide 20
The Shifter - basic design
The basic shifter will perform four operations dependingon its two control inputs. These are:
00 Hold
01 Arithmetic shift left (with carry in) 10 Arithmetic shift right
11 Rotate right
It is implemented simply using multiplexers. There isone multiplexer per bit.
8/3/2019 Hardware Slides 14
21/27
DOC 112: Computer Hardware Lecture 14 Slide 21
The Shifter - Basic design
An eight bit shifter is shown, but clearly the designcan be easily scaled up to any size.
00: Hold01: Shift left with carry10: Arithmetic shift right11: Rotate right
8/3/2019 Hardware Slides 14
22/27
DOC 112: Computer Hardware Lecture 14 Slide 22
Increasing the Shifter functionality
There are many different possible shifts thatprogrammers may want to use. One possibility ourdesign doesn't do is:
Logical Shift Right
This could be done by using first an ALU operation(Data AND 11111110) followed by a rotate right,but that would involve more processing steps andtherefore be slow.
MSB LSB0
8/3/2019 Hardware Slides 14
23/27
DOC 112: Computer Hardware Lecture 14 Slide 23
Increasing the shifter functionality
An alternative would be to add another multiplexer toimplement the shift directly. This would mean a fasterprocessor but at the cost of more hardware.
Shifter8
Data in
Carry in
Data out
MUX
F/cin
F/shift
2
Data in[7]
0
8
i h hif f i li
8/3/2019 Hardware Slides 14
24/27
DOC 112: Computer Hardware Lecture 14 Slide 24
Increasing the shifter functionality
More functionality can be provided by making the carrymultiplexer four way.
Shifter8
Input Output
Input[0]0
CYin
00 -- unchanged01 -- left shift10 -- right shift11 -- right shift
00 -- Input[0]01 -- 010 -- Input[7]11 - Carry in
F/Cin
F/shft
Input[7]MUX
8
8/3/2019 Hardware Slides 14
25/27
DOC 112: Computer Hardware Lecture 14 Slide 25
Function Table of the Shifter
A variety of shifts is now provided, but functions[0,0,0] and [1,0,0] are the same.
8/3/2019 Hardware Slides 14
26/27
DOC 112: Computer Hardware Lecture 14 Slide 26
The Shifter is Built From Multiplexers
8/3/2019 Hardware Slides 14
27/27
DOC 112: Computer Hardware Lecture 14 Slide 27
The 8-bit Processor Data Paths
SHIFTER
ALU
A
B
CY-in
CY-out
Res
MUX
1
IR7
Data In
Carry Out
Data Out
8
F-ALU
F-Shifter
SelA
SelC
RES
C
B
A
IR0
IR
MUX
8
8
8
8
8 8
ClkA
ClkBClkR
ClkC
Control Unit
ClkIR