choosing ingredients for a computer design
TRANSCRIPT
2-1Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Instruction Set ArchitectureChoosing Ingredients
for a Computer Design
2-2Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
סקירת הפרק
מהו מעבדvon Neumannמבנה
שלבי תכנון מעבד קבוצת הפקודותמבנה פקודה
) נתונים( אופרנדים שמירת נתונים וסוגי זכרון
פעולות שיקולים לתכנון קבוצת הפקודות
) CISC( שפה מורכבת מימוש פקודות בחומרה
microcode
2-3Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Von Neumann ArchitectureStored-Program Digital Computer
• Digital computation in ALU• Programmable via set of
standard instructions• Internal storage of data • Internal storage of program• Automatic Input/Output• Automatic sequencing of
instruction execution bydecoder/controller
ArithmeticLogicUnit
(ALU)
input memory output
controller
data/instruction path
control pathVon Neumann ArchitectureData and instructions stored in a single memory unit
Harvard ArchitectureData and instructions stored in a separate memory units
2-4Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Stages in Computer DesignInstruction Set Architecture (ISA)
1. Look at universe of problems to be solved2. Define atomic operations at level of system programmer
• Small and orthogonal operations (each performs different task)• Can be combined to perform any operation
3. Specify instruction set for machine language• Choose a minimum set of basic operations• Not too many ways to solve same problem
Implementation1. Design machine as implementation of ISA2. Evaluate theoretical performance3. Identify performance problem areas4. Improve processor efficiency
2-5Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Instruction Features Instruction
Description of an Operation performed on Operands
Operations Actions performed on data
OperandsSources — data inputs to operationDestinations — data outputs from operationSpecified by
Addressing Mode — location of data in machineData Type —Integer, Long, Floating Point, Decimal, String, Constant,
etc.
2-6Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Instruction Set Architecture General Instruction is instance of data structure
Machine Language is range of data structure Instruction for Operation {legal actions} Operand {legal Addressing Modes}
Describe sources and destinations
Typical machine instructionADD destination, source_1, source_2destination source_1 + source_2
Operand...OperandOperandOperation
2-7Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Instruction DefinitionsOperations and operands
unary — one source operandbinary — two source operandsn-ary — n source operands
Address specifier Describes address format
Addressing modeOperation model
Data width
Intel Non-Intel 2 bytes word half-word 4 bytes dword word 8 bytes quadword doubleword
2-8Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Memory Hierarchy
Long TermStorage
Main Memory(RAM) Cache Register
All Filesand Data
Running Programsand Data
Next FewInstructionsand Data
CurrentData
Memory location inside CPU
Fast access to small amount of
information
Organized by CPU
Memory location in or near CPU
Fast access to important data and
instructions from RAM
Copy of RAM section
Memory location outside CPU
Stores "all" data and instructions of running programs
Organized by addresses
Memory locations outside CPU and RAM
Stores data and instructions of "all"
programs
Organized by OS
2-9Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Register NamingRegisters are part of CPU design
Information stored in registers called architectural stateDescribes machine status and program status
General Purpose (GP) registersHold data for instructions
Width of data is width of standard integer in CPUReferenced by names or numbers
Intel x86: EAX, EBX, ECX, EDX, ESI, EDI, EBP, ESP, EIPGeneral: R0, R1, … , R127
Special Purpose registersMachine status registersOperating system registers
2-10Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Flat Memory OrganizationN-bit address space
Physical Address = AN-1 AN-2 … A1 A0
Can form 2N addresses, from 0 to (2N – 1)
Every byte in RAM has N-bit addressProcessor refers to memory locations by
physical RAM addressesProcessor stores memory addresses in
N-bit address registers
Data Byte 11111…111 Data Byte 11111…110 Data Byte 11111…101 Data Byte 11111…100
… … Data Byte 00000…111 Data Byte 00000…110 Data Byte 00000…101 Data Byte 00000…100 Data Byte 00000…011 Data Byte 00000…010 Data Byte 00000…001 Data Byte 00000…000 Memory Location Address
memory addressesN-bit register
CPU
2-11Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Word Organization in MemoryWord order
Little endianLeast significant byte stored at lower addressWord is stored "little-end-first"Example: 4-byte word 69 b3 36 7d stored as
Big endianMost significant byte stored at lower addressWord is stored "big-end-first"Example: 4-byte word 69 b3 36 7d stored as
AlignmentRequirement that address of s-byte data unit be multiple of sFormally — address A % s = 0
8086 requires segments to be aligned on 16-byte boundariesIA-32 requires pages to be aligned on 4 KB boundaries
stored byte 69 b3 36 7d address 07 06 05 04 03 02 01 00
stored byte 7d 36 b3 69 address 07 06 05 04 03 02 01 00
2-12Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
ImmediateConstant = IMM = numerical value coded into instruction
Register operandsregister name = a CPU storage locationREGS[register name] = data stored in registerREGS[R3] = data stored in register R3 = 11223340
Memory operandsaddress = a memory storage locationMEM[address] = data stored in memoryMEM[11223344] = data stored at address 11223344 = 45
Effective Address (EA) — pointer arithmeticREGS[R3] &(variable)MEM[REGS[R3]+4] = *(&(variable)+4) = *(REGS[R3]+4)
= *(11223340+4) = 45
Specifying Operands
11223340
R3
45
11223344
2-13Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Structured Operation ModelsDefines basic arithmetic procedure and ALU organization
Stack
Z = X + Y push Xpush YADDpop Z
AccumulatorAll operations use accumulator AZ = X + Y load X
add Y
store Z
Push Pointer Pointer – d Stack[Pointer] memory/register
Pop memory/register Stack[Pointer] Pointer Pointer + d
Binary Op
Stack[Pointer + d] Stack[Pointer + d] Op Stack[Pointer] Pointer Pointer + d
Stack ALU used in Java bytecode
Accumulator ALU used in hand calculator
2-14Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
General Register Operation ModelsRegister-Memory Model
Operands can be stored in any REGISTER or MEMORY locationZ = X + Y load R1, X
add R1, R1, Ystore Z, R1
Register- Register ModelMEMORY operands must be loaded to a REGISTERAlso called LOAD-STORE MODELZ = X + Y load R1, X
load R2, Yadd R1, R1, R2store Z, R1
Easier to implementStatistically, most loaded operands are used more than once
2-15Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Typical Addressing ModesMode Syntax Memory Access Use
Register R3 Regs[R3] Register data Immediate #3 3 Constant Direct (absolute) (1001) Mem[1001] Static data
Register deferred (R1) Mem[Regs[R1]] Pointer
Displacement 100(R1) Mem[100+Regs[R1]] Local variable Indexed (R1 + R2) Mem[Regs[R1]+Regs[R2]] Array addressing Memory indirect @(R3) Mem[Mem[Regs[R3]]] Pointer to pointer
Auto Increment (R2)+
Mem[Regs[R2]] Regs[R2] Regs[R2]+d Stack access
Auto Decrement -(R2)
Regs[R2] Regs[R2]-d Mem[Regs[R2]]
Stack access
Scaled 100(R2)[R3] Mem[100+Regs[R2]+Regs[R3]*d] Indexing arrays PC-relative (PC) Mem[PC+value]
PC-relative deferred 1001(PC) Mem[PC+Mem[1001]]
Store data relative to program counter (instruction address)
2-16Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Typical OperationsData transfer
Load (r m), store (m r), move (r/m r/m), convert data typesArithmetic/Logical (ALU)
Integer arithmetic (+ – compare shift) and logical (AND, OR, NOR, XOR)Decimal
Integer arithmetic on decimal numbersFloating point (FPU)
Floating point arithmetic (+ – sqrt trig exp …)String
String move, string compare, string searchControl
Conditional and unconditional branch, call/return, trapOperating System
System calls, virtual memory management instructionsGraphics
Pixel operations, compression/decompression operations
2-17Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Classic Computer Organization
2-18Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Considerations in Classic Computer DesignExpensive memory
RAM ~ $5000/MB wholesale in 1977
Poor compilersNon-optimizingBad error messagingFast code written or optimized in assembly language
Semantic Gap ArgumentBelief among theoreticians in 1960s and 1970Computer language should imitate natural language
Large vocabularyHigh redundancy
2-19Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Implications for Machine Language Machine Language should be high level
Language defines many instructionsEach instruction performs a lot of workLanguage defines many addressing modes
AdvantagesAssembly language programming is easier Each stored instruction in memory more powerfulMore power per instruction requires less memory
2-20Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Classic Machine Design
CISC (Complex Instruction Set Computer)
300 + instruction types
15+ addressing modes
10+ data types
Automated procedure handling
Complex machine implementations
2-21Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
CISCCISC was conventional wisdom in 1960s and 1970s Mainframes
Large and expensive computersOwned by big businesses and governmentsManufacturers: IBM, Control Data, Burrows, HoneywellFrom 1960s to 1980s, mainframes were CISC machines
MinicomputersSmaller computers for smaller organizationsManufacturers: Digital (PDP/VAX), Data General (Eclipse)Promoted academic computer science, smaller operating systems
(Unix), computer networkingMicrocomputers
Intel designed the 8086 (1979) to work like a tiny VAXThe PC is the only CISC computer still manufactured
2-22Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Physical Implementation
Main Memory
Registers
MAR MDR+PCIRDecoderStatusWord
Address Data PC - program counterIR - instruction register
MAR - memory address registerMDR - memory data register
ALU Subsystem
System Bus
INOUT
ALU Operat ion
1
23
A LU Result F lagcontrol
2-23Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
RegistersGeneral Registers
R0 … Rn-1
Register width is standard integer in ISAPC
Program Counter Holds address of next instruction to execute
IRInstruction Register Holds binary code of instruction being executed
MARMemory Address Register Holds physical address for RAM access
MDRMemory Data Register Holds data during Read/Write memory operations
2-24Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Device Communication
A device WRITES with OE = 1 and READS with IE = 1Von Neumann controller distributes OE and IE signals to devices
Bus: A vehicle for carrying many passengers
Device 1
Device 3
Device 2
Write
OE
Read
IE
Write
OE
Read
IE
Write
OE
Read
IE
Syst
em B
us
Device BRead
IE
Device AWrite
OE
2-25Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Atomic Operations Instruction Fetch(1) MAR PC(2) READ(3) IR MDR(4) PC PC + length(instruction)
2-26Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
(1) MAR PC
Main Memory
Registers
MAR MDR+PCIRDecoderStatusWord
Address DataPC- program counterIR- instruction register
MAR- memory address registerMDR- memory data register
ALU Subsystem
System Bus
INOUT
ALU Operat ion
1
23
ALU Result F lagcontrol
2-27Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
(2) READ
Main Memory
Registers
MAR MDR+PCIRDecoderStatusWord
Address DataPC- program counterIR- instruction register
MAR- memory address registerMDR- memory data register
ALU Subsystem
System Bus
INOUT
ALU Opera tion
1
23
A LU Result Flagcontrol
2-28Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
(3) IR MDR
Registers
MAR MDR+PCIRDecoderStatusWord
Address DataPC- program counterIR- instruction register
MAR- memory address registerMDR- memory data register
ALU Subsystem
System Bus
INOUT
ALU Operat ion
1
23
ALU Result F lag
Main MemoryAddress Data
control
2-29Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
(4) PC PC + length(instruction)
Registers
MAR MDR+PCIRDecoderStatusWord
PC- program counterIR- instruction register
MAR- memory address registerMDR- memory data register
ALU Subsystem
System Bus
INOUT
ALU Opera tion
1
23
A LU Result Flag
Main MemoryAddress Data
control
2-30Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Atomic OperationsInstruction: SUB R1, R2, 100(R3) ALU_IN R3ALU 100ADDMAR OUTREADALU_IN MDRALU R2SUBR1 OUT
2-31Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
SUB R1, R2, 100(R3): ALU_IN R3
Registers
MAR MDR+PCIRDecoderStatusWord
PC- program counterIR- instruction register
MAR- memory address registerMDR- memory data register
ALU Subsystem
System Bus
INOUT
ALU Opera tion
1
23
A LU Result Flag
Main MemoryAddress Data
control
R3
2-32Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
SUB R1, R2, 100(R3): ALU 100
Registers
MAR MDR+PCIRDecoderStatusWord
PC- program counterIR- instruction register
MAR- memory address registerMDR- memory data register
ALU Subsystem
System Bus
INOUT
ALU Opera tion
1
23
A LU Result Flag
Main MemoryAddress Data
control
R3
100
2-33Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
SUB R1, R2, 100(R3): ADD
Registers
MAR MDR+PCIRDecoderStatusWord
PC- program counterIR- instruction register
MAR- memory address registerMDR- memory data register
ALU Subsystem
System Bus
INOUT
ALU Opera tion
1
23
A LU Result Flag
Main MemoryAddress Data
control
R3
100 100+R3
2-34Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
SUB R1, R2, 100(R3): MAR OUT
Registers
MAR MDR+PCIRDecoderStatusWord
PC- program counterIR- instruction register
MAR- memory address registerMDR- memory data register
ALU Subsystem
System Bus
INOUT
ALU Opera tion
1
23
A LU Result Flag
Main MemoryAddress Data
control
100+R3
2-35Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
SUB R1, R2, 100(R3): READ
Registers
MAR MDR+PCIRDecoderStatusWord
PC- program counterIR- instruction register
MAR- memory address registerMDR- memory data register
ALU Subsystem
System Bus
INOUT
ALU Opera tion
1
23
A LU R esult Flag
Main MemoryAddress Data
control
100+R3
2-36Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
SUB R1, R2, 100(R3): ALU_IN MDR
Registers
MAR MDR+PCIRDecoderStatusWord
PC- program counterIR- instruction register
MAR- memory address registerMDR- memory data register
ALU Subsystem
System Bus
INOUT
ALU Opera tion
1
23
A LU Result Flag
Main MemoryAddress Data
control
(100+R3)
2-37Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
SUB R1, R2, 100(R3): ALU R2
Registers
MAR MDR+PCIRDecoderStatusWord
PC- program counterIR- instruction register
MAR- memory address registerMDR- memory data register
ALU Subsystem
System Bus
INOUT
ALU Opera tion
1
23
A LU Result Flag
Main MemoryAddress Data
control
(100+R3)
R2
2-38Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
SUB R1, R2, 100(R3): SUB
Registers
MAR MDR+PCIRDecoderStatusWord
PC- program counterIR- instruction register
MAR- memory address registerMDR- memory data register
ALU Subsystem
System Bus
INOUT
ALU Opera tion
1
23
A LU Result Flag
Main MemoryAddress Data
control
(100+R3)
R2 R2-100(R3)
2-39Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
SUB R1, R2, 100(R3): R1 OUT
Registers
MAR MDR+PCIRDecoderStatusWord
PC- program counterIR- instruction register
MAR- memory address registerMDR- memory data register
ALU Subsystem
System Bus
INOUT
ALU Opera tion
1
23
A LU R esult Flag
Main MemoryAddress Data
control
R2-100(R3)
2-40Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Decoding Machine InstructionsMachine Language Instruction
SUB R1, R2, 100(R3)
Microcode Instruction Sequence (Microprogram)ALU_IN R3ALU 100ADDMAR OUTREADALU_IN MDRALU R2SUBR1 OUT
2-41Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
MicrocodeMicrocode
One line of microprogram Implementation-level atomic operationAtomic operation must complete before servicing interrupt
Decoder"Interprets" machine language instruction into microprogramDecoder ROM stores microprogram for every legal instructionNew instruction add microprogram to decoder
Microprogram is sequenced by decoderState machine for each instructionEach state provides control signals to every subsystemEach line of microcode is executed in the correct order
Based on work of Maurice V. Wilkes (1951)
2-42Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
Clock Cycles Per InstructionClock Cycle (CC)
Determined by length of longest microcode operationsOne line of microcode finishes before next line begins
Most microcode lines finish in one clock cycleMemory access may take several clock cycles
Clock Cycles Per InstructionMachine language instruction implemented as lines of microcodeClock Cycles Per Instruction = number of microcode lines
Memory accesses may take extra clock cyclesClock cycles for program = number of microcode lines in program
program Instruction of type
instruction types
CC Instructions of type CC i
ii
Instruction type — same basic microcode structure
2-43Dr. Martin LandInstruction Set ArchitectureComputer Architecture — Hadassah College — Spring 2022
CISC Creates Anti‐CISC Revolution 1974 — 1977
Data General introduces Eclipse 32-bit CISC minicomputerDigital (DEC) introduces VAX 32-bit CISC minicomputerFirst serious inexpensive competition to mainframe computers
1977 — 1990Serious computers became available to small organizationsUNIX developed as minicomputer operating systemTCP/IP developed to support networks of minicomputersComputer Science emerged as separate academic disciplineStudents needed topics for projects, theses, dissertations
1980 — 1990Research results on minicomputer performance
CISC uses machine resources inefficientlyMost machine instructions are rarely used in programsCISC machines run slowly to support unnecessary features