版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、生產(chǎn)實習報告基于FPGA的溫度顯示系統(tǒng)現(xiàn)代電子系統(tǒng)質量提高工程報告專業(yè):電子科學與技術班級:電子12-1姓名:學號:1206040124一、生廣實習任務極其完成情況1 .設計任務設計了一種基于FPGAf口LM75刖勺溫度測量系統(tǒng)。硬件設計上,系統(tǒng)以EP4CE6E22C8N為主控芯片,采用數(shù)字溫度傳感器LM75A檢測環(huán)境溫度,并利用LM75A自帶的IIC總線接口傳輸數(shù)據(jù),通過數(shù)碼管將溫度實時顯示出來;軟件設計上,采用自頂向下模塊化設計思想,先設計出IIC通信模塊、溫度顯示模塊,然后再編寫頂層模塊,將2個模塊整合。2 .電路圖aCt3 .程序流程圖開始(結束4 .編與的程序(一)功能模塊:libr
2、aryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;useieee.std_logic_arith.all;-實體-entityat24c08isport(clkinstd_logic;rst:instd_logic;scloutstd_logic;sdainoutstd_logic;urv_1instd_logic;urv_2instd_logic;sel:outstd_logic_vector(3downto0);seg:outstd_logic_vector(7downto0);beepoutstd_logi
3、c-時鐘信號-復位信號-i2c時鐘線-i2c數(shù)據(jù)線-上限值1-上限值2蜂鳴器輸出信號線);endat24c08;一結構體-architecturearch_at24c08ofat24c08issignaclk_sslowstd_logic;signacounterstd_logic_vector(23downto0);signareaddata_reg_bufstd_logic_vector(15downto0);signareaddata_tenintegerrange0to24564;signareaddata_stdstd_logic_vector(15downto0);signaqia
4、nstd_logic_vector(3downto0);signabaistd_logic_vector(3downto0);signashistd_logic_vector(3downto0);signagestd_logic_vector(3downto0);signaqian_0integerrange0to10;signabai_0integerrange0to10;signashi_0integerrange0to10;signage_0integerrange0to10;-數(shù)碼管部分信號signal sel_0signal seg_0signal countsignal clk_s
5、lowsignal scan_numsignal seg_data_buf-i2c部分信號signal sda_bufsignal linksignal readdata_reg存器signal sda_0signal scl_0std_logic_vector(3downto0);std_logic_vector(7downto0);std_logic_vector(13downto0);std_logic;std_logic_vector(1downto0);std_logic_vector(3downto0);std_logic;-i2c輸入/輸出數(shù)據(jù)寄存器std_logic;-sda輸
6、入輸出方向寄存器std_logic_vector(15downto0);-i2c讀回的數(shù)據(jù)寄std_logic;-與sda端口連接信號std_logic;-與scl端口連接信號-按鍵消抖部分信號signaldelay_cntsignalstart_delaystd_logic_vector(19downto0);std_logic;-消抖延時計數(shù)器-按鍵延時開始-分頻部分信號signalclk_div:std_logic_vector(12downto0);-分頻計數(shù)器,5000分頻,10khz-蜂鳴器部分信號signalbeep_en:std_logic;signalbeep_buf:std
7、_logic;-蜂鳴器使能信號-與beep端口連接的信號-時鐘部分信號signallevel_highstd_logic;-高電平中間值,1249std_logic_vector(12 downto 0):="1001110001000"signallevel_lowsignallevel_hig_edgesignallevel_low_edge-狀態(tài)機部分信號signalmain_statesignali2c_statesignali2c_per_state-分頻部分常量constantdiv_parameter-分頻系數(shù),500-狀態(tài)機部分常量-操作狀態(tài)常量consta
8、ntread_init初始化constantread_high數(shù)據(jù)狀態(tài)constantread_low數(shù)據(jù)狀態(tài)-i2c每一步狀態(tài)常量constantstart- -開始位constantfirst- -數(shù)據(jù)第一位constantsecond- -數(shù)據(jù)第二位constantthirdstd_logic;std_logic;std_logic;std_logic_vector(1downto0);std_logic_vector(2downto0);std_logic_vector(3downto0);std_logic_vector(2downto0)std_logic_vector(2down
9、to0)std_logic_vector(2downto0)std_logic_vector(3downto0)std_logic_vector(3downto0)std_logic_vector(3downto0)std_logic_vector(3downto0)- 低電平中間值,3749- -上升沿,4999- 下降沿,2499-狀態(tài)機主狀態(tài)-i2c狀態(tài)-i2c每一步狀態(tài)尸"000”;-EEPORM尸"001”;-讀高位尸"010”;-讀低位尸"0000"尸"0001”;尸"0010"尸"0011&
10、quot;-數(shù)據(jù)第三位constant fourth-數(shù)據(jù)第四位constant fifth-數(shù)據(jù)第五位constant sixth-數(shù)據(jù)第六位constant seventh-數(shù)據(jù)第七位constant eighth-數(shù)據(jù)第八位constant ack-應答位constant stop一停止位std_logic_vector(3downto0)k"0100"std_logic_vector(3downto0)k"0101"std_logic_vector(3downto0)k"0110"std_logic_vector(3downt
11、o0)k"0111"std_logic_vector(3downto0)k"1000"std_logic_vector(3downto0)k"1001"std_logic_vector(3downto0):="1010"-結構體開始beginscl<=scl_0;seg<=seg_0;sda_0<=sda_bufwhen(link)='1'else'Z'sda<=sda_0;sel<=sel_0;beep<=beep_buf;-按鍵消抖key:pr
12、ocess(clk,rst)beginif(notrst='1')thendelay_cnt<=(others=>'0');elsif(clk'eventandclk='1')thenifstart_delay='1'thenif(delay_cnt/="11110100001001000000")then-20ms延時delay_cnt<=delay_cnt+'1'elsedelay_cnt<=(others=>'0');endif;end
13、if;endif;endprocesskey;-分頻部分div:process(rst,clk)beginif(notrst='1')thenclk_div<="0000000000000"level_high<='0'level_low<='0'level_hig_edge<='0'level_low_edge<='0'elsif(clk'eventandclk='1')thenif(clk_div/=div_parameter-'
14、1')thenclk_div<=clk_div+'1'elseclk_div<="0000000000000"endif;if(level_high='1')thenlevel_high<='0'elseif(clk_div="10011100001") thenlevel_high<='1'endif;endif;if(level_low_edge='1')thenlevel_low_edge<='0'elseif(cl
15、k_div="100111000011")thenlevel_low_edge<='1'endif;endif;if(level_low='1')thenlevel_low<='0'elseif(clk_div="111010100101")thenlevel_low<='1'endif;endif;if(level_hig_edge='1')thenlevel_hig_edge<='0'elseif(clk_div="100
16、1110000111")thenlevel_hig_edge<='1'endif;endif;endif;endprocessdiv;-EEPROMft作部分state:process(clk,rst)beginif(notrst='1')thenstart_delay<='0'scl_0<='1'sda_buf<='1'link<='0'readdata_reg<="0000000000000000"main_state<=&
17、quot;00"i2c_state<=read_init;i2c_per_state<=start;elsif(clk'eventandclk='1')thencasemain_stateis-初始化EEPROMwhen"00"=>-等待讀寫要求scl_0<='1'sda_buf<='1'link<='0'i2c_state<=read_init;i2c_per_state<=start;main_state<="10"
18、-讀取EEPR做據(jù)when"10"=>if(level_hig_edge='1')thenscl_0<='1'elseif(level_low_edge='1')thenscl_0<='0'endif;endif;casei2cstateiswhenread_init=>-讀命令地址casei2c_per_stateiswhenstart=>if(level_high='1')thensda_buf<='0'link<='1
19、9;endif;if(level_lowandlink)='1')thenlink<='1'sda_buf<='1'i2c_per_state<=first;endif;whenfirst=>if(level_low='1')thensda_buf<='0'link<='1'i2c_per_state<=second;endif;whensecond=>if(level_low='1')thensda_buf<='0
20、9;link<='1'i2c_per_state<=third;endif;whenthird=>if(level_low='1')thensda_buf<='1'i2c_per_state<=fourth;endif;whenfourth=>if(level_low='1')thensda_buf<='0'link<='1'i2c_per_state<=fifth;endif;whenfifth=>if(level_low='1&
21、#39;)thensda_buf<='0'link<='1'i2c_per_state<=sixth;endif;whensixth=>if(level_low='1')thensda_buf<='0'link<='1'i2c_per_state<=seventh;endif;whenseventh=>if(level_low='1')thensda_buf<='1'link<='1'i2c_per_stat
22、e<=eighth;endif;wheneighth=>if(level_low='1')thenlink<='0'i2c_per_state <= ack;end if;whenack=>if(level_hig_edge='1')thensda_buf<=sda;endif;if(level_high='1')thenif(sda_buf='1')thenmain_state<="00"endif;endif;if(level_low='1&
23、#39;)thenlink<='0'i2c_state<=read_high;i2c_per_state<=first;endif;whenothers=>null;endcase;whenread_high=>-讀回數(shù)據(jù)casei2c_per_stateiswhenfirst=>if(level_hig_edge='1')thensda_buf<=sda;endif;if(level_high='1')thenreaddata_reg(15downto9)<=readdata_reg(14down
24、to8);readdata_reg(8)<=sda;endif;if(level_low='1')thenwhensecond=>if(level_hig_edge='1')thensda_buf<=sda;endif;if(level_high='1')thenreaddata_reg(14 downto 8);readdata_reg(14 downto 8);readdata_reg(15downto9)二readdata_reg(8) <= sda;end if;if(level_low='1')
25、theni2c_per_state <= third;end if;when third =>if(level_hig_edge='1') thensda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(15 downto 9)<=readdata_reg(8)<=sda;endif;if(level_low='1')theni2c_per_state<=fourth;endif;whenfourth=>if(level_hig_edge=
26、9;1')thensda_buf<=sda;endif;if(level_high='1') thenreaddata_reg(15downto9)<=readdata_reg(14downto8);readdata_reg(8)<=sda;endif;if(level_low='1')theni2c_per_state<=fifth;endif;whenfifth=>if(level_hig_edge='1')thensda_buf<=sda;endif;if(level_high='1
27、9;)thenreaddata_reg(15downto9)<=readdata_reg(14downto8);readdata_reg(8)<=sda;endif;if(level_low='1')theni2c_per_state<=sixth;endif;whensixth=>if(level_hig_edge='1')thensda_buf<=sda;endif;if(level_high='1')thenreaddata_reg(15downto9)<=readdata_reg(14downto8);
28、readdata_reg(8)<=sda;endif;if(level_low='1')theni2c_per_state<=seventh;end if;二二whenseventh=>if(level_hig_edge='1')thensda_buf<=sda;endif;if(level_high='1')thenreaddata_reg(15downto9)readdata_reg(14downto8);readdata_reg(8)<=sda;endif;if(level_low='1')th
29、eni2c_per_state<=eighth;endif;wheneighth=>if(level_hig_edge='1')thensda_buf<=sda;endif;if(level_high='1')thenreaddata_reg(15downto9)readdata_reg(14downto8);readdata_reg(8)<=sda;endif;if(level_low='1')theni2c_per_state<=ack;endif;whenack=>if(level_high='1
30、')thenlink<='1'sda_buf<='0'i2c_per_state<=first;i2c_state <= read_low;endif;whenothers=>null;endcase;whenreadlow=>casei2c_per_stateiswhenfirst=>if(level_hig_edge='1')thenlink<='0'sda_buf<=sda;endif;if(level_high='1')thenreaddata_
31、reg(7downto1)<=readdata_reg(6downto0);readdata_reg(0)<=sda;endif;if(level_low='1')theni2c_per_state<=second;endif;whensecond=>if(level_hig_edge='1')thenlink<='0'sda_buf<=sda;endif;if(level_high='1')thenreaddata_reg(7downto1)<=readdata_reg(6downto0
32、);readdata_reg(0)<=sda;endif;if(level_low='1') theni2c_per_state<=third;endif;whenthird=>if(level_hig_edge='1')thenlink<='0'sda_buf<=sda;endif;if(level_high='1')thenreaddata_reg(7downto1)<=readdata_reg(6downto0);readdata_reg(0)<=sda;endif;if(level
33、_low='1')theni2c_per_state<=fourth;endif;whenfourth=>if(level_hig_edge='1')thenlink<='0'sda_buf<=sda;endif;if(level_high='1')thenreaddata_reg(7downto1)<=readdata_reg(6downto0);readdata_reg(0)<=sda;endif;if(level_low='1')theni2c_per_state<=
34、fifth;endif;whenfifth=>link<='0'sda_buf<=sda;endif;if(level_high='1')thenreaddata_reg(7downto1)<=readdata_reg(6downto0);readdata_reg(0)<=sda;endif;if(level_low='1')theni2c_per_state<=sixth;endif;whensixth=>if(level_hig_edge='1')thenlink<='0
35、'sda_buf<=sda;endif;if(level_high='1')thenreaddata_reg(7downto1)<=readdata_reg(6downto0);readdata_reg(0)<=sda;endif;if(level_low='1')theni2c_per_state<=seventh;endif;whenseventh=>if(level_hig_edge='1')thenlink<='0'sda_buf<=sda;endif;if(level_h
36、igh='1') thenreaddata_reg(7downto1)<=readdata_reg(6downto0);readdata_reg(0)<=sda;endif;if(level_low='1')theni2c_per_state<=eighth;endif;wheneighth=>if(level_hig_edge='1')thenlink<='0'sda_buf<=sda;endif;if(level_high='1')thenreaddata_reg(7down
37、to1)<=readdata_reg(6downto0);readdata_reg(0)<=sda;endif;if(level_low='1')theni2c_per_state<=ack;endif;whenack=>if(level_high='1')thenlink<='1'sda_buf<='1'-非應答位-i2c_per_state<=stop;endif;if(level_low='1')thenlink<='1'sda_buf<=
38、'0'i2c_per_state<=stop;endif;whenstop=>if(level_high='1')thenlink<='1'sda_buf<='1'-停止位endif;if(level_low='1')thenmain_state<="00"endif;whenothers=>null;endcase;whenothers=>null;endcase;whenothers=>null;endcase;endif;endprocess
39、state;-數(shù)據(jù)處理部分anly1:process(readdata_reg_buf)beginreaddata_ten<=conv_integer(readdata_reg_buf)*12;qian_0<=readdata_ten/1000;bai_0<=(readdata_ten/100)rem10;shi_0<=(readdata_ten/10)rem10;ge_0<=readdata_tenrem10;endprocessanly1;anly2:process(qian_0,bai_0,shi_0,ge_0)beginqian<=conv_std_
40、logic_vector(qian_0,4);bai<=conv_std_logic_vector(bai_0,4);shi<=conv_std_logic_vector(shi_0,4);ge<=conv_std_logic_vector(ge_0,4);endprocessanly2;-數(shù)碼管顯示部分scan:process(rst,clk)beginif(notrst='1')thencount<=(others=>'0');clk_slow<='0'elsif(clk'eventandclk=&
41、#39;1')thenif(count="11111011011111")thencount<=(others=>'0');clk_slow<=notclk_slow;elsecount<=count+'1'endif;endif;endprocessscan;seg1:process(clk_slow,rst)beginif(notrst='1')thenscan_num<="00"elsif(clk_slow'eventandclk_slow='1&
42、#39;)thenscan_num<="00"elsescan_num<=scan_num+'1'endif;endif;endprocesssegl;seg2:process(seg_data_buf)begincaseseg_data_bufiswhen"1111"=>seg_0<="10001110"when"1110"=>seg_0<="10000110"when"1101"=>seg_0<="
43、10100001"when"1100"=>seg_0<="11000110"when"1011"=>seg_0<="10000011"when"1010"=>seg_0<="10011000"when"1001"=>seg_0<="10010000"when"1000"=>seg_0<="10000000"when"0
44、111"=>seg_0<="11111000"when"0110"=>seg_0<="10000010"when"0101"=>seg_0<="10010010"when"0100"=>seg_0<="10011001"when"0011"=>seg_0<="10110000"when"0010"=>seg_0<=&
45、quot;10100100"when"0001"=>seg_0<="11111001"when"0000"=>seg_0<="11000000"whenothers=>seg_0<="11111111"endcase;endprocessseg2;seg0:process(scan_num)begincasescan_numiswhen"00"=>sel_0<="1110"seg_data_buf&
46、lt;=ge;when"01"=>sel_0<="1101"seg_data_buf<=shi;when"10"=>sel_0<="1011"seg_data_buf<=bai;when"11"=>sel_0<="0111"seg_data_buf<=qian;whenothers=>null;endcase;endprocessseg0;-數(shù)據(jù)緩存部分ss:process(clk,rst)beginif(notrs
47、t='1')thenclk_sslow<='0'counter<=(others=>'0');if(counter/="111111111111111111111110")thencounter<=counter+'1'elsecounter<=(others=>'0');clk_sslow<=notclk_sslow;endif;endif;endprocessss;buf:process(clk_sslow)beginif(clk_sslow'
48、;eventandclk_sslow='1')thenreaddata_reg_buf<=readdata_reg;elsereaddata_reg_buf<=readdata_reg_buf;endif;endprocessbuf;-蜂鳴器報警部分bep:process(clk,rst)variablecount:integerrange0to50000;-1KHz方波beginif(notrst='1')thencount:=0;beep_en<='0'elsif(clk'eventandclk='1'
49、;)thenif(beep_en='1')thencount:=count+1;if(count>50000) thencount:=0;beep_buf<=notbeep_buf;endif;elseif(noturv_1='1')thenif(readdata_reg>”0000000000000011")thenbeep_en<='1'endif;elsif(noturv_2='1')thenif(readdata_reg>”1111111111100000")thenbee
50、p_en<='1'endif;endif;endif;endif;endprocessbep;endarch_at24c08;(二)測試模塊:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entitytbis-null;endtb;architecturebehv_tboftbiscomponentat24c08clkinstd_logic;rst:instd_logic;scl:outstd_logic;sda :inou
51、tstd_logic;urv_1 :instd_logic;urv_2 :instd_logic;port(-時鐘信號-復位信號-i2c時鐘線-i2c數(shù)據(jù)線-上限值1-上限值2sel:outstd_logic_vector(3downto0);seg:outstd_logic_vector(7downto0);beep:outstd_logic-蜂鳴器輸出信號線);endcomponent;constantclockperiod:time:=20ns;signalclk_tb:std_logic:='0'signalrst_tb:std_logic;signalscl_tb:std_logic;signalsda_tb:std_logic;signalurv_1_tb:std_logic;signalurv_2_tb:std_logic;signalsel_tb:std_logic_vector(3downto0);signalseg_tb:std_logic_vector(7downto0);sign
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 英語語音室建設方案(參考模板)
- 培訓咨詢成果保護合同
- 股東之間的股權轉讓協(xié)議
- 自營采購合同的格式要求
- 離婚協(xié)議書怎么擬寫
- 廣告公司購銷合作協(xié)議范本
- 代理記賬合同
- 招標文件方案技巧
- 小區(qū)物業(yè)服務競標方案
- 專業(yè)解讀實操經(jīng)驗
- 青島版二年級數(shù)學下冊《周期問題》教案
- GB/T 307.1-2005滾動軸承向心軸承公差
- GB/T 23468-2009墜落防護裝備安全使用規(guī)范
- GB/T 14801-2009機織物與針織物緯斜和弓緯試驗方法
- 國家開放大學電大《計算機應用基礎(本)》終結性考試試題答案(格式已排好)任務一
- 2023年福建永泰閩投抽水蓄能有限公司招聘筆試題庫及答案解析
- 2023年惠州市交通投資集團有限公司招聘筆試題庫及答案解析
- 第一學期期末大作業(yè)(經(jīng)濟學)
- 腮腺腫瘤課件
- 變壓器保護課件
- 《大學英語B》形成性考核 參考資料 廣東開放大學
評論
0/150
提交評論