直流電機(jī)VHDL源代碼_第1頁(yè)
直流電機(jī)VHDL源代碼_第2頁(yè)
直流電機(jī)VHDL源代碼_第3頁(yè)
直流電機(jī)VHDL源代碼_第4頁(yè)
直流電機(jī)VHDL源代碼_第5頁(yè)
已閱讀5頁(yè),還剩6頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

直流電機(jī)VHDL源代碼

LIBRARYIEEE;

USEIEEE.Std_

logic

_1164.ALL;

USEIEEE.Std_logic_unsigned.All;

USEIEEE.Std_logic_arith.All;

EN

TI

TY

Dc

countIS

Port(

Clk:INSTD_LOGIC;

AI

:INSTD_LOGIC_VECTOR(3DOWNTO0);

CO:OutSTD_LOGIC_VECTOR(3DOWNTO0);

Pulse:INSTD_LOGIC;

DriverA,DriverB:OUTSTD_LOGIC;

S:OUTSTD_LOGIC_VECTOR(6DOWNTO0);

P:OUTSTD_LOGIC_VECTOR(5DOWNTO0);

Sp:OutSTD_LOGIC);

ENDDccount;

ARCHI

TE

CTUREAOFDccountIS

SIGNALF:STD_LOGIC_VECTOR(5Downto0);

SIGNALF_hz:STD_LOGIC;

SIGNALOSC:STD_LOGIC;

SIGNALOSC1:STD_LOGIC;

SIGNALC:STD_LOGIC_VECTOR(3DOWNTO0);

SIGNALA:STD_LOGIC_VECTOR(3DOWNTO0);

SIGNALCODE:STD_LOGIC_VECTOR(2DOWNTO0);

SIGNALBcd:STD_LOGIC_VECTOR(23Downto0);

SIGNALCOUNT:STD_LOGIC_VECTOR(23Downto0);

SIGNALSUM:STD_LOGIC_VECTOR(4DOWNTO0);

SIGNALD:STD_LOGIC_VECTOR(3DOWNTO0):=“0000”;

SIGNALInd_coil:STD_LOGIC_VECTOR(3Downto0):=“0001”;

SIGNALHz:STD_LOGIC;

SIGNALSpo:STD_LOGIC;

SIGNALSW:STD_LOGIC;

SIGNALKEY:STD_LOGIC;

SIGNALDRA,DRB:STD_LOGIC;

BEGIN

DRIVERA《=DRA;

DRIVERB《=DRB;

P(5Downto0)《=F(5Downto0);

CO(3DOWNTO0)《=C(3DOWNTO0);

A(3DOWNTO0)《=AI(3DOWNTO0);

SP《=SPO;

-----------------Div------------------------

PROCESS(OSC)

VARIABLED_ff:STD_LOGIC_VECTOR(20Downto0);

VARIABLEDELAY:STD_LOGIC_VECTOR(23DOWNTO0);

BEGIN

WAITUNTILClk=‘’1‘’;

IFD_ff(20Downto0)》=2E6THEN

D_ff(20Downto0):=“000000000000000000000”;

ELSE

D_ff(20Downto0):=D_ff+1;

ENDIF;

F_hz《=NotD_ff(6);

OSC《=NotD_ff(10);

OSC1《=NotD_ff(17);

IFDELAY》=500000THEN

DELAY:=“000000000000000000000000”;HZ《=NOTHz;

ELSEDELAY:=DELAY+1;

ENDIF;

ENDPROCESS;

----------------------------------------------

PROCESS(F_HZ,OSC,OSC1,HZ,PULSE)

VARIABLEB:STD_LOGIC;

VARIABLEINT:STD_LOGIC;

VARIABLEData:STD_LOGIC_VECTOR(3DOWNTO0);

VARIABLEUP:STD_LOGIC_VECTOR(2DOWNTO0);

VARIABLEST:STD_LOGIC_VECTOR(2DOWNTO0);

VARIABLESeq:STD_LOGIC_VECTOR(1DOWNTO0);

VARIABLESound:STD_LOGIC_VECTOR(1DOWNTO0);

VARIABLESTOP:STD_LOGIC;

VARIABLEDirection:STD_LOGIC;

BEGIN

---------------7segS

can

-------------------------------

IF(F_HZ=‘’1‘’ANDF_HZ‘’EVENT)THEN

IFST(2DOWNTO0)=“101”THEN

ST(2DOWNTO0):=“000”;

ELSEST(2DOWNTO0):=ST(2DOWNTO0)+1;

ENDIF;

ENDIF;

-----------------------------------------------

IF(OSC=‘’1‘’AndOSC‘’EVENT)THEN

IfA=“1111”Then

IFSeq=“11”ThenSeq:=“00”;

ElseSeq:=Seq+1;

EndIf;

ElseSeq:=Seq;

EndIf;

IFSeq=“00”ThenC(3DOWNTO0)《=“1110”;

ElsifSeq=“01”ThenC(3DOWNTO0)《=“1101”;

ElsifSeq=“10”ThenC(3DOWNTO0)《=“1011”;

ElsifSeq=“11”ThenC(3DOWNTO0)《=“0111”;

EndIf;

EndIf;

IFA=“1111”THENINT:=‘’0‘’;

ELSEINT:=‘’1‘’;

ENDIF;

IF(HZ‘’EVENTANDHZ=‘’1‘’)THEN

IFSTOP=‘’1‘’THENUP:=UP+1;

ELSEUP:=“000”;

ENDIF;

ENDIF;

IFKEY=‘’1‘’ANDCOUNT/=0THEN

IFDIRECTION=‘’0‘’THENDRA《=‘’1‘’;DRB《=‘’0‘’;STOP:=‘’0‘’;

ELSEDRA《=‘’0‘’;DRB《=‘’1‘’;STOP:=‘’0‘’;

ENDIF;

ELSIFKEY=‘’1‘’ANDCOUNT=0THENSTOP:=‘’1‘’;

ELSIFSTOP=‘’1‘’ANDUP《“110”THENDRA《=NOTDRA;DRB《=NOTDRB;

ELSEDRA《=‘’0‘’;DRB《=‘’0‘’;STOP:=‘’0‘’;

ENDIF;

IF(OSC1‘’EVENTANDOSC1=‘’1‘’)THENB:=(INTAnd(BAndINT));

----------------DirectionCho

ic

e-----------------------

IFSW=‘’0‘’ANDB=‘’1‘’ANDData(3DOWNTO0)=“1010”THEN

BCD(23DOWNTO0)《=BCD(23DOWNTO0);B:=‘’0‘’;Direction:=‘’1‘’;

ELSIFSW=‘’0‘’ANDB=‘’1‘’ANDData(3DOWNTO0)=“1011”THEN

BCD(23DOWNTO0)《=BCD(23DOWNTO0);B:=‘’0‘’;Direction:=‘’0‘’;

------------------KEYLOCKON/OFF------------------------------------

ELSIFB=‘’1‘’ANDData(3DOWNTO0)=“1100”THEN

BCD《=BCD;B:=‘’0‘’;SW《=NOTSW;

-------------------B

AC

K-------------------------------

ELSIFSW=‘’0‘’ANDB=‘’1‘’ANDData(3DOWNTO0)=“1101”THEN

BCD(23DOWNTO0)《=(“0000”&Bcd(23Downto4));B:=‘’0‘’;

-------------------CLEAR---------------------------------

ELSIFB=‘’1‘’ANDData(3DOWNTO0)=“1110”THEN

BCD《=“000000000000000000000000”;B:=‘’0‘’;SW《=‘’0‘’;

------------------DOWNCOUNT0------------------------------------

ELSIFBCD=0ANDKEY=‘’1‘’THENSW《=‘’0‘’;KEY《=‘’0‘’;BCD《=BCD;

------------------------------------------------------------------

ELSIFSW=‘’1‘’ANDKEY=‘’1‘’ANDDATA(3DOWNTO0)/=“1110”THENBCD《=COUNT;

ELSIFSW=‘’1‘’ANDDATA(3DOWNTO0)=“1110”THENSW《=‘’0‘’;

BCD《=“000000000000000000000000”;KEY《=‘’0‘’;

-------------------ENTER------------------------------

ELSIFSW=‘’0‘’ANDB=‘’1‘’ANDData(3DOWNTO0)=“1111”ANDBCD/=0THEN

B:=‘’0‘’;SW《=‘’1‘’;KEY《=‘’1‘’;

ELSIFSW=‘’0‘’ANDB=‘’1‘’ANDData(3DOWNTO0)=“1111”ANDBCD=0THEN

BCD《=BCD;B:=‘’0‘’;SW《=‘’0‘’;KEY《=‘’0‘’;

----------------------NUMBERSHIFT---------------------------

ELSIFSW=‘’0‘’ANDB=‘’1‘’THENBcd(23Downto0)《=Bcd(19Downto0)&DATA(3DOWNTO0);B:=‘’0‘’;

ElsifINT=‘’0‘’ThenBcd《=Bcd;

B:=‘’1‘’;

ENDIF;

ENDIF;

------------------------------------------------------

SUM(1DOWNTO0)《=Seq;

Sum(4Downto2)《=Code;

---------------------SOUND-----------------------------

If(Osc‘’EventAndOsc=‘’1‘’)Then

IfINT=‘’1‘’ANDSW=‘’0‘’ThenSound:=Sound+1;Spo《=Sound(1);

ElseSpo《=‘’0‘’;

EndIf;

EndIf;

-------------------------------------------------------

---------------------------DOWNCOUNT--------------------

IFSW=‘’0‘’THENCOUNT《=BCD;

ELSE

If(PULSE=‘’1‘’AndPULSE‘’EVENT)THEN

IFKEY=‘’1‘’ANDCOUNT/=0THEN

----------------------------1---------------------------------------------------

IFCOUNT(3DOWNTO0)=0ANDCOUNT(23DOWNTO4)》=1THEN

COUNT(3DOWNTO0)《=“1001”;

ELSECOUNT(3DOWNTO0)《=COUNT(3DOWNTO0)-1;

ENDIF;

----------------------------2---------------------------------------------------------

IFCOUNT(7DOWNTO4)=0ANDCOUNT(23DOWNTO8)》=1ANDCOUNT(3DOWNTO0)=0THEN

COUNT(7DOWNTO4)《=“1001”;

ELSIFCOUNT(3DOWNTO0)=0ANDCOUNT(23DOWNTO4)》=1THEN

COUNT(7DOWNTO4)《=COUNT(7DOWNTO4)-1;

ENDIF;

----------------------------3-------------------------------------------------------

IFCOUNT(11DOWNTO8)=0ANDCOUNT(23DOWNTO12)》=1ANDCOUNT(7DOWNTO0)=0THEN

COUNT(11DOWNTO8)《=“1001”;

ELSIFCOUNT(7DOWNTO0)=0ANDCOUNT(23DOWNTO8)》=1THEN

COUNT(11DOWNTO8)《=COUNT(11DOWNTO8)-1;

ENDIF;

---------------------------4--------------------------------------------------------------

IFCOUNT(15DOWNTO12)=0ANDCOUNT(23DOWNTO16)》=1ANDCOUNT(11DOWNTO0)=0THEN

COUNT(15DOWNTO12)《=“1001”;

ELSIFCOUNT(11DOWNTO8)=0ANDCOUNT(23DOWNTO12)》=1ANDCOUNT(7DOWNTO0)=0THEN

COUNT(15DOWNTO12)《=COUNT(15DOWNTO12)-1;

ENDIF;

-------------------------5------------------------------------------------------------

IFCOUNT(19DOWNTO16)=0ANDCOUNT(23DOWNTO20)》=1ANDCOUNT(15DOWNTO0)=0THEN

COUNT(19DOWNTO16)《=“1001”;

ELSIFCOUNT(15DOWNTO12)=0ANDCOUNT(23DOWNTO16)》=1ANDCOUNT(11DOWNTO0)=0THEN

COUNT(19DOWNTO16)《=COUNT(19DOWNTO16)-1;

ENDIF;

-------------------------6-------------------------------------------------

IFCOUNT(23DOWNTO20)=0THEN

COUNT(23DOWNTO20)《=“0000”;

ELSIFCOUNT(19DOWNTO16)=0ANDCOUNT(23DOWNTO20)》=1ANDCOUNT(15DOWNTO0)=0THEN

COUNT(23DOWNTO20)《=COUNT(23DOWNTO20)-1;

ENDIF;

ENDIF;

ENDIF;

ENDIF;

------------------7segScan---------------------------

CASESTIS--?@潮

WHEN“000”=》D(3DOWNTO0)《=Bcd(3DOWNTO0);F(5Downto0)《=“111110”;

WHEN“001”=》D(3DOWNTO0)《=Bcd(7DOWNTO4);F(5Downto0)《=“

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論