【正文】
en “0111”=doutwhen “1000”=doutwhen “1001”=doutwhen others=doutend case。yanshi:process(clk)variable fp:integer range 0 to 29999。end process。1hz脈沖clk100:in std_logic。日期顯示dis:out std_logic_vector(23 downto 0)。ponent controlport(setclk: in std_logic。end ponent。ponent h_m_s_countport(clk: in std_logic。qc: out std_logic)。year: out std_logic_vector(7 downto 0))。date:in std_logic_vector(23 downto 0)。signal watch,time,date:std_logic_vector(23 downto 0)。watchport(adclk: in std_logic。end control。計數(shù)值qc:out std_logic進位輸出)。復位q: out std_logic_vector(7 downto 0)。調整信號day_in: in std_logic_vector(7 downto 0)。architecture arch of daycounter is signal temp1,temp2:std_logic_vector(3 downto 0)。else“00000000”。該位為1表示該月為30天day31: out std_logic該位為1表示該月為31天)。功能選擇showdate:in std_logic。end display。set3:out std_logic。1hz脈沖set: in std_logic。end h_m_s_count。set:in std_logic。set1:out std_logic。signal secin,minin,hourin:std_logic_vector(7 downto 0)。調整信號d:in std_logic_vector(7 downto 0)。計數(shù)脈沖set: in std_logic。 then temp2temp1set:in std_logic。then temp2temp1reset: in std_logic。clr: in std_logic。end ponent。天脈沖clk2: in std_logic。調整位選擇data_in: in std_logic_vector(7 downto 0)。day_out: out std_logic_vector(7 downto 0)。set: in std_logic。year_out: out std_logic_vector(7 downto 0))。q1: out std_logic_vector(7 downto 0)。day29: out std_logic。signal day28,day29,day30,day31:std_logic。use 。architecture arch of yearcounter is signal temp1,temp2:std_logic_vector(3 downto 0)。for(t=0。源程序的書寫一般有如下形式:邏輯堆棧段 堆棧段名 SEGMENT STACK 用變量定義預置的堆??臻g 其中: SEGMENT、ASSUME、PROC … ENDP 為偽指令,偽指令是發(fā)給匯編程序 ASM 的,而不和微處理器打交道,在匯編時不產生目標代碼,只是把源程序中各段的設置情況告訴匯編程序。在數(shù)據(jù)定義的同時還可以定義變量,將變量與數(shù)據(jù)結合在一起。④用鍵盤提供數(shù)據(jù)當原始數(shù)據(jù)為任意數(shù)據(jù)時,一般用鍵盤輸入方法,調用 DOS 21H 中斷。第二個文件是列表文件,它把源程序和目標程序列表,以供檢查程序用。如果在匯編時不需要產生列表文件(.LST)和交叉索引文件(.CRF),調用匯編程序時可用分號結束。最后一列為段的組合類型;段的組合類型是告訴連接程序,本段與其它段的關系,組合類型有 NONE、PUBLIC、COMMOM、AT 表達式、STACK 和 MEMORY。)交叉索引文件(.CRF)匯編后產生的交叉索引文件,, 它列出了源程序中定義的符號(包括:標號、變量等)和程序中引用這些符號的情況。與匯編程序一樣,可以在連接時用分號結束后續(xù)詢問。應用程序執(zhí)行當用連接程序 LINK 將目標程序(.OBJ)連接定位后,可產生可執(zhí)行的應用程序文件(.EXE),可以在 DOS 狀態(tài)下執(zhí)行該程序。其中 MAP 文件是否需要建立,由用戶決定,需要則鍵入文件名,不需要則直接送入一個回車鍵。如果在源程序中存在某些語法錯誤時,列表文件可提示某條語句有哪些錯誤,出錯提示顯示在出錯指令行的下面,因此用戶可借助列表文件很快地找到錯誤行,以便調試。(2)段信息匯總表在段信息匯總表中列出該程序用了哪幾個段,如:代碼段 CODE、數(shù)據(jù)段 DATA 和堆棧段 STACK ;每個段所占存儲空間的長度(字節(jié)數(shù));每個段的定位類型,包括 PAGE(頁)、PARA(節(jié))、WORD(字)和 BYTE(字節(jié)),它們表示此段的起始邊界要求,即起始邊界地址應分別可以被 2512 和 1 除盡。在匯編過程中,如果發(fā)現(xiàn)源程序中有語法錯誤,則提示出錯信息,指出是什么性質的錯誤,錯誤類型,最后列出錯誤的總數(shù)。為了完成匯編任務,匯編程序一般采用兩遍掃描的方法,第一遍掃描源程序產生符號表、處理偽指令等,第二遍掃描產生機器指令代碼、確定數(shù)據(jù)等。當然,用立即數(shù)的方法只是將一個數(shù)據(jù)傳送到通用寄存器中,它只是通過通用寄存器傳送數(shù)據(jù)。②在程序運行過程中,當執(zhí)行某些指令和操作時,CPU 自動修改 CS 和 IP 的值,使它們指向新的代碼段。過程名 ENDP 代碼段名 ENDS END 過程名或起始標號在源程序中最少要有一個代碼段,數(shù)據(jù)段根據(jù)需要可有可無,也可以增設附加段。匯編系統(tǒng)盤應包含如下文件: MASM 宏匯編程序文件 LISK 連接程序文件CRFF 索引程序文件(也可不用)匯編源程序編寫)源程序的書寫格式當 CPU 訪問內存時,是把存儲器分成若干個段,通過 4 個段寄存器中存放的地址對內存儲器訪問,因此在編源程序時必須按段的結構來編制程序。t第四篇:數(shù)字鐘程序c語言課程設計include“” void clock(int t)。調整輸入year_out: out std_logic_vector(7 downto 0)年輸出)。monthend arch。signal dayin,monthin,yearin: std_logic_vector(7 downto 0)。year1: in std_logic_vector(1 downto 0)。set2:out std_logic。set: in std_logic。end ponent。set: in std_logic。計數(shù)脈沖set: in std_logic。u4:counter60 port map(qc3,reset,thour,qc4)。q: out std_logic_vector(7 downto 0)。architecture arch of stopwatch is ponent counter99 port(clk: in std_logic。begin process(clk,set)begin if set=39。begin process(clk,set,month_in)begin if set=39。139。qhport(clk: in std_logic。end ponent。setlap: in std_logic_vector(1 downto 0)。end ponent。小時輸出qh:out std_logic。139。調整輸入set1:out std_logic。年月日計數(shù)值輸入dis: out std_logic_vector(23 downto 0)。and year1=“10”)thenday28elseday28end if。該位為1表示該月為28天day29: out std_logic。else“00110001”when day31=39。該位為1表示該月為30天day31: in std_logic該位為1表示該月為31天)。then temp1temp1port(clk: in std_logic。100vhz計數(shù)脈沖en: in std_logic。計數(shù)脈沖clr: in std_logic。調整位選擇脈沖mode: in std_logic。u6:display port map(module,showdate,clk1hz,setlap,watch,time,date,dis,glisten)。signal module:std_logic_vector(2 downto 0)。watch: in std_logic_vector(23 downto 0)。day: out std_logic_vector(7 downto 0)。hour:out std_logic_vector(7 downto 0)。min: out std_logic_vector(7 downto 0))。clk2: in std_logic。data_in: out std_logic_vector(7 downto 0))。調整位選擇脈沖mode:in std_logic。use 。end if。if cj=“011” then計時時間顯示和設置模式h1m1s1else鬧鈴時間現(xiàn)實和設置模式h1m1s1end if。end process speaker。if cj=“001” then setm2end if。end if。 thenif(seth1=“0010”and seth2=“0011”)or seth2=“1001” then其中seth1,seth2分別是調時的小時部位的十位與個位seth2elsif cj=“111” thenseth2end if。時間設置小時部分 sethour1:process(clk1,seth1,seth2,cj)beginif clk139。end process h220。if cj=“001” then min1end if。if cj=“001” then min2end if。if cj=“001” then sec1end if。if cj=“001” then sec2end if。位掃描 choice:process(clkk)位選掃描beginif rising_edge(clkk)thenif sel=“111” thenselelseselend if。分鐘的十位signal m2:std_logic_vector(3 downto 0)。秒的十位signal sec2:std_logic_vector(3 downto 0)。SIGNAL keyout : STD_LOGIC。speak:out std_logic。楊志忠主編《數(shù)字電子技術》,北京高等教育出版社,2003年12第2版。特別是當每一個子模塊編寫調試成功時,心里特別的開心。clkh為驅動時計時器工作的時鐘,與enmin相連接;hour為時計時器的輸出;enhour為時計時器的進位信號,作為下一級的時鐘輸入信號。 1)、分頻器模塊其實是一個計數(shù)器,外加信號頻率為12MHZ時,在內部定義了一個信號從0到11999999的整數(shù)型計數(shù)信號count1,當內部信號計數(shù)為11999999時,count1計數(shù)為0,產生進位信號CLK1為1,當內部信號計數(shù)為11999時,countf計數(shù)為0,產生進位信號CLK1為1,)、秒計數(shù)模塊內部定義時鐘其余時刻均為為秒計時器(second1)是由一個60進制的計數(shù)器構成的,具有清0、置數(shù)和計數(shù)功能。并且為保證數(shù)碼管正常工作提供足夠的工作電流。1.1.2要求(1)基本要求①計時功能:這是數(shù)字鐘的基本功能,每隔一秒鐘計時一次,并在顯示屏上顯示當前時間。關鍵詞:FBGA、數(shù)碼管、按鍵一、系統(tǒng)設計1.1 設計要求 1.1.1 任務設計并制作一個數(shù)字鐘,通過設計,掌握電子設計的一般思路,學習電子設計的一般方法。時間計數(shù)電路由秒個位和秒十位計數(shù)器、分個位和分十位計數(shù)器及時個位和時十位計數(shù)器電路構成,其中秒個位和秒十位計數(shù)器、分個位和分十位計數(shù)器為60進制計數(shù)器,而根據(jù)設計要求,時個位和時十位計數(shù)器為12進制計數(shù)器。其中計時模塊有4部分構成:秒計時器(second1)、分計時器(minute1)、時計時器(hour1)和星期計時器(day1)。其中reset為清0信號,當reset為0時,時計時器清0;set 為置數(shù)信號,當set為0時,時計時器置數(shù),置h1的值。程序控制過程如下說明:四、產品調試與結果分析 1)書寫遺漏錯誤提示在305行和307行附近有一個錯誤,在結束時,沒有加END ,)數(shù)碼管顯示時有閃爍檢查掃描信號時鐘時,發(fā)現(xiàn)掃描信號時鐘為100HZ,掃描