Altera_Forum
Honored Contributor
11 years ago7 segment display from 4 bit binary
So I understand what this is supposed to be doing in theory. However in practice I can't find any practical examples. Basically I have a circuit with two 4 bit numbers in, with a switch (S) to select between the two, and the selected number is shown on the 7 segment display.
Could someone please tell me what I need to change for the syntax of this to compile? Or alternatively if there is an easier way, I would happily use that. From all the examples I could find this seemed like the best way. currently when trying to compile this error displays for each line of the case statement Error (10500): VHDL syntax error at test2.vhd(37) near text "when"; expecting "end", or "(", or an identifier ("when" is a reserved keyword), or a concurrent statement
ENTITY test2 IS
PORT(
AI :IN STD_LOGIC_VECTOR(3 DOWNTO 0);
BI :IN STD_LOGIC_VECTOR(3 DOWNTO 0);
S :IN BIT;
S7 :OUT STD_LOGIC_VECTOR(6 DOWNTO 0));
END test2;
ARCHITECTURE behavior OF test2 IS
PROCESS (AI, BI)
BEGIN
IF (S=0)
CASE "AI" is
when "0000"=> S7 <="0000001"; --1
when "0001"=> S7 <="1001111"; --2 (etc)
when "0010"=> S7 <="0010010";
when "0011"=> S7 <="0000110";
when "0100"=> S7 <="1001100";
when "0101"=> S7 <="0100100";
when "0110"=> S7 <="0100000";
when "0111"=> S7 <="0001111";
when "1000"=> S7 <="0000000";
when "1001"=> S7 <="0000100";
when others => S7 <="1001111"; -- e for error
END CASE;
END IF;
IF (S=1)
CASE "AI" is
when "0000"=> S7 <="0000001";
when "0001"=> S7 <="1001111";
when "0010"=> S7 <="0010010";
when "0011"=> S7 <="0000110";
when "0100"=> S7 <="1001100";
when "0101"=> S7 <="0100100";
when "0110"=> S7 <="0100000";
when "0111"=> S7 <="0001111";
when "1000"=> S7 <="0000000";
when "1001"=> S7 <="0000100";
when others => S7 <="1001111"; -- e for error
END CASE;
END IF;
END PROCESS;
END behavior;
Thank you so much for your time