Design running LEDs with two selects - left-to-right or right-to-left. ( BASYS 3)
Specification
A switch selects the running direction
entity knight_rider is port (ck, sel: in std_logic;
z: out std_logic_vector(15 downto 0));
end knight_rider;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity knight_rider is
port (
clk : in std_logic;
sel : in std_logic;
z : out std_logic_vector(15 downto 0)
);
end knight_rider;
architecture behave of knight_rider is
signal temp : std_logic_vector(15 downto 0);
begin
process(clk)
begin
if (clk'event and clk = '1') then
if (sel = '1') then
temp <= temp(14 downto 0) & temp(15); -- right
to left
else
temp <= temp(0) & temp(15 downto 1); -- left to
right
end if;
end if;
end process;
z <= temp;
end behave;
Get Answers For Free
Most questions answered within 1 hours.