基于FPGA的温度显示系统Word格式.docx
- 文档编号:1467964
- 上传时间:2023-04-30
- 格式:DOCX
- 页数:32
- 大小:137.08KB
基于FPGA的温度显示系统Word格式.docx
《基于FPGA的温度显示系统Word格式.docx》由会员分享,可在线阅读,更多相关《基于FPGA的温度显示系统Word格式.docx(32页珍藏版)》请在冰点文库上搜索。
--复位信号
scl:
outstd_logic;
--i2c时钟线
sda:
inoutstd_logic;
--i2c数据线
urv_1:
--上限值1
urv_2:
--上限值2
sel:
outstd_logic_vector(3downto0);
seg:
outstd_logic_vector(7downto0);
beep:
outstd_logic--蜂鸣器输出信号线
);
endat24c08;
--结构体--
architecturearch_at24c08ofat24c08is
signalclk_sslow:
std_logic;
signalcounter:
std_logic_vector(23downto0);
signalreaddata_reg_buf:
std_logic_vector(15downto0);
signalreaddata_ten:
integerrange0to24564;
signalreaddata_std:
signalqian:
std_logic_vector(3downto0);
signalbai:
signalshi:
signalge:
signalqian_0:
integerrange0to10;
signalbai_0:
signalshi_0:
signalge_0:
--数码管部分信号
signalsel_0:
signalseg_0:
std_logic_vector(7downto0);
signalcount:
std_logic_vector(13downto0);
signalclk_slow:
signalscan_num:
std_logic_vector(1downto0);
signalseg_data_buf:
--i2c部分信号
signalsda_buf:
--i2c输入/输出数据寄存器
signallink:
--sda输入输出方向寄存器
signalreaddata_reg:
--i2c读回的数据寄存器
signalsda_0:
--与sda端口连接信号
signalscl_0:
--与scl端口连接信号
--按键消抖部分信号
signaldelay_cnt:
std_logic_vector(19downto0);
--消抖延时计数器
signalstart_delay:
--按键延时开始
--分频部分信号
signalclk_div:
std_logic_vector(12downto0);
--分频计数器,5000分频,10khz
--蜂鸣器部分信号
signalbeep_en:
--蜂鸣器使能信号
signalbeep_buf:
--与beep端口连接的信号
--时钟部分信号
signallevel_high:
--高电平中间值,1249
signallevel_low:
--低电平中间值,3749
signallevel_hig_edge:
--上升沿,4999
signallevel_low_edge:
--下降沿,2499
--状态机部分信号
signalmain_state:
--状态机主状态
signali2c_state:
std_logic_vector(2downto0);
--i2c状态
signali2c_per_state:
--i2c每一步状态
--分频部分常量
constantdiv_parameter:
std_logic_vector(12downto0):
="
1001110001000"
;
--分频系数,500
--状态机部分常量
--操作状态常量
constantread_init:
std_logic_vector(2downto0):
000"
--EEPORM初始化
constantread_high:
001"
--读高位数据状态
constantread_low:
010"
--读低位数据状态
--i2c每一步状态常量
constantstart:
std_logic_vector(3downto0):
0000"
--开始位
constantfirst:
0001"
--数据第一位
constantsecond:
0010"
--数据第二位
constantthird:
0011"
--数据第三位
constantfourth:
0100"
--数据第四位
constantfifth:
0101"
--数据第五位
constantsixth:
0110"
--数据第六位
constantseventh:
0111"
--数据第七位
constanteighth:
1000"
--数据第八位
constantack:
1001"
--应答位
constantstop:
1010"
--停止位
--结构体开始
begin
scl<
=scl_0;
seg<
=seg_0;
sda_0<
=sda_bufwhen(link)='
1'
else'
Z'
sda<
=sda_0;
sel<
=sel_0;
beep<
=beep_buf;
--按键消抖
key:
process(clk,rst)
begin
if(notrst='
)then
delay_cnt<
=(others=>
'
0'
);
elsif(clk'
eventandclk='
)then
ifstart_delay='
then
if(delay_cnt/="
11110100001001000000"
)then--20ms延时
delay_cnt<
=delay_cnt+'
else
endif;
endif;
endif;
endprocesskey;
--分频部分
div:
process(rst,clk)
clk_div<
="
0000000000000"
level_high<
='
level_low<
level_hig_edge<
level_low_edge<
elsif(clk'
if(clk_div/=div_parameter-'
clk_div<
=clk_div+'
else
if(level_high='
level_high<
if(clk_div="
10011100001"
level_high<
if(level_low_edge='
level_low_edge<
100111000011"
level_low_edge<
if(level_low='
level_low<
111010100101"
level_low<
if(level_hig_edge='
level_hig_edge<
1001110000111"
level_hig_edge<
endprocessdiv;
--EEPROM操作部分
state:
start_delay<
scl_0<
sda_buf<
link<
readdata_reg<
0000000000000000"
main_state<
00"
i2c_state<
=read_init;
i2c_per_state<
=start;
casemain_stateis
--初始化EEPROM
when"
=>
--等待读写要求
scl_0<
sda_buf<
link<
i2c_state<
i2c_per_state<
main_state<
10"
--读取EEPRO数据
if(level_hig_edge='
scl_0<
else
if(level_low_edge='
scl_0<
endif;
endif;
casei2c_stateis
whenread_init=>
--读命令地址
casei2c_per_stateis
whenstart=>
if(level_high='
sda_buf<
link<
endif;
if((level_lowandlink)='
i2c_per_state<
=first;
whenfirst=>
if(level_low='
=second;
whensecond=>
=third;
whenthird=>
=fourth;
whenfourth=>
=fifth;
whenfifth=>
=sixth;
whensixth=>
=seventh;
whenseventh=>
=eighth;
wheneighth=>
=ack;
whenack=>
if(level_hig_edge='
=sda;
if(sda_buf='
main_state<
endif;
i2c_state<
=read_high;
whenothers=>
null;
endcase;
whenread_high=>
--读回数据
readdata_reg(15downto9)<
=readdata_reg(14downto8);
readdata_reg(8)<
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 基于 FPGA 温度 显示 系统