Hey guys I'm trying to exchange 2 pairs of INOUT signals, but without much sucess so far.
I have two PS/2 controlers and I would like to exchange the PS2(1) to PS2(2) signals and at same time PS2(2) to PS2(1) signals.
Perhaps it's simpler to explain with the actual (sniped) code.
-- external ports
ps2_clk_io : inout std_logic := 'Z';
ps2_data_io : inout std_logic := 'Z';
ps2_mouse_clk_io : inout std_logic := 'Z';
ps2_mouse_data_io : inout std_logic := 'Z';
-- signals
signal ps2_mode_s : std_logic := '0';
signal PS2K_DAT_IN : std_logic;
signal PS2K_DAT_OUT : std_logic;
signal PS2K_CLK_IN : std_logic;
signal PS2K_CLK_OUT : std_logic;
signal PS2M_DAT_IN : std_logic;
signal PS2M_DAT_OUT : std_logic;
signal PS2M_CLK_IN : std_logic;
signal PS2M_CLK_OUT : std_logic;
signal ps2_data_out : std_logic;
signal ps2_clk_out : std_logic;
signal ps2_mouse_data_out : std_logic;
signal ps2_mouse_clk_out : std_logic;
-- LOGIC BLOCK
-- PS/2 keyboard
PS2K_DAT_IN <= ps2_data_io when ps2_mode_s = '0' else ps2_mouse_data_io;
PS2K_CLK_IN <= ps2_clk_io when ps2_mode_s = '0' else ps2_mouse_clk_io;
ps2_data_out <= PS2K_DAT_OUT when ps2_mode_s = '0' else PS2M_DAT_OUT;
ps2_clk_out <= PS2K_CLK_OUT when ps2_mode_s = '0' else PS2M_CLK_OUT;
ps2_data_io <= '0' when ps2_data_out = '0' else 'Z';
ps2_clk_io <= '0' when ps2_clk_out = '0' else 'Z';
-- PS/2 Mouse
PS2M_DAT_IN <= ps2_mouse_data_io when ps2_mode_s = '0' else ps2_data_io;
PS2M_CLK_IN <= ps2_mouse_clk_io when ps2_mode_s = '0' else ps2_clk_io;
ps2_mouse_data_out <= PS2M_DAT_OUT when ps2_mode_s = '0' else PS2K_DAT_OUT;
ps2_mouse_clk_out <= PS2M_CLK_OUT when ps2_mode_s = '0' else PS2K_CLK_OUT;
ps2_mouse_data_io <= '0' when ps2_mouse_data_out = '0' else 'Z';
ps2_mouse_clk_io <= '0' when ps2_mouse_clk_out = '0' else 'Z';
As you can see, I would like to exchage the signals between a mouse and a keyboard, using the control signal "ps2_mode_s". If this signal is '0', I need the keyboard on the first port and the mouse on the second. If it's '1', the oposite, mouse on first port and keyboard on second.
I already tried some variations, but I didn't find a proper solution.
(EDIT) Both ports appear to not send or receive any data if I use the mux.
(EDIT) All four signals are connected to the respective modules. PS2K_DAT_IN, PS2K_CLK_IN , PS2K_DAT_OUT, PS2K_CLK_OUT goes to a ps2 keyboard controller and the other four PS2M_DAT_IN, PS2M_CLK_IN , PS2M_DAT_OUT, PS2M_CLK_OUT goes to the ps2 mouse controller module. Both modules are working if I dont use the mux, connecting the signals directly to the INOUT ports.
PS2K_DAT_IN <= ps2_data_io;
ps2_data_io <= '0' when (PS2K_DAT_OUT = '0') else 'Z';
PS2K_CLK_IN <= ps2_clk_io;
ps2_clk_io <= '0' when (PS2K_CLK_OUT = '0') else 'Z';
PS2M_DAT_IN <= ps2_mouse_data_io;
ps2_mouse_data_io <= '0' when (PS2M_DAT_OUT = '0') else 'Z';
PS2M_CLK_IN <= ps2_mouse_clk_io;
ps2_mouse_clk_io <= '0' when (PS2M_CLK_OUT = '0') else 'Z';
Can anyone help, please?