downcnt.vhd
来自「【经典设计】VHDL源代码下载~~ 其中经典的设计有:【自动售货机】、【电子钟」· VHDL 代码 · 共 27 行
VHD
27 行
--downcnt.vhd n modules downcounter
library ieee ;
use ieee.std_logic_1164.all ;
entity downcnt is
generic ( modulus : integer := 8 ) ;
port (
clock : in std_logic ;
e : in std_logic ;--enable 1->enable 0->disable
l : in std_logic ;--load 1->load
q : out integer range 0 to modulus-1 ) ;
end downcnt ;
architecture behavior of downcnt is
signal count : integer range 0 to modulus-1 ;
begin
process
begin
wait until (clock'event and clock = '1') ;--clock positive edge trigger
if e = '1' then
if l = '1' then
count <= modulus-1 ;--loading
else
count <= count-1 ;--counting
end if ;
end if ;
end process;
q <= count ;--output internal signal
end behavior ;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?