TrOll~ \'f uu ni:ty, t[lt cit c,te till hi¢u vilo ph'l! dU'lK gIll trong danh ~,ich tin hi0u t • .\c dl)llg. Danh ",\eh tin hi~L1 t,Ie dl)ng ehi ra ril11g, qUii trlnh tfnh to,Ill dang xct ~c du\l"C tllve h!¢n khl e6 SLt' lhay ,I(;i CLla dc lin hll'U ntul1 lrong danh s,ielL D~ 1l1() til n1<.leh ll)gic td h0p. dc bien v:. tin hi011 troug 1ll()1 qU;! 11"lnl1 process kh(mg chfq'e nh;1Il gi,i 11"i g;!n kh()'j t',IO IrLr()c bl)'j \ I lllilCh It) IH)'P kh(m~ ehlia C:le ph:in III nlll}. Khi lrong 1l1(J hlnh mach e6 de hl6n hO:lc Lin hlCll dwye khll'i lao gi,i Ir! tn['lk, dlCll n~ly s.: Luong dunng \'('ii \'l¢e Lrol1g 111'.ICh ph,li c{) nhu'llg ph:in Ill' luu Ir([ de gHi lri kIH')'i [i.IO. l\'hu' \ ;)y h.hi lll() hlllh h6a e:lll Ink, ehuong trlnh 1m) ph()llg "i: ,inh 1"a de pld.Il Ill' nh(l &i Iuu tn-r de giii Irj J JJ('ii 1,.10. \1'.ICh tn)' Ih:lI1h mi,lch e6 nh6'. Them \':10 (k), trung dlc 1l1{) hlnh lllHeh t{i h(.l'p. de tin hi¢u \'i:1 hien c:\n ph'll dlt'oc ~iin ~Hi 11"1 Irll'lk klli dWK sLr L1t.lng. Moi du knh lufin I~r 11"Lf de I¢nh wait. loop \'i:1 if \'(')'i nhCrng lin hi¢lI ctl~Ll kIllen Iheo SLf('-m d~u c6 Ihe dllng dl: Ill{) 1<\ c,ic Ill,,lcll 16gic l{) h()p. eic phcp loan ,,61H,le nllli +, -, * : c:k phcp to,in quan h0 d de phcp LO(UI ]()gic dcu e6 Lh~ dUO'e ~u dung lrong bi~ll thL"rc. A I' ~ l- B! ' c ) 'I , Sel . l :[~. / ,. '"Z J ) J llsel 'i b) IItllh 7.6. I Lll k,:'\ qU;1 101110' help 1ll;,ldl kkil' [Iklll. C{lIlg Cl.l Il)llg hqp e6 th~ tlwe ili~'n cilia Sl~ t~lI nguycn HC'U co ele lhao I;le lo,.lJ 11"(1' trong hiel! ellen thic!t k2'. Vi Ull, hai ph~r LO(tn cl)ng lrong lrong dO' lll clurong trlnh dU()'i d:I.Y Iii hai phcp e(lIlg lo'.li trlf \'1 cluing kh6ng the Ilu.1'C hi~n d6ng lh()·i. Chllng til co Ihe g,-in d.c ph0p to,tn d6 el10 hai khili ehL"fe nZl1lg kh,ic nhall hOi.ie ~:tn eho cung 1TIl)1 khoi chL"fe n:ulg IUy thw)e \'~IO d.e r~l1lg b1l6e \'C Ii:li nguy0n. Kcu dicu ki¢n ri:tng hUl)C \'C lili ngu)'i.':n yell c:\u : l1' dl.lng 220 l1l(ll b() UHlg. me.leh 1(;llg hqr duqc 0 c() (bng Iren hlnh 7.oa. Tuy nhlen. n(~"ll ctleu ki~n r:l1lg bll(JC yell du hal b(l C(~ng. me.teh nh;lll (hl\fC : 0 Cll dan~ lrl'll hlnh 7.6h. Vi dl.!, process ( !\, B. Sci) 1ll'~il1 if ( Sci = 'I' ) titl'l1 /. <= B + C l'ISl' Z <= A + D: end if; end procl'ss; etC rh~p gein l(n hi0u song ong ccllhc dW"C il" dung ng[1l1 ~\.)n d{)i "("fi 1110t s6 loe.li ll1<'lch lhgic tll hl}'P, Vi duo trong qu;. trtllh ;illh ra gl:l tn 1\11("j Cll,1 b(l c(1!lg (by dll llj(~t bit dl th~ duqc vie'! du6i (L.lng m()1 phcp 1;,ln till hl~ll song sung n[H!" trollg doc.1ll chucmg Irlllh dll"(ri d{IY. Vi lIl.1. architccilJl'l' D,llaF10\\ of FullAddcr is signal A Il Cillo COLlt: BIT: COllI ~ ( A and B ) or ( ( J\ or B ) and Cin ): l'ud DalaF10\\: Irig(j EIl1l \'l~l' then SU<)"J1 ":1 trigO' 1:1111 'ICC Ihl'O 111 (I"l' thll"(\ng dlfo'c Sll" dung lrong de ph;in Ill' n!J(i m()1 bit. Ta x:GI vi till 111(1 1,'1 m;H:h tngo D [:1111 \'IC:C tilen 111((C. Vi d~l, m(l I;i h~lnh \'j m;.lch trigo D 1;\ln "i¢c Ih< 'o 111(I"( btlllg ng(lll ngu' YHDL: [)]ll [J[)OUI -[)() S - C mnl! 7.7,!'ILKh tn-go D 1:\111 yieT \"("1] ("he d(l deing 06 tlk'() 11llrC 121 signal S, Dill, DOut: R1T~ process ( S, Dill ) hegin if ( S ~ 'J' ) then DOut <= Din~ end if; end process; (,hllng ta lh,·\y. danh s,ieh Clie 1111 11I~u !lh',lY e:1I1l eht'ra l'de lin hh:'U S \'~I Din. ek lin hicu n~IY dn 111Ic't de rh:ill Ilr Irigo' D hO'.lI d(lllg dlillg. l\hu \"':Iy. kill till 11l~'1I Ircn dlf(\ng lin hicu S \';1 Din Ihay d(ii gla II"!, qU;l Irlnll C: dli(/e d1l1l1ng lrlllh lTlO rhong th~[e hi¢ll. Cllllllg la lil:iy \'i¢e g,in gi,i Iri eho lin hll'U DOtli dUr)'C '-til Il"Ong chi I¢nh dicll ki¢n if, gicl tf! lin IIl¢u trcn (hrll'l1g tin hl¢lI DOLIt si: kllollg Ihay dr'il lieu gi,i [rj tren du'i"mg S billlg ,()". N0'u gl;'ilq [ll-'Il du'(mg tin hicu S htlllg '1', gi;t Ir! Ircn c1u()"lIf,! tin hi¢u DOllt sc thay (kii \':\ billlg Din mt'Ji kili lin hl~'lI [rong danh siieh [in hi¢lI nltay cam [hay dl;1 gii'ilrl D6 EI h:lIlh \'i ho, t dl)llg cLla rh:in tlr Ing(5 1;1I11 \'I('e theo llllie : JIm \';:IY. lkll Yl~i de milch trigo' 1;1111 vicc thcn llllk. chung Iii plHli chi j"() danh s,kh ell' tin hl¢u t,le d(mg. Kili Clie [in hl¢u I;Ie d(mg thay doi Ihl qUit ll'!nh Illl1 la h:!llh \'1 ella Ill<,lcil sC: dU'9'c Ih~rc hl¢n. N6i dlllllg, h;\ilil \'i CLIa de JlWeh [ng(1 I:lln \"i¢c the() lllll-e sC' duoe X:I:-" tlt,j'J]g Ircn nhCmg ei'llI I¢nh dJCU kl¢n if kll(lug (hi), dl'l. ell the hicli chi knh dicli kl~~n if J h(lng (hiy du lit du I~nll if chi e6 Im)l nh,\llh th('11 \:\ khullg chLra nh;lnh c1st,. l\"hu v'~y. nwi lin hi¢u hO;h: bien khl)llg dUde diL'lI hllicll h(')'i t{11 cil de kh,\ n{l1Ig e(i lhc e6 eua diell ki¢n dell dune llll1 ph\lllg 111:11111 lllll-rllg ph::ill Ill' IIlgu' l~lIll \'i~c th ::o IlUi-C. C;lC ph:lll tll' trig(51;1111 \'i('c theo llll~rc llilf()llg XlI:tt hi('ll lrollg Llu,i Irlllh IllO plll'lIlg khi g'.IP c;le knh if \';\ cast' OJ cau IrltC klH)ng d;IY dll. D(\ln dll!,(Jng trlllh t]'(lng \'1 lit! \'Lra nCli tl'l'll ILrung Ll'Ilg \'(')'i phan Ill' Irigo Elm \'Jce Iheo mt'fe d dtH)e hi~lI dJl'll ht\llg du ]Cnh if e6 e:1lI IrllC khr'lIIg (by dLI. Dc Ir;lnh s~r XUil't hi¢n ella de phSn Ill' lrig(i !i\ln "icc theo mlre khl\llg mOllg l11u6n. ehlJng til ph;11 g;ln [ill hi¢u ,,6i tAt c,i de kha Ilallg e6 the U') ella diC:u kl¢n trong dc du knit rc nhi'inh. Vi dL,I, llC'U [<I b(~ sung de nh;lnli \";10 C,-lU Knh diC:u kl¢n [J'Ollg dO'-,1I1 eilu'()"ng trillil nClI lren, chi I¢nh if sc dwyc hicli 222 d!(~n (tty ell!. Kill dt) doan chmmg tr!nh sc c1U\K chuang Irl11h m() ph(\n~ tt)llg 1HlP nhu 1ll<1t ph,tll tlf At\'D. Vldl.1. si~nal S, DIn, DOu!: BIT: procl2s~ { S, Din) he~in if ( S = '1' ) then DOul <= Din; else l'ud if end process: DOllt <= 'cr; Chung la c6 Ihe rn(l ta ni1L"rng ph:in tu trigo 1;1111 vice thc() \l1Lrc \·t\1 hell lLIU tin hicu Ilm't [{ip ~lci tri '0' hoi.ic 'I' kh()ng d(lllg b(l. DO<ln dUl'ting trlllh tlw"ii d[IY SC blCll di0n ph:in ILl" Ingo'l:l1n \'i¢c then 111LrC c6 glcl Iri '0;: Ihle"1 Lip \\:: '(l' J hi lin 11I¢u (btl \'aO kh6ng dong be) RST nh,)n gl,\ tl"1 b,lng' l\IH( \' (v Irong \'f d\l n;I)" tfll hlCU RST 1:1 till hl~'U kfch ho,.11 nii vO'i lllL!"C gi, l1'i Ifn hiC'u can. RST = I -==> IhicI Wp In,lllg tl1<ii eua trigo' \'~ '0'. si~n<ll S, RST. D[n, DOll!: BIT; Pl'OCI2SS ( S, RST, DIll ) hq!,in if! J(5)T = 'I') then DOLlI <= '0'; c1sif ( S:::: 'I' ) then DOut <= DIn; end if: cnd procl2ss; r ;C'u chLlng: la muCin dOl lin hi~u I{ST thi:l11h tin hi¢Ll kich h It ,/ii IllLK gi,\ tri th'\"p. dic'u ki¢n trollg cJu I¢nh if <.;13 chuyen Ill' ( RST ;:: 'I' ) thi:lllh ( RST = '[)' ). J. XilY {hmg ml.H:h dl'mg htl hai pha C(IC m,lch d6ng h6 hai pha c6 the' du\,l'C m(l ta h:ll1g deb su' dung cae Irign I:lln vice theo 1l1ll'l.:. l\1neh d6nt! h(; hal plw (hr(le hicu (hen h,lng hai qu:i. 11"I11h Troll~ (h.'l. mtl\ qu,i. Il'lnh m{l 1'-1 m~leh Ie) hClp yil !1lach 1:1\ t:int! Ill(lt. lju:! Il'lllh kh.ic Ill,) ta 111'.lc11 16 hop \';1 mach 1:11 IClllg tIll! hai. Vi dl.!. 11110'1 k0' Cll(1 Ill<'lch d6ng h,) hai pha ,,;: du'oc 1l1tl hI bang dn:.lll dllfnng Iflnh trell ng6n ngll' VHDL nllll' sau: D= -I~l· ~·- ~I ;hl; tJ 'II - ~r l . Z B ._~___ D r Phi 2 I I ('n tity T\\'oPhasc is port( A, B: in B[T: PhI. Ph2: in BIT: I: huffer I~J r ): end T\\'oPha" ::: architecturt' Impkmcnl of T\\'oPhasc is signalll: fliT: pron'~ ( A. I. Phi I hegin if ( Phi_l = '1' ) then J) <= " or?: end if: end proc('ss: procl'ss( B. D, Phl_2 ) hegin if ( Phi_2 ::::: 'I' ) thl'1l 7, <::: Band ( not D ): end if end process: end Implement 4. Cric Im~ch triga lam vi('C theo sUtHl ( nip.tlop ) Cae qua Irlnh chua cae tin hi¢u if hO~le wait dieu khi~n thl:O sui.'1!1 kn hO~IC SU'C111 xuong ) la cae qu<i trlnh duqe c1inh gio'. Cilc In'-,Ieh trigci dicu kh[(~n Iheo sU0n l~n hO~lC sui.'m wong clIa tin lm':u se dll'0c 1,:,10 1'<1 lir m6 1<.'\ Iren ng(m ngu YHDL lle'u phcp g,in tin hi¢u ( hO[lc ph~p g.in hie'n ) dUQ'c tln,rc hi~n thea sU0n 10n ho,)c suan xuong ella de tin hi¢u dieu khitn. Kili tim ra ,>uon ella I(n hi¢u dong ho. ChU'(illg Ir1nh m6 phl1ng co tht xac dinh dUQ'c \'j Irf dc dtIu phfin tir Iriga yao !TIn hlnh. NhtI V(I)' m6 hlnh nh(m (hlqc se hO<'11 dqng theo dl! doan Irong giai dm,lil thiel kc. Thune Ifnh event ella tin hi~u dlf~iC dung de hicu dil:n sy' hien Ihien clIa tin hi¢u. Khi chung ta c[in x,\c dinh Sl! hle'n thien ella I(n hi¢LJ. thWle tinh event siS cho ra gi,\ lr! 16gie tu5' Iheo tren <luang lin hi¢u co Xll<lt hi91l "lJ ki¢n hay kh6ng. ThuQc Ifnh stable cGng cho gi,i Ir! 16gic vii e6 )' nghia nguQ'c h.li n"'ii thuQc IInh ennt. Tron!.: vi tlu du6'i duv. chuno- ta mn t,\ ~. _ e Din I I DF/F Q elK DOu! mnh 7.9. Trigo D (ticu khic'll theo ~lf(Jlllil1 hlcu (ICing 110_ trigc) D diJu khie'n theo sHon len bilng ngnn ngO' YHDL. Bieu dil;n cLla 1l1'.lch hao g6m m(ll qUii Irinh process e6 danh sach lin hi~u I[\C dQng chCra lin hicu (kl11g Ito elK. Qua trlnh nay dura m(l\ ulU l~nh if Cll bicLi Ihu c dicu bet kicm tm Slran 12n eLla lill hieu dong ho eLK. Trong Ihai gian tin hi~L1 IhiLI J;)p SU'liIl len, giil Ir! Iren (lLri\ng 11n hi~u DIn dU'(iC gilIl cho (hrong lin hicll DOu\. V i ell.! m() 1:1 hOi.11 d(lllg cua tngo D lam vi¢c thea sU'an len ella tin hieu dong h6 elK. signal eLK. DIn. DOul: BIT; proccss( eLK) begin 225 if ( CLK'eyent and CLK =' I' ) then DOlIt <= Din; end if; cnd process: Trang doc chuang trinh Iren ng6n ngiJ VHDL, cUc bie'n cling, co Ihe sinh ra uk trigo dicu khicn then sub"]} tin hi¢u. Cluing ta hiet n\ng, khi 1l1<)t bien dU0c khai h;lo trang mOt qua Irlnh process, gii.! Ir! cua bien '>0 kh6ng rb"i khhi qua Ir!nh (eo nghla li\ gia Iri cllil bien dU0C kiwi h,-Io hen trong m(l\ qua Irtnh se khollg dW1c SLr d~lng 6 hen llgo}i qua trlnh). l\hu V~IY, Ihoi dic'm 1l1~1 llH)1 hierl ~e sinh ra 11191 trig a dieu kilien then su-an trung qu,-! Irlnh 111<) ph<'lIlg 1;1 thc\i diem khi hie-n dUtfc su dl;mg tmoe Ide du~)"c g[U1 giCI Iri hen Irong qua trlnh clLrqe di~u killen theo till hicu cl{)ng h6. Trong vi ell,! du6i c!iIY, dOi 111 mil c11L]"<1ng trlnh VHDl sc sinh ra hai phi'ln tu: trigo 1~1.I11 Yi¢c Iheo strim k.hl c1uoc 11111 phong. Vi ell;): doan chHang Irlnh 1, tO ra hai plu:tn tu triga dieu khiell Ihen sU<JJ1 trong qUii trlnl1m6 phong. signal CLK. DIn. DOuI: OIT: proccss(CLK) yar"iablc TMP: I31T; hegin if (CLK'event and ClK = ' 1') then DOu! <~TMP: end if: end process: TMP:~ DIn: Trong vi dl;)lld.y, bien TMP duqc SLr dt.wg lru"6c khi duC/c gi.in gi,] Ifi. NIH!" \'i.~y, gia tf! chua trong bic'n TMP lit gia tr! c6 cltrQ"c S<.lU I[in 1~IP trLIlk ella Irlnh It! thJ!c hi~n quil Idnh vu chung la can ph,ii co m(ll trigo de" lUll 11'0· g.i:1 1n nay. Neu chung la doi cho hai phep gan trong dOi.tn chuung Irluh U61 tren, hien TMP se lU"ang ung dan thurin \'6i mOt d{ty dan. Khi do chi e6 Il1l)t phrin tu trigC1 .'>c dtI~)"c t'.lO fa trong qua trlllh 1116 hinh hoa mi teh. 226 . ngu' YHDL: [)]ll [J[)OUI -[ )() S - C mnl! 7.7,!'ILKh tn-go D 1:111 yieT "("1] ("he d(l deing 06 tlk'() 11llrC 121 signal S, Dill, DOut: R1T~. bang dn:.lll dllfnng Iflnh trell ng6n ngll' VHDL nllll' sau: D= -I~l· ~ - ~I ;hl; tJ 'II - ~r l . Z B ._~___ D r Phi 2 I I ('n tity T\'oPhasc is port(. dlllllg, h;ilil 'i CLIa de JlWeh [ng(1 I:lln "i¢c the() lllll-e sC' duoe X:I :-& quot; tlt,j'J]g Ircn nhCmg ei'llI I¢nh dJCU kl¢n if kll(lug (hi),