Dtle t,i thea vi tri : m6i philn tti nll~n gi,\ tri ella cluing trong bicu thue then trM tt!. vr ell.). nhu tren tru phcp gan eu6i : type CoIOl'_list is ( Red, Orange. nIue. White ); type Colocarray is array (CoJoclist) of BlT_ VECTOR ( 1 downto 0); variable X ; Coiocarray; X ;= ( "00" . "10" , "0 I" , "11" ); K hi gan giii tf! eho nhom. ta e() the' kh6ng can thiet (t~lt gia trj eho tAl dl de ph:in tu ella nhom. Vi dl,l. subtype BV7 is I3IT _ VEcrOR ( 7 duwntu 0 ); variable X : BV7; X:= ('0'. '0'. '0'. 'I'. 'I'. 'I'. 'I'. '1'); X '.= ( '0' . '0' . '0' . others => '1' ); X := llvT ( '0' • '0' . '0' . others => 'I' ): g, Cae hien thue djnh kieu Oie bieu thuc djnh kicu la !lhiing bi2u thue hO(IC nh6m ciLlIlg de xac djnh fa nilling tlnh tr'.U1g m~lp mo. Vi d!.J. nhu trong truong hQ'p hai beu li¢t k6 co nhling gia tfj li¢t ke gi6ng nhau. CU phapcua bieu thCre dinh kieu nhu sau: hi/If flll(e phili co kieu trung. vai fl'J/):.ii;'If. 170 VI dl,l. tmng truang hqp hai li¢t kc co nhOng gia tri giong nhau. type Color{ is ( Red. Orange, Yellmv, Green, Blue. Purple); type Color2 is ( Green, Black. White. Yellow); variahle X: CaIOl·I; X ::::: Color!' ( Yellow); Uia tri 'YeUO\v' dU(jc XdC djnh tuong minh la thut)c kicu Colorl. Nhu v(ty phcp gall (r2n lit dung \'6i cu phap. h. Phcp ehuycn dui kicu Phep ehuycn u61 kicu cung dip phuong ti¢n biC'n (k~i gia tq ella nht1ng doi tU<;l'ng Ihw>e nhGng kieu e6 quan h~ eh~t ehe voi nhau \'i dy nille kieu rca I va kieu intej:!,cr. CU ph,ip ella ph~p bien doi kieu nhu "au: VI tiy, signal X: STD_LOGIC_ VELIOR ( ~ downto 0); signal Y: STD_ULOUIC YECrOR ( 3 down to 0): Y <= STD_ULOGIC YECroR ( X ): ~6.5. Cae e:lu true tmln t~ Trang ngon ngfr VIIDL, kie'n true Xil.c djnh eh6e nfmg ella timc the:. Trong kicn true chua ph[in khai IXlo cae ki~u, d.e I[n hi2u. cae htll1g. dc thanh ph[in va de chlfo'ng trinh con. 111(.:0 sau phAn khili bao li\ eAc C{lll Irllc tlu.re hi¢n dong thoi. Cic eau true thlfe bi~n dong thai co the: iit de bi0u tbue gall tin hi~u song song. de khoi \'a cae !<;nh kll{1i tao phien ban cUJ. Ihanh phfin. Cae I~nh thy"e hi~n dong thai dU~1e ket noi veti nhau hang nhG'ng I[n hi~u. Moi khoi ICnh tiwc hi~n dong thai trong mt)t kit'n true xac dinh In91 don yj t[nh toan baD gOIl1 de thao t,le tfnh toan nhu: dQe tin hi¢u \,ao. tlwc hi~1l de tfnh toan trcn cue lin hi~u do va gan nhnng gia Iri tfnh dUQ'C cho de tin hi~u ra. Trang ngon ngt1 VHDL, I1H?t cau true thy"e hi~n d6ng thoi II qua trlnh ( pruees " ). Qua tdnh Iii. lTIt)t du true quan trQng dV(je su tlL.IIl); de m6 1:1 171 hill1h vi hOi 11 dong cua mi LCh. Trong ITIQI kien lr(lc, 1[\1 ci dc qu,\ trlnh sl' dW1C Ih~rc hi¢n d6ng thai khi ma phung. \11)1 qu,\ trlnh duC)'c xay dl!ng tll" nhl1ng cfiu Ink lu,"in IV - hay 6lJl ~t)i Iii c,le \¢nh tufin tlr Trong thoi gian ITIO phlmg, cac \~nh IU(1Il IV Irong ]lll)1 qll'.\ trinh sc ctuae tlll.rc hi¢n \fill IUQ1 trong 1l1(1\ chu trinh VO \wn hM dfill Ill" I~nh thCr nh:it (k"n 10:nh lhu /I va sau do vi¢c thvc hi~n qua trlnh 1<.li quay In)" t.li knh cti.lu. Vi¢c Ilwc hi~n Il1Ql qua Irlnh trong qu,i trlnh m6 phlmg In~n ngon ngiJ VHDL hi dung h.li khi gZtp diu l~nh wait va duC)'c kfeh hoat I' Ii khi c() su thay cit), tn.Lng thai eua it nh[it tnQt trong cac tin hi~u mCuTI Irong danh sitch die till hi¢u I(IC d(mg. Cac I¢nh ttHIn IV trang ngon ngCr VIIDL gum eo: Gill \¢nh gan eho hien; Gill I¢nh gan cho lin hi¢u; Cau I¢nh iF; Gill 1¢1111 case; Gill I~nh rcng null: Cic I¢nh \'()ng \(tp. 1. Phcp gan bien Trang ngon ngu: VIIDL, phep gan bien co lac d~lllg \u"lmg II! phcp gan (). cae ngon ngil" 1(lp Irlnh truyen thong. Phcp g • .in bien IhleL \(\p g[,\ tr! m6"i cho hilYn. Cu. ph<lp cua phep gan bien nhu sau: bit';11 := hilll tllli't": Ve" tnti eua phep gan phil! la bien da dUQ'c khai bilo tir truac. Ve ph,ii ella phcp gan Ia bieu thuc. De phcp gan co the tlwc hi¢n duqc, bieu thuc d \'C trai va bien ave pil,ii clLa phep gan phai cung ki6u, Klli mc)t bien dU"qc gan gia II'" phcp gan duqc Ihl:re hi¢11 vl:ii tl1(\i gLan rno phimg bimg. khong. DieLl d6 e6 nghia IiI sl! Ihay do, gia tri cua bien ctuqc xu)' ra ttk Iho-i ngay t:'.li thui diem rna ph6ng hi¢n tai. Cac hic'n chi dU"<;1c khai bao trong cae gu !. trlnh ho<:tc ChU0Jlg trlnh con va duC)'c slr cl~l!1g de Iuu tnl cac ket qua trung gian. M¢t bien dU"q'c khai [)iio hl':n trung m(ll qua tdnh hO(lc chuang trlnh con se ton t~li C~IC bl) lrang qua trlnh ho~tc chuong lrlnh con do va kh6ng the dU"<;1C truy C~tP 16i Ilr cae e~iu truc :->ong song kh "ic. 172 VI dV ph{;p gan bien, suht."pe Intl6 is integcr rallj!;c 0 to 05635; siglwl S1. S2; In116: si~nal (iT: boolean: pruccss (Sl, S2) variable A, 13 : Int16: COllstant C: Intlo;= 100; bcgin A :~Sl + I: B :~ 52 *2 - C: GT <= A > 13; end pl'ocess; 2. Phep gall tin hieu Trong ngon ngi::i' V HDL. tin hi¢u lA m9t d~ng clui tuVng d[\c bi¢t. Ph{;p gan tin hi~u dung de tbay doi gia tri eua tin hi¢u. Die tin hi¢u lu6n c1uo'C bi~u dicn kc't hQ'p v6i dicn biC:n thui gian. Phcp gan tin hi¢u thay doi gi{\ II'! clla lin hi~u tl(ang lrng thea thui gian va plw thu<)e vao de mo hlnh qua Irlllh Ire Irong d.e phfin Ill' mi leh. Khi tin hi¢u citlqe gan gia Ir!. gia Ir! m6i clo kh(ing dWK g.an \"()'j 1111 hl~U m()\ deh IU."C Ih,1i mil. plliii sau 11191 thoi gian duq'c d~nh Ijeh lrlnh trude trong Iho'i diel1l m6 ph6ng tiep then wang lWg v6i 1110 hlnh tre. Phep gall lin hi~u eo eu ph{lp nhLf sau: fJ/c"II_lfllk xJc djnh dlc gia tri gall. Kieu clla bu;'u_,IIII"c ph"li trung \'6'j ki~ll ella 1{/I)li~;II_,1fc". IfuJi_Ulal/ iii. bieu thlIe C() kieu TIME. Trang 1119t qu,i trinh, vi¢c gan gia Iri clla bi~u thu'c cho tin hi~u sc throc lam tre khi chu trinh mo ph6ng diUlg thlfc hl~n va dUQ"c kiem soit bo-i loan Ilr wait. Chlmg ta hay xct VI d~l ve phep gan tin hi~u trang dOi U1 chuC1ng I["[nh sau: proccss hc~in end; S 1 <::::: nut eLK after 30 ns ; Sl <= DIn aftcr 0 ns ; S3<=SllmdS2; wait on eLK; Trang doc.lrl chuang Irinh nay. Ihao tac g.ln kc'l qua c.:ua phcp tO<Ill "not eLK" cho bien SI 'iC chI9c I1wc hi91l ~au 30 ns tlnh IU tho'j di~m Illt) phong hien lai. Trong Call \¢nh Ihtt hai. thai gian tre clli.l phcp g<.in dU"(fc clio Ix\ng '0', khi do n¢c gtlll gi,i Iri ella lin hi¢u DIn cho tin hi¢u S2 s0 du"(1C tln.!"c hi¢li sau khaang thi:1i gian delta tlnh III th(:ji diem m6 phc'mg hl~n t'.lI. Tm111g !L.r nlllr v;ly. t!"ong ph 'p g.,in lIn hieu 1\111 ta. kct qu<.i ella phc'p tOiln IC)gic and \11lK hi¢n Ir0n cac gia tri hi¢n tho'i cua lill hi¢u SI d S2 Sl: dlf0c gan cho tin hi¢u Sl S,tU khming tho'j ginn delta tinh IV Ihui diem 1116 ph()ng hi¢n Ih('ii. Khi XU<lt hi¢n st! ki~n tren dU'ung lin hi¢u eLK ( gi,i tri tn~n duang tin hi9u eLK chuycn tLr '0' sang 'I' ), tat d. cac giaa d~ch <.tJ dU(Jc dillh lich trlnh Inf(k thai di6m Xuflt hi~n slf ki¢n sc dUQ"c tlwc hi¢n b6i h0 m() ph()ng. Khi tin hl¢U dl:qc gan gi,,\, Ir! trang qua trinh, phcp g{m s2 :.;.{tC dinh m6t h<,1 dieu khien lin hi¢ll. Trang me)t qua trinh, I110t tIll hl~U chi co the' nl 1n01 clicll khien, dicu d6 co nghlu Ib. ben {rang lllQt qua trlnh tin hi~Ll chi e6 Ih~ xu[it phat til me>1 ngu()ll. Neu tin hi~u dU<;1c gan gi{1 II"! trong nhicu qua tl"lnh h;lc !lhau, cllling ta 1161 l"t'ing tin hi~u c6 nhi6u dieu khi~ll. Trong ng{)n ngu' VIIDL, lrong true\ng lWp m()t lin hi¢u c6 nhicu dicu .klllen, cae h~l1n lJu),ct d~nh duc.K xily dl;rng c1~ xac d!llh gia tri cae tin hl~U eo llhiC:u cilCLl khic;n J"\hu' (1;1 de e<\p ltii Irong c!lll"ong ha, Irong lhl~1 ! c' m'lch. ChLlllg la ph~11l bi~1 bai h<li d:'.l1lg thai gian In': khi ta dicu khien d.c Ihao t,IC Ircn Illl 11I¢u thc() Ihi\i gian: IhCii gian Ire qu,in tfnh \"it Ih('ii gi':'lIl Ir(: Ian Iru)-'"cn. 174 Thll'i gian tr~ quan 11nh (hwc the hi¢n m[tC djnh lrung ng()n ngCr VHDL. GlCt II"~ thi:1i gJan tn~ qU{ll1linh lit dt) dili gitii han dn Ihi(,'1 u'la tin hicu tAc dong d~ thiet c6 Ih~ ph,'tn (rng vc1i sV xufit hi~n Ifn hi¢u d[iu vao. Neu thai gian 16n I,.ti cua tin hi¢u dfiu \'ao khong \"lI01 qua gij trj thl:fi gian In! qu;in tlnh thi lTIi lch sc kh6ng phan lJng v()'i s~r Ihay dOl ella tin hi¢u. Th()ng s6 thai gian Ir~ qu,in tinh dU'<;1c sU: dl;lllg lrang quS trinh 1116 hinh hoa cac thiet bi so d~ loal Irir s~r xu[.t hi91l nhOng xung 11hon \'.li dflU \,~IO. Thdi gian tre Ian truycn Ja thai gian In'S xual hien khi tin hi¢u di qlla ll1'.Kh. TiI khoa transpOI't dV<,"ic dung lrong twang hQ"p thai gian 11\': lrong phcp g<ln lu tho-i gian Ir~ Ian truy~n. Neu khong slr dl,lng tiI khoa transport trong phcp gall tin hi¢u. thai gian tre se dVQ"c coi lil. thai gian tre qUiln tinh 1l1()\ each null d\llh. Vi~c SLr dl,lllg tre quail I[nh Vll tn~ Ian truycn tao nen nhu·ng hi¢u Ling khi\c nhau len qUi} trlnh !TIO phong. Chung ta hay xct qua trlnh sau: sij.!;nal S: BIT :::::: '0'; prol'l'sS hegin S <= ' I' after 5 ns ; S <= '0' after 10 ns: end process: Trong c:tu I¢nh thCc nha!. he thong 1110 ph6ng se djnh I\ch lrillh cho ph':p g(ll1 tin hi¢u S gi,.l tri 'J' saL! 5 ns linh tir Ih(1i di~m mo phong hi¢n thai D6i \'(1i cflu I¢nh thCr hai, h¢ 1116 phcmg se djnh Ijeh trlnh eho phcp giil} gli.'l If! '0' eho tin hi~u S sau 10 ns Ifnh tir thai di~1TI m6 ph6ng hien thai. NhLf V(ly, du l¢nh thCr hai sc xoa b6 kc·t qua ella phep gan thu nhAt bui VI gi<.1. Irj thai gian tre 1;:1 thoi gian tre qUiin tfnh. GIU I¢nh thlr nhat chi ra rtmg thai gim1 tre qu<.!n tinh ella phcp gi.1.n 1;:1 5 ns, trong khi do cflu l¢nh tht! hai khil.ng djnb thai gian tr~ qUol[\ tinh ella ph~p giin !~I 10 ns. I\'eu doi cl10 hai phcp gan trong ctO'.1I1 chu·ong trlnh tfen, ehllng la nh(lI1 dU\1C qUe! tdnh duoi day, signal S: BIT:= '0': )11'Ol'l'SS begin S <= '0' after [0 ns: S <= '1' after 5 ns : wait on ClK : end process: 175 Trong trueillg hq'p n:t:', du ICnh g<in thu nhat se X,-lc dinh IDQI ph~p gan gia tri '0' eho tin hi~u S sau 10 ns trnh tu thai di6m IDO ph6ng hit;'11 thl1'i con phep giln th(i' hai ;.,e :de d!nh thao t<lC gan gia tr! '1' eho S sal! :) ns so \'l)i tht'J"i (ticll1 hien Ih{ii. l\'hu \,~ty. khi h6 IDO phong htlt dUll thlfC hi¢n, d.c giao t,.i.e eua phcp g<.in thll hai c1U<,K t1wc hi9n Ihay eho cac giao tik ClW phcp g{1ll thll" nhtit. Dictl do c6 nghl<l Iii, chi c6 phcp gan gia tr[ '1' cha tin hi¢u S tal thl1i diem:) ns tfnh tit thai diem mo phong hi¢n th0i se c1uQ'c th~tc hi¢n. Nc'u lrong dOi lt1 clllwng lrinh lren. chung ta Ihay 1h0i gli.\n tn: qu<ill tfnh bhng thoi gian tre Ian truyell nhu Irang cta'.H1 clllf(1ng trlnh duai day, k61 qu,i thlle hi¢n cua qua Irlnh siS thay dOl, signal S: nIT:== '0'; process hegin S <:::: transport' l' after:) ns : S <:::: tran!olport '0' after IOns; wait on eLK: end process; Trong do •. tIl chuang trlnh nay, vi¢c gan gi,i tri '}' cho tIn h!¢u S se dlf(~C lilm tre :'i ns tlnh tv 1h(1i diem m6 phong. Con phep gem tin hi¢u t11lt hai se t11f'm m()t thaD tae m{1i cho dieu khien eua tin hi~u S. Dicu n:1Y co nghla LI '>C Cl) hai thaD lac cluqc IhLJc hien: mot Ihao 1.le gall gi<.i Irj x,iy ra ,>au :) ns linh til th0i diem md phong vii 1hao t,k gall thu hai se du:(}c !h~tc hi¢n sau 10 os linh tLl" thoi diem 1116 ph('mg, Kct qUt'\ I:t lren du'ong tin hi¢u Sse XU[lt hi~n m()\ XUllg h~ng 'I' co ell) did:) ns t<~i th(1i dic'm:) ns Ilnh Itl" t!1('1i die'm hi¢1\ th('}j. 176 Trang VI tiL!- dang xct 6" In.':n. Chlll1g la d6i ch() hai phep g,in nhl! sau: signal S: BIT :== '0': process hegin S <== tnlllsport '0' after lOllS: S <== transport' l' after 5 ns ; wait on eLK; end process: . :-& gt;ong song kh "ic. 172 VI dV ph{;p gan bien, suht."pe Intl6 is integcr rallj!;c 0 to 056 35; siglwl S1. S2; In116: si~nal (iT: boolean: pruccss (Sl, S2). ns: S <= '1' after 5 ns : wait on ClK : end process: 1 75 Trong trueillg hq'p n:t:', du ICnh g<in thu nhat se X,-lc dinh IDQI ph~p gan gia tri. S2) variable A, 13 : Int16: COllstant C: Intlo;= 100; bcgin A :~Sl + I: B :~ 52 *2 - C: GT <= A > 13; end pl'ocess; 2. Phep gall tin hieu Trong ngon ngi::i'