zorro3k
Newbie level 4
I have a decoder for a keypad
How can i simulate pressed key in test bench ? :|
HTML:
ENTITY key IS
PORT (
clk : IN STD_LOGIC; -- Clock source and
resetn : IN STD_LOGIC; -- Reset on global inputs
row : IN STD_LOGIC_VECTOR (3 DOWNTO 0);
col : OUT STD_LOGIC_VECTOR (3 DOWNTO 0); -- Drive columns
END hexkbd;
ARCHITECTURE keys OF hexkbd IS
SIGNAL key_pressed : STD_LOGIC; -- High when a key pressed
SIGNAL d : STD_LOGIC_VECTOR (3 DOWNTO 0);
BEGIN
-- Scan the keyboard until a key is pressed
PROCESS (clk, key_pressed)
BEGIN
IF (resetn = '0') THEN d <= "0000"; -- asynchronous reset
ELSIF (clk'EVENT AND clk = '1') THEN
IF (key_pressed = '0') THEN d <= d + 1; END IF;
END IF; -- Counter stops counting when a key is pressed
END PROCESS;
-- Column drivers, active low
col(0) <= '0' WHEN d(3 DOWNTO 2) = "00" ELSE '1';
col(1) <= '0' WHEN d(3 DOWNTO 2) = "01" ELSE '1';
col(2) <= '0' WHEN d(3 DOWNTO 2) = "10" ELSE '1';
col(3) <= '0' WHEN d(3 DOWNTO 2) = "11" ELSE '1';
-- Sense keyboard rows with a multiplexer
WITH d(1 DOWNTO 0) SELECT
key_pressed <= NOT row(3) WHEN "11",
NOT row(2) WHEN "10",
NOT row(1) WHEN "01",
NOT row(0) WHEN OTHERS;