Lecture 6 and 7
Lecture 6 and 7
Topics covered:
CPU Architecture
Contents
◆ Single bus
◆ Multiple bus
1
Internal organization of a processor
2
Internal organization of a processor
Internal processor
bus
Control signals
PC
Instruction
Address
decoder and
lines
MAR control logic
Memory
bus
MDR
Data
lines IR
Y
Constant 4 R0
Select MUX
Add
A B
ALU Sub R ( n - 1)
control ALU
lines
Carry-in
XOR TEMP
Z
Single bus organization
4
Single bus organization (contd..)
5
Single bus organization (contd..)
6
Registers and the bus
bus line 0
bus line 1
register
8
Registers and the bus (contd..)
❑ At any one time, only one register may output its contents to
the bus:
◆ Which register outputs its content to the bus is determined by
the control signal issued by the control logic.
◆ Control signal depends on the instruction loaded in the
instruction register IR.
❑ Registers can load data from the bus:
◆ Which registers load data from the bus is determined by the
control signal issued by the control logic.
❑ Registers are clocked (sequential) entities (unlike ALU which
is purely combinatorial).
9
Riin
Registers are connected to the bus via
switches controlled by the signals
Ri Rin & Rout.
Riout
Each register Ri has two control signals,
Riin and Riout.
Y in
ALU
Z in
Z out
Registers and the bus (contd..)
Bus
D Q
1
R iout
Q
Clock
R i in
11
Registers and the bus (contd..)
Bus
D Q
1
R iout
Q
Clock
R i in
Riin = 1:
Multiplexer selects the data on the bus.
Data is loaded into the flip-flop at the rising edge of the clock.
Riin = 0:
Multiplexer feeds back the value currently stored in the flip-flop.
Q output represents the value currently stored in the flip-flop.
12
Registers and the bus (contd..)
Bus
D Q
1
R iout
Q
Clock
R i in
Riout = 1:
Tri-state gate loads the value of the flip-flop onto the bus.
Data is loaded onto the bus at the rising edge of the clock.
Riout = 0:
Gate’s output is in high-impedance (electrically disconnected) state.
Corresponds to open-circuit state.
13
Registers and the bus (contd..)
0 0
D Q D Q
1 1
Clock
Q Clock
Q
Riin Riin
14
Loading multiple registers from the bus (contd..)
15
Arithmetic Logic Unit (ALU)
16
Arithmetic Logic Unit (ALU) (contd..)
17
Arithmetic Logic Unit (ALU) (contd..)
XOR
Output F
18
Performing an arithmetic operation
Add the contents of registers R1 and R2 and place the result in R3.
That is: R3 = R1 + R2
19
Performing an arithmetic operation (contd..)
Instruction
PC Control
decoder and
Signals
control logic
Address
lines
MAR
Memory
bus
Clock cycle 1:
Data
MDR IR R1out, Yin
lines
Y
Constant 4 R1
R
Select MUX
R
Add
A B
ALU Sub R( n - 1 )
control ALU
lines
Carry-in
XOR TEMP
20
Performing an arithmetic operation (contd..)
Instruction
PC Control
decoder and
Signals
control logic
Address
lines
MAR
Memory
bus
Clock cycle 2:
Data
MDR IR R2out, SelectY,
lines Add, Zin
Y
Constant 4 R1
R
Select Y MUX
R
Add=1
A B
ALU Sub R( n - 1 )
control ALU
lines
Carry-in
XOR TEMP
21
Performing an arithmetic operation (contd..)
Instruction
PC Control
decoder and
Signals
control logic
Address
lines
MAR
Memory
bus
Clock cycle 3:
Data
MDR IR Zout, R3in
lines
Y
Clock cycle 4:
Constant 4 R1
R3 has the sum.
R
SelectY MUX
R
Add
A B
ALU Sub R( n - 1 )
control ALU
lines
Carry-in
XOR TEMP
22
Performing an arithmetic operation (contd..)
Clock Cycle 1:
R1out, Yin (Y=R1)
Clock Cycle 2:
Clock Cycle 3:
23
Fetching a word from memory
24
Fetching a word from memory (contd..)
Connections for register MDR
Memory-bus
data lines MDRoutE MDRout bus
MDR
25
Fetching a word from memory (contd..)
26
Fetching a word from memory (contd..)
MOVE (R1), R2
1. Load the contents of Register R1 into MAR.
2. Start a Read operation on the memory bus. Steps can be performed
3. Wait for MFC response from the memory. separately, some may be
4. Load MDR from the memory bus. combined.
5. Load the contents of MDR into Register R2.
27
Fetching a word from memory (contd..)
Step 1:
- Place R1 onto the internal processor bus.
- Load the contents of the bus into MAR.
- Activate the Read control signal.
- R1out, MARin, Read.
Step 2:
- Wait for MFC from the memory.
- Activate the control signal to load data from external bus to MDR.
- MDRinE, WMFC
Step 3:
- Place the contents of MDR onto the internal processor bus.
- Load the contents of the bus into Register R2.
- MDRoutI, R2in
28
Storing a word into memory
Step 1:
- Place R1 onto the internal processor bus.
- Load the contents of the internal processor bus into MAR.
- R1out, MARin.
Step 2:
- Place R2 onto the internal processor bus.
- Load the contents of the internal processor bus into MDR.
- Activate Write operation.
- R2out, MDRin, Write
Step 3:
- Place the contents of MDR into the external memory bus.
- Wait for the memory write operation to be completed MFC.
- MDRoutE, WMFC
29
Execution of a complete instruction
Add the contents of a memory location pointed to by Register R3
to register R1.
ADD (R3), R1
30
Execution of a complete instruction
Task 1: Fetch the instruction
Recall that:
- PC holds the address of the memory location which has the next
instruction to be executed.
- IR holds the instruction currently being executed.
Step 1
- Load the contents of PC to MAR.
- Activate the Read control signal.
- Increment the contents of the PC by 4.
- PCout, MARin, Read, Select4, Add, Zin.
Step 2
- Update the contents of the PC.
- Copy the updated PC to Register Y (useful for Branch instructions).
- Activate the control signal to load data from external bus to MDR
- Wait for MFC from memory.
- Zout, PCin, Yin, MDRinE ,WMFC
Step 3
- Place the contents of MDR onto the bus.
- Load the IR with the contents of the bus.
- MDRout, IRin
31
Execution of a complete instruction (contd..)
Task 2. Fetch the operand (contents of memory pointed to by R3.)
Task 3. Perform the addition.
Task 4. Load the result into R1.
32
Execution of a complete instruction (contd..)
ADD (R3), R1
Step Action
34
Unconditional Branch instructions
Select_Y
35
Conditional Branch instructions
36
Control sequence writing constraints
1- it is not allowed to activate input (Rin) and
output(Rout) gating signals of a specific register in
the same step.
2- it is not allowed to execute read and write
operations for the memory in the same step.
3- it is not allowed to execute read/write operations
and WMFC in the same step.
4- it is not allowed to activate the output gating
signals of two registers on the bus at the same time.
37
Multiple-bus organization
38
Multiple bus organization (Three-bus
organization)
Incrementer
Bus A Bus B Bus C
PC
Register
file
Constant
MUX A
4
ALU R
Instruction
decoder
IR
39
Multiple bus organization (contd..)
40
Multiple bus organization (contd..)
❑ ALU can also pass one of its two input operands unmodified
if needed:
◆ Control signals for such an operation are R=A or R=B.
❑ Three bus arrangement obviates the need for Registers Y
and Z in the single bus organization.
❑ Incrementer unit:
◆ Used to increment the PC by 4.
◆ Source for the constant 4 at the ALU multiplexer can be used
to increment other addresses such as the memory addresses in
multiple load/store instructions.
41
Multiple bus organization (contd..)
Step Action
1. Pass the contents of the PC through ALU and load it into MAR.
Increment PC.
2. Wait for MFC.
3. Load the data received into MDR and transfer to IR through ALU.
4. Execution of the instruction is the last step.
42
Control unit
43
Hardwired control
Step Action
44
Hardwired control (contd..)
45
Hardwired control (contd..)
Control unit organization
Control signals
46
Hardwired control (contd..)
CLK
Clock Control step Reset
counter
Run End
Control signals
47
Hardwired control (contd..)
Control signals such as Zin, PCout, ADD are generated by encoder block
T4 T6
T1
48
Hardwired control (contd..)
49
Microprogrammed control
50
Microprogrammed control (contd..)
51
An example of a microroutine in Bit-Patterns Format
MDR out
in
WMFC
Select
PC out
R1 out
R3 out
Read
Micro -
MAR
R1 in
PC in
Z out
End
Add
IR in
Y in
Z in
instruction
Bit-Patterns Format
1 0 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0
2 1 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0
3 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0
4 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0
5 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0
6 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 0
7 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1
52
Microprogrammed control (contd..)
53
Microprogrammed control (contd..)
Control
store CW
54
Microprogrammed control (contd..)
55
Microroutine for the instruction (Branch < 0)
Address Microinstruction
56
Microprogrammed control (contd..)
Control Unit with Conditional Branching in the Microprogram
External
inputs
Starting and
branch address Condition
IR codes
generator
Control
store CW
57
Microprogrammed control (contd..)
58
Microprogrammed control (contd..)
Microinstruction format
•Simple approach is to allocate one bit for each control signal
- Results in long microinstructions, since the number of control
signals is usually very large.
- Few bits are set to 1 in any microinstruction, resulting in a poor
use of bit space.
•For example:
- Only one ALU function is active at a time.
- Source for a data transfer must be unique.
- Read and Write memory signals cannot be active simultaneously.
59
Microprogrammed control (contd..)
Microinstruction format
•Group mutually exclusive signals in the same group.
•At most one microperation can be specified per group.
•Use binary coding scheme to represent signals within a
group.
Examples:
•If ALU has 16 operations, then 4 bits can be sufficient.
•Group register output signals into the same group, since only one of
these signals will be active at any given time (Why?)
If the CPU has 4 general purpose registers, then PCout, MDRout, Zout,
Offsetout, R0out, R1out, R2out, R3out and Tempout can be placed in a single
group, and 4 bits will be needed to represent these.
60
Microprogrammed control (grouping mechanizm)
Microinstruction
F1 F2 F3 F4 F5
0000: No transfer 000: No transfer 000: No transfer 0000: Add 00: No action
0001: PC out 001: PC in 001: MAR in 0001: Sub 01: Read
0010: MDR out 010: IR in 010: MDR in 10: Write •Each group occupies a
0011: Z out 011: Z in 011: TEMP in
0100: R0 out 100: R0 in 100: Y in 1111: XOR large enough field to
0101: R1 out 101: R1 in
16 ALU
represent all the signals.
0110: R2 out 110: R2 in
0111: R3 out 111: R3 in
functions •Most fields must include
1010: TEMP out one inactive code, which
1011: Offsetout specifies no action.
•All fields do not have to
F6 F7 F8 include inactive code.
61
Vertical and Horizontal Organization
In vertical organization :
• Each microinstruction contains a small number of
control functions leading to more microinstructions
required for the execution of each instruction.
• results in slower operating speeds.
• In horizontal organization :
• Many resources can be controlled with a single
instruction leading into small number of microinstructions
required for the execution of each instruction.
• require that the CPU structure allows
parallel use of resources.
• results in higher operating speed
62
END
63