CBP Comp 1017 Digital Technologies1 Let’s make a Computer … at least the CPU … Pentium 4 Pentium 3 Opteron Ultra Sparc Itanium 2 McKinley
CBP Comp 1017 Digital Technologies2
CBP Comp 1017 Digital Technologies3 CPU Memory Keyboard VDU Computer Program (Code) 1 do this 2 do that 3 now this 4 goto 1
CBP Comp 1017 Digital Technologies4 Program Memory 2. High Level Language like ‘C’ 3. Assembler Instructions mov ax,[x] mov bx,[y] add ax, bx mov [w],ax w = x + y ; 1. Application Let’s consider a spreadsheet cell which adds two numbers x + y. This cell and its instruction is in memory. But it is REPRESENTED in different ways Inside the CPU
CBP Comp 1017 Digital Technologies5 Pentium Data Cache Code Cache Instruction Fetch Instruction Decode Execution Unit
CBP Comp 1017 Digital Technologies6 Minimalist CPU What do we need to build a CPU? “Execution Unit” ALU (Arithmetic Logic Unit) Memory (to store intermediate data) Input Output A good Name
CBP Comp 1017 Digital Technologies7 Arithmetic Logic Unit Input AInput B Output ALU Integer Execution Unit 5 32 add 1 32 sub
CBP Comp 1017 Digital Technologies8 Input AInput B Output ALU MMX instructions add bits of images together! Useful for multimedia Multimedia MMX
CBP Comp 1017 Digital Technologies add Processing Idea Nr. 1 Move data from memory Move data into memory Memory DRAM, Hard Disk.. Move data in and out of data memory store
CBP Comp 1017 Digital Technologies add Processing Idea Nr.2 IP (Code Memory) mov 3 in from memory mov 2 in from memory add the two numbers mov the result to memory Instruction Memory Program Move instructions into CPU from code memory
CBP Comp 1017 Digital Technologies11 Registers Registers are high-speed memory on the CPU chip Parking places for data on the move AX and BX are used for ALU operations MAR is memory address register, here 4. So result, 6+8=14 will go into memory cell address 4 AX BX MAR
CBP Comp 1017 Digital Technologies12 ip Data Memory Instruction Memory mar Our computer so far …
CBP Comp 1017 Digital Technologies13 Instruction Memory A couple of extra bits Data Memory Instruction Register Memory Data Register Data Address add ax,bx 1.Line of code goes in 2.Electrical bit signals come out Energize ax Energize bx Select ALU “add"
CBP Comp 1017 Digital Technologies14 SAM-2
CBP Comp 1017 Digital Technologies15 Moving data into Registers Instruction Memory mar 3 4 mov ax, [1] BX AX mov ax, [1] mov bx, [2] 7 For example …
CBP Comp 1017 Digital Technologies16 Moving data into Memory Instruction Memory mar 3 4 mov [3], ax BX AX mov [3], ax mov [0], bx 7 For example … 8 7
CBP Comp 1017 Digital Technologies17 Adding Numbers Instruction Memory mar 3 4 add ax, bx BX AX Add ax,bx 7 For example … … this means ‘ add ax to bx, put the answer in ax’
CBP Comp 1017 Digital Technologies18 I’ve never wrestled with such a complex problem before It must take a lot of organization and control !
CBP Comp 1017 Digital Technologies19 Pentium Organization and control
CBP Comp 1017 Digital Technologies20 Fetch-Execute Cycle 1. Fetch instruction from memory 2. Decode the instruction and read any registers 3. Do any ALU operations (execute units) 5. Write back results to registers (Organization and Control) add ax, bx 4. Do any Memory Access ALU <- ax ALU <- bx ax + bx (Data cache) ax <- ALU None needed
CBP Comp 1017 Digital Technologies21 add ax, bx add ax bx Fetch-Exec : State 1 Instruction Fetch AX BX
CBP Comp 1017 Digital Technologies Fetch-Exec : State 2 Decode, Register Operations add ax, bx add axbx AX BX
CBP Comp 1017 Digital Technologies Fetch-Exec : State 3 ALU Operation add ax, bx add axbx AX BX 3 1 4
CBP Comp 1017 Digital Technologies Fetch-Exec : State 4 Memory Access add ax, bx add axbx AX BX 3 1 4
CBP Comp 1017 Digital Technologies Fetch-Exec : State 5 Register Write add ax, bx add axbx BX
CBP Comp 1017 Digital Technologies26 Fetch-Execute Cycle 1. Fetch instruction from memory 2. Decode the instruction and read any registers 3. Do any ALU operations (execute units) 5. Write back results to registers (Organization and Control) mov ax, [1] 4. Do any Memory Access Read the ‘1’ Put ‘1’ into MAR Data into ax Read memory at addr ‘1’
CBP Comp 1017 Digital Technologies27 mov ax, [1] mov ax Fetch-Exec : State 1 Instruction Fetch
CBP Comp 1017 Digital Technologies28 mov ax, [1] mov ax Fetch-Exec : State 2 Decode, Register Operations
CBP Comp 1017 Digital Technologies29 mov ax, [1] mov ax Fetch-Exec : State 3 ALU Operation
CBP Comp 1017 Digital Technologies30 mov ax, [1] mov ax Fetch-Exec : State 4 Memory Access
CBP Comp 1017 Digital Technologies31 mov ax, [1] mov ax Fetch-Exec : State 5 Register Write
CBP Comp 1017 Digital Technologies32 Pentium Fetch 2.Decode 3.ALU 4.Mem Ops 5.Reg Write
CBP Comp 1017 Digital Technologies33 The first microprocessor Keypad Lots of Electronics LCD Display Keypad LCD Display Code Memory Programmable Electronics A dedicated design or a re- usable design
CBP Comp 1017 Digital Technologies35