P
Patrick
Guest
hello,
i have a vhdl algorithm for compute the min and max of a signal, but
it is not synthesizable.
i have two loops with a IF..THEN statement inside
is it possible to have a if inside a loop ?
thanks
-- Tri de la RAM matched du plus petit au plus grand signal
TRI_RAM : process (clk_smp,reset,etat,match_int,ram_match_pos,ram_match_neg)
variable ram_match_pos_int_I, ram_match_pos_int_J, tampon_int :
integer;
variable ram_match_neg_int_I, ram_match_neg_int_J : integer;
begin
if reset='1' then
INIT_MATCH_RAM : for I in 0 to N_match-1 loop
ram_match_pos(I) <= (others=>'0');
ram_match_neg(I) <= (others=>'0');
end loop INIT_MATCH_RAM;
seuil_pos <= 0;
seuil_neg <= 0;
else
case etat is
when etat_0 =>
if match_int > 0 then
etat_suivant <= etat_1;
else
etat_suivant <= etat_2;
end if;
when etat_1 =>
ram_match_pos(0) <= conv_std_logic_vector(match_int,22);
TRI_MATCH_RAM_POS : for I in 0 to N_match-1 loop
TRI_J_POS : for J in 0 to N_match-1 loop
ram_match_pos_int_I := conv_integer(ram_match_pos(I));
ram_match_pos_int_J := conv_integer(ram_match_pos(J));
tampon_int := ram_match_pos_int_J;
ram_match_pos_int_J := ram_match_pos_int_I;
ram_match_pos_int_I := tampon_int;
if ram_match_pos_int_I > ram_match_pos_int_J then
ram_match_pos(I) <=
conv_std_logic_vector(ram_match_pos_int_I,22);
ram_match_pos(J) <=
conv_std_logic_vector(ram_match_pos_int_J,22);
etat_suivant <= etat_1;
else
ram_match_pos(J) <= ram_match_pos(J);
ram_match_pos(I) <= ram_match_pos(I);
etat_suivant <= etat_1;
end if;
end loop TRI_J_POS;
end loop TRI_MATCH_RAM_POS;
seuil_pos <= (conv_integer(ram_match_pos(N_match-1))-conv_integer(ram_match_pos(0)))/2;
seuil_neg <= seuil_neg;
etat_suivant <= etat_0;
when etat_2 =>
ram_match_neg(0) <= conv_std_logic_vector(match_int,22);
TRI_MATCH_RAM_MAX_NEG : for I in 0 to N_match-1 loop
TRI_J_MAX_NEG : for J in 0 to N_match-1 loop
ram_match_neg_int_I := conv_integer(ram_match_neg(I));
ram_match_neg_int_J := conv_integer(ram_match_neg(J));
tampon_int := ram_match_neg_int_J;
ram_match_neg_int_J := ram_match_neg_int_I;
ram_match_neg_int_I := tampon_int;
if ram_match_neg_int_I > ram_match_neg_int_J then
ram_match_neg(I) <=
conv_std_logic_vector(ram_match_neg_int_I,22);
ram_match_neg(J) <=
conv_std_logic_vector(ram_match_neg_int_J,22);
etat_suivant <= etat_2;
else
ram_match_neg(J) <= ram_match_neg(J);
ram_match_neg(I) <= ram_match_neg(I);
etat_suivant <= etat_2;
end if;
end loop TRI_J_MAX_NEG;
end loop TRI_MATCH_RAM_MAX_NEG;
seuil_neg <= (conv_integer(ram_match_neg(N_match-1))-conv_integer(ram_match_neg(0)))/2;
seuil_pos <= seuil_pos;
etat_suivant <= etat_0;
when others =>
etat_suivant <= etat_0;
end case;
end if;
end process TRI_RAM;
Controle_etat: process(reset,clk_smp)
begin
if reset='1' then
etat <= etat_0;
elsif clk_smp'event and clk_smp='1' then
etat <= etat_suivant;
end if;
end process Controle_etat;
i have a vhdl algorithm for compute the min and max of a signal, but
it is not synthesizable.
i have two loops with a IF..THEN statement inside
is it possible to have a if inside a loop ?
thanks
-- Tri de la RAM matched du plus petit au plus grand signal
TRI_RAM : process (clk_smp,reset,etat,match_int,ram_match_pos,ram_match_neg)
variable ram_match_pos_int_I, ram_match_pos_int_J, tampon_int :
integer;
variable ram_match_neg_int_I, ram_match_neg_int_J : integer;
begin
if reset='1' then
INIT_MATCH_RAM : for I in 0 to N_match-1 loop
ram_match_pos(I) <= (others=>'0');
ram_match_neg(I) <= (others=>'0');
end loop INIT_MATCH_RAM;
seuil_pos <= 0;
seuil_neg <= 0;
else
case etat is
when etat_0 =>
if match_int > 0 then
etat_suivant <= etat_1;
else
etat_suivant <= etat_2;
end if;
when etat_1 =>
ram_match_pos(0) <= conv_std_logic_vector(match_int,22);
TRI_MATCH_RAM_POS : for I in 0 to N_match-1 loop
TRI_J_POS : for J in 0 to N_match-1 loop
ram_match_pos_int_I := conv_integer(ram_match_pos(I));
ram_match_pos_int_J := conv_integer(ram_match_pos(J));
tampon_int := ram_match_pos_int_J;
ram_match_pos_int_J := ram_match_pos_int_I;
ram_match_pos_int_I := tampon_int;
if ram_match_pos_int_I > ram_match_pos_int_J then
ram_match_pos(I) <=
conv_std_logic_vector(ram_match_pos_int_I,22);
ram_match_pos(J) <=
conv_std_logic_vector(ram_match_pos_int_J,22);
etat_suivant <= etat_1;
else
ram_match_pos(J) <= ram_match_pos(J);
ram_match_pos(I) <= ram_match_pos(I);
etat_suivant <= etat_1;
end if;
end loop TRI_J_POS;
end loop TRI_MATCH_RAM_POS;
seuil_pos <= (conv_integer(ram_match_pos(N_match-1))-conv_integer(ram_match_pos(0)))/2;
seuil_neg <= seuil_neg;
etat_suivant <= etat_0;
when etat_2 =>
ram_match_neg(0) <= conv_std_logic_vector(match_int,22);
TRI_MATCH_RAM_MAX_NEG : for I in 0 to N_match-1 loop
TRI_J_MAX_NEG : for J in 0 to N_match-1 loop
ram_match_neg_int_I := conv_integer(ram_match_neg(I));
ram_match_neg_int_J := conv_integer(ram_match_neg(J));
tampon_int := ram_match_neg_int_J;
ram_match_neg_int_J := ram_match_neg_int_I;
ram_match_neg_int_I := tampon_int;
if ram_match_neg_int_I > ram_match_neg_int_J then
ram_match_neg(I) <=
conv_std_logic_vector(ram_match_neg_int_I,22);
ram_match_neg(J) <=
conv_std_logic_vector(ram_match_neg_int_J,22);
etat_suivant <= etat_2;
else
ram_match_neg(J) <= ram_match_neg(J);
ram_match_neg(I) <= ram_match_neg(I);
etat_suivant <= etat_2;
end if;
end loop TRI_J_MAX_NEG;
end loop TRI_MATCH_RAM_MAX_NEG;
seuil_neg <= (conv_integer(ram_match_neg(N_match-1))-conv_integer(ram_match_neg(0)))/2;
seuil_pos <= seuil_pos;
etat_suivant <= etat_0;
when others =>
etat_suivant <= etat_0;
end case;
end if;
end process TRI_RAM;
Controle_etat: process(reset,clk_smp)
begin
if reset='1' then
etat <= etat_0;
elsif clk_smp'event and clk_smp='1' then
etat <= etat_suivant;
end if;
end process Controle_etat;