Forum Discussion
Altera_Forum
Honored Contributor
8 years agoThe code is as follows.
---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity MUX_0thruF is Port ( SW : in STD_LOGIC_VECTOR (4 downto 0); SEL : in STD_LOGIC; a_to_g : out STD_LOGIC_VECTOR (6 downto 0); an : out STD_LOGIC_VECTOR (7 downto 0); dp : out STD_LOGIC; LD0 : out STD_LOGIC); end MUX_0thruF; architecture Behavioral of MUX_0thruF is begin LD0 <= SW(4); dp <= not SW(4); process(SW) begin case SW is when "00000"=> a_to_g <="1000000"; when "00001"=> a_to_g <="1111001"; when "00010"=> a_to_g <="0100100"; when "00011"=> a_to_g <="0110000"; when "00100"=> a_to_g <="0011001"; when "00101"=> a_to_g <="0010010"; when "00110"=> a_to_g <="0000010"; when "00111"=> a_to_g <="1111000"; when "01000"=> a_to_g <="0000000"; when "01001"=> a_to_g <="0011000"; when "01010"=> a_to_g <="0001000"; when "01011"=> a_to_g <="0000011"; when "01100"=> a_to_g <="1000110"; when "01101"=> a_to_g <="0100001"; when "01110"=> a_to_g <="0000110"; when "01111"=> a_to_g <="0001110"; when "1----"=> a_to_g <="0000000"; when others => a_to_g <="1111111"; end case; end process; process(SEL) begin case SEL is when '0' => an <= "11111110"; when '1' => an <= "01111111"; when others => an <= "11111111"; end case; end process; end Behavioral; The problem I am having is the last part process(SEL) begin case SEL is when '0' => an <= "11111110"; when '1' => an <= "01111111"; when others => an <= "11111111"; end case; end process; I want to be able to use a switch to turn on one seven segment display then switch to another if I choose to. However that would entail shutting all the seven segment displays except for one. Then turning that one off and turning the other one on. This would also mean that instead of declaring the actual parts of the seven segment display, I would have to declare a whole display to be able to turn in on or off. I do not see a pin assignment for the whole display. I was able to do that for the switches which was declared as a vector and for the "a_to_g". I was able to use the pin assighments and declare what each one is. However I do not see where in the pin declaration, how to declare a whole segment display. The only information I am seeing is HEX0[0], HEX0[1], HEX0[2], .... So I originally thought I can declare a whole dislay as HEX0 but the system is telling me that is not a valid pin assignment. Can someone help me with this please. Also, I do not see a pin assignment for the decimal point or dp. Thank you.