ptjw
Junior Member level 3

hello all,
i am currently practicing writing codes in VHDL for a spartan 3E FPGA. there are 4 LEDs that can be interfaced as ports and i have initialized them as so:
i have assigned each led its own variable but is it possible to assign them to an array instead?
eg: led[1] = '1'; <-- turns on led no.1
led[2] = '1'; <-- turns on led no.2 etc etc..
currently the only way i can do it is if i assign them to STD_LOGIC_VECTOR:
leds : out STD_LOGIC VECTOR (1 to 4) := "0000";
but i find it problematic to have to manipulate bits by shifting, AND, OR etc. i know it is possible to declare variable arrays, but i haven't been able to figure it out for declaring arrays in ports and have not found any help anywhere :-?
i am currently practicing writing codes in VHDL for a spartan 3E FPGA. there are 4 LEDs that can be interfaced as ports and i have initialized them as so:
Code:
entity test is
port (
clock : in STD_LOGIC;
push_A : in STD_LOGIC;
push_B : in STD_LOGIC;
push_C : in STD_LOGIC;
push_D : in STD_LOGIC;
led_1 : out STD_LOGIC:= '0';
led_2 : out STD_LOGIC:= '0';
led_3 : out STD_LOGIC:= '0';
led_4 : out STD_LOGIC:= '0');
end test;
i have assigned each led its own variable but is it possible to assign them to an array instead?
eg: led[1] = '1'; <-- turns on led no.1
led[2] = '1'; <-- turns on led no.2 etc etc..
currently the only way i can do it is if i assign them to STD_LOGIC_VECTOR:
leds : out STD_LOGIC VECTOR (1 to 4) := "0000";
but i find it problematic to have to manipulate bits by shifting, AND, OR etc. i know it is possible to declare variable arrays, but i haven't been able to figure it out for declaring arrays in ports and have not found any help anywhere :-?