Beruflich Dokumente
Kultur Dokumente
Computer Architecture
l Topics:
l Processor Design
Where are we now?
l C-Programming
l A real computer language
l Data Representation
l Everything goes down to bits and bytes
l Machine representation Language
l Very limited programming model
l Digital Logic
l Transistors g Gates g Circuits
l Circuits g { Memory, Registers, and
Components}
l What are we going to do now.
Processor Design
l Figure out how a small subset of the
instruction set works in hardware
l Use Hardware blocks to describe data path
Encoded Representation!
Encoded Representation!
l 03 45
l means add 8(%ebp), %eax
addl $4, %eax! 0 5 000 4
l 05
l add $cons, %eax
Arithmetic and Logical
Operations
Instruction Code! l The second byte will
Function Code!
vary based on type of
Subtract (rA from rB)! operands
subl rA, rB! 2 B rA! rB! l Set condition codes
as side effect
And!
A"
l Combinational Logic A"
L"
l Compute Boolean B"
U"
A"
functions of inputs
MUX"
l Continuously respond to B" A
input changes 1
="
l Operate on data and S
implement control B
valA"
A"
srcA"
valW"
Register" W"
Storage Elements
dstW"
file"
l valB"
B"
srcB" Clock"
l Store bits
Clock!
l Addressable memories
l Non-addressable registers
Fetch Instruction
+"
A"
L"
U"
+4"
IR
PC
%edx
IR
A"
Register file
L"
U"
%eax
IR
%eax
A"
Register file
L"
U"
IR
%ebp
address
A"
Register file
L"
U"
%eax
data
IR
%ebp
address
A"
Register file
L"
U"
%eax
data
Structure
!! !
valE , valM
l State Data
Data !
Memory! memory
memory !
l Program counter register (PC) ! !
Addr, Data
specified by PC , !! !!
icode! ifun
rA! , rB
valP !
valC !
l Process through stages
Instruction
Instruction ! PC
PC !
l Update program counter Fetch!
memory
memory ! increment
increment !
PC !
newPC !
PC!
SEQ Stages
!! !
valE , valM
l Fetch Data
Data !
Memory! memory
memory !
l Read instruction from instruction ! !
Addr, Data
memory
!
Decode
valE
l
l Read program registers ! CC CC! ALU
ALU !
Execute! Bch
PC !
Instruction Decoding
Optional! Optional!
icode!
ifun!
rA!
rB!
valC!
l Instruction Format
l Instructionbyte icode:ifun
l Optional register byte rA:rB
l Optional constant word valC
Executing Arith./Logical
OperationOPl rA, rB! 6 rA! rB! fn"
l Fetch l Memory
l Read 2 bytes l Do nothing
l Decode l Write back
l Read operand registers l Update register
l Execute l PC Update
l Perform operation l Increment PC by 2
l Set condition codes
Stage Computation: Arith/
Log. Ops
OPl rA, rB!
icode:ifun M1[PC]! Read instruction byte!
rA:rB M1[PC+1]! Read register byte!
Fetch!
! !
valP PC+2! Compute next PC!
valA R[rA]! Read operand A!
Decode!
valB R[rB]! Read operand B!
valE valB OP valA! Perform ALU operation!
Execute!
Set CC! Set condition code register!
Memory! ! !
Write! R[rB] valE! Write back result!
back! ! !
PC update! PC valP! Update PC!
target:! XX XX Taken!
l Fetch l Memory
l Read 5 bytes l Do nothing
l Increment PC by 5
l Write back
l Decode
l Do nothing
l Do nothing
l Execute l PC Update
l Determine whether to take l Set PC to Dest if branch
branch based on jump taken or to incremented PC if
condition and condition codes not branch
Stage Computation: Jumps
jXX Dest!
icode:ifun M1[PC]! Read instruction byte!
Fetch!
valC M4[PC+1]! Read destination address!
valP PC+5! Fall through address!
Decode!
Execute!
Bch Cond(CC,ifun)! Take branch?!
Memory! ! !
Write!
back! ! !
PC update! PC Bch ? valC : valP! Update PC!
return:! XX XX
target:! XX XX
l Fetch l Memory
l Read 5 bytes l Write incremented PC to new
l Increment PC by 5 value of stack pointer
l Decode l Write back
l Read stack pointer l Update stack pointer
l Execute l PC Update
l Decrement stack pointer by 4 l Set PC to Dest
Stage Computation: call
call Dest!
icode:ifun M1[PC]! Read instruction byte!
Fetch!
valC M4[PC+1]! Read destination address !
valP PC+5! Compute return point!
Decode!
valB R[%esp]! Read stack pointer!
valE valB + 4! Decrement stack pointer!
Execute!
return:! XX XX
l Fetch l Memory
l Read 1 byte l Read return address from old
l Decode stack pointer
l Read stack pointer l Write back
l Execute l Update stack pointer
l Increment stack pointer by 4 l PC Update
l Set PC to return address
Stage Computation: ret
ret
icode:ifun M1[PC]! Read instruction byte!
Fetch!
! !