problem in ISE with mealy FSM

Discussion in 'VHDL' started by nicx82, Jan 20, 2009.

  1. nicx82

    nicx82

    Joined:
    Nov 5, 2008
    Messages:
    9
    Hi,
    i have a problem with an FSM mealy based.
    The problem are the warning from ISE indicated a latches state.
    In simulation this problems are continuos change of signal from a correct value to zero and again from correct value to zer and so on.
    I know that i can correct this problem by rewrite in each state all the output values even if this don't change. This solution work if the output are know to me, but how can i do the same with output signals that depends on the input??(this is a Mealy machine)
    nicx82, Jan 20, 2009
    #1
    1. Advertising

  2. nicx82

    jeppe

    Joined:
    Mar 10, 2008
    Messages:
    348
    Location:
    Denmark
    jeppe, Jan 20, 2009
    #2
    1. Advertising

  3. nicx82

    nicx82

    Joined:
    Nov 5, 2008
    Messages:
    9
    this is the code. tHIS CODE COMPARE 8 NUMBER, BUT THE CODE IS ONLY FOR THE FIRST 3 NUMBER. IN STATE A I COMPARE NUMER 1 AND 2 AND I PUT TO THE OUT THE MAX (MAX<=IN_A OR MAX<=IN_B). I ASSIGN TO THE MAX AN INDEX. IN THE STATE B I COMPARE THE MAX WITH NUMBER 3.IF THE MAX DON'T CHANGE, THE INDEX MUST REMAIN THE SAME, ELSE I UPDATE THE INDEX.

    when
    state_B =>
    if (IN_A(16 downto 6) > IN_B(16 downto 6)) then
    MAX<=IN_A;
    index<="0001";
    S_1<='1';
    S_2<="000";
    DONE<='0';
    elsif (IN_A(16 downto 6) < IN_B(16 downto 6)) then
    max<=IN_B;
    index<="0010";
    S_1<='1';
    S_2<="000";
    DONE<='0';
    else---integer part are equals
    if (IN_A(5 downto 0) > IN_B(5 downto 0)) then
    max<=IN_A;
    index<="0001";
    S_1<='1';
    S_2<="000";
    DONE<='0';
    elsif (IN_A(5 downto 0) < IN_B(5 downto 0)) then
    max<=IN_B;
    index<="0010";
    S_1<='1';
    S_2<="000";
    DONE<='0';
    else--also the fraction part are equals
    max<=IN_A;
    index<="0001";
    S_1<='1';
    S_2<="000";
    DONE<='0';
    end if;
    end if;
    nx_state<=state_C;

    --NOW I COMPARE NEW NUMBER WITH THE MAX OF THE ABOVE STATE
    when
    state_C =>
    if (IN_A(16 downto 6) > IN_B(16 downto 6)) then
    MAX<=IN_A;
    S_2<="001"; --HERE I CAN'T WRITE THE VALUE OF INDEX BECAUSE I DON'T KOW IF IT IS 0001 OR 0010.DEPENDS ON THE ABOVE STATE
    DONE<='0';
    elsif (IN_A(16 downto 6) < IN_B(16 downto 6)) then
    max<=IN_B;
    index<="0011";
    S_2<="001";
    DONE<='0';
    else---parte intera uguale
    if (IN_A(5 downto 0) > IN_B(5 downto 0)) then
    max<=IN_A;
    S_2<="001";
    DONE<='0';
    elsif (IN_A(5 downto 0) < IN_B(5 downto 0)) then
    max<=IN_B;
    index<="0011";
    S_2<="001";
    DONE<='0';
    else--anche la parte frazionaria รจ uguale
    max<=IN_A;
    S_2<="001";
    DONE<='0';
    end if;
    end if;
    nx_state<=state_C_P;
    nicx82, Jan 21, 2009
    #3
  4. nicx82

    jeppe

    Joined:
    Mar 10, 2008
    Messages:
    348
    Location:
    Denmark
    Well - my best advice would be:

    Implement two states instead of one - you could call them

    when state_C0001 =>
    ....
    when state_c0010 =>
    ....

    you must select the correct state in state_B - but then it should be easy.

    Jeppe
    jeppe, Jan 21, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charlie

    FSM Problem

    Charlie, Dec 28, 2003, in forum: VHDL
    Replies:
    5
    Views:
    759
    Charles M. Elias
    Dec 31, 2003
  2. M.A.Khader

    Mealy fsm in sychronous systems.

    M.A.Khader, Aug 30, 2004, in forum: VHDL
    Replies:
    1
    Views:
    666
    Mike Treseler
    Aug 30, 2004
  3. Eric

    FSM IOB problem

    Eric, Mar 17, 2005, in forum: VHDL
    Replies:
    3
    Views:
    642
  4. Ola
    Replies:
    1
    Views:
    2,418
    Mike Treseler
    Nov 21, 2005
  5. engrjet

    Latch problem in FSM

    engrjet, Mar 12, 2008, in forum: VHDL
    Replies:
    1
    Views:
    777
    jeppe
    Mar 13, 2008
Loading...

Share This Page