2017-05-12 14 views
0

FPGA에서 구현되는 VHDL로 엘리베이터를 만들려고합니다. 0-12 층으로되어 있으며, 가고 싶은 방향과 안에있는 버튼에 따라 외부/외부 용 버튼이 있습니다. 나는 바깥 쪽 단추가 작동하는지 먼저 확인하고 내부 구현은 동일합니다. 지금은 컴파일되지만 시뮬레이션 파형은 충돌합니다.VHDL의 엘리베이터 프로젝트가 컴파일되지만 시뮬레이션에서 작동하지 않습니다.

Library ieee; 
    use ieee.std_logic_1164.all; 
    use ieee.std_logic_unsigned.all; 
    use ieee.numeric_std.all; 

entity lift is 
    port (
    CLK: in bit;     --clock initialized by the waveform, for now 
    iUP: in std_logic_vector (3 downto 0);      --input from FPGA 
    iDOWN: in std_logic_vector (3 downto 0);     --output 
    iBUTTON: in std_logic_vector (3 downto 0);     --input from inside the elevator 
    W: in BIT;             --weight s 
    DOOR: in BIT;            --door opened or not 
    ETAJ: out std_logic_vector (12 downto 0):="0000000000001"); --output to LCD 
end lift; 

architecture mama of lift is 
signal directie: bit := '1';          --direction of lift, 1 up/0 down 
signal pozitie: natural := 0;         --position of lift, 0-12 
signal sus: bit;             --up 
signal jos: bit;             --down 
signal UP: std_logic_vector(12 downto 0) :="0000000000000";   --vector for the outside inputs that ask to go up 
signal DOWN: std_logic_vector(12 downto 0) :="0000000000000";  --same as above, but down 
begin  
    merge: process (UP, DOWN, pozitie)      --process to determine if the lift goes up or down 
    variable i : std_ulogic;        --the vector with the outside inputs has 1 if the button is pressed, 0 otherwise 
    variable j : std_ulogic; 
    begin 
    for i in pozitie+1 to 12 loop 
     if UP(i) = '1' then 
      sus <= '1'; 
     end if; 
    end loop; 
    for j in pozitie-1 to 0 loop 
     if DOWN(j) = '1' then 
      jos <= '1'; 
     end if; 
    end loop; 
    end process merge; 

    conv: process(iUP, iDOWN)            --converts input from binary to int 
    begin 
     UP(to_integer(unsigned(iUP)))<='1'; 
     DOWN(to_integer(unsigned(iDOWN)))<='1'; 
    end process conv; 

    moovit: process (UP, DOWN, iBUTTON)        --the moving process 
    variable i : std_ulogic; 
    begin 
     if directie='1' then             --if direction is up and it has to go up 
      while sus='1' loop 
       if CLK'EVENT and CLK='1' and UP(pozitie)='1' then 
        UP(pozitie)<='0'; 
        DOWN(pozitie)<='0'; 
       end if; 
       pozitie <= pozitie + 1; 
      end loop; 
     else 
      while jos='1' loop 
       if CLK'EVENT and CLK='1' and DOWN(pozitie)='1' then 
        DOWN(pozitie)<='0'; 
        UP(pozitie)<='0'; 
       end if; 
       pozitie <= pozitie - 1; 
      end loop; 
     end if; 
    end process; 
end mama; 
+1

StackOverflow에 오신 것을 환영합니다. 정확히 디자인이해야 할 일과 그렇지 않은 것은 무엇입니까? 테스트 벤치는 어떻게 생겼습니까? [mcve] – Staszek

+0

을 제공하십시오.이 엘리베이터 프로젝트를 만들어야합니다. 나는 코드 위에 무엇이 있어야하는지 /해야 하는지를 설명했다. ACTIVE-HDL의 파형에 대한 시뮬레이션을 사용합니다. 나는 엘리베이터 외부에서 나오는 출력을 구현하려고 노력하고있다. 그들은 0에서 3 벡터에 와서 정수로 전환됩니다. 아키텍처 내부에는 UP 또는 DOWN을하려는 모든 층의 입력에 대한 두 개의 벡터가 있습니다. 첫 번째 프로세스는 진행 방향을 확인하고 두 번째는 입력을 변환하고 입력이있는 바닥에는 '1'을 넣고 세 번째 프로세스는 이동 프로세스입니다. 이론적으로는 모두 괜찮지 만 파형에서는 그렇지 않습니다 –

+0

질문을 편집하여 설명을 제공하십시오. – Staszek

답변

1

코드에는 합성과 호환되지 않는 것들이 많이 있습니다. 또는 적어도 작동 여부를 확신 할 수 없습니다. 예를

merge: process (UP, DOWN, pozitie) 
[...] 
for i in pozitie+1 to 12 loop 
    if UP(i) = '1' then 

를 들어 당신은 가변 길이와 루프를 사용하고 있습니다. 이것은 프로세서에서 쉽지만 HDL (Hardware Description Language)을 작성하고 있습니다. 가변 논리 게이트를 사용하면 어떻게 될까요?

이 경우에는 작성자를 사용해야합니다. 예 :

if unsigned(iDOWN) < pozitie then 
    jos <= '1'; 

다음으로 시계 프로세스를 살펴보십시오. CLK'EVENT and CLK='1'으로 시계를 소개하는 법을 아는 것 같습니다. 하지만 문을if 문 내에 넣고 심지어 while 문을 넣습니다. 다시 : 어떻게 하드웨어에서 실현 될 것이라고 기대하십니까?

clk_process: process(clk) 
begin 
    if rising_edge(clk) then 
     [synchronous statement] 
    end if; 
end process; 

추신 :

정상적인 클럭 동기 과정은 다음과 같다 이미 numeric_std을 사용중인 경우 use ieee.std_logic_unsigned.all;을 입력하십시오.