I create a multiplexer called mux21_generic.vhdl. It is a Nx1 mux. I define two architectures, one behavioral, the other structural.
The structural architecture uses a small 2x1 mux in the following way:
architecture structural of MUX21_GENERIC is
component MUX21 is
Port ( A: In std_logic;
B: In std_logic;
S: In std_logic;
Y: Out std_logic);
end component MUX21;
begin -- structural
create_mux:
for i in 0 to N-1 generate
begin
MUX21_i : MUX21 port map(A=>A(i), B=>B(i), S=>SEL, Y=>Y(i));
end generate create_mux;
end structural;
These are the configurations:
-- CONFIGURATIONS --
-- (1) CFG_MUX21_GEN_BEHAVIORAL
configuration CFG_MUX21_GEN_BEHAVIORAL of MUX21_GENERIC is
for behavioral
end for;
end CFG_MUX21_GEN_BEHAVIORAL;
-- (2) CFG_MUX21_GEN_STRUCTURAL
configuration CFG_MUX21_GEN_STRUCTURAL of MUX21_GENERIC is
for structural
for create_mux
for all : MUX21
use configuration WORK.CFG_MUX21_STRUCTURAL;
end for;
end for;
end for;
end CFG_MUX21_GEN_STRUCTURAL;
The compilation works well, so I don't think the problem is in the above configurations.
I guess the problem is in the testbench.
The following code represents how I instantiate, in the "TEST" architecture of the testbench, both the behavioral and the structural mux:
U1 : MUX21_GENERIC
Generic Map (NBIT, 7 ns)
Port Map ( A1, B1, S1, output_beh); -- it should be behavioral
U2 : MUX21_GENERIC
Generic Map (NBIT)
Port Map ( A1, B1, S1, output_str); -- it should be structural
and this is the configuration that I wrote in the testbench:
configuration MUX21GENTEST of TB_MUX21_GENERIC is
for TEST
for U1: MUX21_GENERIC
use configuration WORK.CFG_MUX21_GEN_BEHAVIORAL;
end for;
for U2: MUX21_GENERIC
use configuration WORK.CFG_MUX21_GEN_STRUCTURAL;
end for;
end for;
end MUX21GENTEST;
Now the problem is that when I start the simulation with modelsim, It instantiates both the component with the structural architecture. Modelsim image
I notice that if I exchange the position between the two architectures in the mux21_generic.vhdl file, modelsim uses the behavioral instead of the structural arch. Should it be a configuration problem?