📄 counter.vhd
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
entity counter is
port(
clk: in std_logic;
clk10: in std_logic;
number: in std_logic_vector (15 downto 0);
s_state: in std_logic_vector (1 downto 0);
data: inout std_logic_vector (15 downto 0);
s_over: out std_logic
);
end counter;
architecture behaver of counter is
begin
process (clk,clk10,s_state)
begin
if clk'event and clk='1' then
case s_state is
when "00" =>
data<=number;
s_over<='0';
when "01"=>
if clk10'event and clk10='1' then
if data>"0000000000000000" then
data<=data-'1';
s_over<='0';
else
-- data<="0000000000000000"; -- not necessary
s_over<='1';
end if;
end if;
when "11" =>
data<="0000000000000000";
s_over<='1';
when others =>
data<="0000000000000000";
s_over<='0';
end case;
end if;
end process;
end behaver;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -