11. HS: t 0(- I + I (t = 4); Quay h.li huoc 32; 12. Il2: Gii Iri d"" vao ( h; 0 ): L" = I ( c; 0 ) J: 13. B3: Kitlll Ira L.j' L.\ = I (c I ) \, L.j"* 0: Tln.rc hicn huo-c J3.4: 14. B4: Do L.jlrung vo-i gia Irj hl¢n thoi (c; I ), Ihlfc hi~n hlf6c B5; 15.35: I 0(- I + 1 ( 1=5); Quay I~li bulic H2; 16,82: C.ic lin hi¢u \'ao kh6ng Ihay deli gia tr!; Thvc hi¢n 33: 17,133: Kiem Ira L.\, L,:::: 0, chuyt::n tlii blfOC 35: 18. H5: I <- t + I ( t = 6 ); 19, 32: Cac tin hi¢u vao kh()ng thay doi gia Ir!; Thlfc hi¢n 33; 20.133: Kicm tra Lt., L(, = I (c; 0 ) I, L(, *0 . ThLfc hi¢n bu6c B4: 2 L 84: GiLi tr! hi~n thai dugc thiet 1~lp bang ( c: 0 ); Cuoi cung, ta nh~tn dU<;1c gi:1ll el6 thai gian nhu tren hlnh 5.32. Trong trlfong h<;1p khi qua trlnh phftn lich va 1116 hinh hoa m; lch c6 slr dl,lng de mo hlnh tre kh6ng xJ.e djnh, de tlu,te hi¢n de tinh toan eho vi¢e Xfly dVng danh "aeh SLf ki¢n, la dn phui h"inh th~mh dU<;1c de s~r ki~'n xu,11 hi¢n lrong khO<.ing thoi gian giCra C<_le gi,i Ir! d.11l va .'\\1' r ;lllr Irong vi du doi voi mi \Ch Ircn hinh 5.32, ne'll phan tli OR CO' do In? khdng de djnh \'6i gia Irj clfe tieu d.",= 2 va gia Ir! qre d".li .0 ~,=3, khi do huae thu hai lrang tr~ll t~r tfllh toan neu Iren se dU<;1c ghi nhlf sau: L, = I ( c; U ) }, L, = I (c: I ) J: Sau et6 qua trinh m6 hlnh hoa va m6 phong huong "If ki~n sc duqc tlll.re hi¢n nhu hlnh thu()"ng chi din tinh den gia tI"! 'U'. 1l1cm vao do, do trang qua tdnh 111l.) hlnh hll;} ta ph,ii licn II,IC t' IO them nhCrng danh sach sl,l' ki~n mdi, Iho'i gian Ilwc hi¢n m6 hlnh hoa sc t~U1g kn khi phiii xu 15' cae danh ""tch sl,l' ki¢n. "[\;'(:'u trong qua trlnh phtm tich V~I m6 hlnh hoa 111' lch crin ph"ll Slf dl,lng md hinh v6i Ire quan linh, la dn phili bien d6i Ihui~t tmin va thel11 vao d6 nhiJng Ihao I,i.e t[nh loCU1 tLf<mg ling. Hem nil'a, do vi~c dn thiet ph,,'li Slf clL.ll1g 1'.Ii nhDng SIf ki¢n dJ dUi)'c xLr Iy, ta can phili tang chi phi \'6 Ill;)t b(l nha vii Ihi.\i gian Iinh tmin, Dc nang cao d(l chlnh xac ella qUii Irlnh ph[m tleh m~lch thea Ihoi gian V~l m() hlnh hoa hU'6ng Slf ki~n, cluing la phili Ihu nha d(l\6n ella IUt!ng Ill' thbi gian n. Dicu n(IY SC dim d6n vi~c I[mg dung IUt!ng h6 nh6 dt:: lUll IrQ' de SlY ki¢n Irong truong hQ'p ta gill c(m li-en ve thoi gian Ill<> phong M kh()ng doi. Dc gi;ii quyet van de nay ta ph;H dua fa nhl1ng hien the" thich h<;1p ella phuong philp ,-Inh X".I thoi gian vii phuong phap danh ",i.eh Slf ki¢n. 127 Trl'll 111l.Ie k·. m(H lrong nhli'ng phuong phiip d~ 1[lIlg loc dCl eho qU{1 Idnh 1m) hlnh ho,1 \',\ m(J ph6ng Idgic 1,\ phuong ph.lp m6 hinh hOil. hm'mg sv kien. Vi~c Ifnh loan doi \'6i dc ph:in IV i<)gic chi du(.1'c Ihl!e hi¢n khi ~!l{\ Ir~ lin hi¢u khac \'(~)'i nhU"ng gl,l. trj d5 duqc tinb. U"U diem cLla phuong ph{lp mtl hlnh ho,1 Inf6ng sl! kien E\ qu,t trlnh tinh toan chi Ihl!c hi~n kill c6 UIC sl,l' ki¢n xU:lt hi~n lrong mach, trong khi do khi d.c gia tr.i dau \'~IO Ihay doi. trung hlnh chi etl 2.5'l de tin hieu Irong mach Ihay dOL gia Ir!. Dl~u (kl l~lIn tflll); !TI()t deh d,lllg kc 16e el\) qua Irlnh 1116 hlnh hOii noi chung. Khi Ih~rc hi¢n m6 hlnh hoa trCIl11lll'C d.c ph:ln ttl' logic. la c6 lile xac dinh m(ll ckh d~ d~U1g sl! lilay doi gi,i trj tren c,ic tlubng lin hi¢u fa ella de rh;\n lif dl,fa \'~10 CiIC gl{l trj d::J.u \,~IO ella ph,\n Ilt d6. Vi Llt,l. nc"u Iren m(ll Irong nhung (h\u d.O ella phiin Ilf AI"D gia Irj tin hi¢u kh()l1g deli \'~I b{lIlg '0', khi tltl gi{\ trj lin hi¢u Ircn cMu ra ~l: kh6ng Ihay doi khCll1g ph~l thuQc <10 'il.r Ihay dOL elm gia II"! lin hi¢u Ireil d.e (Hiu \,,~IO khile clla ph,-In ILL D6i \"(')"i ph:in IiI" OR. gia II"! kh()llg d6i htmg 'I' Iren m(ll lrong nhiJng d iu do ~l' d:illl h,ll) kh(ll1g c6 S~I" Ihay c1()J gi,i Ii"! tin hi¢u tren d:ill ra. Nell chl! Y' I{ii nhL"i'ng linh ch,"\1 clb pbrin tlf 16gie. ta c6 the don gi,in boa \'icc tinb IO,-ln trong qll'l Irlllh m6 hlnh boa mtli klli c6 dlC S~f kl~n xuat hi¢n trong lllach. I\'hu \,(Iy. lrong chuang nay chung 1<1 el,! nghicn (Liu nhfing \';"(n (1(' lien quan I{'il qll,i Irlnh 1110 hloh hoa \,:1 1116 phong lll' Ich. 0JhCfng \'~tn de: quan In.m,!! HI lilt hi¢n dU'<)"c h<\11 u(lIlg eua n1i.\ch theo t[H':ii giall \';1 h~lllh \'i l:lln Ire lin hi¢u ella cae phfin ILr logic Irung 1ll',leh. 12X Rai t~p cho chuang 5 1. Hay Slr dl,l!1g phuong phap mo phong btmg bien dieh ::; gia Ir! mo la hoat d9ng ellil 1TIi.ICh Ir6n hlnh 85.1. Mi.tch hO<.~1 d0ng "oi In.mg thai ban (1<.iu Q = u d6i voi vccW gia Irj dfiu vao: "01" Va "! I". A B ~ c D Q , jC IIInh MS.I C K 2. 1 lay slr dl,11lg phlwng phap mo h1nh ho<.1. btmg bien dich mo lil hm.lt d¢llg m<.tch tren hlnh 5.15a d6i voi cae vccta duu vao "00" va "11". Gi,-l thiet r~ng trang m6 hlnh, hai duang Q va NQ deu c1u(jc coi Iii. d.c duang tin hi~u phan hoi voi c19 tre bang nhau. 3. Hay l~p chuang trlnh In~n ngon nget l~p Irlnh truyen thong ( Pascal, C, C++, ) m6 ti.\. diu true va ehuc nang eua phan 111 triga RS master-slavc theo phuong phap hu6ng sl! ki~n. 4. Hay l~p chuang trlnh tren ngon nget l(lp trlnh truyen thong ( Pascal, C, C++, ) mota cAu tnk va chue nang eua thanh ghi d~eh 4 bit theo phuang phap huong .w ki¢n. 5. Hay l(tp chuo'ng trlnh tren I1gon nget I(lp trlnh truyen thong ( Paseal, C, C++, ) me d. cl'u true va ehue nang cua b¢ e¢mg 4 bit thea phuong phi.lp huong sl! kit;n, 129 CHUONG VI. NGON NGO" MO HINH HOA VHDl §6.1. M& dall "gon ngfr VHDL 1. Nhung khai ni~m chung YC "gon ngil VHDL Cae phuong phap thiet kC:' dVa tfen co sb ella cae ng(l]} ngu HDL ng;ly dog Irl1 nen ph6 bien. Cae ngon ngll' 1m) t,i phan cung HOL dugc cae nba thiet ke m,-~ch slr dl;lng chit y6u d~ m6 ta cau true ho~c hanh vi ella cae h~ thong so eho qua trlnh m6 ph6ng ho,~c thiet ke", Phuong phap tiliet kc Iren cO sa cUe ngon nget HDL so \'oi cae phuo'ng phar thiet ke truyen thong tren co Sl1 C{Hl cae cang logic c6 cae Ull diem Sau: Cic phuong phap nay eho phcp lung nang sual thiet kc, no eho phep nha thi6t ke ton it thai gian han ,,-a eho phcp nhung nguCii kh6ng can kien thuc sau ve ph:ln cung c6 the thiel kc phan cung. Phuong phar thiet kc dlfa tren cae ngon ng['r HDL kha co dQng w1'i nhung c6ng ngh~ khac nhau. Cae mo tii tren de ngon ngl1 HDL eung dip cae tai li~u dge l~p v6i phan cUTig cua ITI<;lch di¢n. Su dy.ng d.c chuang trlnh ti~n feh h6 tr0 thiet kc' ta e6 the ehuycn doi cac bieu dicn tren d.e ngolr ngu HDL thanh nhicu mue UTig dl,lllg el10 nilCmg cong I1gh¢ khae nhau. Ngon ngu VHDL ( VHSIC Hardware Description Language) la ngon ngiJ duqc slr dy.ng pho bien trong cong ngh¢ che t~o cae m;:teh VLSI. VHDL duqc eong nh~n la ngon ngii tieu ehuan trong mo d. phdn cling ella IEEE ya clla H9 Quac phong M)'. Vc m,~t ell phap, ngon ngii VHDL HI. m9t ngon ngii duqc drnh kicu ch~t ehe va co m¢t t~p hqp IOn cae c,lu 1¢nh. Ngon ngil: VHDL ho Irq cac phuong phap mo tA nhiel! lap trong do cac thanh pha.n eau Irue ho~e m'.l.llg Iuai cac ph:in tu- co Iht di doi vai cac rno ta hanh vi ho~e d.c thu,~t toano VHDL cung cap kha nang mo tii. cua m<;lch so tren nhling mtl'e d¢ truu tuqng khac nhau: muc thu~t toan; muc cac lhanh ghi, h~l.\n truybn d~t; muc cae eong logic. Nhit thiet ke' c6 the su: (iI,ll1g chien lU<;ic thiet kc tu tren xuang, dau tien mo d. thict ke tren mUc kicn truc, sau d6 chi tiet hO<1 tlmg bl10e thiet ke'. Vi dl,l ta co the mo Iii m~ch so sanh 1119t hit bang ngon ngii VHDL thea 131 nhfrng muc dQ chi tiet khac nhau. M';lch nay bao gam hai dau vao vii mQt dau fa vai cac tin hi~u t~i cac dilu nay la cae tin hi~u so. Nhu V~ly m~tch se . tUCing lIng v6i mQt tlll!C the co hai cHiu vao va mOt dau ra. Kien tnk cua mi.lch d~c t,i quan h¢ gifra cHiu vao va cHiu fa cua m,!-ch va co the mo til thea hanh vi , dong truy~n du li¢u qua m~eh, ho~c theo diu truc eua mi.lCh. 132 M6 ta tren mue th1!C the Tren m(rc thl!C the, ta mo tii ve soluqng d.e ding vao ra cua nwch va cae d'.\Ilg tin hi¢u t<.Li cae c6ng do. Trong vi dJ,L \'e Im.teh so sanh mOt bit, mi tch c1u<;1e rna tii bang rnQt ti1l!e the baa g6m hai c6ng vao va mOt cang ra. Cae du li~u t,!-i cae eang nay la cae bit. enlily COMPARE is porI ( A, B: in BIT: C: oul BIT ); end COMPARE; Mu ta m~ch bang hanh vi D~ mo til m~ch bang hanh vi. trong ngan ngiJ' VIIDL nguiJi la dimg cau truc process. Khi mo t<l. hill1g hanh vi. ta kh6ng can thie', phi.ti cung cap chi tiel \'c vi¢c 'ill!c hi¢n thiet ke. Trang vi ely. nay ta th,i)' mi~ch so sanh c1uQ'c mo ta hang m(lt qua trlnh proccs,>. Qua trlnh nay chiu ti.lc d¢ng clm hai tin hi~u la A va n. archilechlurc BEHA VIOR of COMPARE is begin process ( A, B ) begin if( A = B) Ihen C <= 'I': else C <= '0'; end if end process; end BEHA VIOR; Mb ta .bang dong dft Ii~u Thea bieu dicn bAng dong du li~u, h¢ thong dll<;1C bitu dien nhu cac lu6ng ehuyen d9ng eua cae tin hi¢u dieu khien va cae du li¢u. Thea phuong phap nay, ho';\t dQng eua ITIi.Wh duge bi~u dien nhu cae l!ii.lCh logic t6 hqp, nhu rn,!-ch c(;lng, lm~ch so sunh, m~ch giai mao D6i voi vi oy ve l11i;lch so sanh, ta thay tin hi¢u C duryc gan gia tf! cua bicu thuc logic eua A va B sau lTIQl thai gian 10 ns sau khi co sy· lhay doi gi,i tri tin hi¢u In:n de eong A, B. architechture DATAFLOW of COMPARE is begin C <= not (A xor B) after 10 ns~ end DATAFLOW; Mil hi rn<:tch bang diu truc D6i voi each me) la m~ch qua cau true, ta phai rna til cae lhanh phan cau true va rnoi lien kel giG:a cac thanh phan do. Trang vi dy v~ rn".lch so -",tnh cAu truc eua m<;tch g6m lTIQt phan til XOR e6 hai diiu "ao 10, 11, kel noi veri mQt philn til NOT. Dau ra eua phan IU XOR noi voi d{lu vao eua ph,in til NOT. Cau true ket noi tren duqc me) 1,\ bang dO<;l11 chucmg lrlnh VHDL architcchture STRUcrURE of COMPARE is component XOR_ Gate port ( 10, II ; in BIT; 0 ; out BIT ); end component; component NOT_Gate port ( 10 ; in BIT; 0; out BIT ); end component; signal NET _I ; BIT; begin UO; XOR_Gate port map ( 10 => A, I I => IJ, 0 => NET _I ); UI; NOT_Gate port map (IO => NETJ 0 => C); end STRUCTURE; 133 2. Qua trioh m6 phung Nhu dJ (16 e~p toi trong chuang 4. dc n.goo ngiJ' HDL luon di kem v6i c~e b(l !TIO phong. Ciic thiet ke Ircn llgon ngu YHDL se thlfc hi~n tren b9 rno phong YHDL d~ kiem Ira himh vi eua h¢ thong duqc mo hlnh hmL DC: tiii t';lo hO';lt d¢ng eua mo hinh. nha thict kc dn cung dip I~p hgp dc tiic d¢ng vao mo hlnh. Chuang tdnh mo phong se g~n de t~e d9ng do toi d~u vao clla rno hlnh li.ti nhiJ'ng thai diem Ihai gian x~e djnh va dlfa vao mo hlnh dua ra signal a signal b a b c C <= not (a xor b) after 10 ns signal c Hlnh 6.1 M6 hlnh b6 so ~anh mot bit v:J. cae tin lll¢u qua mll ph()J1g. dc diip ung Clla m~eh. Cac ket qua do duqe nila thiet kE' su dl;mg d~ kie'm tra mlre d(l thieh hqp ella thiet ke. Ta co the thlfC hi¢n ma phong tren bat ky giai dOi.1I1 nao clla qua trlnh thiet ke. T<;li cac mue bao quat nhat eua thiet ke, mo ph6ng eung cap cho ta thong tin v~ hO<;lt d¢ng clla miJch dang thiet k€. Thong thuang mo phong a I1llk nay thlfe hi¢n rat nhanh va khong eung eap eho ta nhung thong tin chi tiet v~ ho~t d¢ng clla m~ch va ch€ d¢ djnh thai gian. Khi qua trlnh thiet kc di xu6ng eae mue thap han,'mo ph6ng se ehiem thai gian dai hon. M6 phung a cae mue thap ehiem nhieu thai gian hon nh11I1g eung dip cho ta nhi~u thong tin chi tiel v~ ho~t d¢ng clla miJch, ch€ d¢ thai gian dong ho. Ngon ngu VIIDL eho ph6p su dl;lIlg CO' che m6 phong hon hqp, trong do In¢t so thanh phan co th~ duqc rno ta a muc cao con m¢t s6 thanh phun khae co the dU'qe 1116 ta chi tic·t. U u diem ella phuong phap rno phong hon hqp la cho phcp nha thie' ke t~p trung vao xay dlfl1g nhung phan tn<;lch quan trc,lllg. De giatn gia thanh th1fC hi¢n mo phong a cac muc thap, dc b¢ rna phong can duqe dung de phat hi¢n cac 16i thiet ke cang sam cang t6t. Trang qua tdnh rna phong 134 . I ) , L.j"* 0: Tln.rc hicn huo-c J3.4: 14. B4: Do L.jlrung vo-i gia Irj hl¢n thoi (c; I ), Ihlfc hi~n hlf6c B5; 15.35: I 0 (- I + 1 ( 1=5); Quay I~li bulic H2; 16,82:. 33: 17,133: Kiem Ira L., L,:::: 0, chuyt::n tlii blfOC 35: 18. H5: I < ;- t + I ( t = 6 ); 19, 32: Cac tin hi¢u vao kh()ng thay doi gia Ir!; Thlfc hi¢n 33; 20.133: Kicm tra. gill c(m li-en ve thoi gian Ill<> phong M kh()ng doi. Dc gi;ii quyet van de nay ta ph;H dua fa nhl1ng hien the" thich h<;1p ella phuong philp ,-Inh X".I