I am trying to implement a multistage multiplexer that selects the even/odd lines of the input signal at each stage. Let's assume for instance I have 8 inputs [a(0) a(2) a(3) a(4) a(5) a(6) a(7)] and three input signals [s(0) s(1) s(2)]. The multiplexer should behave like this : if s(0) = 0, the first stage passes [a(0) a(2) a(4) a(6)] otherwise it passes the odd elements [a(1) a(3) a(5) a(7)]. To do this I am trying to slice the input signal into odd and even elements like this:
entity mux is
port(
s : in std_logic_vector(0 to 3);
vline : in std_logic_vector(0 to 8);
output : out std_logic
);
end mux;
architecture multistage of mux32 is
signal level0even : std_logic_vector(0 to 3);
signal level0odd : std_logic_vector(0 to 3);
signal temp0 : std_logic_vector(0 to 3);
signal level1even : std_logic_vector(0 to 1);
signal level1odd : std_logic_vector(0 to 1);
signal temp1 : std_logic_vector(0 to 1);
signal level2even : std_logic;
signal level2odd : std_logic;
signal temp2 : std_logic;
begin
-- Slicing level0
for k in 0 to 3 loop
level0even(k) <= vline(2*k);
level0odd(k) <= vline(2*k+1);
end loop;
with s(0) select
temp0 <= level0even when "0",
level0odd when "1",
"----" when others;
-- Slicing level1
for k in 0 to 1 loop
level1even(k) <= temp0(2*k);
level1odd(k) <= temp0(2*k+1);
end loop;
with s(1) select
temp1 <= level1even when "0",
level1odd when "1",
"----" when others;
[...]
end multistage;
But Multisim gives me the error " Illegal concurrent statement " at the level0 slicing when writing the previous code. The question is: is there a more elegant and compact way to slice the even/odd elements of a vector ?
Plus, I am trying to write the code in a parametric way to use it for a much larger input vector, but I don't know how to do it since I need to declare the temporary vectors (levelxodd/even) one by one. Does anyone have any suggestion on how to do this ?