名称:脉冲按键电诂按键显示器VHDL代码AX301开发板Quartus
软件:Quartus
语言:VHDL
代码功能:
4、脉冲按键电诂按键显示器
设计一个具有8位显示的电话按键显示器;要求:(1)能准确地反映按键数字
(2)显示器显示从低位向高位前移,逐位显示按键数字,最低位为当前输入位
(3)*设置一个“重拨”键,按下此键,能显示最后一次输入的电话号码;? ? (4)*挂机2秒后能消除显示。
本代码已在AX301开发板验证,开发板如下,其他开发板可以修改管脚适配:
1. 工程文件
2. 程序文件
3. 程序编译
4. 管脚分配
5. RTL图
6. Testebnch
7. 仿真图
整体仿真图
按键消抖模块
控制模块
显示模块
部分代码展示:
LIBRARY?ieee; ???USE?ieee.std_logic_1164.all; --电话按键显示 ENTITY?telephone?IS ???PORT?( ??????clk??????:?IN?STD_LOGIC; ??????key1_in??:?IN?STD_LOGIC; ??????key2_in??:?IN?STD_LOGIC; ??????recall???:?IN?STD_LOGIC;--重播键 ??????close????:?IN?STD_LOGIC;--挂机键 ??????DIG??????:?OUT?STD_LOGIC_VECTOR(5?DOWNTO?0);--数码管位选 ??????SEG??????:?OUT?STD_LOGIC_VECTOR(7?DOWNTO?0)--数码管段选 ???); END?telephone; ARCHITECTURE?trans?OF?telephone?IS ???COMPONENT?display?IS ??????PORT?( ?????????clk??????:?IN?STD_LOGIC; ?????????number???:?IN?STD_LOGIC_VECTOR(3?DOWNTO?0); ?????????tele_num?:?IN?STD_LOGIC_VECTOR(23?DOWNTO?0); ?????????DIG??????:?OUT?STD_LOGIC_VECTOR(5?DOWNTO?0); ?????????SEG??????:?OUT?STD_LOGIC_VECTOR(7?DOWNTO?0) ??????); ???END?COMPONENT; ??? ???COMPONENT?xiaodou?IS ??????PORT?( ?????????clkin????:?IN?STD_LOGIC; ?????????key_in???:?IN?STD_LOGIC; ?????????key_neg??:?OUT?STD_LOGIC ??????); ???END?COMPONENT; ??? ???COMPONENT?control?IS ??????PORT?( ?????????clk??????:?IN?STD_LOGIC; ?????????rst_n????:?IN?STD_LOGIC; ?????????key0?????:?IN?STD_LOGIC; ?????????key1?????:?IN?STD_LOGIC; ?????????key2?????:?IN?STD_LOGIC; ?????????key3?????:?IN?STD_LOGIC; ?????????key4?????:?IN?STD_LOGIC; ?????????recall???:?IN?STD_LOGIC; ?????????close????:?IN?STD_LOGIC; ?????????number???:?OUT?STD_LOGIC_VECTOR(3?DOWNTO?0); ?????????tele_num?:?OUT?STD_LOGIC_VECTOR(23?DOWNTO?0) ??????); ???END?COMPONENT; ??? ??? ???SIGNAL?number????:?STD_LOGIC_VECTOR(3?DOWNTO?0);--输入数量 ???SIGNAL?tele_num??:?STD_LOGIC_VECTOR(23?DOWNTO?0);--电话号码 ???SIGNAL?key0??????:?STD_LOGIC; ???SIGNAL?key1??????:?STD_LOGIC; ???SIGNAL?key2??????:?STD_LOGIC; ???SIGNAL?key3??????:?STD_LOGIC; ???SIGNAL?key4??????:?STD_LOGIC; BEGIN ???--消抖模块 ???i1_xiaodou?:?xiaodou ??????PORT?MAP?( ?????????clkin????=>?clk, ?????????key_in???=>?key1_in, ?????????key_neg??=>?key1 ??????); ??? ??? ???--消抖模块 ???i2_xiaodou?:?xiaodou ??????PORT?MAP?( ?????????clkin????=>?clk, ?????????key_in???=>?key2_in, ?????????key_neg??=>?key2 ??????); ??? ??? ???--控制模块 ???i_control?:?control ??????PORT?MAP?( ?????????clk???????=>?clk, ?????????rst_n?????=>?'1',--复位 ?????????key0??????=>?'0', ?????????key1??????=>?key1, ?????????key2??????=>?key2, ?????????key3??????=>?'0', ?????????key4??????=>?'0', ?????????recall????=>?recall,--重播键 ?????????close?????=>?close,--挂机键 ?????????number????=>?number,--输入数量 ?????????tele_num??=>?tele_num--电话号码 ??????); ??? ??? ??? --显示模块 ???i_display?:?display ??????PORT?MAP?( ?????????clk???????=>?clk, ?????????number????=>?number,--输入数量 ?????????tele_num??=>?tele_num,--电话号码 ?????????DIG???????=>?DIG,--数码管位选 ?????????SEG???????=>?SEG--数码管段选 ??????); ??? END?trans;
?扫描文章末尾的公众号二维码