CSC 307 - Computer System Architecture-Elizade 20182019new
CSC 307 - Computer System Architecture-Elizade 20182019new
Architecture
temp = v[k];
High Level Language v[k] = v[k+1];
Program v[k+1] = temp;
Compiler
• lw $15, 0($2)
Assembly Language lw $16, 4($2)
Program sw $16, 0($2)
sw $15, 4($2)
Assembler
0000 1001 1100 0110 1010 1111 0101 1000
Machine Language 1010 1111 0101 1000 0000 1001 1100 0110
Program 1100 0110 1010 1111 0101 1000 0000 1001
0101 1000 0000 1001 1100 0110 1010 1111
Machine Interpretation
Graphical Interface
Application
Programming Application
Libraries
Operating System
System Programming
Programming Language
Assembler Language
Instruction Set Architecture - “Machine Language”
Processor IO System
Firmware Microprogrammin
g
Computer Design Datapath and Control
Digital Design
Logic Design
Circuit Design Circuits and devices
Fabrication Semiconductors
Materials
The Instruction Set: A Critical Interface
software
instruction set
hardware Computer Organization and
Design
This course • Machine Implementation
• Logic Designer's View
• "Processor Architecture"
• "Computer Organization"
"Construction Engineer"
Instruction Set Architecture
Data Types
Encoding and representation
Architecture Reference Manual
Memory Model
Principles of Operation
Program Visible Processor State Programming Guide
General registers
Program counter …
Processor status
Instruction Set
Instructions and formats
Addressing modes
Data structures
System Model
States
Privilege
• . . . the attributes of a [computing] system as
Interrupts
IO seen by the programmer, i.e. the conceptual
structure and functional behavior, as distinct
External Interfaces from the organization of the data flows and
IO
controls the logic design, and the physical
Management
implementation.
• Amdahl, Blaaw, and Brooks, 1964
Computer Organization
Datapath
Output
MIT Whirlwind, 1951
Computers are pervasive – servers, standalone PCs,
network processors, embedded processors, …
Von-Neumann Machine
Today, “Computers” are
Connected Processors
Proc
Caches
Buses
adapters
Memory
Controllers
Disks
I/O Devices:
Displays Networks
Keyboards
14
Bits, Bytes, Nibbles…
• Bits
• Bytes
• (how they are put in memory?)
Number Systems
• Normal humans: use decimal (base ten)
16
Number Systems
• Decimal (base ten; digits 0..9)
19
Binary to Hexadecimal Conversion
Example
• Binary
Addition
• Hexadecimal 1 carries
3A3E
+ 516B
8BA9
• Binary
Binary Addition Examples
• Add the following
4-bit binary
numbers
1110
or F=
39
Example of binary signals
Two values: 0 or 1
40
Input-Output signals for gates
41
Boolean Algebra
• Basic definitions:
• x+0=0+x=x
• x.1=1.x=x
• x.(y+z)=(x.y)+(x.z)
• x+(y.z)=(x+y).(x+z)
• x+x’=1
• x.x’=0
42
Boolean Algebra Theorems
• x+x=x
• x.x=x
• x+1=1
• x.0=0
• x+x.y=x
• x.(x+y)=x
43
Boolean Function Implementation
y’
Y’.z
44
Boolean Function Implementation
X’.y’.z
X’.y.z
X.y’
X.y’
X’.z
45
Complement of a function
• DeMorgan’s theorem:
• (x+y)’=x’.y’
(x.y)’=x’+y’
• (x+y+z)’=?
• Let A=x+y (A+z)’=A’.z’=(x+y)’.z’=x’.y’.z’
• (x.y.z)’=x’+y’+z’
46
Canonical & Standard Forms
• Consider two binary variables x, y and the AND operation
• four combinations are possible: x.y, x’.y, x.y’, x’.y’
• each AND term is called a minterm or standard products
• Canonical Forms:
• Boolean functions expressed as a sum of minterms or product of maxterms.
47
Minterms
• x y z Terms Designation
• 0 0 0 x’.y’.z’ m0
• 0 0 1 x’.y’.z m1
• 0 1 0 x’.y.z’ m2
• 0 1 1 x’.y.z m3
• 1 0 0 x.y’.z’ m4
• 1 0 1 x.y’.z m5
• 1 1 0 x.y.z’ m6
• 1 1 1 x.y.z m7
48
Maxterms
• x y z Designation Terms
• 0 0 0 M0 x+y+z
• 0 0 1 M1 x+y+z’
• 0 1 0 M2 x+y’+z
• 0 1 1 M3 x+y’+z’
• 1 0 0 M4 x’+y+z
• 1 0 1 M5 x’+y+z’
• 1 1 0 M6 x’+y’+z
• 1 1 1 M7 x’+y’+z’
49
Boolean Function: Example
• F1=m1+m4+m7=x’.y’.z+x.y’.z’+x.y.z=Σ(1,4,7)
51
Boolean Function: Example
• F2=m3+m5+m6+m7=x’.y.z+x.y’.z+x.y.z’+x.y.z=Σ(3,5,6,7)
52
Boolean Function: Example
• F1=M0.M2.M3.M5.M6 = л(0,2,3,5,6)
53
Boolean Function: Example
• F=M0.M1.M2.M4=л(0,1,2,4)=(x+y+z).(x+y+z’).(x+y’+z).(x’+y+z)
54
Maxterms & Minterms: Intuitions
• Minterms:
• If a function is expressed as SUM of PRODUCTS, then if a single
product is 1 the function would be 1.
• Maxterms:
• If a function is expressed as PRODUCT of SUMS, then if a single
product is 0 the function would be 0.
• Canonical Forms:
• Boolean functions expressed as a sum of minterms or product of
maxterms.
55
Standard Forms
56
Nonstandard Forms
57
Implementations
58
• Registers and Transfer Notations
What are Registers?
Registers…
Register Transfer Language (RTL)
• Digital System: An interconnection of hardware
modules that do a certain task on the information.
• Registers + Operations performed on the data stored
in them = Digital Module
• Modules are interconnected with common data and
control paths to form a digital computer system
Register Transfer Language cont.
• Microoperations: operations executed on data stored
in one or more registers.
• For any function of the computer, a sequence of
microoperations is used to describe it
• The result of the operation may be:
– replace the previous binary information of a
register or
– transferred to another register
Shift Right Operation
101101110011 010110111001
Register Transfer Language cont.
• The internal hardware organization of a digital
computer is defined by specifying:
• The set of registers it contains and their function
• The sequence of microoperations performed on the
binary information stored in the registers
• The control that initiates the sequence of
microoperations
• Registers + Microoperations Hardware + Control
Functions = Digital Computer
Register Transfer Language cont.
• Register Transfer Language (RTL) : a symbolic
notation to describe the microoperation transfers
among registers
Next steps:
– Define symbols for various types of microoperations,
– Describe the hardware that implements these
microoperations
Register Transfer (our first microoperation)
• Computer registers are designated by capital
letters (sometimes followed by numerals) to
denote the function of the register
• R1: processor register
• MAR: Memory Address Register (holds an address for a
memory unit)
• PC: Program Counter
• IR: Instruction Register
• SR: Status Register
Register Transfer cont.
R1 7 6 5 4 3 2 1 0
15 0
PC
Numbering of bits
15 87 0
Upper byte PC(H) PC(L) Lower byte
R1
t t+1
Timing diagram
Clock
Synchronized
Load
with the clock
Transfer occurs here
Register Transfer cont.
Bus lines
D3 D2 D1 D0 C3 C2 C1 C0 B3 B2 B1 B0 A3 A2 A1 A0
D3 C3 B3 A3 D2 C2 B2 A2 D 1 C1 B 1 A 1 D0 C0 B0 A0
3 2 1 0 3 2 1 0 3 2 1 0
3 2 1 0 S0
S0 S0 S0
MUX3 MUX2 MUX1 MUX0 S1
S1 S1 S1
Three-State Buffer
Bus and Memory Transfers: Memory
Transfer
• Memory read : Transfer from memory
• Memory write : Transfer to memory
• Data being read or written is called a memory word
(called M)-
• It is necessary to specify the address of M when
writing /reading memory
• This is done by enclosing the address in square brackets
following the letter M
• Example: M[0016] : the memory contents at address
0x0016
Bus and Memory Transfers: Memory Transfer
cont.
AR
x0C 19
x12 x0E 34
R1 x10 45
100 x12 66
x14 0
x16 13
R1←M[AR] x18 22
RAM
R1 R1
100 66
Lecture Three
• Microoperations
Microoperations
• The microoperations most often encountered
in digital computers are classified into four
categories:
– Register transfer microoperations
– Arithmetic microoperations (on numeric data
stored in the registers)
– Logic microoperations (bit manipulations on non-
numeric data)
– Shift microoperations
Arithmetic Microoperations
• The basic arithmetic microoperations are:
addition, subtraction, increment, decrement,
and shift
• Addition Microoperation:
R3 ←R1+R2
• Subtraction Microoperation:
R3 ←R1-R2 or : 1’s complement
R3 ←R1+R2+1
Arithmetic Microoperations cont.
• One’s Complement Microoperation:
R2 ←R2
• Two’s Complement Microoperation:
R2 ←R2+1
• Increment Microoperation:
R2 ←R2+1
• Decrement Microoperation:
R2 ←R2-1
Logic Microoperations
OR Microoperation
• Symbol: , +
• Gate:
AND Microoperation
• Symbol:
• Gate:
• Gate:
• Gate:
• Gate:
• Gate:
Shift Left
**Note that the bit ri is the bit at position (i) of the register
Shift Microoperations:
Logical Shifts
• Transfers 0 through the serial input
• Logical Shift Right: R1←shr R1
The same
? rn-1 r3 r2 r1 r0 0
rn-1 r3 r2 r1 r0
rn-1 r3 r2 r1 r0
?
? rn-1 r3 r2 r1 r0 0
Sign
Arithmetic Shift Left
Bit
Shift Microoperations cont.
• Direct Mapping
• Set Associative Mapping
• Associative Mapping
Direct Mapping
• In direct mapping, a memory block is
mapped into a unique cache line,
depending on the memory address of
the respective block.
• Tags are stored in the cache in order to
distinguish among blocks which fit into
the same cache line.
Direct Mapping If we had a
miss, the
block will be
placed in the
cache line
which
corresponds
to the 14 bits
field in the
memory
address of
the
respective
block:
Cache Memory Organization Techniques
• Advantages of direct mapping are as follows:
• It is simple and cheap;
• The tag field is short; only those bits which are not used to address
the cache have to be stored;
• Access is very fast.
• Disadvantages:
• A given block fits into a fixed cache location
• A given cache line will be replaced whenever there is a reference to
another memory block which fits to the same line, regardless of
what the status of the other cache lines is. This can produce a low
hit ratio, even if only a very small part of the cache is effectively
used
Set Associative Mapping
• In set associative mapping, a memory block is mapped
into any of the lines of a set. The set is determined by the
memory address, but the line inside the set can be any
one.
• If a block has to be placed in the cache the particular line
of the set will be determined according to a replacement
algorithm.
• The number of lines in a set is determined by the
designer. If there are 2 lines/set, it is a two-way set
associative mapping and a four-way set associative
mapping if there are 4 lines in a set.
Set Associative Mapping
• Disadvantage
• Cache hardware is more complex than for direct mapping.
• In practice, 2 and 4-way set associative mapping are used with very good
results. Larger sets do not produce further significant performance
improvement.
Associative Mapping
• In associative mapping, a memory block can be mapped to any
cache line. If a block has to be placed in the cache, the particular
line will be determined according to a replacement algorithm.
• When a new block is to be placed into the cache, the block stored in
one of the cache lines has to be replaced.
Replacement Algorithms
• Random replacement:
• One of the candidate lines is selected randomly.
• First-in-first-out (FIFO):
• The candidate line which holds the block that has been in the cache the
longest is selected.
Structural hazard
Structural hazards
• How to avoid Structural Hazards:
Certain resources are duplicated in order to
avoid structural hazards. Functional units
(ALU, FP unit) can be pipelined themselves in
order to support several instructions at a time.
A classical way to avoid hazards at memory
access is by providing separate data and
instruction caches.
Data Hazards
We have two
instructions, I1 and I2.
In a pipeline, the
execution of I2 can
start before I1 has
terminated. If in a
certain stage of the
pipeline, I2 needs the
result produced by I1,
but this result has not
yet been generated, we Data Hazards
have a data hazard. The Penalty is 2 cycles
Data Hazards
• How to avoid Data Hazards:
• Some of the penalty produced by data hazards
can be avoided using a technique called
forwarding (bypassing).
Forwarding
Data Hazards
The ALU result is always fed back to the ALU input. If the
hardware detects that the value needed for the current
operation is the one produced by the previous operation (but
which has not yet been written back) it selects the forwarded
result as the ALU input, instead of the value read from register
or memory
•
• --------------
• BR TARGET
• --------------
• TARGET - - - - - - - - - - - - - -
Control Hazards