Altera_Forum
Honored Contributor
16 years agoProblem with "WHILE...loop"
Hello,
I am trying to write an FSM module using VHDL.I have to make a "while...loop" that doesn't concern all the states but only a pre-determined number of them.Here is the FSM diagram schematic: file:///C:/Users/CHAKCH%7E1/AppData/Local/Temp/moz-screenshot.jpg https://www.alteraforum.com/forum/attachment.php?attachmentid=1281 After the syntax check,I got the following error message:"error (10552): vhdl expression error at fsm.vhd(122): illegal state in expression". Here is the part of the code related to this issue:
process (etat_suivant,Idle , Start_recep,Reception , Depart_trans , Tran_addr , Ack_1 , Trans_data_1 , Ack_2 ,
Trans_data_2, Ack_3, Stop_cond_1 , Stop_cond_2 , Stop_cond_3) --data transmission process
begin
case state is
when idle =>
SCLK<= '1';
SDIN<= '1';
if SDIN = '0' then etat_suivant<= Start_recep;
end if;
when Start_recep =>
SCLK<= '1';
SDIN<= '0';
if SDIN = '1' then etat_suivant<= Reception;
end if;
when Reception =>
while (m <= 47) loop
while (s <= 7) loop
SDIN<= ADCDAT(s);
s:= s+1;
end loop ;
m:= m+1;
end loop ;
if (m = 48) then etat_suivant<= Depart_trans;
end if;
end case;
while (n <= 15) loop
case state is
when Depart_trans =>
SCLK<= '0';
SDIN<= '0';
if (SDIN = '1') then etat_suivant<= Tran_addr;
end if;
when Tran_addr =>
while (i < 7 ) loop
SDIN<= ADDR(i);
i:= i+1;
end loop ;
DATA_0<= ADDR&'0';
if (i = 7) then etat_suivant<= Ack_1 ;
end if;
when Ack_1 =>
SDIN<= '0';
ACK<='1';
etat_suivant<= Trans_data_1 ;
when Trans_data_1 =>
ACK<='0';
while (j < 8 ) loop
SDIN<= DATA_1(j);
j:= j+1;
end loop ;
if (j = 8) then etat_suivant<= Ack_2;
end if;
when Ack_2 =>
SDIN<= '0';
ACK<='1';
etat_suivant<= Trans_data_2 ;
when Trans_data_2 =>
ACK<='0';
while (k < 8 ) loop
SDIN<= DATA_2(k);
k:= k+1;
end loop ;
if (k = 8) then etat_suivant<= Ack_3;
end if;
when Ack_3 =>
SDIN<= '0';
ACK<='1';
etat_suivant<= Stop_cond_1 ;
when Stop_cond_1 =>
ACK <= '0';
SDIN<= '0';
SCLK<='0';
etat_suivant<= Stop_cond_2 ;
when Stop_cond_2 =>
SDIN<= '0';
SCLK<='1';
etat_suivant<= Stop_cond_3 ;
when Stop_cond_3 =>
SDIN<= '1';
SCLK<='1';
etat_suivant<= Depart_trans ;
when others=>
etat_suivant<=Idle;
if ( n > 15) then
fin<='1';
etat_suivant<= Idle ;
end if;
end case;
end loop;