control.vhd
来自「用层次化设计完成倒计时装置 输入:16位二进制倒计时起始数字、倒计时起始数字的」· VHDL 代码 · 共 57 行
VHD
57 行
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 control is
port(
clk: in std_logic;
reset: in std_logic;
start: in std_logic;
s_over: in std_logic;
s_state: out std_logic_vector (1 downto 0)
);
end control;
architecture behaver of control is
type mystate is (s0,s1,s2);
signal last_state,current_state,next_state: mystate;
begin
process (clk)
begin
if clk'event and clk='1' then
case current_state is
when s0 => next_state<=s1; last_state<=s2;
when s1 => next_state<=s2; last_state<=s0;
when s2 => next_state<=s0; last_state<=s1;
end case;
end if;
end process;
process (clk,reset,start,s_over)
begin
if reset='0' then
current_state<=s0;
s_state<="00";
elsif clk'event and clk='1' then
case current_state is
when s0 =>
s_state<="00";
if start='0' then
current_state<=next_state;
end if;
when s1 =>
s_state<="01";
if s_over='1' then
current_state<=next_state;
end if;
when s2 =>
s_state<="11";
if start'event and start='0' then
current_state<=last_state;
end if;
end case;
end if;
end process;
end behaver;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?