【正文】
1 數(shù)字系統(tǒng)設(shè)計與硬件描述語言 期末考試作業(yè) 題目: 智能空調(diào)控制器的設(shè)計 學(xué)院: 電子信息工程學(xué)院 專業(yè): 電子信息工程 學(xué)號: 3012204273 姓名: 王歡 20210109 2 一、 選題設(shè)計描述 1. 功能介紹 對于這次的期末課程作業(yè),我選擇的是智能空調(diào)控 制器的設(shè)計。眾所周知,日常使用的空調(diào)至少具有定時、控溫、模式選擇等基本功能。我設(shè)計的這個智能空調(diào)主要能實(shí)現(xiàn)以下幾種功能: ①四種模式選擇:強(qiáng)風(fēng)、弱風(fēng)、自然風(fēng)、睡眠狀態(tài)。 ②工作時間設(shè)定:半小時、一小時、一個半小時、兩小時。 ③工作溫度設(shè)置:可以自由設(shè)置溫度,然后將室溫與設(shè)置的溫度進(jìn)行比較,當(dāng)室溫低于設(shè)置的溫度時,空調(diào)溫度升高;當(dāng)室溫高于設(shè)置的溫度時,空調(diào)溫度下降;并且當(dāng)室溫達(dá)到設(shè)置的溫度時,溫度就不再變化。 2. 算法簡介 按照上述的幾種功能介紹,我將分幾個模塊依次介紹: ①模式選擇模塊:因?yàn)橛?4種模式,所以用一個 4路數(shù)據(jù)選擇器就可以實(shí)現(xiàn)?!?00”、“ 01”、“ 10”、“ 11”分別代表“強(qiáng)風(fēng)”、“弱風(fēng)”、“自然風(fēng)”、“睡眠狀態(tài)”。 ②時間設(shè)置模塊:半個小時即三十分鐘,可以用一個三十進(jìn)制的計數(shù)器來實(shí)現(xiàn)定時,一個小時即六十分鐘,可以用一個六十進(jìn)制的計數(shù)器實(shí)現(xiàn),依此類推即可。 ③溫度設(shè)置模塊:室溫與設(shè)置溫度的比較需要用比較語句來實(shí)現(xiàn),空調(diào)溫度的增減都需要用計數(shù)器來實(shí)現(xiàn),所以這是一個包含比較和計數(shù)兩種功能的電路。 3 ④開關(guān)模塊 :我采用的是一個是 三輸入開關(guān)控制器,三個輸入分別代表模式選擇、時間設(shè)置、溫度設(shè)置,只要其中有一個模塊開始工作,那么開關(guān)就打開,空調(diào)就開始工作。 ⑤顯示模塊:上述幾個模塊都需要這個模塊來進(jìn)行顯示。用兩個 BCD七段譯碼器來分別顯示顯示十位和個位。就可以看出溫度和時間的變化。 二、 程序源代碼及說明 ①模式選擇,四選一數(shù)據(jù)選擇器:仿真見圖一 LIBRARY IEEE。 USE 。 ENTITY xuanze IS PORT(a,b,c,d,s1,s2 : IN STD_LOGIC。 a,b,c,d 是數(shù)據(jù)端口, s1 和 s2 是選擇端口。 y : OUT STD_LOGIC)。 END ENTITY xuanze。 ARCHITECTURE one OF xuanze IS SIGNAL ss : STD_LOGIC_VECTOR (0 TO 1)。 BEGIN ss=s2amp。s1。 將兩個標(biāo)準(zhǔn)邏輯位類型變成一個標(biāo)準(zhǔn)邏輯矢量類型 PROCESS(ss) BEGIN CASE ss IS 用 case 語句實(shí)現(xiàn)多路選擇 WHEN 00 = y=a。 4 WHEN 01 = y=b。 WHEN 10 = y=c。 WHEN 11 = y=d。 WHEN OTHERS = NULL。 END CASE。 END PROCESS。 END ARCHITECTURE one。 ②定時半小時,三十進(jìn)制計數(shù)器:仿真見圖二 library ieee。 use 。 use 。 entity thirty is port(clk,clr:in std_logic。 gewei,shiwei:out std_logic_vector(3 downto 0)。 個位和十位 dingshi:out std_logic)。 定時脈沖 end entity。 architecture arc of thirty is signal jinwei: std_logic。 進(jìn)位 begin process(clk,clr) variable ge:std_logic_vector(3 downto 0)。 begin 5 if clr=39。139。 then ge:=0000。 clr有清零作用 elsif clk 39。event and clk=39。139。 then if ge=1000 then ge:=ge+1。 jinwei=39。139。 當(dāng)個位加到“ 1000” 即第九個時鐘上升 時產(chǎn)生一個進(jìn)位。 elsif ge=1001 then ge:=0000。 個位加到 9 之后返回 0 jinwei=39。039。 else ge:=ge+1。 jinwei=39。039。 end if。 end if。 gewei=ge。 end process。 process(clk,clr,jinwei) variable shi:std_logic_vector(3 downto 0)。 Begin if clr=39。139。 then shi:=0000。 else if clk 39。event and clk=39。139。 then if jinwei=39。139。 then if shi=0010 then shi:=0000。 十位從“ 0000”變成“ 0010”, 6 即經(jīng)過了 30 個時鐘脈沖,然后 返回“ 0000”。同時產(chǎn)生一個定 時脈沖。 dingshi=39。139。 else shi:=shi+1。dingshi=39。039。 end if。 end if。 shiwei=shi。 end if。 end if。 end process。 end arc。 ③定時一小時,六十進(jìn)制計數(shù)器:仿真見圖三 library ieee。 use 。 use 。 entity sixty is 7 port(clk,clr:in std_logic。 gewei,shiwei:out std_logic_vector(3 downto 0)。 個位和十位 dingshi:out std_logic)。 定時脈沖 end entity。 architecture arc of sixty is signal jinwei: std_logic。 進(jìn)位 begin process(clk,clr) variable ge:std_logic_vector(3 downto 0)。 begin if clr=39。139。 then ge:=0000。 clr 有清零作用 elsif clk 39。event and clk=39。139。 then if ge=1000 then ge:=ge+1。jinwei=39。139。 當(dāng)個位加到“ 1000” 即第九個時鐘產(chǎn)生 一個進(jìn)位。 else if ge=1001 then jinwei=39。039。ge:=0000。 個位加到 9之后返回 0 else ge:=ge+1。jinwei=39。039。 end if。 end if。 8 end if。 gewei=ge。 end process。 process(clk,clr,jinwei) variable shi:std_logic_vector(3 downto 0)。 Begin if clr=39。139。 then shi:=0000。 elsif clk 39。event and clk=39。139。 then if jinwei=39。139。 then if shi=0101 then shi:=0000。dingshi=39。139。 十位從“ 0000”變成“ 0101”, 即經(jīng)過了 60 個時鐘脈沖,然后 返回“ 0000”。同時產(chǎn)生一個定 時脈沖。 else shi:=shi+1。dingshi=39。039。 end if。 end if。 else shi:=shi。 end if。 shiwei=shi。 end process。 9 end arc。 ④溫度控制,仿真見圖四和圖五 library ieee。 use 。 use 。 entity wendu is 根據(jù)室溫和設(shè)定溫度的比較判斷溫 度是上升還是降低 port (clk,en: in std_logic。 clk 時鐘 en 開關(guān) /使能端 shiwei,gewei,romeshi,romege: in std_logic_vector(0 to 3)。 shiwei 設(shè)置溫度的十位 ; gewei 設(shè)置溫度的個位; romeshi 設(shè)置室溫的十位 ; romege 設(shè)置溫度的個位。 shiout,geout:out std_logic_vector(0 to 3))。 shiout 輸出溫度的十位 geout 輸出溫度的個位 end wendu。 architecture behave of wendu is signal hs,hg:std_logic_vector(0 to 3)。 begin 10 process(clk,en,shiwei,gewei,romeshi,romege,hs,hg) begin if en=39。039。 then hs=romeshi。hg=romege。 elsif clk39。event and clk=39。139。 then if hsamp。hgshiweiamp。gewei then 室溫低于設(shè)置的溫度,溫度上升 if hg1001 then hg=hg+1。 else hg=0000。hs=hs+1。 end if。 elsif hsamp。hgshiweiamp。gewei then 室溫高于設(shè)置的溫度,溫度下降 if hg0000