ringup.vhd
来自「关于自动打铃器的程序设计。应该还是不错的哦!~」· VHDL 代码 · 共 45 行
VHD
45 行
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity ringup is
port( reset: in std_logic;
alarm: out std_logic;
hourhdis: in integer range 0 to 2;
hourldis: in integer range 0 to 9;
minhdis: in integer range 0 to 5;
minldis: in integer range 0 to 9;
sechdis: in integer range 0 to 5;
secldis: in integer range 0 to 9);
end ringup;
architecture ruarchi of ringup is --这块部分能够改进,增加功能。
constant rt: integer:=5;
constant stop: integer:=2;
begin
process(secldis)
variable cnt: integer;
begin
cnt:=sechdis*10+secldis;
if reset='1' then
alarm<='0';
elsif (hourhdis=0 and hourldis=6 and minhdis=0 and minldis=0 and sechdis<2) or
(hourhdis=1 and hourldis=0 and minhdis=3 and minldis=0 and sechdis<2) then
if cnt<rt then --第一次响铃
alarm<='1';
elsif cnt>=rt and cnt<rt+stop then
alarm<='0';
elsif cnt<2*rt+stop then --第二次响铃
alarm<='1';
elsif cnt>=2*rt+stop then
alarm<='0';
end if;
end if;
end process;
end ruarchi;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?