unit-1 CO (1)
unit-1 CO (1)
M=2^n*y
1.Hardwired control
2.Microprogrammed control
• In the Hardwired Organization,
• the control logic is implemented with gates, flip-flops,
decoders, and other digital circuits.
• Adv: produces fast mode operation.
• Disadv: requires changes in the wiring among various
components if design has to be modified.
• In the Microprogrammed Organization,
• the control information is stored in a control memory
• The control memory is programmed to initiate the
required sequence of microoperations.
• Adv: microprogram in control memory has to be updated,
if design has to be modified.
CONTROL UNIT for the BASIC COMPUTER
Instruction Register (IR)
CU consists of 15 14 13 12 11 - 0 Other inputs
•Two decoders
•A sequence counter 3x8
•No.of control logic gates decoder
7 6543 210
D0
I Control
D7 Control
logic outputs
gates
T15
T0
15 14 . . . . 2 1 0
4 x 16
Sequence decoder
15 0 4096 x 16
IR
15 0 15 0
TR DR
7 0 7 0 15 0
OUTR INPR AC
COMMON BUS SYSTEM
• The basic computer has
• eight registers
• a memory unit
• a control unit
• Paths must be provided to transfer information from
one register to another and between memory and
registers.
• To avoid excessive wiring, memory and all the
register are connected via a common bus.
• The connection of the registers and memory of the
basic computer to a common bus system is shown in
below fig.
S2
S1 Bus
S0
Computer Memory unit
4096 x 16
7
Registers
Common AR 1
Bus System PC 2
DR 3
AC 4
INPR
IR 5
TR 6
OUTR
CLOCK
16-bit common bus
• Control variables: Various S2
S1
S0
Bus
• Memory address is PC 2
Address
• This allows the Accumulator and
Write Read
Data Register to swap data
simultaneously (same clock cycle) AR 1
• T0: AR←PC
The address of the instruction is moved to AR.
• T1: IR←M[AR], PC←PC+1
The instruction is fetched from the memory to IR ,
and the PC is incremented.
• T2: D0,…, D7←Decode IR(12-14), AR←IR(0-11), I←IR(15)
Register Transfer for the Fetch Phase
•T0: AR PC (S2S1S0=010, T0=1)(Load of PC=1)
•T1: IR M [AR], PC PC + 1 (S2S1S0=111, T1=1)(Load of IR=1)
•T2: D0, . . . , D7 Decode IR(12-14), AR IR(0-11), I IR(15)
T1 S2
T0 S1 Bus
S0
Memory
7
unit
Address
Read
AR 1
LD
PC 2
INR
IR 5
LD Clock
Common bus
INSTRUCTIO
N SET
Table: Basic Computer Instructions
Hexadecimal Code
Symbol I=0 I=1 Description
AND 0xxx 8xxx AND memory word to AC
ADD 1xxx 9xxx Add memory word to AC
Memory LDA 2xxx Axxx Load AC from memory
reference STA 3xxx Bxxx Store content of AC into memory
BUN 4xxx Cxxx Branch unconditionally
Instructions BSA 5xxx Dxxx Branch and save return address
ISZ 6xxx Exxx Increment and skip if zero
r: SC 0
CLA rB11: AC 0
CLE rB10: E0
CMA rB9: AC AC’
CME rB8: E E’
CIR rB7: AC shr AC, AC(15) E, E AC(0)
CIL rB6: AC shl AC, AC(0) E, E AC(15)
INC rB5: AC AC + 1
SPA rB4: if (AC(15) = 0) then (PC PC+1)
SNA rB3: if (AC(15) = 1) then (PC PC+1)
SZA rB2: if (AC = 0) then (PC PC+1)
SZE rB1: if (E = 0) then (PC PC+1)
HLT rB0: S 0 (S is a start-stop flip-flop)
CLA 7800 Clear AC
CLE 7400 Clear E
CMA 7200 Complement AC
CME 7100 Complement E
CIR 7080 Circulate right AC and E
CIL 7040 Circulate left AC and E
INC 7020 Increment AC
SPA 7010 Skip next instr. if AC is positive
SNA 7008 Skip next instr. if AC is negative
SZA 7004 Skip next instr. if AC is zero
SZE 7002 Skip next instr. if E is zero
HLT 7001 Halt computer
MEMORY REFERENCE
INSTRUCTIONS
Symbol Operation Symbolic Description
Decoder
AND D0 AC AC M[AR] AND memory word to AC
ADD D1 AC AC + M[AR], E Cout Add memory word to AC
LDA D2 AC M[AR] Load AC from memory
STA D3 M[AR] AC Store content of AC into memory
BUN D4 PC AR Branch unconditionally
BSA D5 M[AR] PC, PC AR + 1 Branch and save return address
ISZ D6 M[AR] M[AR] + 1, if M[AR] + 1 = 0 then PC PC+1
Increment and skip if zero
- The effective address of the instruction is in AR and is placed there during
timing signal T2 when I = 0, or during timing signal T3 when I = 1
- Memory cycle is assumed to be short enough to be completed in a CPU cycle
- The execution of MR Instruction starts with T4
AND to AC
D0T4: DR M[AR] Read operand
D0T5: AC AC DR, SC 0 AND with AC
ADD to AC
D1T4: DR M[AR] Read operand
D1T5: AC AC + DR, E Cout, SC 0 Add to AC and store carry in E
LDA: Load to AC Memory, PC, AR at time T4
AC
Transmitter
Keyboard interface INPR FGI 1-bit Input FlaG
p: SC 0
INP F800 pB11: AC(0-7) INPR, FGI 0 Input char. to AC
OUT F400 pB10: OUTR AC(0-7), FGO 0 Output char. from AC
SKI F200 pB9: if(FGI = 1) then (PC PC + 1) Skip on input flag
SKO F100 pB8: if(FGO = 1) then (PC PC + 1) Skip on output flag
ION F080 pB7: IEN 1 Interrupt enable on
IOF F040 pB6: IEN 0 Interrupt enable off
ADDRESSING MODES
Addressing Modes
• The way the operands are chosen during program execution is
dependent on the addressing mode of the instruction
• The addressing mode specifies
• a rule for interpreting or
• modifying the address field of the instruction before the operand is
actually referenced
• Purpose of accommodating addressing mode techniques is one
or both of the following:
1. To give programming versatility to the user by providing such facilities
as pointers to memory, counters for loop control, indexing of data, and
program relocation
2. To reduce the number of bits in the addressing field of the instruction
• Adv: writing programs that are more efficient with respect to the
• number of instructions and
• execution time
• An example of an instruction format with a distinct
addressing mode field is shown in below.
• The operation code specifies the operation to be
performed
• The mode field is used to locate the operands needed for
the operation
• There may or may not be an address field in the
instruction
• If there is an address field, it may designate a memory address or
a processor register
• Register Mode:
• operands are in registers that reside within the CPU
• The particular register is selected from a register field in
the instruction.
• Register Indirect Mode:
• the instruction specifies a register in the CPU whose contents give the
address of the operand in memory
• i.e., the selected register contains the address of the operand rather than
the operand itself
• Advantage : the address field of the instruction uses fewer bits to select a
register to specify a memory address directly
(Effective address)
A:
A:
Q:
A:
A:
Q:
A:
A:
Q:
A:
A: ZERO
Case study – Instruction set of some common CPUs
CISC & RISC
(32 registers=
10 global registers + 10 local registers + 6 low overlapping registers +
6 high overlapping registers)
As an example,
• Suppose that procedure A calls procedure B,
• Registers R26 through R31 are common to both procedures
• procedure A stores the parameters for procedure B in these
registers
• Procedure B uses local registers R32 through R41 for local
variable storage.
• If procedure B calls procedure C,
• it will pass the parameters through registers R42 through R47
• When procedure B is ready to return at the end of its
computation,
• the program stores results of the computation in registers R26
through R31 and
• transfers back to the register window of procedure A.
• Registers R10 through R 15 are common to procedures A
and D because the four windows have a circular
organization with A being adjacent to D
• General organization of register windows will have
the following relationships:
• number of global registers = G = 10 (above example )
• number of local registers in each window = L = 10
• number of registers common to two windows = C = 6
• number of windows = W = 4
• The number of registers available for each window is:
• window size = L + 2C + G
• window size is 10 + 12 + 10 = 32 registers (above example )
• The total number of registers needed in the processor
is:
• register file = (L + C)W + G
• register file consists of (10 + 6) x 4 + 10 = 74 registers
(above example )
Q:
A:
A:
Berkeley RISC I
• The Berkeley RISC I is a 32-bit integrated circuit CPU
• It supports
• 32-bit addresses and
• either 8-, 16-, or 32-bit data
• It has a
• 32-bit instruction format (fixed)
• a total of 31 instructions (few)
• There are three basic addressing modes (few) for branch
instructions:
• register addressing
• Immediate operand
• relative to PC addressing
• It has a register file of 138 registers arranged into
• 10 global registers and 8 windows of 32 registers in each (as in
above Fig.)
• the instruction format can specify
• a processor register with a register field of five bits
• Below figure shows the 32-bit instruction formats used
for
• register-to- register instructions
• memory access instructions
Figure: Berkeley RlSC I instruction formats
• For register-to-register instructions,
• the 5-bit Rd field selects one of the 32 registers as a destination
for the result of the operation.
• The operation is performed with the data specified in fields Rs
and S2
• Rs is one of the source registers
• If bit 13 is 0 -- the low-order 5 bits of S2 specify another source register
• If bit 13 is 1 -- S2 specifies a sign-extended 13-bit constant
• Thus the instruction has a three-address format
• second source is a register or an immediate operand
• Memory access instructions (above fig.)
• use Rs to specify a 32-bit address in a register
• S2 to specify an offset
• Register R0 contains all 0's