-- Target Devices: XC9572-PC44
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity EnterMice is
Port ( KB : in STD_LOGIC_VECTOR (9 downto 0);
J1_Fire1 : in STD_LOGIC;
J1_Fire2 : in STD_LOGIC;
J1_Fire3 : in STD_LOGIC;
J1_Up : in STD_LOGIC;
J1_Down : in STD_LOGIC;
J1_Left : in STD_LOGIC;
J1_Right : in STD_LOGIC;
J2_Fire1 : in STD_LOGIC;
J2_Fire2 : in STD_LOGIC;
J2_Fire3 : in STD_LOGIC;
J2_Up : in STD_LOGIC;
J2_Down : in STD_LOGIC;
J2_Left : in STD_LOGIC;
J2_Right : in STD_LOGIC;
M_Left : in STD_LOGIC;
M_Right : in STD_LOGIC;
M_Data : in STD_LOGIC_VECTOR (3 downto 0);
M_JoyMode : in STD_LOGIC; -- 0=std mouse, 1=joystick mode
KB_J : out STD_LOGIC;
KB_K : out STD_LOGIC;
KB_L : out STD_LOGIC);
end EnterMice;
architecture Behavioral of EnterMice is
signal KB0 : STD_LOGIC;
signal KB1 : STD_LOGIC;
signal KB2 : STD_LOGIC;
signal KB3 : STD_LOGIC;
signal KB4 : STD_LOGIC;
signal KB5 : STD_LOGIC;
signal KB6 : STD_LOGIC;
signal KB7 : STD_LOGIC;
signal KB8 : STD_LOGIC;
signal KB9 : STD_LOGIC;
begin
with KB select
KB0 <= '0' when "1111111110",
'1' when others;
with KB select
KB1 <= '0' when "1111111101",
'1' when others;
with KB select
KB2 <= '0' when "1111111011",
'1' when others;
with KB select
KB3 <= '0' when "1111110111",
'1' when others;
with KB select
KB4 <= '0' when "1111101111",
'1' when others;
with KB select
KB5 <= '0' when "1111011111",
'1' when others;
with KB select
KB6 <= '0' when "1110111111",
'1' when others;
with KB select
KB7 <= '0' when "1101111111",
'1' when others;
with KB select
KB8 <= '0' when "1011111111",
'1' when others;
with KB select
KB9 <= '0' when "0111111111",
'1' when others;
-- inverted logic - 0's active
KB_J <= (KB5 or J2_Fire1) and -- Joystick 2
(KB6 or J2_Up) and
(KB7 or J2_Down) and
(KB8 or J2_Left) and
(KB9 or J2_Right) and
(M_JoyMode or KB0 or J1_Fire1) and -- Joystick 1
(M_JoyMode or KB1 or J1_Up) and
(M_JoyMode or KB2 or J1_Down) and
(M_JoyMode or KB3 or J1_Left) and
(M_JoyMode or KB4 or J1_Right) and
(not M_JoyMode or KB0 or M_Left) and -- Mouse in joystick mode
(not M_JoyMode or KB1 or M_Data(0)) and
(not M_JoyMode or KB2 or M_Data(1)) and
(not M_JoyMode or KB3 or M_Data(2)) and
(not M_JoyMode or KB4 or M_Data(3));
KB_K <= (M_JoyMode or KB0 or J1_Fire2 or not M_Left) and -- Mouse button priority
(M_JoyMode or KB0 or M_Left) and -- Mouse in standard mode
(M_JoyMode or KB1 or M_Data(0)) and
(M_JoyMode or KB2 or M_Data(1)) and
(M_JoyMode or KB3 or M_Data(2)) and
(M_JoyMode or KB4 or M_Data(3)) and
(M_JoyMode or KB5 or J2_Fire2); -- Joystick 2
KB_L <= (M_JoyMode or KB0 or J1_Fire3 or not M_Right) and -- Mouse button priority
(M_JoyMode or KB0 or M_Right) and
(M_JoyMode or KB5 or J2_Fire3); -- Joystick 2
end Behavioral;
#PINLOCK_BEGIN
NET "J1_Down" LOC = "S:PIN9";
NET "J1_Fire1" LOC = "S:PIN7";
NET "J1_Fire2" LOC = "S:PIN13";
NET "J1_Fire3" LOC = "S:PIN11";
NET "J1_Left" LOC = "S:PIN12";
NET "J1_Right" LOC = "S:PIN14";
NET "J1_Up" LOC = "S:PIN8";
NET "J2_Down" LOC = "S:PIN44";
NET "J2_Fire1" LOC = "S:PIN1";
NET "J2_Fire2" LOC = "S:PIN4";
NET "J2_Fire3" LOC = "S:PIN5";
NET "J2_Left" LOC = "S:PIN2";
NET "J2_Right" LOC = "S:PIN3";
NET "J2_Up" LOC = "S:PIN42";
NET "KB<0>" LOC = "S:PIN34";
NET "KB<1>" LOC = "S:PIN27";
NET "KB<2>" LOC = "S:PIN29";
NET "KB<3>" LOC = "S:PIN26";
NET "KB<4>" LOC = "S:PIN28";
NET "KB<5>" LOC = "S:PIN40";
NET "KB<6>" LOC = "S:PIN43";
NET "KB<7>" LOC = "S:PIN39";
NET "KB<8>" LOC = "S:PIN38";
NET "KB<9>" LOC = "S:PIN37";
NET "M_Data<0>" LOC = "S:PIN22";
NET "M_Data<1>" LOC = "S:PIN20";
NET "M_Data<2>" LOC = "S:PIN19";
NET "M_Data<3>" LOC = "S:PIN18";
NET "M_JoyMode" LOC = "S:PIN6";
NET "M_Left" LOC = "S:PIN25";
NET "M_Right" LOC = "S:PIN24";
NET "KB_J" LOC = "S:PIN33";
NET "KB_K" LOC = "S:PIN36";
NET "KB_L" LOC = "S:PIN35";
#PINLOCK_END