5 8051 : (CPU) Central Processing Unit
Total Page:16
File Type:pdf, Size:1020Kb
Mechatronics 1387Spring 8051 +P+KJ1+@8$ O5 >.K8$J1+@8$ %+@F(! 28P1 -.S O1O5 YData bus Y ROM Y RAM Y CPU ! (+' l@C E,G$) .K8Š$J1+@8$ u' "FS •Dc Peripheral & Interface Ciruits YControl bus Y Address bus Address bus Data bus Countrol bus CPU Interface RAM ROM circuitry Peripheral devices (CPU) Central Processing Unit :$%&' ( )$* + , #!" ! CPU u' "FS *>7 8P/^ %.C"$ •.`T$ +.8Š$J1+@8$ u' •Dc 9'+hh "33 (Fetch & Execute Instructions) hhhhm); *+hc 1 2[^y (98$+h^ ') "h8F(! *hh>J 7^', (1 (Arithmatic/Logic Operations) "hh?G$ 1 "hh 3T$ Rhh8F(! whhh<) (2 (Sequence/ Timing Control) +.8Š$J jFKk$ •Dc jFKk$ R8F(! *, B$ 1 ˆ8+ -+KJ (3 : ! CPU u' "F:% •Dc Instruction Program Register (IR) Counter (PC) *+, m); *%/ : CPU "F:% *hh>2[^y ' Registers Ch,"$ "S: \hhŽ$ *+, +p'% *%/ 1 "$.(! \hhŽ$ Special purpose (Stack pointer ' Status Register hh)$) Instruction Registers decode and */, v: a%; I)mp) : (PC) program Counter countrol unit 2[^y % (next instrudion) */, "h8F(! J ' 2$)+, General purpose Arithmatic Registers and Logic unit B$+^ *+, binary J : (IR) Instruction Register .%.C "$ *mp) IR % Y+c -y% (instruction) G.R. Vossoughi, Sharif Univ. of Tech. 5 Mechatronics 1387Spring instruction *+, binary hJ (2h(c+) +8 / lh$! : Instruction Decode/Control unit instruction B%1;% +hhc 2, 7mc (I+8€ 1 "hhP+KJ R8F(!) 8) %.$ R8F(! w<) 1 IR % %.c.$ +[)%.$ 98$+^ E z +,) "_' 1 "?G$ R8F(! B%1;% +hhc 2, l$! : Arithmatic Logic Unit (ALU) (Instruction decoder / Control unit "K^'% *+c 1 2[^y 98$+^ ' "8F(! *hhhh>J ",', CPU J 9'+ I(! C IhhC •A H 2J .G)hh(> .%.C "$ 2K#W fetching 2[^y "8F(! *>J ' instruction ",', 2, . C, "$ m); .C, "$ +' ly+$ l$C %.: 2[^y 98$+^ B%+J (Fetch) ",', 2Fy+$ ' R8F(! .%.C "$ 2KCVW Address bus *1 +, Program Counter (PC) *.KT$ O1 .%%+W "$ -/^ READ "P+KJ -p83 O2 I%% +H data bus *1 +, 1 IC Ih).: 2hz.,+$ a%; (data) K'% ' (instruction) 98$+h^ O3 .%.C "$ IR "hhF:% +hhhK`8c B1% 2, data bus *1 (instruction code) .hh,D$ Bhh$+^ O4 .%%+W "$ l?K$ (Instruction Register) (*/, Fetch l@83 *+, "hhhW%$; 7mc) %.C "$ I%% &'D^ (Program Counter) PC *.KT$ O5 CPU Address bus N Program Data bus Counter Opcode Instruction RAM Register N+2 Control bus Clock N+1 Opcode N Read N-1 G.R. Vossoughi, Sharif Univ. of Tech. 6 Mechatronics 1387Spring IC ",', B$+^ ' J +8 / l$C (Execution stage) 98$+^ *+c 2Fy+$ ' Rh8F(! *.hhKT$ -3 7mc h8)%.$ "hP+KJ *hhhmPp83 8P. Y (instruction decoding) *+c 7mc 8)%.$ "P+KJ *hhmPp83 8P. 1 e@/P, 1 ALU B1% 2, "F:% *h>register .C, "$ ALU v3. "_' 1 "?G$ R8F(! v3. l$J .G, CPU %+@F(! 1 >%"$ l8@n 2$)+, u' Y 98$+^ 1 "8F(! *>J 2!.(<$ Program “drives” the CPU : %%+W "$ }kn$ 2$)+, (Address, Data & Control bus) "$ ( ) 12 3 . /0/ :$%&' ()$* + , #- 2K^+W @, "J+Kn$ \> , 2J -hp83 7'> •.G: ' Z83 *%/ 73 l@nK$ (bus) IWVW u' .'%+W }kn$ instruction Fetch &k, % *y .,D$ IWVW 23 u' +> &?) 1 %+@F(! . ).C "$ +tJy ">%a %; "'hh). .,D$ cpu YC, 78, n *% cpu u' *+, a, a%; [email protected] % 9' VhP 1 73 "K8,16 a, a%; 8051 +hhhP+KJ1+@8$ *+, . 7C% hh>.: 7', 2n 65535 .C, 2KC% 2[^y 64Kb = ' 65535=216 +tJy ). "$ +P+KJ1+@8$ 1024 lh@83 +> % 2J 73 w.m#$ 9', 9' YC, 78, n *% CPU u' *+, a, hK'% [email protected] % 1 HD )h$) I/O " )c RD8m< 1 2[^hhy Y CPU 98, I%% 78, n v?^ write ' Read Zm$ l$.! "@' ( a,K'% •.G: %/ ') data bus ’+! VP .%%+W "$ l?K$ (... 1 .hK8)$ IJ 988/ Zm$ *h>2Žkn$ 1 '%+W •.`T$ +.8Š$J1+@8$ u' B1% R!Az -%hh 7!+3 .`31+f1+@8$ 2J %.C"$ 2K#W "KH1 •A h t $ .%%+W "$ •.`T$ CPU v3. R!Az 0%+f 7!+3 .73 "K8, 32 data bus .`31+f1+hh@8$ 9' % 2J 73 w.m#$ 9', 9' 73 "K8, 32 Y P-IV .73 "K8, 8 a, K'% 8051 % . 73 2^+z 1% I.(> a,K'% [email protected]% (uni-directional) 73 2^+hhhG@' I.(> a, a%; G.R. Vossoughi, Sharif Univ. of Tech. 7 Mechatronics 1387Spring -hhh?K) jFKk$ R8F(! IJ “>(> &?) 2J 73 "'hhhmPp83 * 2!.(<$ l$C a, -+KJ B. "$ mPp83 2hhh).p' *2hh).() .C,"$ % Im! a,K'% 1 a, a%; *1 +, R!Az 1 I%., ‰.K$ 8`, m); &?) 1 "P+KJ *hhmPp83 %/ 1 w) .%+, w) WRITE 1 READ 1 Clock .%% CPU ‰.) 2, *%' "pK`, ,)$8 )) 5 67% :$%&' ()$* + , #4 CD-ROM Y HDD Y FDD )$ : (mass storage) I. ) *hh3I+8:” RDh8m< - Y Keyboard Y+hhK'+f Y-8$+ )$ : (Human interface) B`) , • RD8m< - speaker Y Mouse :• l$.! *>%+, ' >$ *>R+f 1 profi Y 7)+K' *hhh>2@ C : (Communication) "z RD8m< - 2G31 -'+3 1 *.$ >+pF(! 1 >.`3 ‰.) )$ : “'.K8).$ 1 "P+KJ RD8m< - : 9$ :$%&' ()$* + , # Application B./, %hh3 "$ +H+, user , Z8?K`$ •hh 2J *Dhh^ w+) i].(/$ • % D^ 7k3 , *D^w+) 2'] 1% E'+z D^ w+) 9' Y%.C "$ 2K:hhC Software .73 ‚'+n l,H l,?$ w+W'% v3. K:3 9' .C, "$ Application Software Dh^ 7k3 hh, Z8?K`$ .hhhhG, Input/output Subroutines (user interface) a( % (... 1 A/D 1 D/A %+, 1 HD YCRT Y keyboard )$) Operating System 98† E'+z +h.8Š$J u' *>"c1+: 1 > *%11 28FJ 1 I%., hh> Subroutine 2hh).p' .%+8W "$ w<) "'hhh>Subroutine Input/output routines ' Basic I/O System )hh$) IC *mp) ROM % “•$.(!“ (access to hardware) .).C "$ 2KC.) assembly B, 2, •$.(! 1 (IBM-PC % BIOS Hardware *hhh>+K$f %11 , •$.(! I/O subroutines I%hhh#K3 B%+J initialize E'+z (Subroutine parameters ) 2hhhz.,+$ E'+z 2FSy •'K) Y subroutine call w<) ef 1 I'%+hW h€; CPU *hhhh>+K`8c *%/ .%.C "$ 7^', RAM % "Žkn$ *h> a%; E'+z ' 1 CPU *hhhh>+K`8c +p'% *%/ G.R. Vossoughi, Sharif Univ. of Tech. 8 Mechatronics 1387Spring B%+hhhJ reset ef 2n8(> 2J 73 start-up 2$)+, u' *1y ROM Yh> I/O subroutine +, I1A! 2, (pc) program counter I.hhhh(> Y CPU B%+hhhhhJ reset ef .%%+hhhW "$ -hhh/^ CPU B(> ) .,D$ a%; % %.c.$ 2h$)+, VP 1 2K^h' +88— – 0000H •].(/$ – ROM B1% "hhkn$ a%; *+p'% a%; 2, jmp u' 0000H a%; % ˆF€ 2K P) '%+W >.: +c CPU v3. (startup 2$)+, 1 2[^y B%+J u† B.‹(> "hh8F(! w<) +, I1A! Start up 2$hhhhh)+, ( ... 1 %+8W "$ w<) ROM % Track Y Bootstrap Loader w, ROM B1% +p'% routine u' B% S , Y-.(/$ *hh> ",'ˆ8! Operating "K(`H 2$)+, 9' .)Š3"$ B, -+KJ 1 I).:+^ RAM lh:% 2, uh`'% -1 .)Š3"$ B; 2, -+KJ 1 I).:+^ (RAM) 2[^y l:% 2, u`'% *1 system (DOS Command Language hhh)hh$) user interface 9h8$h +, I1A! Operating Sytem .C, "$ Application Software 8P. 1 "`'.)2$)+, 2, B8nk, 7P.m3 7mc "'hh>D, *% +P+KJ1+@8$ 1 .`31+f1+@8$ 98, R1# O2O5 "8$ %) 7`8) IC I%% +H IC u' *1 +, 2J CPU u' Dc *D8† .h`31+f1+@8$ •].S (73 %+, 9'† "Ky 1 IC 9'† l@nK$ %.: CPU > main frame 1 >+.Š8$J +P+KJ1+@8$ u' % Z8), +' w+W'% % IC I%% Bn) •Dc l@nK$ +.8Š$J1+@8$ u' +W hh)$) Rhhh8S.Ž: 8`, % •$.(! 2K P . 73 IC I%% *c IC u' % I%+ $) •Dc 28FJ u' (interrupt ' 2#H1 •.G: %/ 1 -'+3 *hhhhhh>R+f %/ Y ROM 1 RAM &'<W h, .,D$ *> 7'%1T$ 2K P .C, +.8Š$J1+@8$ u' +%1T$ 8`, 73 9@($ +P+KJ1+@8$ .73 28c. l,H ("P+KJ *>ZK`83 %) >+P+KJ1+@8$ %+,J %.$ 2, 2c. External External Serial Parallel Clocks interrupts Device Device Internal Clocks Interrupt Serial Parallel Timers control interface interface CPU RAM ROM G.R. Vossoughi, Sharif Univ. of Tech. 9 Mechatronics 1387Spring *c IC u' % (+hhhP+KJ1+@8$ %+,) "P+KJ %+, u' 7:3 *+, 8) %.$ •Dc ˆF€ 2@' 2, 2c. , 1 "y+z 2'D> 9' 2J C,"$ 7:3 l,H IC "(J 8`, %/ , +P+KJ1+@8$ *>%+, VP IC I%% .%%"$ 2p) 98'f 8`, >%+, 2).p' 7:3 "'). 9' h, .73 (interrupts) 2#H1 0%+f % m); "'). Y>+P+KJ1+@8$ "FJ *> 2Žkn$ "@' ' clock *hhhhh>e Pf )$) jFKk$ (events) b'H1 2, )."$ (+hhhP+KJ1+@8$) "P+KJ ZhhK`83 .C, .pk3f •/'+3 ( *+G_ *>78/_1 98$+^ ' "8F(! J %/ 1 j8z % +P+KJ1+@8$ 1 .hhh`31+f1+@8$ u' 98, *> R1# +p'% "@' , B%+JJ "'). Y(98p3) R!Az 0%+f \> , .hhh`31+f1+@8$ u' .73 (instruction set) 1 I'%+W "y+z ... 1 (arrays) •D, *>2'; , B%+J J 7P.m3 Y"K', 8 1 "K', 4 Y"K',2 *>I%% . C, "$ >%+,J 2).p' *+, "S: (instruction) "8F(! *>J *% VP C, 2,n$ *>J 1 2P u' B%+J 0.$: 1 9C1 \> 73 9@($ +hP+KJ1+@8$ u' % 2@); -y u' % %.c.$ ">% a%; *>$ 1 > instruction *8`, Y2hh'D> 9KCmp) 98'f .[(, Y1 9' v3. l?K`$ .G, > 78, -+KJ "'). 2@); -y Y%.C "() I'% +hhhP+KJ1+@8$ u' % .`31+f1+@8$ 1 hhhh> instruction %/ &'D^ , ) .73 +'Vf B@$ +P+KJ1+@8$ % "S: *hhhhh> instruction %1y 8051 +P+KJ1+@8$ u' % -t$ *+, . ,' "$ &'D^ • / , + 3 ... 1 7:3 1 "y+z *hh> 2'D> 80286 .hh`31+f1+@8$ u' % 2K^ @, .K`'D)+ %/ 2@); -y 1 2K^ @, .hK`'D)+ 60/000 .K`'D)+ B.8F8$3/1 %1y pentuim u' % 1 B.8F8$1/2 %1y 80486 u' % 1134/000 %1y (. 73 IC \+Ž$ B.8F8$ 42 %1y Pentium IV .K`'D)+ B.8F8$ 5/5 %1y pentiume pro % 1 G.R. Vossoughi, Sharif Univ. of Tech. 10 Mechatronics 1387Spring MSC-51 I%.): *>+P+KJ1+@8$ *D^7k3 Rkn$ O3O5 , 2, INTEL 7J+C v3. 1980 2>% l'1 % 2J K`> >+P+KJ1+@8$ *I %.): MSC-51 8K$ 9hK^+W , philips 1 Fujitsu Y AMD Ye(' )$ jFKk$ *hhh>7J+C e3 1 IC 2_+! : )%.() 2_+! , 2, (%.: ™: *>"').