OpenCores
URL https://opencores.org/ocsvn/special_functions_unit/special_functions_unit/trunk

Subversion Repositories special_functions_unit

[/] [special_functions_unit/] [Open_source_SFU/] [log2_vhdl/] [parts/] [mux.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 divadnauj
-- Nombre de archivo    : mux.vhd
2
--      Titulo                          : multiplexor configurable
3
-----------------------------------------------------------------------------   
4
-- Descripcion                  : multiplexor con opcion de configuracion de las lineas
5
--                                                        seleccion y ancho de dato. Los datos a multiplexar 
6
--                                                        debe ingresar por i_data concatenados, ejemplo, si se 
7
--                                                        quiere multiplexar data1 y data2 deben ingresar por i_data
8
--                                                        como data2&data1, de esta manera se consigue: 
9
--                                                              0 -> i_select:  o_data -> data1 
10
--                                                              1 -> i_select:  o_data -> data2 
11
--                                                        
12
--
13
--      SELECT_BITS             : lineas de seleccion del multiplexor
14
--              DATA_BITS               : ancho de los datos a multiplexar
15
--
16
--      i_data                  : datos de entrada
17
--      i_select                        : Numero 2
18
--      o_data                  : Resultado
19
--
20
-----------------------------------------------------------------------------   
21
-- Universidad Pedagogica y Tecnologica de Colombia.
22
-- Facultad de ingenieria.
23
-- Escuela de ingenieria Electronica - extension Tunja.
24
-- 
25
-- Autor: Cristhian Fernando Moreno Manrique
26
-- Marzo 2020
27
-----------------------------------------------------------------------------   
28
library ieee;
29
        use ieee.std_logic_1164.all;
30
        use ieee.numeric_std.all;
31
 
32
 
33
entity mux is
34
 
35
        generic (SELECT_BITS    :               natural := 2;   -- dos lineas de seleccion (2^2 datos).
36
                                DATA_BITS       :               natural := 8); -- Cada dato de 8 bits
37
        port      (i_data               : in    std_logic_vector(2**SELECT_BITS*DATA_BITS-1 downto 0);
38
                                i_select                : in    std_logic_vector(SELECT_BITS-1 downto 0);
39
                                o_data          : out std_logic_vector(DATA_BITS-1 downto 0));
40
end entity;
41
-----------------------------------------------------------------------------   
42
 
43
architecture main of mux is
44
 
45
        type data_array is array(2**SELECT_BITS-1 downto 0) of std_logic_vector(DATA_BITS-1 downto 0);
46
        signal w_data : data_array;
47
 
48
begin
49
 
50
        A: for i in 0 to 2**SELECT_BITS-1 generate
51
                w_data(i) <= i_data((i+1)*DATA_BITS-1 downto i*DATA_BITS);
52
        end generate;
53
 
54
 
55
        o_data <= w_data(to_integer(unsigned(i_select)));
56
 
57
end main;
58
-----------------------------------------------------------------------------   

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.