Lecture1 Merged
Lecture1 Merged
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Digital vs Analog
+5 +5
1 0 1
V V
Time Time
–5 –5
+5 +5
1 0 1
V V
Time Time
–5 –5
AND AB C OR AB C NOT A C
0 0 0 0 0 0 0 1
0 1 0 0 1 1 1 0
1 0 0 1 0 1
1 1 1 1 1 1
A A
1 A 1 1
A A
0 A
0 0
a ab
b ab + cd
c e (ab+cd)
d cd
e
B 1 = B
B + 0 = B
[Duality Principle: Interchange + and .
operations and replace 1’s by 0’s and 0’s by
1’s]
B
1 = B
B
0 = B
T2: Null Element Theorem
B 0 = 0
B + 1 = 1 [ B + 1 = 1.(B+1) …. 2(b) Identity
= (B+B’).(B+1) …. 5(a) Complement
= B+B’.1 … 4(b) Distributive
= B + B’ …..2(b) Identity
= 1 ….. 5(a) Complement ]
B
0 = 0
B
1 = 1
T3: Idempotency Theorem
B B = B
B + B = B
B
B = B
B
B = B
T4: Involution Theorem
B = B
B = B
T5: Complement Theorem (Postulate 5)
B B = 0
B +B = 1
B
B = 0
B
B = 1
Basic Boolean Theorems
Boolean Theorems of Several Variables
Reference
Text Book:
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Algebraic Method
1. x.(x’+y) = x.y
3. (x+y).(x’+z).(y+z) = (x+y).(x’+z)
Algebraic Method
Minterm: w.x.y’.z
Implicant: x’.y.z, x’.y’.z, …….
Prime Implicant: y.z, x’.z, x’.y’ (x’.y’.z’ + x’.y’.z), ……
Essential Prime Implicant: x’.y’, x.y
= x’.y’+x.y+x’.y.z+x’.y’.z+wxy’z | = x’.y’+x.y+x’.y.z+x.y.z+wxy’z
= x’.y’ + x.y + x’.z + wxy’z | = x’.y’ + x.y + y.z + wxy’z
XY+XY=X(Y+Y)=X
mo m1 m3 m2
Karnaugh Map (Map Method)
Gray code
Karnaugh Map (Map Method)
Karnaugh Map (K- Map) Steps
1. Sketch a Karnaugh map grid for the given problem.in power of 2N Squares
2. Fill in the 1’s and 0’s from the truth table of sop or pos Boolean function
3. Circle groups of 1’s.
Circle the largest groups of 2, 4, 8, etc. first.
Minimize the number of circles but make sure that every 1 is in a circle.
4. Write an equation using these circles.
B’C’D’ = (A’+A)B’C’D’
=A’B’C’D’+AB’C’D’
Karnaugh Map (Map Method)
Don’t Care Conditions
• it really does not matter since they will never occur(its output is either
‘0’ or ‘1’)
• The don’t care terms can be used to advantage on the Karnaugh
map
Karnaugh Map (Map Method)
K- Map for POS
(B+C+D)(A+B+C’+D)(A’+B+C+D’)(A+B’+C+D)(A’+B’+C+D)
(B+C+D)=(A’A+B+C+D)=(A’+B+C+D)(A+B+C+D)
(1+0+0+0)(0+0+0+0)(0+0+1+0)(1+0+0+1)(0+1+0+0)(1+1+0+0)
=(C+D)(A’+B+C)(A+B+D)
(C’D’)’ = C+D
(AB’C’)’=A’+B+C
(A’B’D’)’=A+B+D
Karnaugh Map (Map Method)
F = m(0,2,3,4,6,8,10,11,12,14)
F = πM(1,5,7,9,13,15)
Reference
Text Book:
Combinational Circuits
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Logic Blocks
Binary Binary
Digital Gates Digital
. Output
Input .
. Signal
Signal
In Out
Logic Logic
In Out
Circuit Circuit
State
Selection input
determines the input
that should be
connected to the output
Multiplexers
4-data input MUX implementation
Quadruple 2-to-1 Line Multiplexer
Multiplexer circuits can be combined with common selection
inputs to provide multiple-bit selection logic.
I0
Y
I1
Demultiplexers
Multiplexer & Demultiplexer
Decoders
Decoder: 2-to-4-line decoder
Decoders
(Full Adder)
Decoders to Index in Memory
Decoders to Index in Memory
Encoders
An encoder is the inverse operation of a decoder.
C = D1 + D3 + D5 + D7
B = D2 + D3 + D6 + D7
A = D4 + D5 + D6 + D7
Encoders
Text Book:
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Digital Systems
DIGITAL
CIRCUITS
Why Binary Arithmetic?
3+5 =8
10000
0000 0000 0000
1111 1111 1111
0 0010 0 0
–7 2 –0
–1
6 –6 6
–2 7 7 7
–0 –5 –7 1010 –8
1010 0111 1010 0111 0111
1000 1000 1000
5 + 3 = -8! -7 - 2 = +7!
Overflow: An Error
Examples: Addition of 3-bit integers (range - 4 to +3)
Overflow rule: If two numbers with the same sign bit (both
positive or both negative) are added, the overflow occurs if
and only if the result has the opposite sign.
Overflow and Finite Universe
Decrease Increase
Infinite -∞ . . .1111 0000 0001 0010 0011 0100 0101 . . .∞
universe
of integers
No overflow
0000
1111 0001
1110 0010 Finite
1101 Decrease Universe
Increase
0011 of 4-bit
1100
0100 binary
1011 integers
0101
1010 0110
0111
1001 1000
Forbidden fence
Overflow Conditions
0111 1000
5 0101 -7 1001
3 0011 -2 1100
-8 1000 7 10111
Overflow Overflow
0000 1111
5 0101 -3 1101
2 0010 -5 1011
7 0111 -8 11000
No overflow No overflow
Overflow when carry in to sign does not equal carry out
Real Numbers
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Comparator
Adding bits:
0+0= 0
0+1= 1
1+0= 1
carry
1 + 1 = (1) 0
Adding integers:
1 1 0
0 0 0...... 0 1 1 1 two = 7ten
+ 0 0 0...... 0 1 1 0 two = 6ten
= 0 0 0 . . . . . . 1 (1)1 (1)0 (0)1 two = 13ten
Subtraction
Direct subtraction
s=a+b
a b
Decimal Binary
0 0 0 00
0 1 1 01
1 0 1 01
1 1 2 10
CARRY
SUM
Half-Adder
carry sum
Full Adder
s=a+b+c
a b c
Decimal value Binary value
0 0 0 0 00
0 0 1 1 01
0 1 0 1 01
0 1 1 2 10
1 0 0 1 01
1 0 1 2 10
1 1 0 2 10
1 1 1 3 11
CARRY SUM
Full-Adder
OR carry
AND
AND
HA
HA
a XOR sum
XOR
b
c
FA
Ripple Carry Adder
c32
c32 c31 . . . c2 c1 0 a31 (discard)
a31 . . . a2 a1 a0 b31 FA31
+ b31 . . . b2 b1 b0 s31
c31
s31 . . . s2 s1 s0
a2
b2 FA2 s2
a1
b1 FA1 c2 s1
a0
b0 FA0 c1 s0
c0 = 0
How Fast is Ripple-Carry Adder?
Longest delay path (critical path) runs from (a0, b0) to
sum31.
Suppose delay of full-adder is 100ps.
Critical path delay = 3,200ps
Clock rate cannot be higher than 1/(3,200×10 –12) Hz =
312MHz.
Must use more efficient ways to handle carry.
Speeding Up the Adder
a0-a15 16-bit
ripple s0-s15
b0-b15
carry
c0 = 0 adder
a16-a31 16-bit
ripple 0
b16-b31
Multiplexer
carry
0 adder s16-s31
a16-a31 16-bit
ripple 1
b16-b31
carry
1 adder
Binary Subtractor
M = 1subtractor ; M = 0adder
Concept of Fast Adders
Text Book:
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Sequential Circuit
Inputs Outputs
Combinational
circuit
Storage
Next
state Present
state
Timing signal
(clock)
Clock
a periodic external event (input)
Clock
S-R Latch
S-R Latch
S-R Latch with control input
D Flip-Flop
D S
Q
C
Q’
Y R
S R C Q Q’
0 0 1 Q0 Q0’ Store
D C Q Q’ 0 1 1 0 1 Reset
1 0 1 1 0 Set
0 1 0 1 1 1 1 1 1 Disallowed
1 1 1 0 X X 0 Q0 Q0’ Store
X 0 Q0 Q0’
D Flip-Flop
x E
D Q
z x
E C
D C Q Q’
D Q 0 0 1
1 1 0
C Q’ X 0 Q0 Q0’
J K CLKQ Q’
0 0 1 Q0 Q0’
0 1 1 0 1
1 0 1 1 0
1 1 1 Q0’ Q0
J-K flip-flop
J K CLKQ Q’
Created from D flop
J sets 0 0 1 Q0 Q0’
K resets 0 1 1 0 1
J=K=1 -> invert output 1 0 1 1 0
1 1 1 Q0’ Q0
Edge Triggered J-K flip-flop
Edge Triggered T flip-flop
C T Q Q’
0 Q0 Q0’
1 TOGGLE
Asynchronous Input
Reference
Text Book:
Sequential Circuits
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Sequential Circuit: Analysis
x D0
Q1 Q0
Q
D
Q’
y
Q
D Q1
Q0 D1 Q’
Clk
y(t) = x(t)Q1(t)Q0(t)
Q0(t+1) = D0(t) = x(t)Q1(t)
Q1(t+1) = D1(t) = x(t) + Q0(t)
Sequential Circuit: Analysis
Next State Output
State Table
Present
State
x=0 x=1 x=0 x=1
00 00 10 0 0
01 10 10 0 0
10 00 11 0 0
11 10 11 0 1
y(t) = x(t)Q1(t)Q0(t)
Q0(t+1) = D0(t) = x(t)Q1(t)
Q1(t+1) = D1(t) = x(t) + Q0(t)
Sequential Circuit: Analysis
State Table and State Diagram
Next State Output
Present
State
x=0 x=1 x=0 x=1
Let: s0 s2 0 0
s0 = 00
s0
s1 s2 s2 0 0
s1 = 01
s2 s0 s3 0 0
s2 = 10
s3 = 11 s3 s2 s3 0 1
1/1
0/0 0/0
S0 S1 0/0 S2 1/0 S3
1/0
1/0 0/0
Sequential Circuit: Example
Mealy vs Moore
Mealy Model
Inputs
Input Output Outputs
Logic Logic
Combina- Memory Combina-
tional Element tional
Moore Model
Input:
0100011011101111110
Output:
0000000000100011110
Design Example
0
Input:
0100011011101111110
Output:
0000000000100011110
Design Example
DA = Ax + Bx
DB = Ax + B’x
Y = AB
Implementation by other flip-flop
Characteristic Table
D Q(t+1) T Q(t+1) J K Q(t+1)
0 0 0 Q(t) 0 0 Q(t)
1 1 1 Q’(t) 0 1 0
1 0 1
1 1 Q’(t)
Excitation Table
Text Book:
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Counter Design: T Flip-Flop
3-bit counter
Counter Design: T Flip-Flop
Counter Design: T Flip-Flop
Counter
n-bit counter: Range:
Decade counter:
Mod-m counter:
Binary Ripple Counter
Up Down Function
1 X count up
0 1 count down
0 0 no change
Function Table
Counter with Parallel Load
Function Table
Register with Parallel Load
Register with Parallel Load
Shift Register
Serial Transfer
Text Book:
Computer Fundamentals
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Model of Computer
-- Model of Computer
Computer Model
Computer Model
Algorithm: Procedure/Method to achieve
desired result
Computer Program:
- Set of Instructions
- Executes in Sequence
Peripherals Computer
Central Main
Processing Memory
Unit
Computer
Systems
Interconnection
Input
Output
Communication
lines
Structure - The CPU
CPU
Computer Arithmetic
Registers and
I/O Login Unit
System CPU
Bus
Internal CPU
Memory Interconnection
Control
Unit
Structure - The Control Unit
Control Unit
CPU
Sequencing
ALU Logic
Control
Internal
Unit
Bus
Control Unit
Registers Registers and
Decoders
Control
Memory
Von Neumann Principle
• Stored Program concept
• Main memory storing programs and data
• ALU operating on binary data
• Control unit interpreting instructions from
memory and executing
• Input and output equipment operated by
control unit
• Princeton Institute for Advanced Studies
– IAS
• Completed 1952
Structure of Von Neumann machine
CPU Internal Structure
What is a program?
• Two steps:
– Fetch
– Execute
Instruction Cycle with Indirect
Structure of Von Neumann machine
Computer Components: Top Level View
CPU With System Bus
Reference
Computer Fundamentals
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Von Neumann Principle
• Stored Program concept
• Main memory storing programs and data
• ALU operating on binary data
• Control unit interpreting instructions from
memory and executing
• Input and output equipment operated by
control unit
• Princeton Institute for Advanced Studies
– IAS
• Completed 1952
Structure of Von Neumann machine
CPU Internal Structure
What is a program?
• Two steps:
– Fetch
– Execute
Instruction Cycle with Indirect
Structure of Von Neumann machine
Computer Components: Top Level View
CPU With System Bus
What is a Bus?
• A communication pathway connecting two
or more devices
• Usually broadcast
• Often grouped
– A number of channels in one bus
– e.g. 32 bit data bus is 32 separate single bit
channels
Advantage of Bus System
• Carries data
– Remember that there is no difference between
“data” and “instruction” at this level
• Width is a key determinant of performance
– 8, 16, 32, 64 bit
Address bus
Computer Fundamentals
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
What is a program?
• Two steps:
– Fetch
– Execute
Computer Components: Top Level View
Example of Program Execution
Data Bus and Address Bus
• Size of Address Bus:
SIZE BINARY DEC HEXA
8 0000 0000 0 00
8 1111 1111 255 FF
8 0101 0111 87 57
8 0000 0110 6 06
10 11 1111 1111 1023 3FF
12 1111 1111 1111 4095 FFF
16 1111 1111 1111 1111 216 -1 FFFF
20 1111 1111 1111 1111 1111 220 -1 FFFFF
30 11 ………………………….. 1111 230 -1 3FFFFFFF
32 1111 ………………………… 1111 232 -1 FFFFFFFF
Data Bus and Address Bus
• Size of Address Bus and Memory Capacity:
Fetch Cycle:
MAR <- PC
Read
PC <- PC+1
IR <- MBR
Example of Program Execution
Instruction Execution
(LDA M) LOAD AC: Load the accumulator by the contents of memory location
specified in the instruction
(ADD M) ADD AC: Add the contents of memory location specified in the
instruction to accumulator and store the result in accumulator
(STA M) STORE AC: Store the contents of accumulator the memory location
specified in the instruction
Computer Program
High Level Code Assembly Code Machine Code (HEX)
Y=X+Y LDA X 1940
ADD Y 5941
STA Y 2941
CPU Registers
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Components of Computer
• The Control Unit and the Arithmetic and Logic
Unit constitute the Central Processing Unit (CPU)
• CPU has temporary storage space - Registers
• Data and instructions need to get into the system
and results out
– Input/output
• Temporary storage of code and results is needed
– Main memory
Connecting
• General Purpose
• Data
• Address
• Condition Codes
How Many GP Registers?
• Between 8 - 32
• Fewer = more memory references
• More does not reduce memory references and
takes up processor space
• Large enough to hold full address
• Large enough to hold full word
• Often possible to combine two data registers
– C programming
– double int a;
– long int a;
Control & Status Registers
• Program Counter
• Instruction Decoding Register
• Memory Address Register
• Memory Buffer Register
Condition Code Registers
X Sup IE OV E C Z S
Reference
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
What is an Instruction Set?
• The complete collection of instructions that are
understood by a CPU
• Format of the instruction
• Machine Code
– Binary
• Usually represented by assembly codes
OPCODE Operation
1000 MOV R0, AC (R0 = AC)
–c=a+b
How Many Addresses
• More addresses
– More complex (powerful?) instructions
– More registers
• Inter-register operations are quicker
– Fewer instructions per program
• Fewer addresses
– Less complex (powerful?) instructions
– More instructions per program
– Faster fetch/execution of instructions
Design Decisions (1)
• Operation repertoire
– How many ops?
– What can they do?
– How complex are they?
• Data types
• Instruction formats
– Length of op code field
– Number of addresses
Design Decisions (2)
• Registers
– Number of CPU registers available
– Which operations can be performed on which
registers?
• Addressing modes
Types of Operand
• Addresses
• Numbers
– Integer/floating point
• Characters
– ASCII etc.
• Logical Data
– Bits or flags
Specific Data Types
• General - arbitrary binary contents
• Integer - single binary value
• Ordinal - unsigned integer
• Unpacked BCD - One digit per byte
• Packed BCD - 2 BCD digits per byte
• Near Pointer - offset within segment
• Bit field
• Byte String
• Floating Point
Integer Representation
• Only have 0 & 1 to represent everything
• Positive numbers stored in binary
– e.g. 41=00101001
• Sign-Magnitude
• Two’s compliment
Floating Point
• Data Transfer
• Arithmetic
• Logical
• Conversion
• I/O
• System Control
• Transfer of Control
Data Transfer
• Specify
– Source
– Destination
– Amount of data
• May be different instructions for different
movements
– e.g. IBM 370
• Or one instruction and different addresses
– e.g. VAX
Arithmetic
• Add, Subtract, Multiply, Divide
• Signed Integer
• Floating point
• May include
– Increment (a++)
– Decrement (a--)
– Negate (-a)
Shift and Rotate Operations
SHR
SHL
ASR
ASL
ROR
ROL
Logical
• Bitwise operations
• AND, OR, NOT
Input/Output
• May be specific instructions
• May be done using data movement
instructions (memory mapped)
• May be done by a separate controller
(DMA)
Systems Control
• Privileged instructions
• CPU needs to be in specific state
– Kernel mode
• For operating systems use
Transfer of Control
• Branch
– e.g. branch to x if result is zero
• Skip
– e.g. increment and skip if zero
• Conditional Instruction
– ISZ Register1
– Branch xxxx
– BNZ xxxx
– BP xxxx
• Subroutine call
– interrupt call
Branch Instruction
Nested Procedure Calls
Reference
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Instructions
• Instruction Set
• Format of Instructions
– Single Operand
– Two Operands
– Three Operands
Addressing Modes
• Immediate
• Direct
• Indirect
• Register
• Register Indirect
• Displacement (Indexed)
• Stack
Immediate Addressing
• Operand is part of instruction
• Operand = address field
• e.g. ADD 5
– Add 5 to contents of accumulator
– 5 is operand
• No memory reference to fetch data
• Fast
• Limited range
Immediate Addressing Diagram
Instruction
Opcode Operand
Direct Addressing
• Address field contains address of operand
• Effective address (EA) = address field (A)
• e.g. ADD A
– Add contents of cell A to accumulator
– Look in memory at address A for operand
• Single memory reference to access data
• No additional calculations to work out
effective address
• Limited address space
Direct Addressing Diagram
Instruction
Opcode Address A
Memory
Operand
Indirect Addressing
Pointer to operand
Operand
Register Addressing
• Operand is held in register named in
address filed
• EA = R
• Limited number of registers
• Very small address field needed
– Shorter instructions
– Faster instruction execution
Register Addressing
• No memory access
• Very fast execution
• Very limited address space
Register Addressing Diagram
Instruction
Opcode Register Address R
Registers
Operand
Register Indirect Addressing
• Indirect addressing
• EA = (R)
• Operand is in memory cell pointed to by
contents of register R
• One fewer memory access than indirect
addressing
Register Indirect Addressing Diagram
Instruction
Opcode Register Address R
Memory
Registers
Instruction
Opcode Register R Address A
Memory
Registers
8085 Microprocessor
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Intel 8085 CPU Block Diagram
8085 Microprocessor
• Data Bus: 8 bits
– Size of register: 8 bits
– can handle 16 bits
• Address Bus: 16 bits
– memory is byte organized
– Memory size: 64 KB (216)
• Data bus and address bus are multiplexed
Intel 8085 Pin Configuration
Instruction Fetch Cycle
Memory Read and Write Cycle
8085 Instruction Format
• One Byte
– D7 D6 D5 D4 D3 D2 D1 D0 Byte 1
• Two Bytes
– D7 D6 D5 D4 D3 D2 D1 D0 Byte 1
D7 D6 D5 D4 D3 D2 D1 D0 Byte 2
• Three Bytes
D7 D6 D5 D4 D3 D2 D1 D0 Byte 1
– D7 D6 D5 D4 D3 D2 D1 D0 Byte 2
D7 D6 D5 D4 D3 D2 D1 D0 Byte 3
8085 Instruction Set
8085 Instruction Set
8085 Instruction Set
8085 Instruction Set
8085 Instruction Set
8085 Instruction Set
8085 Instruction Set
8085 Instruction Set
8085 Instruction Set
8085 Instruction Set
8085 Instruction Set
8085 Instruction Set
• RETURN (return)
PCL <- (SP)
PCH <- ((SP) + 1)
(SP) <- (SP) + 2
Instruction: CALL/RETURN
Nested Procedure Calls
Instruction Cycle
• Two steps:
—Fetch
—Execute
Instruction Cycle with Interrupts
Subroutine/Procedure/Function
• Independent unit of code to perform a
subtask of the main task.
• Used in modular programming
• How to provide facility for procedure call
Procedure Call
• Tasks to be performed before procedure
CALL
— Retain the current status of the processor
— After returning from procedure/interrupt
routine, we must restart the execution from
the point where we have stopped.
• Current status of the processor
— Program Counter
— Program Status Word (PSW)
• How to Retain these information
• Any other information need to be saved?
Provision in Organization
• Store the relevant information in main
memory
— Implement a stack in MM (Control Stack)
• Need to keep the address of TOP of stack
— Use of a register, SP: Stack Pointer
— To keep the address of the Top of the Stack
• After completion of the procedure, restore
the information from stack
Instructions
• PUSH R
— source is the register R
• POP R
— destination is the register R
• CALL address
— starting address of the procedure
• RETURN
Main Memory
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Structure - Top Level
Peripherals Computer
Central Main
Processing Memory
Unit
Computer
Systems
Interconnection
Input
Output
Communication
lines
Structure - The CPU
CPU
Computer Arithmetic
Registers and
I/O Login Unit
System CPU
Bus
Internal CPU
Memory Interconnection
Control
Unit
CPU Internal Structure
Computer Components
Semiconductor Memory
• RAM (Random Access Memory)
– Misnamed as all semiconductor memory is
random access
– Read/Write
– Volatile
– Temporary storage
– Static or dynamic
Memory Cell Operation
Memory Cell
Memory Module
Memory Module
Parameters of Memory Module:
• Addressable Memory Space
– Size of Address Bus
• Size of Memory Location
– Size of Data Bus
• Memory Capacity
• Memory Organization
– Byte organized
Dynamic RAM
• Bits stored as charge in capacitors
• Charges leak
• Need refreshing even when powered
• Simpler construction
• Smaller per bit
• Less expensive
• Need refresh circuits
• Slower
• Main memory
• Essentially analogue
– Level of charge determines value
Dynamic RAM Structure
DRAM Operation
• Address line active when bit read or written
– Transistor switch closed (current flows)
• Write
– Voltage to bit line
• High for 1 low for 0
– Then signal address line
• Transfers charge to capacitor
• Read
– Address line selected
• transistor turns on
– Charge from capacitor fed via bit line to sense amplifier
• Compares with reference value to determine 0 or 1
– Capacitor charge must be restored
Static RAM
• Bits stored as on/off switches
• No charges to leak
• No refreshing needed when powered
• More complex construction
• Larger per bit
• More expensive
• Does not need refresh circuits
• Faster
• Cache
• Digital
– Uses flip-flops
Stating RAM Structure
State 1
C1 high, C2 low
T1 T4 off, T2 T3 on
State 0
C1 low, C2 high
T1 T4 on, T2 T3 off
Static RAM Operation
• Transistor arrangement gives stable logic
state
• State 1
– C1 high, C2 low
– T1 T4 off, T2 T3 on
• State 0
– C2 high, C1 low
– T2 T3 off, T1 T4 on
• Address line transistors T5 T6
• Write – apply value to B & compliment to B
• Read – value is on line B
SRAM v DRAM
• Both volatile
– Power needed to preserve data
• Dynamic cell
– Simpler to build, smaller
– More dense
– Less expensive
– Needs refresh
– Larger memory units
• Static
– Faster
– Less dense
– Cache
Reference
Computer Organization and Architecture –
Designing for Performance
William Stallings, Seventh Edition
Computer Organization
Hamacher, Vranesic and Zaky, Fifth Edition
Main Memory
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
SRAM v DRAM
• Both volatile
– Power needed to preserve data
• Dynamic cell
– Simpler to build, smaller
– More dense
– Less expensive
– Needs refresh
– Larger memory units
• Static
– Faster
– Less dense
– Cache
Read Only Memory (ROM)
• ROM
– Semiconductor memory
– Random Access
• Permanent storage
– Nonvolatile
• Microprogramming
• Library subroutines
• Systems programs (BIOS)
• Function tables
Types of ROM
• Written during manufacture
– ROM
• Programmable (once)
– PROM
– Needs special equipment to program
• Programmable (Read “mostly”)
– Erasable Programmable (EPROM)
• Erased by UV
– Electrically Erasable (EEPROM)
• Takes much longer to write than read
Organisation in detail
• Memory chip of 16Mbit = 16Mx1
• A 16Mbit chip can be organised as 1M of
16 bit words
• A bit per chip system has 16 lots of 1Mbit
chip with bit 1 of each word in chip 1 and so
on
Organisation in detail
• A 16Mbit chip can be organised as a 4096
x 4096 array
– Reduces number of address pins
• Multiplex row address and column address
• 12 pins to address (212=4096)
• Adding one more pin doubles range of values so x4
capacity
Organisation in detail
Organisation in detail
Dynamic RAM Structure
Refreshing
• Refresh circuit included on chip
• Disable chip
• Count through rows
• Read & Write back
• Takes time
• Slows down apparent performance
Typical 16 Mb DRAM (4M x 4)
Memory Module Organisation
256K bit Memory
chip
Memory Module Organisation
256KByte Module
Organisation
Memory Module Organisation
1MByte Module Organisation
Memory Module Organization
Computer Organization
Hamacher, Vranesic and Zaky, Fifth Edition
Cache Memory
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
So you want fast?
• It is possible to build a computer which
uses only static RAM
• This would be very fast
• This would cost high
• Alternatives??
Locality of Reference
• During the course of the execution of a
program, memory references tend to
cluster
Locality of Reference
• During the course of the execution of a
program, memory references tend to
cluster
• e.g. loops
Cache
• Small amount of fast memory
• Sits between normal main memory and
CPU
• May be located on CPU chip or module
Memory Hierarchy
• Registers
• L1 Cache
• L2 Cache
• Main memory
• Disk cache
• Disk
• Optical
• Tape
Cache/Main Memory Structure
Cache operation – overview
• CPU requests contents of memory location
• Check cache for this data
• If present, get from cache (fast)
• If not present, read required block from
main memory to cache
• Then deliver from cache to CPU
• Cache includes tags to identify which block
of main memory is in each cache slot
Cache Read Operation - Flowchart
Cache Design
• Size
• Mapping Function
• Replacement Algorithm
• Write Policy
• Block Size
• Number of Caches
Size does matter
• Cost
– More cache is expensive
• Speed
– More cache is faster (up to a point)
– Checking cache for data takes time
Typical Cache Organization
Write Policy
Cache Memory
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Cache Design
• Size
• Mapping Function
• Replacement Algorithm
• Write Policy
• Block Size
• Number of Caches
Mapping Function
• Cache of 64kByte
• Cache block of 16 bytes
– i.e. cache is 4k (212) lines of 16 bytes
• 16MBytes main memory
• 24 bit address
– (224=16M)
Direct Mapping
• Each block of main memory maps to only
one cache line
– i.e. if a block is in cache, it must be in one
specific place
• Address is in two parts
• Least Significant w bits identify unique word
• Most Significant s bits specify one memory
block
• The MSBs are split into a cache line field r
and a tag of s-r (most significant)
Direct Mapping Address Structure
• 24 bit address
• 4 bit word identifier (16 byte block)
• 20 bit block identifier
– 8 bit tag (=20-12)
– 12 bit slot or line
• No two blocks in the same line have the same Tag field
• Check contents of cache by finding line and checking Tag
Direct Mapping Function
Word
Tag 20 bit 4 bit
Word
Tag 8 bit Set 12 bit 4 bit
Cache Memory
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Cache Mapping
• Direct Mapping
• Associative Mapping
• Set Associative Mapping
– K way Set Associative Mapping
Mapping: Example
• A block set associative cache consists of a
total of 64 lines divided into 4-line sets. The
main memory contains 4096 blocks, each
consisting of 128 words.
– What is the size of main memory and cache
memory
Mapping: Example
• A block set associative cache consists of a
total of 64 lines divided into 4-line sets. The
main memory contains 4096 blocks, each
consisting of 128 words.
– How many bits are there in a main memory
address
– How many bits are there in each of the TAG,
SET and WORD fields.
Replacement Algorithms
• Direct mapping
– No choice
– Each block only maps to one line
– Replace that line
Replacement Algorithms
• Associative & Set Associative
– Hardware implemented algorithm (speed)
– Least Recently used (LRU)
• e.g. in 2 way set associative
• Which of the 2 block is lru?
– First in first out (FIFO)
• replace block that has been in cache longest
– Least frequently used
• replace block which has had fewest hits
– Random
Replacement Algorithms
• Least Recently Used (LRU)
– Program usually stays in localized area for a
reasonable period of time.
– There is a high probability that the blocks that
have been referenced recently will be
referenced again soon.
– When a block is to be overwritten, it is sensible
to overwrite the one that has gone the longest
time without being referenced.
– This block is called the Least Recently Used
(LRU) block and the technique is called the
LRU replacement policy.
Least Recently Used (LRU)
• Consider four-line set in a set-associative
cache
• Control bits:
– TAG bits
– 2-bit counter for each line(to track the LRU
block)
– d_bit: dirty bit
– f_bit: occupied bit
• Initially reset all the counters, d_bit and
f_bit
Least Recently Used (LRU)
• A cache hit occurs:
– set the counter value to 0 of this cache line
– for other counters, if the value is less than the
referenced line, increment the counter value
provided f_bit is 1.
– otherwise, do not change the counter value
Least Recently Used (LRU)
• A cache miss occurs:
– Set is not full
– Set is full
• Cache organization:
– 16 lines/blocks in the cache
– block size is 512
• Data in Main memory:
– block0 contains i, j, etc
– block1 onward: Array A
– block25 onward: Array B
Example
Array stored in memory:
Computer Organization
Hamacher, Vranesic and Zaky, Fifth Edition
Control Unit
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Computer Components: Top Level View
CPU Internal Structure
Micro-Operations
• A computer executes a program
• Program – set of instructions
• Fetch/execute cycle
• Each cycle has a number of steps
• Called micro-operations
• Each step does very little
Constituent Elements of Program Execution
Fetch:
- MAR<- PC, Read
- MBR <- Memory
-
Single Bus Organization of CPU
Fetch - 4 Registers
• Memory Address Register (MAR)
– Connected to address bus
– Specifies address for read or write op
• Memory Buffer Register (MBR)
– Connected to data bus
– Holds data to write or last data read
• Program Counter (PC)
– Holds address of next instruction to be fetched
• Instruction Register (IR)
– Holds last instruction fetched
Fetch Sequence
• Address of next instruction is in PC
• Address (MAR) is placed on address bus
• Control unit issues READ command
• Result (data from memory) appears on
data bus
• Data from data bus copied into MBR
• PC incremented by 1 (in parallel with data
fetch from memory)
• Data (instruction) moved from MBR to IR
• MBR is now free for further data fetches
Fetch Sequence
• t1: MAR <- PC
• t2: MBR <- memory
PC <- PC +1
• t3: IR <- MBR
– (tx = time unit/clock cycle)
Fetch Sequence – Is it correct
01
Functional Requirements
• Define basic elements of processor
• Describe micro-operations that processor
performs
• Determine functions that control unit must
perform
Basic Elements of Processor
• ALU
• Registers
• Internal data paths
• External data paths
• Control Unit
Functions of Control Unit
• Sequencing
– Causing the CPU to step through a series of
micro-operations
• Execution
– Causing the performance of each micro-op
• This is done using Control Signals
Control Signals
• Clock
– One micro-instruction (or set of parallel micro-
instructions) per clock cycle
• Instruction register
– Op-code for current instruction
– Determines which micro-instructions are
performed
• Flags
– State of CPU
– Results of previous operations
• From control bus
– Interrupts
– Acknowledgements
Model of Control Unit
Reference
Computer Organization and Architecture –
Designing for Performance
William Stallings, Seventh Edition
Computer Organization
Hamacher, Vranesic and Zaky, Fifth Edition
Control Unit
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Model of Control Unit
Control Signals - output
• Within CPU
– Cause data movement
– Activate specific functions
• Via control bus
– To memory
– To I/O modules
Example Control Signal Sequence - Fetch
• MAR <- PC
– Control unit activates signal to open gates
between PC and MAR
• MBR <- memory
– Open gates between MAR and address bus
– Memory read control signal
– Open gates between data bus and MBR
Single Bus Organization of CPU
Universal Shift Register
CPU with Internal Bus
ALU
Register and Bus Connection
Internal and External Bus
Read and Write Signal
Read and Write Signal
Timing Diagram
Control Step for Execution
• ADD R1, R2, R3
– Add the contents of Register R1 and R2 and
store the result in R3
Single Bus Organization of CPU
Operation:
R3 ← R1+R2
Steps:
Y ← R1
Z ← Y+R2
R3 ← Z
Control Step for Execution
• ADD R1, R2, R3
– Add the contents of Register R1 and R2 and
store the result in R3
Steps:
Y ← R1
Z ← Y+R2
R3 ← Z
Clock Timing
• Time needed for micro-operation 2
– R2out, ADD, Zin
Instruction Fetch and Execute
• ADD (R3), R1
– Add the content of Register R1 to the content
of memory location whose memory address is
in register R3 and store the result in R1
Addressing Mode:
(R3) : Register Indirect
R1: Register Direct
Single Bus Organization of CPU
PC contains the
Address of the
Instruction.
Issues for PC
Updates:
When and how
Assumption:
Instruction length
- one word
Instruction Fetch and Execute
• ADD (R3), R1
– Add the content of Register R1 to the content
of memory location whose memory address is
in register R3 and store the result in R1
Instruction Fetch and Execute
• ADD (R3), R1
– Add the content of Register R1 to the content
of memory location whose memory address is
in register R3 and store the result in R1
Fetch Phase:
Computer Organization
Hamacher, Vranesic and Zaky, Fifth Edition
Control Unit
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Single Bus Organization of CPU
PC contains the
Address of the
Instruction.
Issues for PC
Updates:
When and how
Assumption:
Instruction length
- one word
Instruction Fetch and Execute
• ADD (R3), R1
– Add the content of Register R1 to the content
of memory location whose memory address is
in register R3 and store the result in R1
Instruction Fetch and Execute
• ADI data, R1
– Add the content of Register R1 to the data
specified in the program and store the result in
R1
Addressing Mode:
data : Immediate
R1: Register Direct
Instruction Format: Two words
1st Word: Opcode
2nd Word: data
Single Bus Organization of CPU
PC contains the
Address of the
Instruction.
Issues for PC
Updates:
When and how
Assumption:
Instruction length
- two word
Instruction Fetch and Execute
• ADI data, R1
– Add the content of Register R1 to the data
specified in the program and store the result in
R1
Fetch Phase:
- Fetch Opcode
- Fetch the memory address
(part of the program)
- Fetch the data from Memory
- perform addition
Instruction Fetch and Execute
• ADD M, R1
– Add the content of Register R1 to the content
of memory location whose memory address is
specified in the program and store the result in
R1
Execute Phase:
Computer Organization
Hamacher, Vranesic and Zaky, Fifth Edition
Control Unit
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Control Unit
Single Bus Organization of CPU
PC contains the
Address of the
Instruction.
Issues for PC
Updates:
When and how
Assumption:
Instruction length
- one word
Single Bus Organization: another version
• Already discussed
– Single Bus Organization
• Other Possibilities
– Two Bus
– Three Bus
CPU Organization: Two Internal Buses
Control Step for Execution
Step Action
1 R1out, Genable, Yin
2 R2out, ADD, ALUout, R3in
CPU Organization: Two Internal Buses
For Execution
Step Action
1 R1out, Genable, Yin
2 R2out, ADD, ALUout, R3in
Control Step for Execution
• ADD R1, R2, R3
– Add the contents of Register R1 and R2 and
store the result in R3
Step Action
1 R1out, Genable, Yin
2 R2out, ADD, ALUout, R3in
ADD R4, R5, R6: Add the content of register R4 and R5;
and store the result in R6
Additional Features
• Special circuit to increment the PC
• CALL/RETURN
Control Unit: Hardwired Control
Problems With Hard Wired Designs
• Complex sequencing & micro-operation
logic
• Difficult to design and test
• Inflexible design
• Difficult to add new instructions
Reference
Computer Organization and Architecture –
Designing for Performance
William Stallings, Seventh Edition
Computer Organization
Hamacher, Vranesic and Zaky, Fifth Edition
Micro-programmed Control
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Control Unit: Hardwired Control
Problems With Hard Wired Designs
• Complex sequencing & micro-operation
logic
• Difficult to design and test
• Inflexible design
• Difficult to add new instructions
• Alternative approach:
– Micro-Programmed Controlled
Implementation: Control Unit
• The control unit generates a set of control
signals
• Each control signal is on or off
• Represent each control signal by a bit
• Have a control word for each micro-
operation
• Have a sequence of control words for each
machine code instruction
• Add an address to specify the next micro-
instruction, depending on conditions
Single Bus Organization: another version
Control Steps: Fetch and Execute
ADD (R3), R1: Add the content of register R1 and memory
location pointed by R3; and store the result in R1
Micro-programmed Control
• Use sequences of instructions to control
complex operations
• Called micro-programming or firmware
Program Execution
0 1 1 1 0 0 1 0
1 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 1
Micro Program
Control Micro-Opeartion for MOV R1, R2
Step
0 PCout, MARin, Read, Select4, Add, Zin
1 Zout, Pcin, Yin, WMFC
2 MDRout, IRin
3 R2out, R1in, End
4
2000 0 1 1 1 0 0 1 0
2001 1 0 0 0 0 0 0 0
2002 0 0 0 0 0 1 0 0
2003 0 0 0 0 0 0 0 1
2004
Micro Program
Memory Location Instruction Machine Code
(Main Memory)
01000 MOV R1, R2
01001 ADD R1, M
01002 DEC R2
2000 0 1 1 1 0 0 1 0
2001 1 0 0 0 0 0 0 0
2002 0 0 0 0 0 1 0 0
2003 0 0 0 0 0 0 0 1
2004
Control Unit Organization: Micro Programmed
Control Unit Organization
Fetch and Execute
Micro-program Word Length
• Based on 3 factors
– Maximum number of simultaneous micro-
operations supported
– The way control information is represented or
encoded
– The way in which the next micro-instruction
address is specified
Micro-instruction Types
Computer Organization
Hamacher, Vranesic and Zaky, Fifth Edition
Micro-programmed Control
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Micro-instruction Types
• Microinstruction sequencing
• Microinstruction execution
• Must consider both together
Design Considerations
• Size of microinstructions
• Address generation time
– Determined by instruction register
• Once per cycle, after instruction is fetched
– Next sequential address
• Common in most designed
– Branches
• Both conditional and unconditional
Sequencing Techniques
Computer Organization
Hamacher, Vranesic and Zaky, Fifth Edition
Micro-programmed Control
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Sequencing Techniques
Computer Organization
Hamacher, Vranesic and Zaky, Fifth Edition
Input/Output
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Computer Components: Top Level View
Input/Output Problems
Chapter 7: Input/Output
Page No.: 200 - 227
CS 322M Digital Logic & Computer Architecture
Input/Output
J. K. Deka
Professor
Department of Computer Science & Engineering
Indian Institute of Technology Guwahati, Assam.
Three Techniques
Interrupt Driven I/O
• Overcomes CPU waiting
• No repeated CPU checking of device
• I/O module interrupts when ready
Interrupt Driven I/O Basic Operation
Chapter 7: Input/Output
Page No.: 200 - 227