Код VHDL не работает на плате, но работает при моделировании

Я работаю над проектом с использованием vhdl для настройки платы fpga spartan 3E. то, что мне нужно сделать, это гениальная головоломка, в моем основном коде есть конечный автомат для управления логикой.

все работает хорошо, когда я имитирую код с помощью симулятора xilinx, но когда я запускаю файл .bit на плату FPGA, происходит то, что первый светодиод последовательности включается, а затем выключается, это должно произойти, но затем, когда я нажимаю вправо кнопка просто перестает работать, и следующая последовательность никогда не отображается. Конечно, есть проблема с отключением кнопок, и по этой причине я использую счетчик, чтобы предотвратить ошибку системы.

Я усердно работаю над этим кодом, чтобы он работал, но эта проблема не исчезнет, ​​возможно, я делаю что-то не так, чего не знаю, или я не делаю то, что должен.

вот мой основной код, который представляет собой конечный автомат и тактовый процесс со счетчиком.

Flag_conte = starts ou blocks the counter
Flag_estou_contando = 1=counting, 0= not counting, 3= just finished count.
BCD = board buttons IN
LEDs = corresponds to 4 leds that will show the sequence in the game

entity Algoritmo is
    port(
         clk:   in std_logic;
         BCD: in std_logic_vector (3 downto 0);
          botaoStart: in std_logic;       
        botaoReset: in std_logic;         
          seven_seg: out std_logic_vector(6 downto 0);
          anode:   out std_logic_vector(3 downto 0);
          LEDS: out std_logic_vector(3 downto 0)
        );
END Algoritmo;

 architecture Behavioral of Algoritmo is

    subtype state_type is integer range 5 downto 0;
    signal state, nextstate: state_type:=0;
    signal Inicio, nclk: std_logic:= '0';
    --variable posicaoAtual: integer :=0;
    type mem1 is array (0 to 13) of std_logic_vector (3 downto 0);    
    constant vetorSequencia: mem1 := ( "0001", "0010", "0100", "1000", "0001", "0010", "0100", "1000", "0001", "0010", "0100", "1000", "0001", "0010");  

    constant generic1hz: integer:= 12_500_000;
    signal t3count:integer:=0;
    signal posA, posB, signalScore, Flag_conte,

Flag_estou_contando: integer: = 0;

    signal valor: integer :=12_500_000;
Begin
-------------
process (state,BCD,botaoStart,Flag_estou_contando)
variable Pos: integer :=0;
variable score: integer:=0;
variable posicaoAtual: integer:=0; 
variable tentativa: std_logic_vector (3 downto 0);
begin   
    case state is   
     when 0 => if (botaoStart = '0')  
     then nextstate <= 0;-- estado idle, esperando entrada do tclado,led1=1;
                     else nextstate <= 1;
                     end if;

      when 1 =>-- if(Flag_estou_contando =0)then
                        if(nextstate=2)then
                            Flag_conte <=0;
                            nextstate <= 2;
                        else if (nextstate/=2)then
                            if (posicaoAtual < score)then
                                    if(Flag_estou_contando=0)then
                            LEDS <= vetorSequencia(posicaoAtual);
                                        posA <= posicaoAtual;
                                        Flag_conte<=1;
                                        valor<=10_000_000;
                                    else if(Flag_estou_contando=1)then
                                        LEDS <=vetorSequencia(posicaoAtual);
                                    else if (Flag_estou_contando=3)then
                                        --posicaoAtual:=0;
                                        posicaoAtual := posicaoAtual + 1;
                                        posA <= posicaoAtual;
                                        nextstate <=1;
                                        Flag_conte<=0;
                                    end if;end if;end if;

                            else if(posicaoAtual = score)then   
                                    if(Flag_estou_contando=0)then
                                        Flag_conte<=1;
                                        valor<=10_000_000;
                                        --  posicaoAtual :=0;
                                        posA <= posicaoAtual;
                                    else if(Flag_estou_contando=1)then
                                        LEDS <=vetorSequencia(posicaoAtual);
                                        nextstate<=1;
                                    else if(Flag_estou_contando=3)then
                                        posicaoAtual:=0;
                                        posA <= posicaoAtual;
                                        Flag_conte<=0;
                                        nextstate <= 2;
                                    end if;end if;end if;
                            end if;end if;
                            Flag_conte <=1;
                        end if;end if;


      when 2 => --if(Flag_estou_contando=0)then 
                    if (BCD = "0000")then 
                        if(Flag_estou_contando=0)then
                        LEDS <= "0000";  --nextstate <= 2;
                        else if (Flag_estou_contando=1)then
                            nextstate<=2;
                                    else if (Flag_estou_contando=3)then
                                        Flag_conte <= 0;
                                        nextstate<=3;
                                    end if;end if;end if;
                            else if(BCD /= "0000")then 
                                    if(Flag_estou_contando=0)then
                                        Flag_conte<=1;
                                        valor<=200_000_000;
                                        tentativa := BCD;
                                        LEDS <= tentativa;
                                    else if(Flag_estou_contando=3)then 
                                        nextstate <= 3;
                                    else if(Flag_estou_contando=1)then
                                        LEDS <= tentativa;
                                        nextstate <=2;
                                    end if;end if;end if;
                            end if;end if;

                when 3 => if (vetorSequencia(Pos) = tentativa)then  
                                if (Pos < score)then
                                       nextstate <= 2; 
                                        Pos := Pos + 1;
                                        posB <= Pos;
                                else if(Pos = score)then
                                       score := score + 1;
                                        signalScore <= score;
                                        nextstate <= 1;
                                        Pos := 0;
                                if (score = 15)-- if score =15 finish game
                                            then nextstate <= 5;    
                                        end if;--end if
                                end if;end if;
                        else -- se estiver errado, perde o jogo
                            nextstate <= 4; -- goes to game over
                    end if;                 

      when 4 => if (botaoReset = '1')  -- game over  
                                then nextstate <= 4;-- "U LOST nOOB"
                elsif (botaoReset = '0') 
                            then nextstate <= 0; -- 
                end if;  
      when 5 => if (botaoReset = '1') -- jogo ganho   
                                then nextstate <= 5; -- "GG"
                        elsif (botaoReset = '0') 
                                then nextstate <= 0;
                  end if;    
         end case;


 end process;

    process (clk, Flag_conte)

    variable sum, count :integer:=0;
    begin 



if rising_edge(clk) then
        if(Flag_estou_contando = 0) then
            if (Flag_conte = 1) then 
                count :=0;
                Flag_estou_contando <=1;
            end if;
        end if;
    if(Flag_estou_contando=3) then      
        if(Flag_conte =0)then
            Flag_estou_contando <= 0;
        else
            Flag_estou_contando <=3;
        end if;
    end if;

    if (Flag_estou_contando =1)then
        if(count < valor)then
            count := count + 1;
        else
            count:=0;
            Flag_estou_contando <=3;        
        end if;
    end if;

    sum := sum +1;              
    if(sum = generic1hz)then -- 1hz generate
        state <= nextstate;
        nclk <= not nclk;
        sum := 0;--restart count for 1hz generate

    end if;
end if;

end process;
end Behavioral;

if i wasnt clear, please let me know i will try to explain better, if anyone could help i would be very greatful, thank you for your time.

person Andrey Viktor Kandauroff    schedule 27.11.2016    source источник


Ответы (1)


Вы должны попробовать имитацию места размещения и маршрута, чтобы проверить, что происходит: http://www.xilinx.com/support/documentation/sw_manuals/xilinx11/pp_p_process_simulate_post_place.htm

На некоторых устройствах семейства вы можете использовать технологию chipcope для отладки:

https://www.xilinx.com/support/documentation/sw_manuals/xilinx10/isehelp/ise_c_process_analyze_design_using_chipscope.htm

Извините за мой английский.

С Уважением.

person user1785960    schedule 28.11.2016