giao trinh kien truc may tinh 8891

Download Giao Trinh Kien Truc May Tinh 8891

Post on 16-Nov-2015

15 views

Category:

Documents

10 download

Embed Size (px)

DESCRIPTION

Giao Trinh Kien Truc May Tinh 8891

TRANSCRIPT

GIO TRNH KIN TRC MY TNH

GIO TRNH KIN TRC MY TNH

GIO TRNH KIN TRC MY TNH

CHNG I. GII THIU CHUNG V KIN TRC MY TNH.

I. Khi nim v kin trc my tnh

Kin trc my tnh (Computer architecture) l mt khi nim tru tng ca mt h thng tnh ton di quan im ca ngi lp trnh hoc ngi vit chng trnh dch.

Ni cch khc, kin trc my tnh c xem xt theo kha cnh m ngi lp trnh c th can thip vo mi mc c quyn, bao gm cc thanh ghi, nh cc ngt ... c th c thm nhp thng qua cc lnh.

II. Lch s pht trin ca my tnh.

Chic my tnh in t u tin l ENIAC c ra i nm 1946, c ch to t nhng n in t, rle in t v cc chuyn mch c kh.

Lch s pht trin ca my tnh in t c th chia lm bn th h nh sau:

- Th h 1: (1945-1955). My tnh c xy dng trn c s n in t m mi n tng trng cho 1 bit nh phn. Do my c khi lng rt ln, tc chm v tiu th in nng ln. Nh my ENIAC c khi lng 30 tn, tiu th cng sut 140KW.

- Th h th 2: (1955-1965). My tnh c xy dng trn c s l cc n bn dn (transistor), my tnh u tin th h ny c tnl TX-0 (transistorized experimental computer 0).

- Th h th ba: (1965-1980). My tnh c xy dng trn cc vi mch c nh (SSI) v c va (MSI), in hnh l th h my System/360 ca IBM. Th h my tnh ny c nhng bc t ph mi nh sau:

- Tnh tng thch cao: Cc my tnh trong cng mt h c kh nng chy cc chng trnh, phn mm ca nhau.

- c tnh a chng trnh: Ti mt thi im c th c vi chng trnh nm trong b nh v mt trong s c cho chy trong khi cc chng trnh khc ch hon thnh cc thao tc vo/ra.

- Khng gian a ch rt ln.

- Th h th t: (1980- ). My tnh c xy dng trn cc vi mch c ln (LSI) v cc ln (VLSI).

y l th h my tnh s ngy nay, nh cng ngh bn dn pht trin vt bc, m ngi ta c th ch to cc mch t hp mc cc ln. Nh my tnh ngy cng nh hn, nh hn, mnh hn v gi thnh r hn. My tnh c nhn bt u xut hin v pht trin trong thi k ny.

Da vo kch thc vt l, hiu sut v lnh vc s dng, hin nay ngi ta thng chia my tnh s th h th t thnh 5 loi chnh, cc loi c th trm ln nhau mt phn:

- Microcomputer: Cn gi l PC (personal computer), l nhng my tnh nh, c 1 chip vi x l v mt s thit b ngoi vi. Thng dng cho mt ngi, c th dng c lp hoc dng trong mng my tnh.

- Minicomputer: L nhng my tnh c trung bnh, kch thc thng ln hn PC. N c th thc hin c cc ng dngm my tnh c ln thc hin. N c kh nng h tr hng chc n hng trm ngi lm vic. Minicomputer c s dng rng ri trong cc ng dng thi gian thc, v d trong iu khin hng khng, trong t ng ho sn xut.

- Supermini: L nhng my Minicomputer c tc x l nhanh nht trong h Mini nhng thi im nht nh. Supermini thng c dng trong cc h thng phn chia thi gian, v d cc my qun gia ca mng.

- Mainframe: L nhng my tnh c ln, c kh nng h tr cho hng trm n hng ngn ngi s dng. Thng c s dng trong ch cc cng vic sp xp theo l ln (Large-Batch-Job) hoc x l cc giao dch (Transaction Processing), v d trong ngn hng.

- Supercomputer: y l nhng siu my tnh, c thit k c bit t tc thc hin cc php tnh du phy ng cao nht c th c. Chng thng c kin trc song song, ch hot ng hiu qu cao trong mt s lnh vc.

Da vo kin trc ca my tnh ngi ta cng phn my tnh ra cc loi khc nhau nh sau:

- Kin trc SISD (single instruction - single data, n dng lnh - n dng d liu), s nh hnh 1-1.

Hnh 1-1: Kin trc my tnh SISD.

- Kin trc CIMD (Single Instruction Multiple Data, n dng lnh- a d liu), s nh hnh 1-2.

Hnh 1-2: Kin trc SIMD.

- Kin trc MIMD (Multiple Instruction Multiple Data, a dng lnh- a d liu), s nh hnh 1-3.

Hnh 1-3: Kin trc MIMD.

CHNG II. BIU DIN THNG TIN TRONG MY TNH

I. H nh phn (Binary)

I.1. Khi nim:

H nh phn hay h m c s 2 ch c hai con s 0 v 1. l h m da theo v tr. Gi tr ca mt s bt k no tu thuc vo v tr ca n. Cc v tr c trng s bng bc lu tha ca c s 2. Chm c s c gi l chm nh phn trong h m c s 2. Mi mt con s nh phn c gi l mt bit (BInary digiT). Bit ngoi cng bn tri l bit c trng s ln nht (MSB, Most Significant Bit) v bit ngoi cng bn phi l bit c trng s nh nht (LSB, Least Significant Bit) nh di y:

23 22 21 20 2-1 2-2

MSB1 0 1 0 . 1 1 LSB

Chm nh phn

S nh phn (1010.11)2 c th biu din thnh:

(1010.11)2 = 1*23 + 0*22 + 1*21 + 0*20 + 1*2-1 + 1*2-2 = (10.75)10.

Ch : dng du ngoc n v ch s di k hiu c s ca h m.

I.2. Bin i t nh phn sang thp phn

V d : Bin i s nh phn (11001)2 thnh s thp phn:

Trng s v tr: 24 23 22 21 20

Gi tr v tr: 16 8 4 2 1

S nh phn: 1 1 0 0 1

S thp phn: 1*24 + 1*23 + 0*22 + 0*21 + 1*20 = (25)10

I.3. Bin i thp phn thnh nh phn

thc hin vic i t thp phn sang nh phn, ta p dng phng php chia lp nh sau: ly s thp phn chia cho c s thu c mt thng s v s d. S d c ghi li lm mt thnh t ca s nh phn. Sau , s thng li c chia cho c s mt ln na c thng s th 2 v s d th 2. S d th hai l con s nh phn th hai. Qu trnh tip din cho n khi s thng bng 0.

V d 1: Bin i s thp phn (29)10 thnh nh phn:

29/2 = 14 + 1(LSB)

14/2 = 7 + 0

7/2 = 3 + 1

3/2 = 1 + 1

1/2 = 0 + 1(MSB)

Vy (29)10 = (1101)2 .

i vi phn l ca cc s thp phn, s l c nhn vi c s v s nh c ghi li lm mt s nh phn. Trong qu trnh bin i, s nh u chnh l bit MSB v s nh cui l bit LSB.

V d 2: Bin i s thp phn (0.625)10 thnh nh phn:

0.625*2 = 1.250. S nh l 1, l bit MSB.

0.250*2 = 0.500. S nh l 0

0.500*2 = 1.000. S nh l 1, l bit LSB.

Vy : (0.625)10 = (0.101)2.

II. H thp lc phn (Hexadecima).II.1. Khi nim:

Cc h my tnh hin i thng dng mt h m khc l h thp lc phn.

H thp lc phn l h m da vo v tr vi c s l 16. H ny dng cc con s t 0 n 9 v cc k t t A n F nh trong bng sau:

Bng 2.1 H thp lc phn:

Thp lc phnThp phnNh phn

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

150000

0001

0010

0011

0100

0101

0110

0111

1000

1001

1010

1011

1100

1101

1110

1111

II.2.Bin i thp lc phn thnh thp phn.

Cc s thp lc phn c th c bin i thnh thp phn bng cch tnh tng ca cc con s nhn vi gi tr v tr ca n.

V d : Bin i cc s a.(5B)16. b. (2AF)16 thnh thp phn.

a. S thp lc phn: 5 B

Trng s v tr: 161 160

Gi tr v tr : 16 1

S thp phn: 5*16 + B*1 = (91)10.

b. S thp lc phn: 2 A F

Trng s v tr: 162 161 160

Gi tr v tr : 256 16 1

S thp phn: 2*256 + A*16 + F*1 = (687)10.

II.3.Bin i thp phn thnh thp lc phn.

bin i cc s thp phn thnh thp lc phn, ta s dng phng php chia lp, vi c s 16.

V d : Bin i (1776)10 thnh thp lc phn.

1776/16 = 111 + 0 (LSB).

111/16 = 6 + 15 hoc F.

6/16 = 0 + 6 (MSB).

S thp lc phn: (6F0)16.

II.4. Bin i thp lc phn thnh nh phn.

Cc s thp lc phn rt d i thnh nh phn. Thc ra cc s thp lc phn cng ch l mt cch biu din cc s nh phn thun li hn m thi (bng 2-1). i cc s thp lc phn thnh nh phn, ch cn thay th mt cch n gin tng con s thp lc phn bng bn bit nh phn tng ng ca n.

V d: i s thp lc (DF6)16 thnh nh phn:

D F 6

1101 1111 0110

(DF6)16 = (110111110110)2.

II.5. Bin i nh phn thnh thp lc phn.

bin i mt s nh phn thnh s thp lc phn tng ng th ch cn gp li thnh tng nhm gm 4 bit nh phn, bt u t du chm nh phn.

V d: Bin i s nh phn (1111101000010000)2 thnh thp lc phn.

1111 1010 0001 0000

F A 1 0 S thp lc phn: (FA10)16.

III. H BCD (Binary Code decimal).

Gia h thp phn v h nh phn cn tn ti mt h lai: h BCD cho cc s h thp phn m ho bng h nh phn, rt thch hp cho cc thit b o c thm phn hin th s u ra dng cc loi n hin s khc nhau. y dng bn s h nh phn (bn bit) m ho mt s h thp phn c gi tr nm trong khong t 0..9. Nh vy y ta khng dng ht cc t hp c th c ca 4 bit; v tm quan trng ca cc s BCD nn cc b vi x l thng c cc lnh thao tc vi chng.

V d: (35)10 = (00110101)2.

IV. Bng m ASCII.(American Standard Code for Information Interchange).

Ngi ta xy dng b m biu din cho cc k t cng nh cc con s V cc k hiu c bit khc. Cc m gi l b m k t v s. Bng m ASCII l m 7 bit c dng ph bin trong cc h my tnh hin nay. Vi m 7 bit nn c 27 = 128 t hp m. Mi k t (ch hoa v ch thng) cng nh cc con s thp phn t 0..9 v cc k hiu c bit khc u c biu din bng mt m s nh bng 2-2.

Vic bin i thnh ASCII v cc m k t s khc, tt nht l s dng m tng ng trong bng.

V d: i cc k t BILL thnh m ASCII:

K t B I L L

ASCII 1000010 1001001 1001100 1001100

HEXA 42 49 4C 4C

Bng 2-2: M ASCII.

Column bits(B7B6B5)

Bits(row)

000 001 010 011 100 101 110 111

R

O

WB4B3B2B101234567

00000NULDLESP0@P\p

10001SOHDC1!1AQaq

20010STXDC22BRbr

30011ETXDC3#3CScs

40100EOTDC4$4DTdt

50101ENQNAK%5EUeu

60110ACKSYN&6FVfv

70111BELETB7GWgw

81000BSCAN(8HXhx

91001HTEM)9IYiy

A1010LFSUB*:JZjz

B1011VTESC+;K[k{

C1100FFFS-N^n~

F1111SIUS/?O_oDEL

Control characters:

NUL = Null; DLE = Data link escape; SOH = Start Of Heading;

DC1 = Device control 1; DC2 = Device control 2; DC3 = Device control 3.

DC4 = Device control 4; STX = Start of text; ETX = End of text;

EOT = End of transmission; ENQ = Enquiry; NAK = Negative acknowlege.

ACK = Acknowlege; SYN = Synidle; BEL = Bell.

ETB =