2014-10-19 93 views
0

我已經更新了程序,它完成了,但現在我正在嘗試模擬該項目。我能夠清楚時鐘並點亮引腳,但是我無法使燈亮起來,計數和狀態甚至沒有顯示。我相信我有這一切設置正確,但我可能是錯的。再次感謝Morten Zilmer提供錯誤代碼的幫助。交通VHDL模擬問題

http://tinypic.com/r/24yog0z/8

這是文件的模擬, simulation image

entity traffic is 
port (clk: in std_logic; 
     clr: in std_logic; 
     lights: out std_logic_vector (5 downto 0)); 
end traffic; 

architecture traffic of traffic is 
type state_type is (s0, s1, s2, s3, s4, s5); 
signal state: state_type; 
signal count : std_logic_vector (3 downto 0); 
constant sec5: std_logic_vector (3 downto 0) := "1111"; 
constant sec1: std_logic_vector (3 downto 0) := "0011"; 

begin 
process(clk, clr) 
begin 
if clr = '1' then 
     state<= s0; 
     count <= x"0"; 
elsif (clk'event and clk = '1') then 
    case state is 
    when s0 => 
     if count <= sec5 then 
      state <= s0; 
      count <= count +1; 
     else 
      state <= s1; 
      count <= x"0"; 
      end if; 
    when s1 => 
     if count <= sec1 then 
      state <= s1; 
      count <= count +1; 
     else 
      state <= s2; 
      count <= x"0"; 
      end if; 
    when s2 => 
     if count <= sec1 then 
      state <= s2; 
      count <= count +1; 
     else 
      state <= s3; 
      count <= x"0"; 
      end if; 
    when s3 => 
     if count <= sec5 then 
      state <= s3; 
      count <= count +1; 
     else 
      state <= s4; 
      count <= x"0"; 
      end if; 
    when s4 => 
     if count <= sec1 then 
      state <= s4; 
      count <= count +1; 
     else 
      state <= s5; 
      count <= x"0"; 
      end if; 
    when s5 => 
     if count <= sec1 then 
      state <= s5; 
      count <= count +1; 
     else 
      state <= s0; 
      count <= x"0"; 
      end if; 
    when others => 
      state <= s0; 
end case; 
end if; 
end process; 

c2 : process (state) 
begin 
case state is 
    when s0 => lights <= "100001"; 
    when s1 => lights <= "100010"; 
    when s2 => lights <= "100100"; 
    when s3 => lights <= "001100"; 
    when s4 => lights <= "010100"; 
    when s5 => lights <= "100100"; 
    when others => lights <= "100001"; 
    end case; 
end process; 
end traffic; 
+2

所以,讓我直截了當,你仍然有問題,你已經接受了莫滕的答案?你的問題編輯涵蓋了你的語法錯誤,elseif(clk'event和clk ='1')然後在你的第24行。編輯掉問題和問題文本不會留下任何有價值的東西給任何人找到讀你的問題和Morten的答案。現在還不清楚。 '新'問題沒有一個有效的答案。 - – user1155120 2014-10-19 20:15:51

+0

我沒有緩解,我應該發表第二篇文章。我的原始問題是,我無法弄清楚語法錯誤。我只是想要一些幫助,所以我用新的細節更新了我的問題,而不是創建一個新的帖子,從而混亂論壇。我很抱歉讓大衛感到不方便,我認爲這是我們應該如何做到的。下次遇到任何問題時,我會牢記這一點。 – Josh 2014-10-20 00:50:15

+0

不會給我帶來任何不便。將原始問題的價值和仍然可以接受的答案作爲知識庫的一部分代替別人再次詢問(或者如果 - elsif顯示很多,請檢查頁面頂部的搜索),將其破壞。如果你現在需要回答這個問題,現在把這個回到Morten回答它的方式,並提出一個新問題。 – user1155120 2014-10-20 01:09:04

回答

1

變化elseifelsif,爲有效的VHDL語法。

+0

非常感謝您,我甚至都不認爲這是問題所在。我的思想開始將java,C++和vhdl混合成一種奇怪的語言......再次感謝您。 – Josh 2014-10-19 17:12:53