【正文】
0101” and sec2=“1001”)thenhou2elsif hou2=“1001”and(min1=“0101” and min2=“1001”)and(sec1=“0101” and sec2=“1001”)thenhou2elsif(hou2=“1001”and cj=“110”)or(hou1=“0010”and hou2=“0011”and cj=“110”)thenhou2elsif((min1=“0101” and min2=“1001”)and(sec1=“0101” and sec2=“1001”))or(cj=“110”)thenhou2end if。小時十位 h110:process(clk1,hou2,min1,min2,sec1,sec2,cj)beginif clk139。end if。event and clk1=39。if cj=“001” then seth1beginif clk139。end if。event and clk1=39。if cj=“001” then setm1end if。139。end process setmin2。thenif seth1=hou1 and seth2=hou2 and setm1=min1 and setm2=min2 thenspeakelse speakend if。disp:process(sel,cj,hou1,hou2,min1,min2,sec1,sec2,seth1,seth2,setm1,setm2)顯示beginif sel=“010” thenseloutcase h1 is顯示小時的十位when “0000”=doutwhen “0001”=doutwhen “0010”=doutwhen others =doutend case。elsif sel=“110” thenseloutcase s1 is顯示秒的十位when “0000”=doutwhen “0001”=doutwhen “0010”=doutwhen “0011”=doutwhen “0100”=doutwhen “0101”=doutwhen others=doutend case。end process disp。139。end if。139。entity clock is port(clk1hz:in std_logic。秒表啟動/停止控制reset:in std_logic。功能選擇脈沖showdate:in std_logic。星期輸出qh:out std_logic整點報時)。end ponent。module: out std_logic_vector(2 downto 0))。q: out std_logic_vector(3 downto 0))。start_stop: in std_logic。end ponent。d:in std_logic_vector(7 downto 0)。qh:out std_logic。set: in std_logic。month: out std_logic_vector(7 downto 0)。showdate:in std_logic。time:in std_logic_vector(23 downto 0)。end ponent。signal qc:std_logic。u3:stopwatch port map(clk100,reset,start_stop,mcentsec,msec,mmin)。u7:weekcounter port map(qc,weekclk,weekout)。architecture arch of adjust is signal temp2,temp1:std_logic_vector(3 downto 0)。功能選擇脈沖module: out std_logic_vector(2 downto 0)功能輸出)。begin process(mode,setclk)begin if mode=39。復(fù)位q: out std_logic_vector(7 downto 0)。begin process(clr,clk)begin if clr=39。計數(shù)使能clr: in std_logic。architecture arch of counter99 is signal temp1,temp2:std_logic_vector(3 downto 0)。計數(shù)脈沖set: in std_logic。進位day28: in std_logic。end daycounter。139。139。 then temp2year2: in std_logic。該位為1表示該月為29天day30: out std_logic。039。when “00000011”=day28day28day28day28day28day28day28day28day28day28day28port(module: in std_logic_vector(2 downto 0)。閃爍位選擇watch: in std_logic_vector(23 downto 0)。顯示輸出glisten:out std_logic_vector(5 downto 0)閃爍輸出)。then disdisdisdisdisglisten(1 downto 0)glisten(5 downto 2)glisten(3 downto 2)glisten(5 downto 4)glisten(1 downto 0)glisten(5 downto 4)glisten(3 downto 0)glistenport(set:in std_logic。set2:out std_logic。q3: out std_logic_vector(7 downto 0))。 then case setlap is when“00”=set1q1set1q2set1q3set1port(clk: in std_logic。調(diào)整輸入sec:out std_logic_vector(7 downto 0)。整點報時qc: out std_logic進位)。d:in std_logic_vector(7 downto 0)。ponent hourcounter port(clk: in std_logic。qc:out std_logic)。d: in std_logic_vector(7 downto 0)。q1: out std_logic_vector(7 downto 0)。signal secset,minset,hourset: std_logic。u2:sec_mincounter port map(clk,secset,secin,sec,qcsec)。計數(shù)脈沖set:in std_logic。end hourcounter。then temp2temp1port(clk: in std_logic。月輸出qc: out std_logic進位)。139。分和秒輸出qc:out std_logic進位)。139。百分秒輸出,當(dāng)超過60分轉(zhuǎn)為秒sec: out std_logic_vector(7 downto 0)。en: in std_logic。end ponent。qc: out std_logic)。begin u1:counter99 port map(clk,start_stop,reset,tcentsec,qc1)。process(qc3)begin if rising_edge(qc3)then flagport(clk: in std_logic。architecture arch of weekcounter is signal temp:std_logic_vector(3 downto 0)。調(diào)整信號setlap: in std_logic_vector(1 downto 0)。月輸出year: out std_logic_vector(7 downto 0)年輸出)。day_in: in std_logic_vector(7 downto 0)。day29: in std_logic。ponent monthcounterport(clk: in std_logic。qc: out std_logic)。year_in: in std_logic_vector(7 downto 0)。setlap: in std_logic_vector(1 downto 0)。set3:out std_logic。end ponent。day28: out std_logic。end ponent。signal smonth,syear:std_logic_vector(7 downto 0)。u3:monthcounter port map(qcday,monthset,monthin,smonth,qcmonth)。library ieee。entity yearcounter isport(clk: in std_logic。end yearcounter。 then temp2temp1第三篇:C語言課程設(shè)計數(shù)字鐘程序C語言數(shù)字鐘程序include“” void clock(int t)。void main(){ int t,i,j,n。用戶通過屏幕編輯程序鍵入源程序,檢查無誤,可將源程序存到匯編系統(tǒng)盤上,該程序的擴展名為由于每個段的物理空間為≤ 64KB,所以程序中各段可以分別為一個或幾個。 對于堆棧段也可以根據(jù)需要可有可無,但在連接(LINK)時計算機將顯示警告性的錯誤: Warning : N STACK segment There was 1 error ,該錯誤提示不影響程序的運行,如果程序中用到堆棧時必須設(shè)置堆棧段。MOV AX,邏輯段名 MOV 段寄存器,AX 其中邏輯段名為程序中定義各邏輯段的名字,(不包括代碼段),段寄存器是指與各邏輯段相對應(yīng)的各段寄存器(DS、ES、SS)。)程序中的數(shù)據(jù)與變量在匯編源程序中的數(shù)據(jù)除了立即數(shù),由指令產(chǎn)生的數(shù)和通過鍵盤輸入的數(shù)以外,還胡大量的數(shù)據(jù)是通過偽指令語句進行預(yù)置和分配的,也就是在某邏輯段中(除代碼段),將所需的數(shù)據(jù)以某種形式存放起來,在程序中可任意調(diào)用。EQU 和=可以出現(xiàn)在程序的邏輯段內(nèi)也可出現(xiàn)在邏輯段外。③用編程的方法提供數(shù)據(jù)假如原始數(shù)據(jù)是一組有規(guī)律的數(shù)據(jù)項,則用編程序的方法形成這一組數(shù)據(jù),不用專門為這組數(shù)據(jù)分配存儲單元,節(jié)省了存儲空間。4)返回 DOS 狀態(tài)的方法 文件時,是在 DOS 狀態(tài)下進行的, 文件后正常返回 DOS 狀態(tài),一般用如下兩種方法:采用 DOS 4CH 功能調(diào)用和采用返回(RET)斷點的方法。源程序用宏匯編程序翻譯(匯編)后,可以得到三個文件: 的目標(biāo)文件,在該文件中,將源程序的操作碼部分變?yōu)闄C器碼,但地址操作數(shù)是可浮動的相對地址,而不是實際地址,因此需經(jīng) LINK 連接文件進行連接才能形成可執(zhí)行文件。)匯編操作過程在 DOS 狀態(tài)下,鍵入 MASM ↓則調(diào)入宏匯編程序,屏幕顯示與操作如下: masm ↓ Microsoft(R)Macro Assemble Version Copyright(C)Microsoft Corp 19811985,1987,All right filename [.ASM ]: MYFILE ↓ Object filename [ ]: MYFILE ↓ Source listing [ ]: MYFILE ↓ Crossreference []: MYFILE ↓ 50678 + 410090 Bytes symbol space free 0 Warning Errors 0 Severe Errors 其中劃線部分為用戶鍵入部分,MYFILE 為源程序名(),方括號中是機器規(guī)定的默認(rèn)文件名,如果用戶認(rèn)為方括號內(nèi)的文件名就是要鍵入的文件名,則可只在劃線部分鍵入回車符。之后可重新進入屏幕編輯狀態(tài),調(diào)入源程序()進行修改,修改完畢,再進行匯編,直到匯編通過為止。)列表文件(.LST)列表文件(.LST)是通過匯編程序(MASM)產(chǎn)生的,可以在 DOS 狀態(tài)下用 TYPE 命令顯示或打印該文件,以便分析調(diào)試源程序。該列表清單 中是以 PARA 為 CODE 段、DATA 段和 STACK 段的起始邊界地址。STACK :表明連接程序首先要把本段與同名同類別的其它段相鄰地連接在一起,然后為所有定義為棧段的連接在一起的段,定義一個共同的段基地址,即連接成一個物理段。另外由于列表文件給出了各條指令的偏移地址,對和程序時設(shè)置斷點很方便。連接程序 LINK 是把一個或多個獨立的目標(biāo)程序模塊裝配成一個可重定位的可執(zhí)行文件, 文件。最后一個詢問是問是否在連接時用到庫文件,對于連接匯編語言源程序的目標(biāo)文件,通常是不需要的,因此直接鍵入回車鍵。D LINK MYFILE,;↓ IBM Personal Computer Linker Version (C)Copyright IBM Corp 1981,1982,1983 2)內(nèi)存映象文件(.MAP)由連接程序 LINK 文件,它實際上是連接程序的列表文件,它給出了每個段的地址分配情況及長度。執(zhí)行操作如下: D MYFILE ↓ 或 D ↓在源程序 MYFILE 中如果有顯示結(jié)果的指令,