Computer Architecture I: Digital Design
Computer Architecture I: Digital Design
Computer Architecture
Data Bus
Volatile Memory (RAM) Input Output
M[0]
I/O Bus
M[1] CPU
Control
Mano Unit
Inputdefines
and (CU)is as 4096 words.
Output
Memory
defined using the
This requires ASCII busCLK
an Address of 12 bits
Control code of length 8 bits.
to act as selection inputs to
Bus address/data multiplexers.
M[K] Arithmetic and Logic
The fundamental unit of addressable
memoryUnit is the word. Each word is 16
(ALU)
bits long. The Data bus carries exactly
1 word of data between Memory and
CPU.
PC 12 bits
AR
DR
16 bits
IR
AC
INR
8 bits
OUTR
SCR
4 bits
E
1 bit
R 1 bit
Stored programs
• A stored program is a set of instructions and data
expressed in binary language, stored in non-volatile (ie.
disk storage) memory
15 14 12 11 0
IR
Mode I OpCode Address
bit
Instruction Hierarchy
• It is desirable to engineer the computer to support a
reasonable number of independent instructions
– Examples:
• Add, subtract, transfer, shift, logic, comparison, branch,
input, output
– 4 bits can be used to support 24 = 16 unique
instructions
• Leaves 12 bits to represent an address space of 4096 words
– However, 16 instructions is not enough for most
program needs
15 14 12 11 0
IR
I OpCode Address
Instruction Hierarchy
• It is desirable to engineer the computer to support a
reasonable number of independent instructions
– Use a hierarchical scheme (1+3 scheme)
• OpCode – 3 bits – supports 8 unique codes
– 0-6 (instructions)
– 7 (toggle)
• Mode – 1 bit – supports 2 addressing modes
– I=0 Direct addressing
– I=1 Indirect addressing
• Special Case :: OpCode = 7 (toggle) PLUS Mode bit (I)
– Use 12 bits of Address field to specify additional instructions
15 14 12 11 0
IR
I OpCode Address
Instruction Hierarchy
• Mano’s instruction set consists of 25 instructions:
Instruction
– We will utilize a Sequence Counter Register (SC, or SCR). This is a register that
holds a count value, can be reset to zero and can be incremented (or
decremented) by one
CLR
– Each instruction will require a specified
SC number of time steps to complete a
sequence of microoperations. Each step of the sequenceINCis marked by a count
value in SC.
……
Timing and Control
• The SC outputs a string of bits whose value is in the range from
0 to 2L-1
– Eg. for L=3, from 0 to 7
• We need a way of converting the bit string value to single bit
valued outputs labelled T0, T1, T2, T3, and so on, up to Tx
(where x = 2L-1)
• A decoder serves our purpose, recalling that the output from the
DEC is a 1 only on one line (the rest are 0`s)
Tx T2 T1 T0
….. CLR
SC INC
L-to-2 DEC
L
……
…
Timing and Control
• Step 1: Where do we fetch the next instruction from
at T0 (start time)?
PC
T0 : AR = PC Load
AR
Timing and Control
• Step 2: How do weMemory
obtain the instruction from
Note how the PC is updated in parallel.
Connect it all
2 1 0 together !
3x8 DEC Enable one
specific logic
7 6 5 4 3 2 1 0 circuit Signal the SC to
advance (INC) to
next timing
Control
value, or reset.
Control
Logic
Outputs
Timing inputs Gates
F E D C B A 9 ... 1 0
4x16 DEC
Clock has
3 2 1 0
4-bit
not been
INC included!
Sequence
Counter (SC) CLR
An Architectural Basis for Programming
15 14 12 11 0
IR 0 1 1 1 Operation control bits
Register Reference Instructions
• The complete set of all instructions defined by Mano
– Mnemonic means a string that suggests the meaning.
Hex Mnemonic Binary coding Meaning
7800 CLA 0111100000000000 CLear Accumulator
7400 CLE 0111010000000000 CLear E
7200 CMA 0111001000000000 CoMplement Accumulator
7100 CME 0111000100000000 CoMplement E
7080 CIR 0111000010000000 CIrcular shift Right
7040 CIL 0111000001000000 CIrcular shift Left
CLA
Hex Mnemonic RTL CMA
INC
7800 CLA AC = 0
7200 CMA AC = ~ AC AC
7020 INC AC = AC + 1
AC
Register Reference Instructions
• Skip on <condition> : AC register.
– Tests sign/value status of 2’s complement integer in AC
– If status matches query, advance PC by one instruction word
0 8 AND
1 9 ADD
2 A LDA
3 B STA
4 C BUN
5 D BSA
6 E ISZ
15 14 12 11 0
IR I OpCode Memory Address
Memory Reference Instructions
• Direct access mode (I=0) operation semantics
Operation Codes The actual number of timing steps (Tk) may vary
from 1 to 2 (or even 3) steps, depending on how the
Direct control timing circuits are designed.
I=0 Mnemonic RTL
0 AND DR = M[AR] ; AC = AC ^ DR
1 ADD DR = M[AR] ; AC = AC + DR
2 LDA DR = M[AR] ; AC = DR
3 STA DR = AC ; M[AR] = DR
4 BUN AR = IR(0-11) ;
PC = AR
5 BSA AR = IR(0-11) ;
M[AR] = PC , PC = AR + 1
6 ISZ AR = IR(0-11) ; DR = M[AR] ;
AC = DR ; AC = AC + 1 ; DR = AC ;
M[AR] = DR , (AC=0) : PC = PC + 1
Memory Reference Instructions
• Indirect access mode (I=1) operation semantics using
AND and ADD
– First, fetch the pointer (address) data from memory to
obtain the indirect reference
– Second, fetch the needed data from the just-fetched address
The actual number of timing steps (Tk) may vary
Operation Codes from 2 to 3 steps, depending on how the control
timing circuits are designed.
Indirect
I=1 Mnemonic RTL
8 AND AR = IR(0-11) ; DR = M[AR]
AR = DR(0-11) ; DR = M[AR]
AC = AC ^ DR
9 ADD AR = IR(0-11) ; DR = M[AR]
AR = DR(0-11) ; DR = M[AR]
AC = AC + DR
Memory Reference Instructions
• Transfer instructions
– Copy data to or from memory and CPU
• Loading (fetching) refers to memory-to-CPU transfers
• Storing refers to CPU-to-memory transfers
Operation Codes
Direct Indirect
I=0 I=1 Mnemonic RTL
2 A LDA DR = M[AR] ; AC = DR
3 B STA DR = AC ; M[AR] = DR
M
Data DR AC
Address bus
AR
MUX
Memory Reference Instructions
• ADDition, Logical AND instructions
– Logical AND is done on all bits in parallel
– Numeric (2’s complement) addition may be done in serial,
or in parallel using Look-Ahead circuits
Operation Codes
Direct Indirect
I=0 I=1 Mnemonic RTL
0 8 AND DR = M[AR] ; AC = AC ^ DR
1 9 ADD DR = M[AR] ; AC = AC + DR
M
Data DR AC
Address bus
AR
MUX ADD/AND Logic
Memory Reference Instructions
• Branching
– Instructions that explicitly modify the PC during execution
– This implies that the next instruction to be executed is not located in
the next contiguous word of storage.
– Used to program IF-THEN-ELSE (Decision control) and WHILE-DO
(Repetition control) constructs in high-level languages.
(a) BEFORE COMPLETION OF (b) AFTER COMPLETION
EXECUTION (after DECoding) OF EXECUTION
M M
T0: AR = PC, SC = SC + 1
T1: IR = M[AR], PC = PC +1, SC = SC +1
T2: {D0..D7} = DEC(IR(12..14)), AR = IR(0..11), I = IR(15), SC = SC+1
D0.T3: DR = M[AR], SC = SC+1
I’.D0.T4: AC = AC^DR, SC = 0
I.D0.T4: AR = DR(0..11), SC = SC+1
I.D0.T5: DR = M[AR], SC = SC+1
I.D0.T6: AC = AC^DR, SC = 0
– Note how the Direct and Indirect forms of the instruction are
differentiated using the I (or I’) bit value for control differentiation.
Memory Reference Instructions
• Branch UNconditional instruction
– I = 0 :: Replace PC by address in IR(0-11)
– I = 1 :: Replace PC by the address found at the address in IR(0-11)
• That is :: PC = M[ M[ IR(0-11) ] ]
Operation Codes
Direct Indirect
I=0 I=1 Mnemonic RTL
4 C BUN AR = IR(0-11)
PC = AR
PC
IR
I=1 I=0
M
Data DR
Address bus
AR
MUX
Memory Reference Instructions
• Branch and SAve instruction
– Used for programming subroutine calls
Operation Codes
Direct Indirect
I=0 I=1 Mnemonic RTL
5 D BSA AR = IR(0-11)
M[AR] = PC , PC = AR + 1
M M
Return addr.
Subr. entry instr. Subr. entry instr.
Memory Reference Instructions
• Increment and Skip if Zero instruction
– Used to implement a counter based <do-while> construct
I=0 I=1 Mnemonic RTL
6 E ISZ AR = IR(0-11) , DR = M[AR]
AC = DR , AC = AC + 1 , DR = AC
M[AR] = DR , (AC=0) : PC = PC + 1
15 14 12 11 0
IR 1 1 1 1 I/O operation control bits
Input/Output Instructions
• Used for communicating data between CPU and I/O peripheral
devices
• Also, need instructions to support programmed polling.
– Polling refers to waiting for a condition to be true before proceeding
16 bit
OpCode Mnemonic Meaning
F800 INP Input ASCII char
F400 OUT Output ASCII char
F200 SKI Skip if input flag (FGI=1)
F100 SKO Skip if output flag (FGO=1)
F 8
4
2
1
15 14 12 11 0
IR 1 1 1 1 I/O operation control bits
Input/Output Instructions
• Each peripheral device has a communications and control
interface that interacts with the computer’s interface logic circuits
– Input
• Need a data buffer (INPR) and a flag (FGI) indicating buffer empty/full
– Output
• Need a data buffer (OUTR) and a flag (FGO) indicating buffer empty/full
FGO
Status
Printer Receiver
Interface OUTR Data
NOTE:
AC(H) AC(L) Only the low order part
of AC is used.
16 bit
OpCode Mnemonic Meaning
F080 ION Interrupt Enabled (IEN 1)
IEN
F040 IOF Interrupt Disabled (IEN 0)
15 14 12 11 0
IR 1 1 1 1 I/O operation control bits
Interrupts
• In this approach, interrupts are used only with I/O handling
– In addition to a flip-flop to store the Interrupt Enable state, one more
flip-flop (R) is needed to store the I/O Status (Ready/Not_ready).
– In general, interrupts may be used with arbitrary instructions for
exception trapping and handling
1-bit registers
We will also
require one final =0
IEN IEN
register, called TR All of these
(for transfer). This =1 flipflops are
can be 16 bits, but assumed to be
must be at least 12 =1 FGI
FGI reset to 0 when
bits. bootstrapping the
=0 computer.
=1 FGO
FG0
=0
R1 R
Control Bus
Interrupt Handling Flowchart
Fetch/Decode Instruction
Store return address
in location 0
M[0] PC IEN
Execute =0
IEN
Instruction
=1 FGI
=1 Branch to location 1
FGI PC 1
=0 FGO
=1
FG0 Reset Interrupt, Ready
IEN 0 R
=0 R0
R1
TR
Control Bus
Interrupt Handling Flowchart
2 1 0
3x8 DEC
7 6 5 4 3 2 1 0
Control
Control
Logic
Outputs
Gates
F E D C B A 9 ... 1 0
4x16 DEC
3 2 1 0
4-bit INC
Sequence
Counter (SC) CLR
Control Logic
• Timing of microoperations requires explicit enabling of
logic circuits through the Control Unit logic gates
• Need signals …
T2 D7’ I T3 : AR M[AR]
R T0 : AR 0
D5 T4 : AR AR + 1
R
T0
LD
D5 INC
AR
T4
CLR
Clk
To From
Bus Bus
Control Logic
• In previous lectures we discussed complex register
circuits
– Control was exerted through enabling inputs
• The textbook provides additional examples of
controlling logic circuits
– Control of single flip-flops
– Control of common bus
• All registers can be adapted to controls
• Indeed, all computer circuits can be adapted to controls
– Using enable inputs
– Using control circuits
– Using counters, and so on.
Representing a Complete Architecture
• Small Scale Integration
– Logic Gates
– Simple Circuits – Combinational & Sequential
CPU Buses
9 Registers Address
- AR, PC, DR, AC, IR, TR, OUTR, INPR, SC
Data
7 Flip-flops
- I, S, E, R, IEN, FGI, FGO Control
• Instruction Set
• Control architecture
• Instruction processing
– Register access
– Memory access (Direct, Indirect)
– I/O access
– Interrupts
• Timing sequences of micro-operations