【正文】
設(shè)計(jì)各個(gè)模塊的功能:1. second計(jì)時(shí)模塊:begin process(clks,sets,ss) begin if sets=39。) then if(qs=59) then qs=0。end process。elsif(clkmn39。039。clk1=39。當(dāng)clk上升沿來臨時(shí),hour模塊開始從0計(jì)數(shù)到23,并輸出一個(gè)控制信號(hào)clk1控制day模塊,此時(shí)clk1=1 ,并回到0然后循環(huán)計(jì)數(shù),此時(shí)clk1=0。 elsif (clkd39。039。 end if。 end if。 elsif monthin=2 then if(qd=28) then qd=1。 clk2=39。 當(dāng)上一個(gè)模塊的時(shí)鐘信號(hào)來臨時(shí),如果是閏年,并且是1月,day模塊開始則從1計(jì)數(shù)到31,而如果是2月,則day模塊開始計(jì)時(shí)從1計(jì)數(shù)到29,如果其他月份時(shí),則計(jì)數(shù)從1到30,之后并輸出一個(gè)控制信號(hào)clk2控制month模塊,此時(shí)clk2=1 ,計(jì)數(shù)到最大值時(shí)都會(huì)回到1然后循環(huán)計(jì)數(shù),此時(shí)clk2=0。139。Years計(jì)時(shí)模塊:begin process(clk) beginif(clk39。Alarm_clock鬧鐘比較模塊:beginprocess(s2a,mn2a,h2a,d2a,m2a,y2a,s1a,mn1a,h1a,d1a,m1a,y1a ,run)beginif ( run rem 4 =0 ) then ring=39。 定義13個(gè)輸入信號(hào)和一個(gè)輸出信號(hào)ring用于當(dāng)前時(shí)間與鬧鈴時(shí)間進(jìn)行比較,如果是閏年信號(hào)run就輸出ring=1,否則剩余的信號(hào)兩兩相等,則ring=1,既滿足了鬧鈴功能,也滿足了閏年提醒的功能。(以上只是各個(gè)模塊的一小段VHDL程序,詳細(xì)的程序請(qǐng)看附錄。十三、論文結(jié)論: 這次設(shè)計(jì),讓我遇到了許多的問題,同時(shí)也加深了我對(duì)集成電路軟件應(yīng)用的了解和掌握,在設(shè)計(jì)這個(gè)程序的過程中,讓我最感到困難的是編寫好一個(gè)程序后,如何修改編譯提示的錯(cuò)誤,尤其是當(dāng)我設(shè)計(jì)day模塊時(shí),對(duì)應(yīng)不同年份,不同的月份,需要分多種情況,所以在這設(shè)計(jì)過程中用到了很多if語句,當(dāng)編譯時(shí)總會(huì)提示出有錯(cuò)誤,后來經(jīng)過不斷編譯不斷修改提示錯(cuò)誤后最終完成了day模塊的設(shè)計(jì)。為了確保整個(gè)系統(tǒng)的正確運(yùn)行,每個(gè)底層的實(shí)體在寫好之后我都把它們進(jìn)行了仿真,確保仿真結(jié)果正確性。 sets: in std_logic。 輸出當(dāng)前時(shí)間(作為與制定鬧鈴時(shí)間比較)end second。event and clks=39。秒計(jì)數(shù) end if。qts=qs。139。 signal clk1 : std_logic。 ss : in integer range 0 to 59。139。 wait for clk_period*10。 wait。use 。 mnx: out integer range 0 to 59 。 end if。 clk2=39。end if。entity test is end test。 signal mns : integer :=12。 setmn : in std_logic:=39。 mnx : out integer:=0。039。wait for clk_period*100。wait。小時(shí)調(diào)制時(shí)間信號(hào) alarmh: in std_logic。architecture shi of hour issignal qh:integer range 0 to 23。139。 end if。 hy=qh。signal seth : std_logic:=39。 signal hx : integer :=0。139。 begin DUT :hour port map(clkh,seth,alarmh,ha,hs,qth,clk3,hx,hy)。 Stimulus process stim_proc: process begin seth=39。wait for clk_period*100。 Day模塊:library ieee。 作為判斷月份信號(hào) da: in integer。begin process(clkd,setd,ds,yearin,monthin) begin if setd=39。) then if ( yearin rem 4 =0) then 當(dāng)前為閏年 if ((monthin=1) or (monthin=3) or (monthin=5) or (monthin=7) or (monthin=8) or (monthin=10) or (monthin=12)) then當(dāng)前為大月31天 if(qd=31) then qd=1。 clk2=39。139。139。 elsif qd28 then qd=qd+1。 clk2=39。 process(alarmd,da)beginif alarmd=39。use 。signal yearin : integer :=2013。 constant clk_period : time := 1ms。 monthin:in integer :=12。 begin DUT :day port map(clkd,setd,alarmd,yearin,monthin,da,ds,qtd,clk2,dx,dy)。 Stimulus process stim_proc: process begin setd=39。wait for clk_period*100。wait for clk_period*100。 alarmm: in std_logic。 end month。event and clkm=39。 end if。qtm1=qm。architecture one of test issignal clkm : std_logic:=39。signal qtm1 : integer :=12。 setm : in std_logic:=39。 clk4 : out std_logic。 clkm = 39。039。wait for clk_period*100。entity year isport ( clky: in std_logic。 yy: out integer range 2013 to 2099) 。139。 then yx=ya。use 。139。 constant clk_period : time := 1ms。 ys : in integer:=2013。139。wait for clk_period*100。wait for clk_period*100。use 。 s2a:in integer range 0 to 59 。architecture one of alarm_clock is beginprocess(s2a,mn2a,h2a,d2a,m2a,y2a,s1a,mn1a,h1a,d1a,m1a,y1a ,run)beginif ( run rem 4 =0 ) then ring=39。end。signal h1a: integer:=12 。signal m2a: integer:=12 。 mn1a:in integer:=30 。 d2a: in integer:=1。 clk_process :process begin run=2013。wait for clk_period*70。wait for clk_period*10。wait for clk_period*10。end process。wait for clk_period*10。wait for clk_period*10。 run = 2016。 y2a: in integer:=2013 。 d1a: in integer:=1。signal ring: std_logic:=39。signal m1a: integer:=12 。use 。 是閏年,提醒elsif (mn1a=mn2a and h1a=h2a ) then ring=39。 h2a: in integer range 0 to 59。 s1a:in integer range 0 to 59。wait for clk_period*100。039。 clky = 39。 qty2: out integer:=2013。139。 signal ys : integer :=2013。entity test is end test。end process。 else qy=qy+1。architecture nian of year issignal qy:integer range 2013 to 2099。 alarmy: in std_logic。end process。alarmm=39。 wait for clk_period/2。 my : out integer:=12)。 alarmm : in std_logic:=39。 signal clk4 : std_logic。signal setm : std_logic:=39。my=qm。end process。) then if(qm=12) then qm=1。begin process(clkm,setm,mts) begin if setm=39。 mts: in integer range 1 to 12。 end process。wait for clk_period*800。wait for clk_period*100。139。 ds : in integer:=1。139。 signal da : integer :=1。architecture one of test issignal clkd : std_logic:=39。 then dx=da。 end if。039。 clk2=39。 clk2=39。 elsif qd29 then qd=qd+1。139。 then if ds=0 then qd=qd。 qtd: out integer。use 。wait for clk_period*100。wait for clk_period*100。139。 hs : in integer:=0。 constant clk_period : time := 1ms。signal alarmh : std_logic:=39。小時(shí)testbenchlibrary ieee。process(alarmh,ha)beginif alarmh=39。clk3=39。139。預(yù)定小時(shí)時(shí)間 hs: in integer range 0 to 23。END。139。 end process。 end ponent。 alarmmn : in std_logic:=39。 signal clk2 : std_logic。039。qtmn=qmn。 end if。event and clkmn=39。 end minute。 setmn: in std_logic。 wait for clk_period