Make your own free website on Tripod.com
Generic    Multiplexer

-- Variable input mux presently limited to maximum 16 inputs.
-- Developed on 25th April 1997 by Rajkumar...

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;

use work.muxpkg.all;

Entity vmux is
  generic(
           input_length : integer := 2 
         );

  port   ( muxin  :  in  std_logic_vector(input_length - 1  downto 0);
	   muxout :  out std_logic;
           sel    :  in  std_logic_vector(sel_ip(input_length) downto 0)
	 );
end vmux;

Architecture A_vmux of vmux is

begin
  muxout <= muxin(conv_integer(sel));
end A_vmux;


-------------------------------------------------------------------------------
-- The pkg file for this mux is here
-------------------------------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;

Package muxpkg is
 Function sel_ip (inputlength : integer) return integer;
end muxpkg;

Package body muxpkg is

 Function sel_ip (inputlength : integer) return integer is
   variable retlength : integer range 0 to 16;

 begin
   for i in 0 to 4 loop
     if ( (2 ** i) >= inputlength ) then
    	retlength := i - 1;
    	exit;
     end if;
   end loop;
   return retlength;
   end sel_ip;
end muxpkg;









Back To Main Page: