EmbDev.net

Forum: FPGA, VHDL & Verilog N:1 MUX with 2:1 MUXs, VHDL


von Matlabo (matlabo)


Rate this post
useful
not useful
Hi !
 So I'm trying to write VHDL code to implement an N:1 MUX with 2:1 MUXs.
At the beginning I used a process but the compiler quickly pointed out 
to me that we can't use port map inside a process
  So I omitted the process and turn the variables into signals and I got 
this:
1
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_unsigned.all;        
4
use ieee.numeric_std.all;            
5
6
7
8
entity MUX8_1 is
9
  generic (
10
      N : integer := 8;  -- N vers 1
11
      C : integer := 3   -- Signaux de contrôle
12
    );
13
  port (
14
    E : IN std_logic_vector(N-1 downto 0);
15
    CTRL : IN std_logic_vector(C-1 downto 0);
16
    S : OUT std_logic
17
  );
18
end MUX8_1;
19
20
21
22
23
architecture MUX8_1_arc of MUX8_1 is
24
--generic map (
25
--       N => 8,
26
--       C => 3
27
--  )
28
29
component MUX2_1 is
30
  port (
31
    E :  IN std_logic_vector (1 downto 0);
32
    SLCT : IN std_logic; --avec 1 downto 0, la conversion
33
    S : OUT std_logic               -- ne peut se faire
34
  );
35
end component;
36
37
38
  signal L : integer := N;
39
  signal a : integer := 0;
40
  signal E1 : std_logic_vector(N-1 downto 0);
41
  signal T1 : std_logic_vector(N-1 downto 0) := E;
42
  signal T : std_logic;
43
begin
44
  Controle : for j in 0 to C-1 generate
45
    L <= L/2;
46
    a <= 0;
47
48
    E1 <= T1;
49
    T1 <= (others => '0');
50
51
    Entree : for i in 0 to 2*L-1 generate
52
      if (a mod 2 = 0) then
53
        MUX : entity work.MUX2_1 port map(E1(2*L-1-i downto 2*L-2-i), CTRL(j), T);
54
        T1 <= T1&T;
55
      end if;
56
      a <= a + 1;
57
    end generate;
58
59
  end generate;
60
61
62
end MUX8_1_arc;

And here are the errors and warnings that I got:

** Error: C:\Users\loune\OneDrive\Bureau \EE\S2\MSCL\Devoir Maison 
1\Ex1_N.vhd(53): illegal concurrent statement.
** Error: C:\Users\loune\OneDrive\Bureau \EE\S2\MSCL\Devoir Maison 
1\Ex1_N.vhd(54): (vcom-1450) Actual (slice name) for formal "E" is not a 
static signal name.


** Warning: C:\Users\loune\OneDrive\Bureau \EE\S2\MSCL\Devoir Maison 
1\Ex1_N.vhd(51): (vcom-1147) Range in parameter specification of FOR 
GENERATE must be static.

** Warning: C:\Users\loune\OneDrive\Bureau \EE\S2\MSCL\Devoir Maison 
1\Ex1_N.vhd(41): (vcom-1013) Initial value of "T1" depends on value of 
signal "E".

** Warning: C:\Users\loune\OneDrive\Bureau \EE\S2\MSCL\Devoir Maison 
1\Ex1_N.vhd(38): Nonresolved signal 'L' may have multiple sources.
Drivers:

C:\Users\loune\OneDrive\Bureau \EE\S2\MSCL\Devoir Maison 
1\Ex1_N.vhd(45):Conditional signal assignment line__45

** Warning: C:\Users\loune\OneDrive\Bureau \EE\S2\MSCL\Devoir Maison 
1\Ex1_N.vhd(39): Nonresolved signal 'a' may have multiple sources.
Drivers:

C:\Users\loune\OneDrive\Bureau \EE\S2\MSCL\Devoir Maison 
1\Ex1_N.vhd(57):Conditional signal assignment line__57

C:\Users\loune\OneDrive\Bureau \EE\S2\MSCL\Devoir Maison 
1\Ex1_N.vhd(46):Conditional signal assignment line__46


Any help is welcome.

: Edited by User
von Gustl B. (-gb-)


Attached files:

Rate this post
useful
not useful
This is a very nice task! You have to build a tree of MUX 2:1 
recursively. In VHDL this can be done using the if ... generate and for 
i in .... generate statements.

von Matlabo (matlabo)


Rate this post
useful
not useful
So Nicee !! Truly appreciate your help

I'm excited to implement this solution. Thanks again!

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.