Forum Discussion
Altera_Forum
Honored Contributor
14 years agoDE1 Board Read KEY
I need to press and hold key 1 and than press key 2 to increase value. How to Read keys only if both keys are pressed. This is what is have which is not working correct. (programming languages vhdl).
if key(0) and key(1) are pessed do somthing PORT ( KEY : IN STD_LOGIC_VECTOR(3 DOWNTO 0); ); SIGNAL A, B, C, D : STD_LOGIC_VECTOR(1 DOWNTO 0); BEGIN A <= Not(KEY(0) & KEY(1)); B <= Not(KEY(0) & KEY(2)); C <= Not(KEY(0) & KEY(3)); Readkey: process(KEY) begin if (A = 1) then D <= "00"; -- 1 end if; if (B = 1) then D <= "01"; -- 2 end if; if (C = 1) then D <= "10"; -- 3 end if; end process;1 Reply
- Altera_Forum
Honored Contributor
A is a vector. It will have the value "00" when no key is pressed, and the value "11" when both are. So you can simply have:
Your process' sensitivity list should have all your inputs, in that case A,B and C. I'm almost sure that if you simulate this, the process would be triggered on a KEY change but would still see the previous values of A, B and C because of the delta delay. It wouldn't change anything for Quartus synthesis though. Ps: your component has no outputif (A = "11") then