Quantcast
Channel: Altera Forums
Viewing all articles
Browse latest Browse all 19390

Mux for INOUT ports

$
0
0
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.

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 found a proper solution.


Can anyone help, please?

Viewing all articles
Browse latest Browse all 19390

Trending Articles