lundi 22 décembre 2014

VHDL one if holds true in every case and the other doesn't

The ssd process that follows this is to show me what I have for the both users. The code atm seems to store the data for both users perfectly well and also recall it in any given time. However the problem is that I cannot seem to change the fact that whenever I press either of the buttons -to increase or decrease the number hold in either user by the decimal 1-. It changes the first user's number no matter what. It does not matter if the switch(7) is '1' or '0'. Additionally I can select the second user, although I cannot make any change on him as well -the buttons only affect the first user-. Here is my problem and I do not have any clue why this happens, but my only intuition is that I have a terrible design right here. Anyway below is the code for the interested and the helpful:


process (clk)


begin



if(switch(7) <= '1') then --first user

if(rising_edge(clk)) then
if(btn(0)='1' and lastButtonState(0) = '0') then--increase by 1
user0 <= user0 + "001";
end if;
lastButtonState(0) <= btn(0);
if(btn(1) = '1' and lastButtonState(1) = '0') then --decrease by 1
user0 <= user0 + "111";
end if;
lastButtonState(1) <= btn(1);
end if;



elsif (switch(6) = '1') then --second user
if(rising_edge(clk)) then
if(btn(0) = '1' and lastButtonState(0) = '0') then
user1 <= user1 + "001";
end if;
lastButtonState(0) <= btn(0);

if(btn(1) = '1' and lastButtonState(1) = '0') then

user1 <= user1 + "111";

end if;
lastButtonState(1) <= btn(1);
end if;


end if;


end process;


process (user0, user1, switch) begin



if(switch(7) = '1') then
case user0 is
when "000" => a_to_g <= "0000001";
when "001" => a_to_g <= "1001111";
when "010" => a_to_g <= "0010010";
when "011" => a_to_g <= "0000110";
when "100" => a_to_g <= "1001100";
when "101" => a_to_g <= "0100100";
when "110" => a_to_g <= "0100000";
when others => a_to_g <= "0001111";
end case;


elsif (switch(6) = '1') then
case user1 is
when "000" => a_to_g <= "0000001";
when "001" => a_to_g <= "1001111";
when "010" => a_to_g <= "0010010";
when "011" => a_to_g <= "0000110";
when "100" => a_to_g <= "1001100";
when "101" => a_to_g <= "0100100";
when "110" => a_to_g <= "0100000";
when others => a_to_g <= "0001111";
end case;

end if;
end process;

Aucun commentaire:

Enregistrer un commentaire