Week 6
Week 6
Bindu Agarwalla
1
Fundamental Concepts
Processor fetches one instruction at a time and perform the operation specified.
Processor keeps track of the address of the memory location containing the next
instruction to be fetched using Program Counter (PC).
Assuming that the memory is byte addressable, increment the contents of the
PC by 4 (fetch phase).
PC ← [PC] + 4
Carry out the actions specified by the instruction in the IR (execution phase).
Single Bus CPU Organization
Basic Operations involved in the execution
of an instruction
Transfer a word of data from one processor register to another or to the ALU.
Perform an arithmetic or a logic operation and store the result in a processor register.
Fetch the contents of a given memory location and load them into a processor register.
Store a word of data from a processor register into a given memory location.
Register Transfer Operation
MOV R1, R2
1. R2in
R1out,
Fetching a Word from Memory
MOV (R1),R2
2. WMFC
MDRinE,
3. MDRout, R2in
Storing a Word into Memory
MOV R2, (R1)
Address into MAR;
Data into MDR
1. R1out, MARin
2. MDRin ,Write
R2out,
3. WMFC
MDRoutE,
Performing an Arithmetic or
Logical Operation
ADD R1, R2, R3
Put one of the operands into Y register
Put the other operand on the bus and
perform the operation
Send the result into the destination
1. R1out, Yin
3. Zout, R3in
Execution of a Complete Instruction
Add (R3), R1
2. WMFC
2. WMFC
5. WMFC
6. MDRoutB, R5outA, SelectA, ADD, R5in, end
Hardwired Control Unit
To execute instructions, the processor must have some means of
generating
the control signals needed in the proper sequence.
Two categories:
Hardwired control Unit and
Microprogrammed control Unit
For CU to perform it’s function, it has some inputs that allows it to determine the state of
the system and outputs that allows it to control the behaviour of the system.
Internally, the CU must have some logic to perform its sequencing and execution
function.
Hardwired Control Unit
Inputs to CU:
1. Clock(Contents of control step counter)
2. Instruction Register (Contents of IR)
3. Flags(Contents of condition codes)
2. Next find out , in which instructions the signal is appearing and then find
out the step number of that instruction the signal is appearing.
3. Say, Zin is appearing in the 6th step of the instructionAdd (R3), R1. It means Zin
signal need to be generated for the step no 6 of ADD instruction, so when both the cases
are true, Zin need to be generated, like that for JMP L1 instruction , Zin is generated in
step no 4. i.e., in either of the two instructions Zin signal need to be generated.
4. So, the logic function, for Zin will be OR of the above two AND cases.
Zin= ADD.T6+ JMP.T4+........................................[+.........indicates other possible
cases]
5. Again, we hve seen that Zin is required for all the instructions in the step no 1 during
the fetch phase of any instruction, i.e., irrespective of any instruction, in the step no 1
Zin required. So,
Zin= T1+ ADD.T6+ JMP.T4+.......................................
Generating the Zin Signal
Add (R3), R1
1. PC out, MARin, Read, Select4, Add, Zin
2. Zout, PCin, Yin, WMFC
3. MDRout, IRin
4. R3out, MARin, Read
5. R1out, Yin, WMFC
6. MDRout, SelectY, Add, Zin
7. Zout, R1in, end
JMP L1
1. PC out, MARin, Read, Select4, Add, Zin
2. Zout, PCin, Yin, WMFC
3. MDRout, IRin
4. Address_field_of_IRout, SelectY, Add, Zin
Step 2: We have seen that Zin is active for all the instructions in control sequence no 1.
i.e., it is not dependent on the instruction.
Next, Zin is active in the step no 6 for the ADD instruction,
Zin is active in the step no 4 for the JMP instruction,
Zin is active in the step no 4 for the BR instruction........
Step 3:
Zin= T1 + ADD.T6 + JMP.T4 + BRN.T4.N
Logic function for Zin Signal
Logic function for End signal
End= ADD.T7 + BRN.T5.N + BRN.T4.N + BR.T5+.......................
Problem
A hardwired CPU uses 10 control signals S1 to S10, in various time
steps T1 to T5, to implement 4 instructions I1to I4 as shown below:
T1 T2 T3 T4 T5
I1 S1, S3, S2, S4, S1, S7 S10 S3,S8
S5 S6
I2 S1, S3, S8,S9, S5, S6, S6 S10
S5 S10 S7
Write the expressions to represent the circuit for generating control signals S5
and S10 respectively? What will be the specification of step decoder and
instruction decoder in the hardwired control unit?
Solution
Step 1: Find the required signals S5 and S10 in the given control seuence.
T1 T2 T3 T4 T5
I1 S1, S3, S2, S4, S1, S7 S10 S3,S8
S5 S6
I2 S1, S3, S8,S9, S5, S6, S6 S10
S5 S10 S7
Step decoder 3: 8
Instruction decoder 2 : 4
Problem
A computer has 58 instructions; each instruction requires at most 15
steps to complete its execution. What will be the specification of
instruction and step counter decoder used in hardware control unit
design?
Step decoder 4: 16
Instruction decoder 6 : 64
Problem
A hardwired CPU has only 3 instructions I1, I2 and I3, which use the
following signals in time steps T1-T5
T1 T2 T3 T4 T5
I1 Ain,Bout PCout,Bin Zout,Ain Bin,Cout End
,Cin
I2 Cin,Bout, Aout,Bin Zout,Ain Bin,Cout End
Din
I3 Din,Aout Ain,Bout Zout,Ain Dout,Ain End
ML 0 1 2 3 4 5 6 7
Address
Content 10 23 25 20 12 3 1 2
3
25
12
20
Consider an example of memory organization as shown in the figure
below. Which valuewill be loaded into the accumulator when the
instruction “LOAD INDIRECT 7” is executed
ML 0 1 2 3 4 5 6 7
Address
Content 10 23 25 20 12 3 1 2
2
25
7
20
Consider a three word machine instruction-
ADD A[R0], @B
The number of memory cycles needed during the execution cycle of the
instruction is??
Microprogrammed Control Unit
An alternative to a hardwired control unit is a microprogrammed control unit, in which the
logic of the control unit is specified by a microprogram.
The term microprogram was first coined by M. V. Wilkes in the early 1950s
Introduction to Microprogrammed CU
Add (R3), R1
1. PC out, MARin, Read, Select4, Add, Zin
2. Zout, PCin, Yin, WMFC
3. MDRout, IRin
4. R3out, MARin, Read
5. R1out, Yin, WMFC
6. MDRout, SelectY, Add, Zin 7. Zout, R1in, end
μ P M M R S A Z Z P Y W I R R R R R S X M D R R R W . . . . E
i C A D e e d i o C i M R 3 1 1 2 2 u O U i i 4 4 r n
n o R R a l d n u i n F i o o i i o b R L v n i o i d
s u i o d e t n C n u u n n u n u t
t t n u c t t t t e
r t t
u
c
t
i
o
n
1 1 1 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Terms Related to Microprogrammed Control Unit
Control Store: The instruction set of any computer is finite. The microroutines for
all the instructions in the instruction set is stored in a special memory called as
Control store/ Control Memory.
μPC: μPC points to the next microinstruction that need to be fetched from Control
store.
Organization of Control Memory
The fig. shows how the control words or
microinstructions could be arranged in a control
memory.
There is one bit for each internal processor control line and one bit for each system bus control line.
There is a condition field indicating the condition under which there should be a branch, and there
is a field with the address of the microinstruction to be executed next when a branch is taken.
Interpretation
To execute this microinstruction, turn on all the control lines indicated by a 1 bit; leave off all control
lines indicated by a 0 bit. The resulting control signals will cause one or more micro-operations to be
performed.
If the condition indicated by the condition bits is false, execute the next microinstruction in sequence.
If the condition indicated by the condition bits is true, the next microinstruction to be executed is
indicated in the address field.
Microprogrammed CU
To execute any instruction, the CU should first find the starting address of the
corresponding microroutine and then can generate the control signals in sequence
by reading the control words one by one.
Microprogrammed CU
Address Microinstruction
2 MDRout, IRin
......... ................................................................................
1. When a new instruction is loaded into the IR, the μPC is loaded with the starting
address of the microroutine for that instruction.
3. When an End microinstruction is encountered the μPC is loaded with the address
of the first CW in the microroutine for the instruction fetch cycle.
Thank You