หน่วยประมวลผลกลาง cpu
DESCRIPTION
หน่วยประมวลผลกลาง CPU. CPU. Address bus. ROM. RAM. Input. Output. Data bus. RD. WR. RD. I/O. RD. I/O. WR. Control bus. โครงสร้างหลักของระบบคอมพิวเตอร์. โครงสร้างพื้นฐานของซีพียู. Clock. Timing and Control unit. Program Counter (PC). A0. Reset. Address reg. MER. MEW. - PowerPoint PPT PresentationTRANSCRIPT
หน่�วยประมวลผลกลาง CPU
โครงสร�างหล�กของระบบคอมพิ�วเตอร�
RD RDWRControl bus
RDI/O WRI/O
CPUROM RAM Input Output
Address bus
Data bus
โครงสร�างพิ��น่ฐาน่ของซี!พิ!ย"
Timingand
Controlunit
Register
Clock
Reset
MERMEWIORIOW
Instructiondecode
Sta
tus
regi
ste
rALU
accu
mul
ator
Inst
ruct
ion
reg
ProgramCounter
(PC)
Add
ress
reg
A0
A15
D0
D7
ชน่�ดของค%าส�&งที่!&ใช�ก�บซี!พิ!ย"
Instruction
Transfer data instruction
Arithmetic and Logic instruction
Branch and control instruction
Internal data
External data
คณิ�ตศาสตร์
Logic
การ์หมุ น/เลื่��อนข้�อมุ�ลื่
Jump
Subroutine
conditionalunconditional
conditionalunconditional
ต�วอย�างค%าส�&ง
AT89c51 PIC18F458
ข��น่ตอน่ใน่การประมวลผลของซี!พิ!ย"เร์��มุต�น
เพิ่��มุค�า program counter ข้��น 1 แลื่ะเฟตซ์ค�าโอเปอแร์นด์
เพิ่��มุค�า program counter ข้��น 1
ปฏิ�บั%ต�ตามุค&าส%�ง
เฟตซ์ไบัตค&าส%�งจากหน�วยความุจ&า
ถอด์ร์ห%สไบัตค&าส%�ง
ค&าส%�งชน�ด์ 1 ไบัต
เพิ่��มุค�า program counter ข้��น 1 แลื่ะเฟตซ์ค�าโอเปอแร์นด์
Fetch cycle
execute cycle
Yes เพิ่��มุค�า program counter ข้��น 1
แลื่ะเฟตซ์ค�าโอเปอแร์นด์
Yesค&าส%�งชน�ด์ 2 ไบัตNo No
การประย)กต�ใช�ซี!พิ!ย" (ต�วอย�างการควบค)มหลอดไฟ)
CPU
อ)ปกรณ์�เอาต�พิ)ต
#E002HMemory
Address bus
Data bus
MEMR
IOR
IOW
อ)ปกรณ์�อ�น่พิ)ต
#E001H
0
1011
01
0
Flowchart
เร�&มต�น่
อ�าน่ข�อม"ลจากอ)ปกรณ์�อ�น่พิ)ต
#E001H
1’s complement ข�อม"ลที่!&อ�าน่เข�ามาได�
ส�งข�อม"ลออกอ)ปกรณ์�เอาต�พิ)ต
#E002H
Program
Address
0000
0003
0004
0005
0008
0009
Hex
90 E0 01
E0
F4
90 E0 02
F0
02 00 00
Mnemonic code
MOV DPTR,#0E001H
MOVX A,@DPTR
CPL A
MOV DPTR,#0E002H
MOVX @DPTR,A
LJMP 0000H
ค%าส�&งใน่หน่�วยความจ%าAddress
Data bitData
D7 D6 D5 D4 D3 D2 D1 D0
0000 1 0 0 1 0 0 0 0 90
0001 1 1 1 0 0 0 0 0 E0
0002 0 0 0 0 0 0 0 1 01
0003 1 1 1 0 0 0 0 0 E0
0004 1 1 1 1 0 1 0 0 F4
0005 1 0 0 1 0 0 0 0 90
0006 1 1 1 0 0 0 0 0 E0
0007 0 0 0 0 0 0 1 0 02
0008 1 1 1 1 0 0 0 0 F0
0009 0 0 0 0 0 0 1 0 02
000A 0 0 0 0 0 0 0 0 00
000B 0 0 0 0 0 0 0 0 00
การอ�าน่และตรวจสอบข�อม"ล ค%าส�&งที่!& 1
Address Data
0000 90
0001 E0
0002 01
0003 E0
0004 F4
0005 90
0006 E0
0007 02
0008 F0
0009 02
000A 00
000B 00
Control Unit
InstructionDecoder
0 0
00 00
MEMR
Program Counter Address bus
0000
Data bus
90
InstructionRegister
Control Bus
01
9 0
การอ�าน่ข�อม"ล Operand ค%าส�&งที่!& 1
Address Data
0000 90
0001 E0
0002 01
0003 E0
0004 F4
0005 90
0006 E0
0007 02
0008 F0
0009 02
000A 00
000B 00
Control Unit
InstructionDecoder
9 0
00 01
MEMR
Program Counter Address bus
0001
Data bus
E0 01
InstructionRegister
00 00
Data Register
Control Bus
E0 01
00 03
การปฏิ�บ�ต�ตาม ค%าส�&งที่!& 1 ( MOV DPTR,#E001H )
Address Data
0000 90
0001 E0
0002 01
0003 E0
0004 F4
0005 90
0006 E0
0007 02
0008 F0
0009 02
000A 00
000B 00
Control Unit
InstructionDecoder
9 0
00 03
Program Counter Address bus
Data busInstructionRegister
Control Bus
00 00
Data Pointer Register
E0 01
Data Register
E0 01
การอ�าน่และตรวจสอบข�อม"ล ค%าส�&งที่!& 2
Address Data
0000 90
0001 E0
0002 01
0003 E0
0004 F4
0005 90
0006 E0
0007 02
0008 F0
0009 02
000A 00
000B 00
Control Unit
InstructionDecoder
9 0
00 03
MEMR
Program Counter Address bus
0003
Data bus
E0
InstructionRegister
Control Bus
04
00 00
Data Pointer Register
E0 01
Data Register
E0 01
E 0
การปฏิ�บ�ต�ตาม ค%าส�&งที่!& 2 ( MOVX A,@DPTR )
Control Unit
InstructionDecoder
E 0
00 04
IOR
Program Counter Address bus
E001
Data bus
5AH
InstructionRegister
E0 01
Data Pointer Register
E0 01
Data Register
Control Bus
อ)ปกรณ์�อ�น่พิ)ต
#E001H
0
1011
01
0
0 0
Accumulator
5 A
การอ�าน่และตรวจสอบข�อม"ล ค%าส�&งที่!& 3
Address Data
0000 90
0001 E0
0002 01
0003 E0
0004 F4
0005 90
0006 E0
0007 02
0008 F0
0009 02
000A 00
000B 00
Control Unit
InstructionDecoder
E 0
00 04
MEMR
Program Counter Address bus
0004
Data bus
F4
InstructionRegister
E0 01
Data Pointer Register
E0 01
Data Register
Control Bus
5 A
Accumulator
F 4
00 05
การปฏิ�บ�ต�ตาม ค%าส�&งที่!& 3 ( CPL A )
Address Data
0000 90
0001 E0
0002 01
0003 E0
0004 F4
0005 90
0006 E0
0007 02
0008 F0
0009 02
000A 00
000B 00
Control Unit
InstructionDecoder
F 4
00 05
Program Counter Address bus
Data busInstructionRegister
Control Bus
5 A
Accumulator
ALU
การปฏิ�บ�ต�ตาม ค%าส�&งที่!& 3 ( CPL A )
Address Data
0000 90
0001 E0
0002 01
0003 E0
0004 F4
0005 90
0006 E0
0007 02
0008 F0
0009 02
000A 00
000B 00
Control Unit
InstructionDecoder
F 4
00 05
Program Counter Address bus
Data busInstructionRegister
Control Bus
5 A
Accumulator
ALU
A 5
การอ�าน่และตรวจสอบข�อม"ล ค%าส�&งที่!& 4
Address Data
0000 90
0001 E0
0002 01
0003 E0
0004 F4
0005 90
0006 E0
0007 02
0008 F0
0009 02
000A 00
000B 00
Control Unit
InstructionDecoder
F 4
00 05
MEMR
Program Counter Address bus
0005
Data bus
90
InstructionRegister
E0 01
Data Pointer Register
E0 01
Data Register
Control Bus
A 5
Accumulator
9 0
00 06
การอ�าน่ข�อม"ล Operand ค%าส�&งที่!& 4
Address Data
0000 90
0001 E0
0002 01
0003 E0
0004 F4
0005 90
0006 E0
0007 02
0008 F0
0009 02
000A 00
000B 00
Control Unit
InstructionDecoder
9 0
00 06
MEMR
Program Counter Address bus
0006
Data bus
E0 02
InstructionRegister
E0 01
Data Register
Control Bus
A 5
Accumulator
E0 02
การปฏิ�บ�ต�ตาม ค%าส�&งที่!& 4 ( MOV DPTR,#E002H )
Address Data
0000 90
0001 E0
0002 01
0003 E0
0004 F4
0005 90
0006 E0
0007 02
0008 F0
0009 02
000A 00
000B 00
Control Unit
InstructionDecoder
9 0
00 06
Program Counter Address bus
Data busInstructionRegister
E0 01
Data Pointer Register
E0 02
Data Register
Control Bus
A 5
Accumulator
E0 02
00 08
9 0
การอ�าน่และตรวจสอบข�อม"ล ค%าส�&งที่!& 5
Address Data
0000 90
0001 E0
0002 01
0003 E0
0004 F4
0005 90
0006 E0
0007 02
0008 F0
0009 02
000A 00
000B 00
Control Unit
InstructionDecoder
F 0
00 08
MEMR
Program Counter Address bus
0008
Data bus
F0
InstructionRegister
E0 02
Data Register
Control Bus
E0 02
Data Pointer Register
A 5
Accumulator
การปฏิ�บ�ต�ตาม ค%าส�&งที่!& 5 ( MOV A,@DPTR )
Control Unit
InstructionDecoder
F 0
00 08
IOW
Program Counter Address bus
E002
Data bus
A5
InstructionRegister
E0 02
Data Register
Control Bus
E0 02
Data Pointer Register
A 5
Accumulator
อ)ปกรณ์�เอาต�พิ)ต
#E002H
00 09
F 0
การอ�าน่และตรวจสอบข�อม"ล ค%าส�&งที่!& 6
Address Data
0000 90
0001 E0
0002 01
0003 E0
0004 F4
0005 90
0006 E0
0007 02
0008 F0
0009 02
000A 00
000B 00
Control Unit
InstructionDecoder
0 2
00 09
MEMR
Program Counter Address bus
0009
Data bus
20
InstructionRegister
E0 02
Data Register
Control Bus
E0 02
Data Pointer Register
A 5
Accumulator
00 0A
E0 02
การอ�าน่ข�อม"ล Operand ค%าส�&งที่!& 6
Address Data
0000 90
0001 E0
0002 01
0003 E0
0004 F4
0005 90
0006 E0
0007 02
0008 F0
0009 02
000A 00
000B 00
Control Unit
InstructionDecoder
0 2
00 0A
MEMR
Program Counter Address bus
000A
Data bus
0000
InstructionRegister
00 00
Data Register
Control Bus
E0 02
Data Pointer Register
A 5
Accumulator
00 0A
การปฏิ�บ�ต�ตาม ค%าส�&งที่!& 6 ( LJMP 0000H )
Address Data
0000 90
0001 E0
0002 01
0003 E0
0004 F4
0005 90
0006 E0
0007 02
0008 F0
0009 02
000A 00
000B 00
Control Unit
InstructionDecoder
0 2
00 00
Program Counter Address bus
Data busInstructionRegister
00 00
Data Register
Control Bus
E0 02
Data Pointer Register
A 5
Accumulator
การอ�าน่และตรวจสอบข�อม"ล ค%าส�&งที่!& 1
Address Data
0000 90
0001 E0
0002 01
0003 E0
0004 F4
0005 90
0006 E0
0007 02
0008 F0
0009 02
000A 00
000B 00
Control Unit
InstructionDecoder
0 2
00 00
Program Counter Address bus
Data busInstructionRegister
Control Bus
00 00
Data Register
E0 02
Data Pointer Register
A 5
Accumulator