tlll.rc hi~n d.c Iinh IO(lIl so hqc \"it l{lgic su dl,lI1g Gic c.ic {O.in IU \'6i m{)1 s() uic toan h'.lllg. Cae 10(111 tll" d~IC trung cho phcp lo,in se duqc t1wc bi2n cem de loan hi mg lil de ngu(ln dl1 li¢u eho de phcp toano 1. C~ic toan tit Cae loan Ilt dlH1c pl1flll chia theo dc !TItfc dc) uu lien vii tl"(11 I~t tinh lOall. Trong b,ing 5.1 dU'a ra dc nholll phep toan YlJi tnii"c L1<) ltU lien t[mg d in. Clc quy lfOC ve 1r(lt IV t1wc hi¢n cae ph~p toan trong oieu thue dltqe the hi~n nlm sau: Trollg bicll thll"c cac phep lo,in e6 tnt1c dl) lfU lien IOn han 'Ie dWl"C tlwe hien truck. C.ic d,lu ngoi~c dem cUllg giup x(\C djnh dung tr[\1 tu tinh 10:.1.11 oieu thu·c. Cae ph~r toan lrong nh{l!l1 YO'j Cltng 1Il(1\ mlte d(l uu !i':n -;c dU"<;J"C t1wc hi~n IV Ir.ii 4ua ph:li trong d.e oieu thu'(' Hang 6.1. Cae Imln tit \'A !l1(i"c d6 uu lien. Gic e!ll~D Io.:in IOOle and, or, nand, nor, xor eic phcp lOan quail he :::, I:::, <, <:::, >, >::: Cae phcp loan c<;Jug +, -, & Toan Ill" d,lu +, - Gie ph~p toan !lh 1Il , , /, mod. rem Cae phcp loan kh,ie ** . ao", not a. Cae I)hcp tOlin lllgic Trong ng()n ngl[ YHDL dc phcp toan \6gic gom eo and, or, nand, nor. xur \'~t not. Lie phcp tn{1ll ntlY Ille d(lIlg lCn d.c dlt h¢u ki~u BIT, Boolean V;I 1l1,ing m(ll chi~u de BIT. 86i Y{ij cae phc:p lo{m hai ngoi and. or. nand, nor. xur. Cilc lo(m h,.mg ph.ii eung kieu. Trnng trl10ng hop de loin hdllg \a de ]11,llIg mc)1 chicu de BIT thl de mang phai co eung d<) clai. Cae phcp !Oitn nh! phan xae dl11h cae ham trcn e{lc bil eua nhil"ng ph:in tu ll1ilng C(~l cung chi so. kCI qUi.l s~ 1;1 !1lQI m.ing c() cung d() d;\i \';1 gi6i h •. tIl cae chi ~.,(i Ph0p tOal1 illQt ngoi not xac d!nh phcp dao oil doi \'oi loan h'.l1lg eua II,·. Trong twang iwp lOan h'.ll1g lil m¢1 mang thi phep toan not lik: d<)ng 10n 1M ci de ph{in IV CLb. mango 163 Vi ell}. signal A. n, C: nrc VECfOR ( 6 down to 0 ): A <= 13 and C h. Cae phcp tmill quan h~ Cae tmin tlI quan h¢ g6m co cae phep toan ~o sanh ":::" . "/=", "<" . "<=" , ">" . ">:::". Cae phcp loan so silnh 1,1 dc phcp toan hCli ngoi v~\ efc to{1ll hi ll1g ph,i.i co clll1g h~u. Kct quit so s<lnh nh(m kicu lloolc'lIl. Phcp tOi.\l1 ":::" kic'm Ira quail h~ "hJng": "/=" - kie'm tra quan he "khi.le" . "<" - quail h~ "nhl) han": "<=" - nila hlm hO(lC b,l.l1g , ">" - "k'm hll"il" , ">=" - "16"11 hem h()~c b~lllg". KCI 4Ui.\ I1h~1l gia trj true I1(U quail h6 dW1c nghi¢m dung vi:t nh~H1 gl{l Ir~ false lrong Info-ng h0P ngLI0c i'.H. e{\(: quan h¢ "=" vii "/=" xac djnh w1i 1119i kicu da li¢u. Glll cac qwm h¢ con 1\li "<" , "<:::" , ">" , ">=" chi xae c1jnh vCti cae kicu li¢t ke, so nguyen. l1le'll1g l11¢t ehicu cae li¢t k(: ho~c so nguyen. 51! sap xep G'te gia 1r! Irong mien xae dinh eua kicu xae dinh k61 tjUet cLla cae phcp Imin so : anh. Cie : 6 nguyen duqc StlP xcp theo IhCI \tf II! nhl~n III Gie s6 ,1m deil cae so dtlung. Cie m.:tng st: dlI~1C so sanll hilllg dch '>0 s<inh lirng ph::i11 Ill: clla m~\llg btl{ di.lU lu dn Ir{li ella mien xac d~nh chi ,,() m,'lllg. VI cit,!, signal A. B: unsigned ( 6 down to 0 ); signal C. D. E: Boolean; C <= ( A = Il l: C. C{IC phcp toan c(mg Ciic pbcp t0611 c¢ng bao g6m "+". "-" . "&". Cae pilip to,in "+", "-" time hl~n trcn de d6i ILH,mg kicu integer. Phcp loan noi "&" ap d~ll1g v6i cae d6i Ilf\mg la mang thanh ghi. Phcp to,il1 nay xily cl\fng ll1<.'mg m6i ballg dich ghcp noi hai 1TIi.l.ng nam trong toan b;:.mg Vo\ nhau. Mc)i toan hi.~ng ella phcp tOil.ll "&" co Ihe' ia m¢t mang hO(IC philll IL1 ella m tng. Cae phcp loAn Ili'ty cling thlfc hi~n v{)'i cae to<l[1 h •. mg c6 ki~u signed Yll. unsigned. 164 signal W: BIT_ VECfOR (3 downto O)~ signal X: integer rangc {) to 15~ signal Y. Z: unsigned ( 3 do".'nto 0 )~ Z<=X+Y+Z~ Y <:::: Z ( 2 down to 0 ) & W( I )~ d. Cae phep toall d!llh d{iu Cie phcp loan lTI(lt ngbi "+", "-" , "abs" tlNc hi¢n vtii d.c to(lll h:.\llg d,.mg so va tni I'.li gia tri elmg kieu. c. C~ic phcp toan nhan Cic phcp toan nh,l11 "*'*" , ,,*" . "r , mod, rem !lwe hi~n (rC'1l cae kicll integer. Pllcp (OUI1 ,:,*" the hien phcp nang 1011 Ill}' thlra~ ,,*" - phcp nh[\ll; "j" - phcp chia: mod - Itiy m()(lull: rem·- lAy ph:ill dlL Vi dl,l, 2. Cae tmin Iwng signal A. B, C: integer range 0 to 31 ~ A<=Il'Il; D<:::: E mod 4: , , Trong !1l0t bieu thue, cae Imin tiI dung de tmin h'.lll; ;ti11'f4 ,, elC ~i:' Ir! clla chung. Thl'Hlg thuang trong ngbn ngCi: YHDL c6 nhlcu d,.tng tmill Il:mg. Cac loan h,.mg cOng c6 the In. ehinh cae bicu thue. Cae dang loan han o tron" noon noCi: VHDL baD gam: . . 0 0 0 (;:- Cac hang, ky hi~u nhu 'x' , "1001" , 345;· ale ten. d!nh danh; Cit chi s6~ 165 Cae tcn ngin \'a biet danh: - Cae ten thU(lC I[nil: Ciie I1h6m: Oic bi~u thli'c d!nh kieu: Ole phc'p goi h~lIn; Cae hieu thlfC ehuycn deli kieu. Cue htlllg ky' yi\ gJ,i 11'\ k5' hi~u hO(IC ia gia Ifj ~O, gia Ifi k)' IV, cae gia If! ii¢! kc , c;.ic gl<i tfi xau. 166 eic gi;i Ir! so lil. c<ie lli\ng gia Ir! nguyen. Cae gi<.1. Ifi so dL19'C bi~u di.211 tU)' thu()c Ihen h¢ e(l so l11a gi<.\ Irj diS hieu (hell. • Trong h6 cO" sci mui".l'i cae gia II"! ~6 duQ'c yie·1 nhu blnh Ihuang. • Trang h~ co s6 khae 111 2 )- 16, ta \'i2'1 du6i d,.mg ((1_"\0' # gl([ 1/1 /Ulllt; Vfdu, 2# 1101 Cae htll1g ky IV i~l de ky It! fieng Ie dU'(1e vicl Hong hai ngo(lC do'n. V[ ell:'. '1.'. Cae h,\ng li¢1 kc iu cae hang du~J'C xae djnh Irong djnh nghla kicu ii~t kc. Trong ngon ngil' VHDL cae gi,i If! licl k0 ella cue ki~u ii~t k0 khcic nhau co the Irung nhau. V[ du, type Color is ( Red, Green, illuc ): type Lighl is ( Red, Yellow, Green ): eie gia Jrj X[IU ky It! la bicl] dicn ella mung ky III me)! chicu dc k}' It!. C6'tul( d,.mg hilng x{iu: de xilu ky It! \'3. xiiu de bit. • Ck x{iu ky tL.r Iii ehu6i de k)' tt! ntllTI giua hai driu moe b:p. V[ d'-:l, "Demo", ''100lO01''. • X;lu cae bil duqe bicu dien IL1o'ng II! nhu X[tll ky II!, nhlIng ph[m bi¢t c<.I.c de ch.tng xflu nhj phfm. oclal \'a hcxa bitng de k)' h.r chi he co s6, Vf du, B" 10011 ",0 "277", X "4C", h. C:ie ten ,"';} d!nh danh Ok dinh uanh d6i khi con g9i 1m)! cach don giin IiI t2n. Dinh danh li\ uk !en deli \'6i htmg, bien, tin hi¢u, th~re th~, ella d.c ding, cl1l1O'ng Irlnh COil \'(1 ella cac khai baa tham so. Cae IV klloi\. trong IJgon ngCf VHDL ciing 1~1 cae dinh danh. Cae ten phii btlt dau Itl chiJ cai va chi chua chi.1 GiL ehiJ so \"~l (Hlu gi lch noi '_'. D[llI g,~ch noi '_' kh6ng !h~ la ky tI! sau cung trung llH)! d!nh danh. Trong ng()]l ngi.1 VHDL cac tcn va djnh danh kh6ng ph[1ll bi¢t theo chu hoa \'U chiI !l1lfOllg. Mt)t s6 djnh danh nhl1 entity, port, is \'tl end 1~1 de ILl' khoj trong ng6n ngu VHDL. Moi tv khoa eo 5' nghia xac djnh trung ng(m ngu vii khong the su dl,Jl1g trong de 1lll,lC dfch kh,k. e. Tell du''lc chi s6 hlHl Nhung len nily x<.le djnh m()t phfin tu ella doi luqng Inelng. Cll philp m6 I,i cLla ten chi s6 nhu sau: Trong do, hilll_ll!(((" ph<.ii tra l<;Ii gia tfj lu chi so clla phfln tt! lTIi.ing trong mien x<.tc djnh clla chi s6. Vi dl,l, type Memory is array ( 0 to 7 ) or intcj:!;cr range 0 to 1023: variable Data_Array: Memory: ,"'ariablc ADDR: integer ranj:!;c 0 to 7; ,'ariable Data: integcr nlllge 0 to 1023; Data :::: Data_Array ( ADDR ): d. Ten ngan \'U hi~t danh Ten ngltn x,\c dtllh chuai eac ph,ln lU eua d6i tuqng m<.lng. Huang Clb uic chi s6 phan tu ll1,ing la to hO(lc downto. Tuy nhicn chieu chi so cll<1 len nglm ph,ii luong thlch voi ehicu chi so cua ki~u milng tuang LIng. Ten ngtlll co the st'r (h,lllg cung \'oi cac bi~l danh (alia'> ). 167 Bi¢t danh (,,\0 r<'l 1110t ten ll10i elm ll1Ql ph:in ho~c tO~U1 be) mango Bi~t danh eung Gtp m(l( co che truy G~p khCle Wi phein tir eua m;'ll1g. V[dl;!. variable Org : BIT_ VEcrOR ( 7 down to a ): alias AI : lllT_ VECfOI( (0 to 3) is ORG ( 7 down to 4 ): alias 1\2 : BIT_ VECfOR ( 107 duwnto 100) is ORO: alias 1\3 : BIT is ORG ( 7 ); e, nUHk tlnh Thw.)c (fnh ];\ <IiI It¢u gan !Jen v6i d(ii tuong (rong ngon ngCr VHDL. Thw)c tinh trong ngCm ngCr VHDL ella de hic'n hOile tin hieu llf(mg ung \'oj nhiJng gi;.l(r! Cl.l the \'ll duq·c xac d!l1h Iheo lJUY tac Cll ph,ip sau: Cae Ihu(K t[nll duoe dinh nghia trude trong ngon ngu· VHDL iiI left, right, luw, high. range, reverse-range. length. 168 Cae thu(K tfnh left hO;IC right tni. l<:ti chi ~o clla phi.ln Ilr ben Inii ohAt [m(lc hell pll,lj nh~t( ella ki~u du li~u. CCic thU(K tfnh hij!;h, low tnt 1;.11 chi so ella phiin lit can ni1ft( hO(lc thllP nhflt cua kicu dG li¢u. CCic thu()c tinh range VlI reverse range X~IC dinh kho:lllg ella chi st). - Thm)c tinh length dua ra so luqng cac phfill Ilr eua !1l()( IlIT_ VECfOR. Vi elL,l, suht)'pe Index_range is integer range 10 downto 0: \'ariable Veetl : BIT_ VECfOR (lndx_rangc); khi do ta St e6: Veer J' lert f-) Indx_rangc' left:::::::: J 0; Veetl' right f-) Indx_range' rij!;ht:::::::: 0; VectI' high B Indx_runge' high == 10; Veetl' lo~,' B Indx_ntnge' low == 0; VeetI' range B Indx_rangc == 10 downto 0: Veell' reverse_range B Indx_range == () to 10: V eet l' leng;th «-t 11. Gic thu()c tfnh event V~I stable chi co d6i vO"i e,le tin hi~u, C[IC tbUl)e tfnh 11;11' chi rtmg tren duo'ng tin hi~u dang xd c6 xu[it hi¢n sV ki¢n hay gi,i tf! trell duong tin hi~u 6n djnh t<.li th()·i diem hicn t'.ll. Trong qua trlnh long hqp 1l1<.lCh, cae IIlll¢e tinll nily thuang dll11g vO"i de lenh wait ";1 l¢nh if, Trong ngon ngiI VHDL con e6 m¢t so thuQc tinh ltuQ'e djnh nghla trudc kh[lC. Ph[in 16n d.c Ihu9c Ifnh nllY duqc dung eho qUii trlnh \TIc. phung. Vi d~ nill!" d.c Ihu9c tfnh delayed, activc, behavior. structure, last_cwll. l:lst acth c. f. Cae nh(lI11 Cae I1hom kCI hqp mC)1 hO(lC nhicu gia tl"j vao 11l¢1 gi[l Ifj kC·I hqp ella kicu Im'tllg ho(1C kitu han ghi. Nh6m duqe dung de gun gi<\ Irj eho deli tU'Cfng kicLi m:lIIg ho(1C b<.ln ghi khi kh6i t<.IO hOZlc trong de bieu th(J'e gan. Vi¢e d.lnli chi so de ph,l.n Ill' duQ'c d(1C t<1 thea t6n ho~e Illeo \'! Irf. 8(lc 1,\ Ihea len: sl! luang {fng giiJ'a c<le phan tll' clla nht'1l11 V~l pilan Ilf ella deli lu'(;mg du~)'C gall dLfQ·C chi 1"0 thea ten ella tlrng ph{in Iii <I gi'l tr! clb chung. Vi dl,l, t)·pc Coloclist is ( Red. Orange, Blue, White ): type Coiocarray is army (Color_lisl) of I31T _VECTOR ( I down to () ); variablc X : Color3lTay; X := ( Red => "00", Elue => "10", Orange => "01", Whit(.: => "II" ): 169 . "/=" - kie'm tra quan he "khi.le" . "<" - quail h~ "nhl) han": "<=" - nila hlm hO(lC b,l.l1g , ">" - "k'm. the hien phcp nang 1011 Ill}' thlra~ ,,*" - phcp nh[ll; "j" - phcp chia: mod - Itiy m()(lull: rem - lAy ph:ill dlL Vi dl,l, 2. Cae tmin Iwng signal. ">=" - "16"11 hem h()~c b~lllg". KCI 4Ui. I1h~1l gia trj true I1(U quail h6 dW1c nghi¢m dung vi:t nh~H1 gl{l Ir~ false lrong Info-ng h0P ngLI0c