📄 control.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 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -