Altera_Forum
Honored Contributor
13 years agoVHDL DE2 board understanding Processes and Signals
So I wrote a program to turn on LEDS if SW, a switch, is '1' and off if '0'.
entity StateLCD is
port(
SW : in std_logic_vector(0 downto 0);
LEDG : out std_logic_vector(7 downto 0);
LEDR : out std_logic_vector(7 downto 0));
end StateLCD;
architecture StateLCD_Behaviour of StateLCD is
SIGNAL LEDState: std_logic_vector(7 downto 0);
begin
process(SW)
begin
if(SW = "1") THEN
LEDState <= "11111111";
else
LEDState <= "00000000";
end if;
LEDG <= LEDState;
end process;
end StateLCD_Behaviour;
It works, but shouldn't it only work if I used variables instead of signals? With signals, It seems like the LEDS should be turning off when SW is '1' and turning on at '0' since signals only update at the end of a process. So I would be getting the opposite of the output I want? Where as variables would update immediately. Thanks for any help.