In: Electrical Engineering
I need to develop a VHDL code for a FPGA basys 3, 4 digit 7 segment display. So when binary 0, 1 ,and 2 are inputted the display says bad. When binary 3,4,5,6, the display says good.
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity display is
port ( clock : in
std_logic;
reset : in
std_logic;
binary : in
std_logic_vector(2 downto 0);
W4 : out
std_logic; --A1
V4 : out
std_logic; --A2
U4 : out
std_logic; --A3
U2 : out
std_logic; --A4
W7 : out
std_logic; --CA
W6 : out
std_logic; --CB
U8 : out
std_logic; --CC
V8 : out
std_logic; --CD
U5 : out
std_logic; --CE
V5 : out
std_logic; --CF
U7 : out
std_logic; --CG
V7 : out
std_logic --DP
);
end display;
architecture arch of display is
signal segment : std_logic_vector(7 downto 0);
signal display_refresh_count : std_logic_vector (19 downto 0):= x"00000";
begin
process(clock, reset)
begin
if (reset = '1') then
display_refresh_count <= x"00000";
else
if rising_edge
(clock) then
display_refresh_count <=
display_refresh_count + 1;
end if;
end if;
end process;
process (display_refresh_count(19 downto 18))
begin
W4 <= '1'; V4 <= '1'; U4
<= '1'; U2 <= '1';
case (display_refresh_count(19
downto 18)) is
when "00"=>
if (binary = "000" or binary = "001" or binary = "010") then
segment <= "10000011";
--display 'b'
elsif (binary = "011" or binary = "100" or
binary = "101" or binary = "110") then
segment <= "10010000";
--display 'g'
end if;
W4 <=
'0'; --display on segment 1
when
"01"=> if (binary = "000" or binary = "001" or binary = "010")
then
segment <= "10001000";
--display 'A'
elsif (binary = "011" or binary = "100" or
binary = "101" or binary = "110") then
segment <= "11000000";
--display 'O'
end if;
V4 <=
'1'; --display on segment 2
when
"10"=> if (binary = "000" or binary = "001" or binary = "010")
then
segment <= "10100001";
--display 'd'
elsif (binary = "011" or binary = "100" or
binary = "101" or binary = "110") then
segment <= "11000000";
--display 'O'
end if;
U4 <=
'0'; --display on segment 3
when
"11"=> if (binary = "000" or binary = "001" or binary = "010")
then
segment <= "11111111";
-- keep blank
elsif (binary = "011" or binary = "100" or
binary = "101" or binary = "110") then
segment <= "10100001";
--display 'd'
end if;
U2 <=
'0'; --display on segment 4
when
others=> null;
end case;
end process;
W7 <= segment(0);
W6 <= segment(1);
U8 <= segment(2);
V8 <= segment(3);
U5 <= segment(4);
V5 <= segment(5);
U7 <= segment(6);
V7 <= segment(7);
end arch;
--Simulated