4) Bo dem Johnson va giai ma thap phan
2.3.1 Cac birdc thirc hien mot project tren FPGA
I I y y
Trong thiet ke phan cimg bang ngon ngir (HDL: Hardware Desciption Language) ngoai each diing cac ngon ngu md ta phan cimg nhu ABEL, VHDL hoac Verilog,... con cd mdt phuang phap kha tien dung, dd la su dung ky thuat
> t i f f
dd boa. Vdi phuang phap nay ngudi diing cd the thiet ke cac he thdng tir don
I 1H
gian den phuc tap mdt each nhanh chdng dua tren thu vien cd san hay tu minh
> t m^
tao ra bang each sir dung cac ngon ngii ke tren. Dua vao mdi dae tinh cua timg
t I I
bg chip cu the, nha san xuat cung cap cho ngudi diing mdt thu vien tuong ung,
> y f
cac thanh phan cd trong thu vien la nhimg thanh phan ca ban, chu yeu ma ngudi
X / f f f
diing thudng cd nhu cau sii dung den. Trong qua trinh thiet ke, neu ngudi diing
r y y f i f •>
tim khdng thay thanh phan can thiet cho thiet ke cua minh thi ed the tu tao ra no bang each diing cac thanh phan trong thu vien de xay dung nen hoac diing cac ngon ngir da ndi tren de md ta chiing rdi luu trir lai. LTu diem ciia phuang phap
, f r f
do boa la: tinh true quan, nhanh chdng trong thiet ke cac he thdng vira va nhd,
f f f y y y i
khdng ddi bdi ngudi thiet ke phai biet nhieu ve ngdn ngir md ta phan cung, tiet
\ f >
kiem tai nguyen tren chip (dung lugng phan su dung den). Thdi gian can cho
I f f I t r y \
thiet ke cang riit ngan neu ngudi diing da thiet ke phan cung ung dung mdt phan
> t y
hoac toan bd bang cac limb kien rdi rac. Nhuge diem cua phuang phap dd hoa la
f f f f I y y f
nd ddi bdi ngudi thiet ke phai nam rd eau tnie cua he thdng phan cimg can thiet ke. Trong khi van de nay trd nen don gian hon neu diing ngdn ngu de md ta, bdi
> f I f f y f y
vi nd khdng yeu cau ngudi thiet ke biet chi tiet hoac tudng tan ve eau tnie phan
X I f f
cung, ma ehi yeu cau ngudi thiet ke nam duge nguyen ly boat ddng cua no, thong qua bang chan ly la da ed the md ta duge nd rdi. Nhung phuang phap diing ngdn
t f f f
ngir md ta cung cd nhuge diem la thudng rat tdn tai nguyen eiia chip, bdi eau triic ben trong he thdng duge ngudi diing md ta se duge phan mem thiet ke tu dong e4u tnie (dat c^u hinh) thdng qua cau lenh ma ngudi thiet ke da viet ra, vi vay khdng tranh khdi sir triing lap trong viec sir dung cac phan tir (yeu td) logic (thanh
, f y I
phan chinh cua chip), chinh vi the ma gan nhu hang nam, cac nha san xuat chip
f y y t f -• \ I
lai dua ra cac phien ban nang cap phan mem thiet ke de nham tdi uu hoa trong thilt kS sao cho tiet kiem khdng gian tren chip duge nhieu nhat.
f f y * *
Sau day xin trinh bay rd ban phuang phap thiet ke phan cung bang do hoa,
s ^ I
tren ca sd sir dung phan mem thiet Maxplus2 cua Altera (My). Giao dien ciia ciia phan mem Maxplus2 cd dang nhu sau:
MAX'^pius II Manager - d:\hieu\fpga_aiteraUrltWbkhun&
MAX+pkjsII File Assign Options Help
D : ( ^ ^y k7 i>^m3Bs m A Bii@@
. ' ^<
Hinh 12: Giao dien ciia ciia phan mem MaxplusZ.
2.3.1.1 Tao mot project
y ^ f f t
Bude dau tien ta phai xac dinh ten ciia project thiet ke. Trong eira so Manager, tra ehgn File | Project | name de md hop thoai. Sau dd danh ten ciia project cua minh vao d Project Name, ehgn thu muc ma minh can lam viec va an OK.
PnycctNanif,_;u^4^ Project Name: S S Directoiyis: c:\max2work\tutorial Files: Directories: B c : \ {r^ max2work Drives:
Show Only Tops of Hierarchies
OK Cancel
Hinh 13: Chi ro ten va thu- muc lam viec cua project.
MAX^plus II c:Vnax2workUutor1alWd1 -[yd1,g^f "GfapWpE^jtorJ.
• ^ MAX-fpkjf n Fie Edt View SyirM Assign UtJRJes Opbons Wnjow Help
A
n
\
O
Hinh 14: Man hinh cua Graphic Editor.
I I y •>
Bude ke tiep la ve so dd. Trong cua sd Manager ta ehgn MAX + PLUS II |
•> f t
Graphic Editor. Cua sd Graphic Editor xuat hien ben trong cua sd Manager. Ta cd the di chuyen hoac dinh lai kich thudc cua sd Graphic Editor va tang them
t t f t
kich thudc cua cOra sd Manager de eung cap them khdng gian lam viec. 0 hinh 14, cua sd Graphic Editor duge cue dai boa sao cho choan bet ehd toan bo eira sd Manager.
Thanh tieu de d hinh 14 bao gom mdt sd ten menu va bieu tugng, cac ten
f > -1
nay da khdng xuat hien d hinh 12. Dieu nay la do cua sd Manager ludn ludn
I H f
chi ra cac muc ed san trong bat ky ling dung nao hien dang duge su dung. Mot
I t t f
sd bieu tugng duge su dung de ggi cac muc cua Graphic Editor ciing xuat hien dgc theo eanh ben trai cua cua sd.
t f f . ^ 1
De thay md ta cua mdt muc ciia Graphic Editor ket hgp vdi mdi bieu tugng, dinh vi chudt len tren bieu tugng; mot thdng bao duge hien thi gan dudi day cua
•> t f
eira sd. Hai bieu tugng thdng dung nhat la
t f
cac bieu tugng trong gidng nhu kinh liip.
t t f
Cac bieu tugng nay duge su dung de thay
hinh cua so dd Ion hon hoac nhd hon.
2.3.1.2 Dat ten cho sa do
So dd duge tao ra phai duge dat ten. Ta ehgn File | Save as de md hop pop-up
duge mieu ta d hinh 15. Thu muc ma ta da
ehgn cho project nay da duge ehgn trong
hop pop-up. Graphic Editor se tao ra mot
tap tin rieng cho so do va liru tap tin trong thu muc cua project. Trong hop c6 nhan File Name, ta chon VDl.gdf. Ta phai su dung ten nay mot each chinh xac. Ten VDI phai phu hgrp vai ten ciia project va ph4n ma rong la gdf, chii vilt tit ciia graphic design file (tap tin thiet ke do hoa), phai duac su dung cho tat ca cac
y I t y
so do. Nhap OK de trd ve Graphic Editor .
2.3.1.3 Nhdp vdo cdc ky hieu cong logic
Graphic Editor cung cap vai thu vien chiia cac phan tur mach, cac
^ t
phan tii nay cd the duge nhap vao trong so dd. Vdi thi du dan gian eila ta, ta se sii dung thu vien cd ten la Primitives, thu vien nay chiia cac
t t
cdng logic CO ban. De truy cap thu
I
vien, ta nhap ddi chudt vao khoang trong d giira man hinh Graphic Editor de md hop pop-up d hinh 16 (each khac de md hop nay la ehgn Symbol | Enter Symbol).
Hop cd nhan Symbol Libraries
.gnler Symbol
Symbol Name: J
MegaWizard Plug-In Manager. Symbol Libraries:
c:\max2work\tutorial c: \maxplus2\max2lib\prim c: \maxplus2\max2lib\mf
; c:\maxplus2\max2lib\mega_lpm
Directory is: c:\max2work\tutorial
Symbol Files: Directories: | ^ c : \
p=> max2work
Drives c:
OK Cancel
Hinh 16: Nhap mot cong logic tir thu* vien
<^r ^ t
liet ke vai thu vien ed san, bao gdm thu vien Primitives. De md thu vien nay, ta
I f y t
nhap ddi chudt tren ddng ket thiic bang chir prim. Mdt danh sach eac cdng logic
t r trong thu vien duge tu ddng hien thi trong hop Symbol Files. Ta nhap ddi chuot
t y •>
vao ky hieu and2 de nhap ky hieu nay vao trong so dd (ta cd the thuc hien each
f y f • >
khac, nhap chudt vao and2 rdi nhap OK). Ky hieu cdng AND2 - ngd vao liic
f t
nay xuat hien ben trong eira sd Graphic Editor.
f > T >
Bat ky ky hieu nao trong so dd cd the duge ehgn bang each sir dung chuot. Ta dinh vj con trd chudt len tren ky hieu cdng AND trong so dd va nhap chuot de ehgn. Ky hieu se duge ndi len mau dd. De di chuyen mot ky hieu, ta ehgn ky hieu va trong khi van tiep tuc giir niit chudt, ta re (drag) chudt de di chuyen ky hieu. De de dang dinh vi tri eiia mdt ky hieu dd hoa, mdt mang dudng hudng dan ke d cd the duge hien thi trong cua so Graphic Editor bang each chon
Option/ShowGuideline. Khoang each giira cac dudng cd the duge hieu chinh
bang each sii dung Option/ Guideline Spacing.
WAX+plus II c:\maK2wDrkttutoriaI\vd1 -[vd1,gdf-Graphic Editor]
^ MAX+phjs n Fie Edt View Symbol Assign Utities Options Window Help
A &*A A A n \ o PIN_NAME PIN NAME i.^f:-' Ufr^J I> -I > PIN_NAME PIN NAME
Hinh 17: Scr do hoan tat tirag phan tir.
Ham logic yeu cau cdng AND 2 - ngd vao thir hai, mdt cdng OR 2 - ngo
t ''
vao va mdt cdng NOT. Ta su dung cac bude sau day de nhap chiing vao trong so do.
t t
Dinh vj con trd chudt tren ky hieu cdng AND ma ta da nhap vao, an giir phim Ctrl cua ban phim, nhap va re chudt ra khdi ky hieu cdng AND. Graphic Editor tu ddng sao chep ky hieu cdng AND. Thii tuc tat (shortcut) nay cho ta sao chep mdt phan tii mach mdt each thuan Igi khi ta can nhieu ban sao eiia cimg mdt phan tu trong so dd. DT nhien mdt phuang phap khac la nhap vao timg trudng hgp cua phan tu bang each md thu vien Primitives nhu duge md ta nhu tren.
Ta nhap ky hieu cdng OR va cdng NOT vdi ciing phuang phap da md ta khi nhap ky hieu cdng AND. De tim cac cong eo ban , ta sir dung thanh cugn
n f ""
(scrol bar) de cugn xudng danh sach cac ky hieu cdng va tim ky hieu ten or2 va not. D I dinh hudng cdng NOT sao cho cdng nay hudng xudng ta chon ky hieu cdng NOT va k^ den sii dung lenh Edit/Rotate/270 de quay ky hieu nay 270 do nguge chieu kim ddng hd.
y t t y
Cac ky hieu trong so dd cd the duge di chuyen bang each ehgn chiing va re
^ t
chudt, nhu da duge giai thich d tren. Nhieu ban mdt ky hieu ed the duge ehgn
» ^ I
ddng thdi bang each nhap chudt va keo mdt dudng bao quanh cac ky hieu. Cac
, t y f ,
ky hieu duge ehgn se duge di chuyen ciing nhau bang each nhap chudt tren bat
ky ky hieu nao trong chiing va di chuyen. Ta nen thir nghiem vdi thii tuc nay. Ta sap xep cac ky hieu sao cho so dd xuat hien gidng nhu so do d hinh 17.
2.3.1.4 Nhap cdc ky hieu ngo vdo vd ngd ra
Den day cac ky hieu cdng logic da duge dua vao, ta can nhap cac ky hieu
de bieu dien cac port ngd vao va ngd ra ciia mach. Ta md thu vien Primitives Ian nira.
I f f t
Ta nhap chudt bat cii noi nao trong hop cd nhan Symbol Files va ke den go ky tu "i" de nhay qua danh sach ky hieu den danh sach eac ten bat dau bang chir
f t I
i. Bien phap tat nay ed the duge sii dung ciing vdi cac thanh cugn duge eung cap
*
tren hop Symbol File, ta nhap ky hieu cd ten la input vao so dd. Ta nhap them
t t m^
hai trudng hgp nira cho ky hieu nhap. De bieu dien ngd ra ciia mach, ta md thu
f f
vien Primitives va nhap ky hieu cd ten la output. Sap xep cac ky hieu nhu duge minh boa dhinh 17.
2.3.1.5 Gdn ten cho cdc ky hieu ngo vdo vd ngo ra
Ta ehd den chir PIN_NAME tren ky hieu chan ngd vao d gdc trai tren ciia
S I
so dd va nhap ddi chudt. Ten cua chan duge ehgn, cho phep ta go vao ten mdi cua chan. Ta go xl lam ten ciia chan nay. Viec go phim Enter ngay sau khi go
t f f
ten chan lam cho chudt tap trung di chuyen den chan mdt each true tiep ben dudi
chan dang duge dat ra. Phuang phap nay ed the duge su dung de dat ten mot sd
bat ky eac chan. Ta gan cac ten x2 va x3 cho eac chan ngd vao d dudi theo thir
f
tu. Sau ciing ta gan ten f cho chan ngd ra.
2.3.1.6 Noi day cdc niit
Bude ke tiep la cac dudng (eac day) de ndi cac ky hieu trong so dd vdi nhau. Ta nhap chudt tren bieu tugng trong gidng dau mui ten dgc theo eanh trai eiia eira so Manager. Bieu tugng nay duge ggi la cong cu Selection, cho phep Graphic Editor tu dgng thay doi giira eac che do lira ehgn mot ky hieu tren man
hinh hoac cac day den cac ky hieu ket ndi. Che do thich hgp duge ehgn phu thudc vao vj tri chudt dang trd den.
Di chuyen eon trd chuot len ky hieu ngd vao xl. Con trd chuot xuat hien dudi dang dSu miii t6n khi trd vao ba't eii nai nao tren bieu tugng ngoai trii d eanh ben phai. DSu miii ten ed nghia la ky hieu se duge lua ehgn neu niit chudt duge an. Ta di chuyen chudt trd den dudng nhd, ggi la pinstub, tren eanh phai eiia ky hieu ngd vao x l . Con trd chudt thay doi thay doi thanh mot crosshair, cho phep mot day duge ve de ndi pinstub den mot vi tri khac tren so dd. Mot ket ndi giQa hai hay nhieu pinstub trong sa do duge ggi la mot niit (node). Ten nay xuat phat tir thuat ngir ve dien, trong dd thuat ngii niit tham chieu den mdt sd diem bat ky trong mot mach duge ket ndi vdi nhau bang cac day va do vay ed ciing mot dien ap.
Ta ndi ky hieu ngd vao eiia xl den cong AND d phia tren ciia so dd nhu sau. Trong khi chudt dang trd tdi pinstub ky hieu xl, ta nhap va giu niit chudt.
Re chudt vi phia ben phai cho den khi dudng (day) duge ve dat den pinstub tren
ngd vao cua cong AND; ke den nha niit chudt. Hai pinstub da duge ket ndi va bieu di6n mdt niit dan tren mach.
ii« MAXtplus II -c:Vnax2workUutorial\vdT -rvdl.eiif^'Crdphic Ldttorl-
* ^ MAX+plus II File Edit View Symbol Assign Utilities Options Window Help
^;;&M;J^.,^»^'1>.±^. ...-' — -
fct w f ntm I M U A M i n . ^
D i^y # "o 1^? i:^^mBBS iM^*A m •'Qt> ^0> ^^ ""^^
A B - A = 0 - zfTi: k A n \ o €1 < x i I y X2 I y X3 I > O n Y 3 > -IZZ> F
Ta sir dung cimg thu tuc de ve mdt day tir pinstub tren ky hieu ngd vao x2 defn ngo vao khac tr6n cong AND. Ke den ve mot day tir pinstub tren ngd vao
cua c6ng NOT ve phia tren cho den khi dat den day dang ndi x2 vdi cong AND.
Nha nut chudt va quan sat thay ed mot diem ndi duge tu ddng ve. Ba pinstub tuong ling vdi ky hieu ngd vao x2, ngd vao cong AND va ngd vao cong NOT liie nay bi^u di6n mot niit dan trong mach.
Di hoan tat sa dd, ta ndi ngd ra eiia cong NOT vdi cong AND phia dudi va
ndi ky hieu ngd vao cua x3 den eung cong AND dd. Ta ndi cac ngd ra cua 2 e6ng AND vdi cong OR va ndi cong OR vdi ky hieu ngd ra f. Neu cd bat ky Idi nao duge tao ra trong khi bet ket ndi cac ky hieu, eac day bi nham cd the duge ehgn bang chudt va den loai bd bang each gd phimDelete hoac bang each ehgn Edit/Delete. Sa do hoan tat duge md ta d hinh 18. Ta luu sa dd nay bang each sir dung File/Save.
Do thi du cua ta ra't dan gian, ta di dang ve tat ca eac day trong mach ma
khdng tao ra mdt sa do hdn don. Tuy nhien, trong cac sa dd Idn mot sd nut can duge ket ndi ed the tach xa nhau, trong trudng hgp nay that bat tien de ve cac day giiJa chiing. Trong eac trudng hgp nhu vay, cac niit duge ket ndi bang each gan cac nhan cho chiing thay vi ta ve cac day.
2.3,2 Tong hgp mach tir sa do
Sau khi mot so dd da duge dua vao trong mot he thdng CAD, sa dd nay duge xir ly bang cac tong hgp ban dau. Cac cdng nay phan tich so do tao ra mot phuang trinh logic cho mdi ham logic trong mach. trong MAX + PLUS II, eac cdng cu tong hgp duge dieu khien bdi chuong trinh umg dung duge ggi la Compiler.
Sit dung Compiler
De md eira so Compiler, ta nhap chudt tren bieu tugng Compiler hoac ehgn MAXPLUSIII Compiler.
Vdi hudng dan nay ta se ehi sir dung eac cdng cu duge can den de cho phep ta thuc hien mot md phong ehiic nang ciia sa dd. De ra lenh cho Compiler sir dung cac cdng cu nay, ta ehgn Processing I Functinal SNF Etractor. Cira sd