Upload
cs11
View
215
Download
0
Embed Size (px)
Citation preview
7/25/2019 MCs 2 HowMCsWork
1/26
Lesson 2 How Computers Work
Semester 1 Microcontrollers
Lecturers: Juan Daz
Jorge Garca
Electrical EnergyConversion andPower Systems
Universidadde Oviedo
Presentation:
Ignacio lvarez GarcaISA-Uniovi 2004
7/25/2019 MCs 2 HowMCsWork
2/26
Outline
Introduction
Blocks in a Computer
Instructions execution
7/25/2019 MCs 2 HowMCsWork
3/26
A computer
Machine that executes instructions sequentially Program=sequence of instructions
Instructions and Data stored in MEMORY Memory organized in addresses
Instructions, data and operations in BINARY CODE
Read instructionfrom memory
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
Content
01101100
00101110
11111100
Instructions in binary code
Data in binary code
11101100
01101101
11101011
00000000
00000111
00000010
MOV X,3
MOV Z,X
ADD Z,Y
0
7
2
7/25/2019 MCs 2 HowMCsWork
4/26
Parts of a computer
Control Unit (CU): organizes theoperation of the computer
Artimetihc-Logic Unit (ALU):executes arithmetic (+,-,*,/) andlogic (bit level) (AND, OR, )operations
Registers: Temporary places forstoring information
Memory: Main place ofinformation storage (code anddata)
I/O Devices: Allowcommunication with the outerworld
CPU
ALU
CU
registers
Memory
I/O
7/25/2019 MCs 2 HowMCsWork
5/26
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000000
00000111
00000010
MOV X,3
MOV Z,X
ADD Z,Y
0
7
2
CPUInstruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count. Inst1
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
7/25/2019 MCs 2 HowMCsWork
6/26
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000000
00000111
00000010
MOV X,3
MOV Z,X
ADD Z,Y
0
7
2
CPUInstruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count. Inst1
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
11101100
7/25/2019 MCs 2 HowMCsWork
7/26
CPU11101100
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000000
00000111
00000010
MOV X,3
MOV Z,X
ADD Z,Y
0
7
2
Instruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count. Inst1
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
MOV X,3
7/25/2019 MCs 2 HowMCsWork
8/26
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000000
00000111
00000010
MOV X,3
MOV Z,X
ADD Z,Y
0
7
2
CPUInstruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count. Inst1
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
MOV X,3
00000011
7/25/2019 MCs 2 HowMCsWork
9/26
CPU
00000011
MOV X,3
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000000
00000111
00000010
MOV X,3
MOV Z,X
ADD Z,Y
0
7
2
Instruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count. Inst1
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
00000011
7/25/2019 MCs 2 HowMCsWork
10/26
CPU
00000011
00000011
MOV X,3
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000000
00000111
00000010
MOV X,3
MOV Z,X
ADD Z,Y
0
7
2
Instruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count. Inst1
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
00000011 3
7/25/2019 MCs 2 HowMCsWork
11/26
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000011
00000111
00000010
MOV X,3
MOV Z,X
ADD Z,Y
3
7
2
CPUInstruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count. Inst1
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
+1Inst2
00000011
00000011
MOV X,3
7/25/2019 MCs 2 HowMCsWork
12/26
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000011
00000111
00000010
MOV X,3
MOV Z,X
ADD Z,Y
7
2
CPUInstruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count.
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
00000011
00000011
MOV X,3
Inst2Inst2
3
7/25/2019 MCs 2 HowMCsWork
13/26
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000011
00000111
00000010
MOV X,3
MOV Z,X
ADD Z,Y
7
2
CPUInstruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count.
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
00000011
00000011
Inst211101011
3
7/25/2019 MCs 2 HowMCsWork
14/26
CPU11101011
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000011
00000111
00000010
MOV X,3
MOV Z,X
ADD Z,Y
7
2
Instruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count.
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
00000011
00000011
Inst2MOV Z,X
3
7/25/2019 MCs 2 HowMCsWork
15/26
CPU
00000011
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000011
00000111
00000010
MOV X,3
MOV Z,X
ADD Z,Y
7
2
Instruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count.
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
00000011
Inst2MOV Z,X
00000011
3
7/25/2019 MCs 2 HowMCsWork
16/26
CPU
00000011
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000011
00000111
00000010
MOV X,3
MOV Z,X
ADD Z,Y
7
2
Instruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count.
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
Inst2MOV Z,X
00000011
00000011
3
7/25/2019 MCs 2 HowMCsWork
17/26
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000011
00000111
00000010
MOV X,3
MOV Z,X
ADD Z,Y
7
2
CPUInstruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count.
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
Inst2MOV Z,X
00000011
00000011
00000011 3
3
7/25/2019 MCs 2 HowMCsWork
18/26
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000011
00000111
00000011
MOV X,3
MOV Z,X
ADD Z,Y
7
3
CPUInstruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count.
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
Inst2MOV Z,X
00000011
00000011
+1Inst3
3
7/25/2019 MCs 2 HowMCsWork
19/26
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000011
00000111
00000011
MOV X,3
MOV Z,X
ADD Z,Y
7
3
CPUInstruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count.
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
Inst2MOV Z,X
00000011
00000011
Inst3
3
11101011
7/25/2019 MCs 2 HowMCsWork
20/26
11101011
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000011
00000111
00000011
MOV X,3
MOV Z,X
ADD Z,Y
7
3
CPUInstruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count.
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
Inst2ADD Z,Y
00000011
00000011
Inst3
3
7/25/2019 MCs 2 HowMCsWork
21/26
11101011
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000011
00000111
00000011
MOV X,3
MOV Z,X
ADD Z,Y
7
3
CPUInstruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count.
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
Inst2ADD Z,Y
00000011
00000011
Inst3
3
00000111
7/25/2019 MCs 2 HowMCsWork
22/26
7/25/2019 MCs 2 HowMCsWork
23/26
11101011
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000011
00000111
00000011
MOV X,3
MOV Z,X
ADD Z,Y
7
3
CPUInstruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count.
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
Inst2ADD Z,Y
00000111
00000011
Inst3
3
00000011
00001010
7/25/2019 MCs 2 HowMCsWork
24/26
11101011
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000011
00000111
00000011
MOV X,3
MOV Z,X
ADD Z,Y
7
3
CPUInstruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count.
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
Inst2ADD Z,Y
00000111
00001010
Inst3
3
00000011
00001010 10
7/25/2019 MCs 2 HowMCsWork
25/26
11101011
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000011
00000111
00000011
MOV X,3
MOV Z,X
ADD Z,Y
7
3
CPUInstruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count.
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
Inst2ADD Z,Y
00000111
00001010
???
3
00000011
00001010 10
7/25/2019 MCs 2 HowMCsWork
26/26
11101011
Execution of Instructions
Example: x=3; z=x+y;
Address
000..00
000..01
000..10
Inst1:
Inst2:
Inst3:
X:
Y:
Z:
. . .
. . .
. . .
Content
01101100
00101110
11111100
11101100
01101101
11101011
00000011
00000111
00000011
MOV X,3
MOV Z,X
ADD Z,Y
7
3
CPUInstruction:
Operand 1:
Operand 2:
ALU
Result:
Prog. Count.
Read instructionfrom memory
Decodeinstruction
Getoperands
Calculateresult
Store result
Fetch nextinstruction
Inst2ADD Z,Y
00000111
00001010
???
3
00000011
00001010 10
Repeat