Files
lt16lab/soc/peripheral/scrolling_controller.vhd

105 lines
3.6 KiB
VHDL

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity scrolling_controller is
port(
clk : in std_logic;
rst : in std_logic;
on_off : in std_logic;
cnt_start : out std_logic;
cnt_done : in std_logic;
next_char : out std_logic;
hex_char : in std_logic_vector(4 downto 0);
seg_data : out std_logic_vector(3 downto 0);
seg_off : out std_logic;
seg_shift : out std_logic;
seg_write : out std_logic;
seg_clear : out std_logic
);
end entity scrolling_controller;
architecture Behavioral of scrolling_controller is
type state_type is (s_off, s_wait, s_update);
signal state : state_type;
begin
process(clk)
begin
if clk'event and clk='1' then
if rst = '1' then
state <= s_off;
seg_clear <= '1';
cnt_start <= '0';
next_char <= '0';
seg_data <= (others => '0');
seg_off <= '0';
seg_shift <= '0';
seg_write <= '0';
else
case state is
when s_off =>
if on_off = '0' then
state <= s_off;
seg_shift <= '0';
seg_write <= '0';
seg_clear <= '0';
cnt_start <= '0';
next_char <= '0';
else
state <= s_update;
seg_data <= hex_char(3 downto 0);
seg_shift <= '1';
seg_write <= '1';
seg_clear <= '0';
seg_off <= hex_char(4);
cnt_start <= '1';
next_char <= '1';
end if;
when s_wait =>
if on_off = '1' then
state <= s_off;
seg_clear <= '1';
cnt_start <= '0';
next_char <= '0';
elsif cnt_done = '0' then
state <= s_wait;
seg_shift <= '0';
seg_write <= '0';
seg_clear <= '0';
cnt_start <= '0';
next_char <= '0';
else -- cnt_cone = '1'
state <= s_update;
seg_shift <= '0';
seg_write <= '0';
seg_clear <= '0';
cnt_start <= '1';
next_char <= '1';
end if;
when s_update =>
if on_off = '0' then
state <= s_wait;
seg_data <= hex_char(3 downto 0);
seg_shift <= '1';
seg_write <= '1';
seg_clear <= '0';
seg_off <= hex_char(4);
cnt_start <= '0';
next_char <= '0';
else
state <= s_off;
seg_clear <= '1';
cnt_start <= '0';
next_char <= '0';
end if;
end case;
end if;
end if;
end process;
end Behavioral;