So here is my second attempt. It works better, but the correct values are displayed on the LEDs only when I keep the key pressed down. When I release, the value displayed is the one on the third column again on the same row. Does anyone know where I am still going wrong? Also, are there too many processes here? Could I have designed this a better way? Thanks very much for any help as I am just in the learning phase still with VHDL.
ARCHITECTURE behaviour of KeypadScanner IS
SIGNAL pulse_10us : STD_LOGIC;
SIGNAL count : INTEGER := 0;
SIGNAL Key_write : STD_LOGIC_VECTOR (3 DOWNTO 0) := "0111";
BEGIN
Keypad_write<= Key_write;
----------------------------
PROCESS (clock_50)
BEGIN
If (clock_50'EVENT AND clock_50 = '1' ) THEN
count<= count + 1;
If (count = 500) THEN
count<= 0;
END IF;
END IF;
END PROCESS;
--------------------------------
PROCESS (clock_50)
BEGIN
If (clock_50'EVENT AND clock_50 = '1' ) THEN
IF (count = 0) THEN
pulse_10us<= '1';
ELSIF (count = 1) THEN
pulse_10us<= '0';
END IF;
END IF;
END PROCESS;
-------------------------------------
PROCESS (clock_50)
BEGIN
If (clock_50'EVENT AND clock_50 = '1' ) THEN -- clock signal
IF pulse_10us = '1' THEN -- enable signal
If (Key_write = "0111") THEN
Key_write<= "1011";
ELSIF (Key_write = "1011") THEN
Key_write<= "1101";
ELSIF (Key_write = "1101") THEN
Key_write<= "0111";
END IF;
END IF;
END IF;
END PROCESS;
--------------------------------------------
PROCESS (clock_50)
BEGIN
If (clock_50'EVENT AND clock_50 = '1' ) THEN -- clock signal
IF pulse_10us = '1' THEN -- enable signal
CASE Key_write IS
WHEN "0111" =>
If (Keypad_read = "0111" ) THEN
LED<= "00000001";
ELSIf (Keypad_read = "1011") THEN
LED<= "00000100";
ELSIf (Keypad_read = "1101") THEN
LED<= "00000111";
END IF;
WHEN "1011" =>
If (Keypad_read = "0111" ) THEN
LED<= "00000010";
ELSIf (Keypad_read = "1011") THEN
LED<= "00000101";
ELSIf (Keypad_read = "1101") THEN
LED<= "00001000";
END IF;
WHEN "1101" =>
If (Keypad_read = "0111" ) THEN
LED<= "00000011";
ELSIf (Keypad_read = "1011") THEN
LED<= "00000110";
ELSIf (Keypad_read = "1101") THEN
LED<= "00001001";
END IF;
WHEN OTHERS =>
LED<= "11111111";
END CASE;
END IF;
END IF;
END PROCESS;
------------------------------------------
END behaviour;