when \ when \ when \ when \ when \
when others => null;
end case;
case sel is
when \ when \ when \ when \ when \ when \ when \ when \ when \ when \ when \ when \ when \ when \ when \ when \
when others => null;
end case;
case sel is
20
显示加号
when \
when \
when \when \when \when \when \when \when \when \when \when \when \when \when \when \when \when \when others => null;
end case;
when others=>null; end case;
end process;
end leddisp_arc; 加法计算模块:
该模块实现对点阵显示方式的控制,控制模块的引脚功能如图5所示,其中:CLK为时钟输入端;RST为复位端,低电平有效;Q[1..0]为功能方式输入端,用来识别按下键的类型;DATAIN[4..0]接收来自KEYBOARD模块送来的键值;DATAOUT[4..0]输出键值码;当按下ENTER键输出键码值大于9时,进位输出CO为高电平,点亮一个发光二极管。
21
图5 加法计算模块图
源程序: library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all;
entity control is port(
rst,clk : in std_logic;
q : in std_logic_vector(1 downto 0); datain : in std_logic_vector(4 downto 0); dataout : out std_logic_vector(4 downto 0); co : out std_logic ); end control;
architecture control_arc of control is signal s : std_logic_vector(4 downto 0); signal temp1 : std_logic_vector(4 downto 0); begin
process(q,rst,clk,datain) begin
if(rst='0')then
dataout<=\
co<='0';
22
elsif (clk'event and clk='1') then
if (q=\
co<='0'; dataout<=datain;
elsif (q=\
s<=datain; dataout<=\
elsif (q=\
temp1<=datain+s;
if(temp1>\
co<='1';
temp1<=temp1-\ dataout<=temp1; else dataout<=temp1;
end if;
elsif (q=\
dataout<=\
end if;
end if;
end process; end control_arc;
3.4、仿真结果:
(1)键盘扫描模块仿真图:
图6 键盘扫描模块仿真图
(2)点阵显示模块仿真图:
23
相关推荐: