1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Điện Tử - Cơ Sở Thiết Kế Mạch - Design Trên Máy Tính (Phân 2) part 3 potx

7 372 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 7
Dung lượng 136,24 KB

Nội dung

Irlnh Iruycn Ih6ng de khai b,io hai kitu "Color'" viI "Lighl'" iiI sai \'~ m~tt ell ph,ip. Dicu do I~\ do n2~u m(lt hien X co kicu 12t "Colm". thl khl thl.fC hi~ll phcp g,in x ,= Red: ehuong trlnh dich se kh()ng xac dinh dLlqc gia Ifi 'Red' Ihuc)c mien x<.le dPlh cua kieu n~lo! Neu gia tr! 'R.:J' J6 thU(1C kicu "Color" Ihl pilcp gem lit dung. Tl'Ong trlfong hqr gia trj 'Red' thu(le ki~u "Light" thi phep gem do Ii:I sai. D~ gi,ii LJuye'( tinh tri lllg m(lp ma do. tl'Ong ngt'lll ngu YHDL ton 1'.11 co ehe dinh kieu. Co ehe nay cho phcp xae dinh mr)t each tU'ong 111mh giet tri dang xcI Ihu(le kleU n(lo. M6i d6i IU(,mg xuilt hi~n trong kicu co mc)t vi trf nhflt dll1h \'il duqc Xi.le dinh b6i trtll tLl xu:it hien. :\1(lt c<tch mac dinh, doi ILlqng dtiu lien c6 \"i trf O. deli tuqllg tiep theo c(l vi lrf I. v.\'. Trong qua trlnh tcing IWp phi."in clrng, kfch thude ella tin hicu ho,)c bi61 klCU li¢t kc dUQ'e x<\c dinii blri so Iwmg bit nh() nhSI de mJ h6a s6luqng de gia tr! li¢1 kc. h. Kicli s(i nguj"cn Kicu nguyen Ji:t llli~n xac dinh eua dte so nguyen. Ttlt Cit c.ie plIcp loan to il1 hqc th61lg thu(l'ng deu.up dl;lI1g dur/c eho so nguyen, Cal' phep to;in th~rc hi¢ll tren kic'u nguyen IiI: +. *, /. Quy ti.k Cll pilar kilai hi.lo kicu nguyen co dang nhu sau: type U;/1 ku;;{ is ran<>e mU;/1 \() Il(l{/\C/I . . ~ ~, mi/II \(j' IIglI\(,1I I~\ mien can eua t(lp hop s(j nguyen. Vi dy, t,ype lnteg~r is rangs -2 I 474R3047 to 2147403647:., t)'pe Twos_complement_Integer is range -3276R to 32707: c. Cae kieu duoe dinh nUh)a tru6c tron" VHDL . . ~ ~ Tileo tieu ehufin IEEE 1076 - 1987 ngu'()'i ta x<\c dinh hai gOI ehutin: g6i Standard \,~I goi Textio Irong tim \'i~n STD. Moi gOI chua t(lp hqp eic kicu V~I toan tLe. Trong gOI Standard chua tat d. cae t¢p nguon elm ng6n ngiJ' YIIDL l:So v(1i cae !l1~nh d~ [In. Sall d:IY \,\ m(lt s6 \";iC:u ehu,-In dlHl'e 1116 ta trong g/ll Standard. Bouh'<ln: kiC:ll lid kc c6 h,-11 giCI Ir~ faise vii true \/ii qLlan h~ fHI~e < trul'. Ck phcp t,:i.e dQng kn doi tlf()'ng \";i~u Uoolcan ;;\ rh0p lo,ln 16gie vtl quan he. Cae phep toan n~\y If,-I h.li gi.1 tri ki0u Boolean. Bit: ki0u liet ke \'(ii hai giCI Iri '0' vii 'J'. C:IC phcp 10:\11 16glC c6 Ihe Ilwe hl~n Iren de Mii tu'qng kieLJ Bit va Ir.l h.li gia In kiell Hit. Character: kicu iI~t \ ;C veii mien \.ac d!nh 1:1 t~IP hnp die k;' Ill' ASCII, eic k~' Ill' kh(mg hicll du(.'iC bi~u dien billlg 10;1 eht'l'a ha k)' ILL Cae k)' It.r hl~n hlnh dlf<,'IC bicu dicn giua hai da'u lm'lc do)). ]nte~cr: kieu so nguyen v6i nhullg giii trj dlfong ho(tc [l1n. Mien Xiie dPlh Cll,1 ki~u Intl'~cr lfOng g6i Standard la: ILl' -2. [47.41)1.647 d0'l1 2.147 A!n.G-l-7, Ck phcp to.ln tren C<IC dc'li IUcl'ng kicu I ntcgrr Iii UtC phcp tmin so h')c: +, ;" ,/ ' Natural: III m(lt kiC:u COil clla kieu ,,,6 nguycil \':1 dltng de: chi utC ,,(l ngu)'C'n kh('ng [lin - ,,,6 IV nilien. P()~itivc: Iii ki.::'u con clm ki~u so nguyen sir dung de hieu dicn c.\c s6 duong. Bit vector: Iil. kicu bicu dicn 111,'lIlg eae Bit. Strill;:!;: kieu ch-[' lt~u bao g6m ndng cac Charater. M()I glcl In KIC:U Strin~ dWl'C chl'l'a Hong m()t cap m6c kcp. Real: mt'l 1,'\ GtC s6 tlwc Irong gi6i h'.ln: tu -1.ClI : + 38 (kn I.OE + ::IS. Phy-,icaltypc Time: kieu Time dU9c Sll' dy.ng de' hie'u di~ll uie ~l,i If! thl~i gl<111 dLll1g Irong qua Irinh m(i pbong, d. KiC'u m.in~ Tlflmg 11.1' IIbll' trong etc ng(lI1 ngCf 1~lp trlnh truycn Ih6ng. lrong ng()Il ngCr VHDL. phiin Ill' kieu m:ing 121 nh6m cae phfin tLI' clll1g kicu vi:t duoe truy c:tp \l'ri nlHr m(ll d(ii tu<:m~. Ph:in ttr kieu mang trung ng6n ngi.1' Vl-IDL e6 nhCing dae dlcm nhu ~all. CCIC ph,-\II ILl' clla m:l1lg c{l Ihe lit l119i ki(:u lfOng ngt'lllllgt"i' VI-IDL, SCi ill'(!ng e.ie dl! s6 ella m.ing ( noi deh khat 1<'1 s6 ehicu cua 1l1,-'llIg e6 Ihe' nh:lIl 1l19i gi.l Ir\ dll'ong. Nting chi cl'i m()t va chi m(lt chi s6 dung de Iru)' nil~lr Ill'i ph~in ttl'. !'i7 Mien hie'n lhien elH' ehi s6 xilc dinh s(i phan tu cua llliing \,~I hu6ng ~,jp :\c'p chi ,,6 trong 1l1ilng: llr c,ie chi ,,6 eao xu6ng c,\c chi so lhftp ho\\C nguoe 1'.11. Kicll elm chi s6 co the' 1;'1 kitu nguyen ho~\C kicu li¢t kc. Khiie \'{j'i de ng6n ngu IZlp trlllh tru),cn thong, trong ng(lI1 IlgU" YHDL rn;ing dw)"C cilia Uun hai lo".li: m<.lng c6 r~lllg bU(K \';'1 m lng kh6ng rllng bw)c. M:.ing c6 r~ng hU(le III milng lrong d6 kie'u eLla chi s6 e6 mien xac dinll dUlye quy d!nh mQ\ d.ch lU"i".mg Inlllh. Dicu do co nghTiI Iii ,au klu dU<;Ic Khai ])(io, mang co Krcll thw'K c6 dinh. 'llnr y,Jy m:"lng c6 r:ltlg hU(K tHong II,!" "oi doi tllvng kltu lll<.ing Iiong ele ngllll ngCr li)p trlnh Iruycn til6ng. eli phiip eua 11l,ing co fling bUi)e: t)PC ICII_lIhllIg is array (Alw(f!l'.;_ (liil_( 11I·_.\() ) uf Alell (1l0 1!/itlll III Trong (h). / :/i()(iIlX_( ,i(/_cJlI_,wJ'];'llIlicn con clJ<1 kitu nguycn ho~\C kicll lil:! t l:. / :/(,'u_Cliu-,)Jh'il_,/i·la kicu ella phfill lU m;ing. vr dl.!, khai b<.io mlmg ella 64 rhfin lU- nguyen. type Arl-is array (0 to 63) oflntcgcr: Miin!.! khl')'l!! rllll!! bw.)e III ki0u milll!! Iron!! d6 mien ""ie dinh elta ' L. L klCII chi Stl \';1 lur6ng s{lr xc'p ella de chehi sli kh()lIg \"iie dinh illae ell! s6 IU\l'n,!! chil'u ella lll:ing (tWl"e chi roo \'!m \'ity (kii Ill"ting llliing kh()J1g r;lIlg bU(le eo the e6 s(i !UO'llg ph:11l Ill' kh()ll~' :>;;Il' dlllh. 1\6i c iell kllile mill'g kh(lng ri\ng hU(K' e6 "(1 kich IlJU\l'c bll,'n Ihicn 'lIm \'<.)y dung lu\mg btl nho slr dung Chll lllr)1 ll1,ing kh(')llg rilllg hill'll" e6 the thay doi tU)' theo nhu cliu slr ell.mg, Dlcu nlly khae \ 6"i de ng(l/l ngLr 1(lp tflllh lruyen th6ng nlnr C. Pa"eal. . ell phiip eua m<.lng kh()ng riltlg hur)c: f~Pt' /(;II_"hing is arra~' ( 1(;/1 / :/{'II ('hi ,I/! n.ll1gc < > ) of Ai ('II 1)1111'11_1/;'. Ihl /":/(;11 ('/11' sli'lll kicu eon xile dinh chi sCi. Vfdu. t.ype B1T_ VECfOR is array (i'atUl'HI ran~e < » of BIT: type String is array ( pustiy(' rHng~' < > ) of dwractc,,: ;-,uhtypc B4 is I31T _VECTOR ( 3 down to 0 ): \.'ariablc V5 : BIT_VECTOR (4 downtn () ): rv1ang IlllJ'tillg dl:ll1,!! tl2 bicu di~n call Ink luyc'n 1111h nhu tl1a1111 gill. RAM. ROM. eic phfin ILl' m;lng dune d;inh dja chi hang de elll :-;6. do del chi <;(i ella m;lng ph;l] co ki~u n\i 1"<.1t: nl11i kicu :-;0 nguy0n. kil:U li~·t kc. Vi (IL.I: m6 I;; Ix) Ilh6'c6 kich Ihu6c 16 x 10: suhtypt, int J. is Integer range 0 to 15: ;-,uht.\pc ImlO is lntcgt'r range 0 to 1023: f)'pc \1ClIIllfY is array ( Inl 1- ) of Illi [0: Ta e6 the truy c;)p t6"i de phfin Ilr cLla tn~ing thco chi :-;6. Vi d~l. LtC Iruy e(lp lai de ph;"in IU eLla tn,ing X thea ehl :-;6 l. variable X: Mcmory: variable 1: int 1-: variable Y: IntlO: Y:=XI ]+3 I: l\gClllllgO" VI-IDL elm phep kh;\i b;Io de 1l1;lng nhi(:u ehicu. Vi dl,l \'c truy c;)p mang nhi(:u ehicu duqe dua ra du6i day. Vi til.l. type T\\oarray is array ({) 10 7. 0 to 3) of BIT: constant 'l\nlROM : Twoanay:= 11'11', 'U', '()', 'I' I ( '(I', ' (' , '()' , '(' I ( '0', '0' ,']' ,'(' I ( '1', ' I' , '0' , '1 t ) X := TwoROM (2,3); ('0' ,'0' ,'(' ,'(' I, I '0' , ']' , '0' , '(' I, ( '(' , '0' , '0' , '(' ), ('(', '(', ']', ']')); C. Kicil ban nhi " Rill ghi 1;\ ullom eua m()t ho~\e nhieu ph£ill tu' thw.)e nhO'ng ki~ll kh.ie nluLI \'~\ dLil.K truy dp tdi nhu 1l1t)1 d6i tI1Q'ng. Rill ghi e6 nhung d,)e dicm saL!. NMi ph:in tLf eua \xill ghi duq'c truy nh(lp t6i then I~n trl1()'ng. eic phiin ttl ella Ixin ghi co the nh~1ll moi kicll ella ngbn ngiI VBDL kc C<.I 1l1<"lIlg yil \xln gill. VI d~l kiell h,ln ghi: type Datc_ Type is ( Sun, Mon. Tue, Wed. Till'. Fri. Sal ): typc Holyclay is rccord Y car : Intc!!;cr rangt' 1900 to 1l)99~ Month: Integ:cr ran!!;c I to 12: Day : Integer range I to 31 ~ Date : Date_Type: end record: eic phfln ILf eua h.ln ghi dU(Jc tru)' nhttp theo ten b<.'ltl giti \':1 ll'll 11 LflJng. Hai tklllh [1h,'ln n~ly ng[1ll deh nhau h()oi d:lu ',' . Vi d~l, signal S: Iioliday: variable T I: Inte~cr rangc ( 1900 to 2099 ): variable T2: Datc_ Type: Tl := S.Year: T2 : = S. Data; f. Cae kicli trung goi Standard Logie n.:" Il1d hinh hOii uic till 1H~'n C() tile: nh;:1ll nhicu hO'n 1w.i giii tr!, IlUn,g ngon ngO' VIIDL X{IC djnh gl)i Standard Logic ( tuong ling voi chu[ln IEEE ](iO Std 1164 - 19(3). Hai kicu dG' li¢u co ~& Irnng goi nay I:l STD_ULOGIC va STD_LOGIC. STD_CLOGIC xac djnh ki~u dlilL¢u grim chin giii II"!. etC gi<.1 tr~ tin hil:u klc'u STD_ULOGIC kh6ng th~ tham gia \'110 dlc pbcp lOitn logic Y~I so hQc co h,in. Trong tru'cmg hOp n~IY 1<1 ph,ii 1l1(:i rong C(IC phcp tU~ln so hQC va logic C0 b,ll1 bang each cung Ci;IP cac h,1111 quye"t dlllh. Trong nhling tru'ung IWp khi lin hi¢u tren Im''lt dUi'J"ng co the nh,)n duoc til" nhieu nguon lin hi0u kh(lc nhau, chung ta cOng ph,'li cung eilp dc kiln quycl d!nh. Vi dy., trong Iru'ong hqp tr0n hinh 5.11. dlf()"Il,g tin hi¢u s Iii kc"t n6i eLliI hi.!1 dLfCl"ng tinl1]l.::u d(lC 1~1l1 SI \"i\ s] , khl d6 t<.li diem kel noi cll<\ hai dU'o-ng tin hi~Ll ta ([in ph<li xac djnh giu tin hi¢u tren s DlI:ll1l1;ll 1Iilll1 quycI dll1h gl~i In lin hl~LI mnh 6.11 Trlrollg hOp ,Lf dung hiltll quyfl ,1mh. dlfCl"llg s sCi nh[ln throc tu gi<.i Irj lIn hi~u trcn duo-n,g "I \',\ S, nhu Ih6 n£\O. Thong thu'cmg giil trj Iren duong S du~1"C X(IC djnh b~ll1g de phcp loCm OR, AKD hO~lc XOR. Trong Irll'bng i10P gi,t Irj CUi.! tin hi¢u duqc 1110 1,1 b~l11g m(lt lrong chin gi;'t trj CLla kicu STD_lJLOOIC. ta din phai Im'1 rQng cac phcp tocin \('lgic cha dc giAlr! khong IhuQc I(lp hqp { '0', 't 'J hay I 'rills~', 'Irue' 1. NIlllng phcp to,in m6 r¢ng d6 duC)'c bieu dicn htlllg dlC hilln lJuy6t d.ll1h. Cae gia If! clla kicu STD_ULOGIC: type STD_ULOGIC is ('U', 'X', 'I)', ,\" 'Z', '\Y', 'L', 'H', '.' ), STD_LOGIC lil ki~u dU'\JC x,-ie d!nh. Cae hiun quye't dinh cua kiC"u l\~y du"Oc cung dip hlii g6i Stand and Logic. Tunng tll' nhu' nIT V;I nrr_ V ECrOR. n~6n ngu VHDL CUllg cap hai kl,-'u STD_L'LOGIC VECTOR V" STD_LOGIC VECTOR. Vi dL,l. cntity ADDER is port ( A. It in STU_LOGIC YLCfOR ( 3 do\~nto 0 ). Cin : in STU_LOGIC: S ,out STD_LOGIC_ VECTOR ( ,downto () . Coul, (lut STD_LOGIC: ), end ADDER; 161 g. Kicli signed va unsigned Ki~u e6 d:ill signed va kh6ng dflu unsigned dLIqe sir dl,lOg doi v6i nbu'l1g d6i tuVng sc uuqe truy C(lp t6i nhLI cae bit va nhLI d.C s6 nguyen. Hai h~u nilY' dLIQ'C djnh nghLa lrang hai g6i NUMERIC~BIT va NUMERIC_STD nhu' "au: t~[pe signed is array (natural range <» of BIT/ STD_LOClIC: ty'pe unsigned is array (natural range <» of BIT/ STD_LOGIC: Vi dl,!. Card_Input: unsigned ( 3 down to 0 ); Score: signed (4 downto 0) := "00100"; cae phep toun so hqe dlIqe Ina r¢llg eho nhling kit~u dO' li¢u nilY vii dlIq'C 1116 ta trung cae goi NUMERIC_BIT va NUMERIC_STD. Cie d6i tuVng ki6u unsigned duqe bieu dien nlllr cae so nguyen nhj phflll kll6ng drlll. h. Kicu con Cae kieu COil I~l IlH?t t(lp h(,ip COn eua de kicll drr dU'<;K djnh nghLil khtic. Phep kiwi bao ki~u con c{) the ntul1 a 1l1i,li \'j tri cho pllcp J hai baa kicu. SI! kh.ic bi¢t giua kiell can vii kieu la 0 ella kicu con chi la t(lp con ella m{)t ki~u hOZlC llH?t kieu con diJ dlt~K dinh nghia trltlk. Kicll can Ihuang dung dC gioi IWIl c,ie dang du' li~u trong de phep gem va Ir-:n de duo'l1g dn li¢u. V6i \'i¢c khai b,IO de kicu eOIl, cac (h.Ulg du li~Ll c6 the dLIqe nh(Ul c,Ie gi{l tri eo nghL<I. Cte kieu con k6 thLra I11qi Imln tll" vii ehuong trlnh con tae d¢ng len cae ki6u eha. Vi Ul,!. eile kicu natural \'~l positive iil eSc ki~u con eua kicLL nguyen integer. Ck kiwi bao kicu con cll dc.lllg sau: suht)'pc Int4 is Integer range 0 to 15: subtype IlIT_ VECTOR6 is IlIT_ VECTOR \ 5 downto \J): §6.4 Toan hi va hieu thuc Trong ngon llgU VHDL. de hiell thue lil C<l.e eong Ihuc. Cile et'lllf! therc nay xac djnh cae tae dQng linh toiln ICn cae doi 11I(jllg du lieu. Cie hi~u Ihue in2 . s(j nguyen. Vi dy, t,ype lnteg~r is rangs -2 I 474R3047 to 21474 036 47:., t)'pe Twos_complement_Integer is range -3 276R to 32 707: c. Cae kieu duoe dinh nUh)a tru6c tron". t l:. / :/(,'u_Cliu-,)Jh'il_,/i·la kicu ella phfill lU m;ing. vr dl.!, khai b<.io mlmg ella 64 rhfin lU- nguyen. type Arl-is array (0 to 63) oflntcgcr: Miin!.!. thco chi :-; 6. Vi d~l. LtC Iruy e(lp lai de ph;"in IU eLla tn,ing X thea ehl :-; 6 l. variable X: Mcmory: variable 1: int 1-: variable Y: IntlO: Y:=XI ] +3 I: lgClllllgO"

Ngày đăng: 10/07/2014, 02:20

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN