電氣實(shí)踐23.1fpga程序二設(shè)計(jì)實(shí)驗(yàn)附錄_第1頁
電氣實(shí)踐23.1fpga程序二設(shè)計(jì)實(shí)驗(yàn)附錄_第2頁
電氣實(shí)踐23.1fpga程序二設(shè)計(jì)實(shí)驗(yàn)附錄_第3頁
電氣實(shí)踐23.1fpga程序二設(shè)計(jì)實(shí)驗(yàn)附錄_第4頁
電氣實(shí)踐23.1fpga程序二設(shè)計(jì)實(shí)驗(yàn)附錄_第5頁
已閱讀5頁,還剩8頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1libraryuseuseentitydecoderisport(a,b,c:instd_logic;d1,d2:instd_logic;d_out:outstd_logic);

指令 architecturemainofdecodersignals:std_logic_vector(2downto0);casesiswhen"001"=>d_out<=d1andd2;when"010"=>d_out<=d1ord2;when"011"=>d_out<=d1;--d1notwhen"100"=>d_out<=(d1andnotd2)or(notd1andd2);when"101"=>d_out<=(d1andd2)or(notd1andnotd2);whenothers=>d_out<='Z';endcase;endprocess;libraryuseuseentitystate_stepperisport(clk,dir:instd_logic;q:outstd_logic_vector(3downto

architecturessofstate_stepperistypestate_typeis(s0,s1,s2,s3);signalstate:state_type;signalq_out:std_logic_vector(3downto0);ifclk'eventandclk='1'thencasestateiswhens0=>endif;whens1=>endif;whens2=>endif;whens3=>endif;endcase;endif;endwithstateq_out<="0001""0010""0100""1000"endss;library useuseieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entityCTR60isq:outstd_logic_vector(7downto0);c:outstd_logic);endarchitecturebehaveofCTR60signalIQ:std_logic_vector(7downto0);process(clr,clk,IQ)isif(clr='1')thenIQ<=" elsif(clk'eventandclk='1')thenif(IQ(7downto0)=" IQ(7downto0)<=" elsif(IQ(3downto0)="1001")thenIQ(3downto0)<="0000";IQ(7downto4)<=IQ(7downto4)+1;elseIQ(3downto0)<=IQ(3downto0)+1;endendif;endprocess;endbehave;library useuseieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entityCTR24isq:outstd_logic_vector(7downto0));endCTR24;architecturebehaveofCTR24signalIQ:std_logic_vector(7downto0);process(clr,clk,IQ)isif(clr='1')thenIQ<=" elsif(clk'eventandclk='1')thenif(IQ(7downto0)=" IQ(7downto0)<=" endif;endprocess;endbehave;

elsif(IQ(3downto0)="1001")thenIQ(3downto0)<="0000";IQ(7downto4)<=IQ(7downto4)+1;elseIQ(3downto0)<=IQ(3downto0)+1;endif;library useuseieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entitycontrolish_in:instd_logic_vector(7downto0);m_in:instd_logic_vector(7downto0);s_in:instd_logic_vector(7downto0);H_OUT:outstd_logic_vector(7downto0);M_OUT:outstd_logic_vector(7downto0);S_OUT:outstd_logic_vector(7downto0);en:outstd_logic;F_out:outstd_logic_vector(2downto0));endcontrol;architecturebehaveofcontroltypestate_typeis(s0,s1,s2,s3,s4,s5,s6);signalstate:state_type;signalIQH:std_logic_vector(7downto0);signalIQM:std_logic_vector(7downto0);signalIQS:std_logic_vector(7downto0); if(mode'eventandmode='1')thencasestateiswhens0=>state<=s1;whens1=>state<=s2;whens2=>state<=s3;whens3=>state<=s4;whens4=>state<=s5;whens5=>state<=s6;whenendcase;endif;end if(mode'eventandmode='1')thencasestateiswhens0=>whens1=>if(IQH(7downto4)="0010")thenIQH(7downto4)<="0000";elseIQH(7downto4)<=IQH(7downto4)+1;endif;IQH(3downto0)<=h_in(3downto0);whens2=>if(IQH(3downto0)="1001")thenIQH(3downto0)<="0000";elseIQH(3downto0)<=IQH(3downto0)+1;endif;IQH(7downto4)<=h_in(7downto4);whens3=>if(IQM(7downto4)="0101")thenIQM(7downto4)<="0000";elseIQM(7downto4)<=IQM(7downto4)+1;endif;IQM(3downto0)<=m_in(3downto0);whens4=>if(IQM(3downto0)="1001")thenIQM(3downto0)<="0000";elseIQM(3downto0)<=IQM(3downto0)+1;endif;IQM(7downto4)<=m_in(7downto4);whens5=>if(IQS(7downto4)="0101")thenIQS(7downto4)<="0000";elseIQS(7downto4)<=IQS(7downto4)+1;endif;IQS(3downto0)<=s_in(3downto0);whens6=>if(IQS(3downto0)="1001")thenIQS(3downto0)<="0000";elseIQS(3downto0)<=IQS(3downto0)+1;endif;IQS(7downto4)<=s_in(7downto4);endcase;endendprocess;endbehave;library useuseieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entitydivideisclk_out:outendarchitecturebehaveofdivideissignalsignalcout:integerrange0to199999;if(CLK_IN'eventandCLK_IN='1')thenif(cout<=50000)thenelsif(cout<99999)elsecout<=0;endif;endif;endprocess;endbehave;library useuseieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entityscanisf_in:instd_logic_vector(2downto0);H_IN:instd_logic_vector(7downto0);M_IN:instd_logic_vector(7downto0);S_IN:instd_logic_vector(7downto0);Segctr:outstd_logic_vector(7downto0);q_out:outstd_logic_vector(3downtoendarchitecturescaofscantypestate_typeis(s0,s1,s2,s3,s4,s5);signalstate:state_type;signalQ:std_logic_vector(3downto0); if(clk'eventandclk='1')thencasestateiswhens0=>state<=s1;whens1=>state<=s2;whens2=>state<=s3;whens3=>state<=s4;whens4=>state<=s5;whenendcase;endif;end casestatewhens0=>Segctr(6downto0)<=" elseSegctr<=" endQ<=H_IN(7downto4);whens1=>Segctr(5downto0)<="000000";elseSegctr<=" endQ<=H_IN(3downto0);whens2=>Segctr(7downtoSegctr(4downto0)<="00000";elseSegctr<=" endQ<=M_IN(7downto4);whens3=>Segctr(7downtoSegctr(3downto0)<="0000";elseSegctr<=" endQ<=M_IN(3downto0);whens4=>Segctr(7downtoSegctr(2downto0)<="000";elseSegctr<=" endQ<=S_IN(7downto4);whens5=>Segctr(7downtoSegctr(1downto0)<="00";elseSegctr<=" Q<=S_IN(3downto0);endif;endcase;endprocess;endlibrary --顯示譯模塊disuseuseieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entitydisyisport(a:instd_logic_vector(3downto0);f:outstd_logic_vector(7downto0));enddisarchitecturedataofdisyiscasea whenothers=>f<=" endcase;endprocess;enddata;library useentitytri_gateport(indate,en:instd_logic;yout:outstd_logic);endarchitecturetrioftri_gateisendif;endprocess;endtri;library useuseieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entityClockisSeg7:outstd_logic_vector(7downto0);Segctr:outstd_logic_vector(7downto0));endarchitecturedigital_clockofClocksignalCM,CS,CLK1Hz,CLK_COU,EN:std_logic;signalHour:std_logic_vector(7downto0);signalMinute:std_logic_vector(7downto0);signalSecond:std_logic_vector(7downtosignalHSCAN:std_logic_vector(7downto0);signalMSCAN:std_logic_vector(7downto0);signalSSCAN:std_logic_vector(7downto0);signalflash:std_logic_vector(2downto0);signalY:std_logic_vector(3downto0);componentCTR60isport(clr,clk:instd_logic;q:outstd_logic_vector(7downto0);c:outstd_logic);endcomponentcomponentCTR24isport(clr,clk:instd_logic;q:outstd_logic_vector(7downto0));endcomponentCTR24;componentcontrolisport(mode,set:instd_logic;h_in:instd_logic_vector(7downto0);m_in:instd_logic_vector(7downto0);s_in:instd_logic_vector(7downto0);H_OUT:outstd_logic_vector(7downto0);M_OUT:outstd_logic_vector(7downto0);S_OUT:outstd_logic_vector(7downto0);en:outstd_logic;F_out:outstd_logic_vector(2downto0));endcomponentcontrol;componentdivideisport(CLK_IN:instd_logic;clk_out:outstd_logic);endcomponentdivide;componentscanisport(clk,clk1:instd_logic;f_in:instd_logic_vector(2downto0);H_IN:instd_logic_vector(7downto0);M_IN:instd_logic_vector(7downto0);S_IN:instd_logic_vector(7downto0);Segctr:outstd_logic_vector(7downto0);q_out:outstd_logic_vector(3downtoendcomponentcomponentdisyport(a:instd_lo

溫馨提示

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

評論

0/150

提交評論