2013-04-24 57 views
0

我有以下代碼:我不明白這個VHDL代碼有什麼問題嗎?

entity wave_select is 
port(address:in std_logic_vector(6 downto 0); 
ws1: in std_logic; 
ws0: in std_logic; 
wave_out: out std_logic_vector(6 downto 0)); 
end wave_select; 


architecture choose_arch of wave_select is 
signal internal_sine:std_logic_vector(6 downto 0); 
signal internal_tri:std_logic_vector(6 downto 0); 
signal internal_sqr:std_logic_vector(6 downto 0); 

begin 
U0: entity sine_tbl port map(addr=>address, sine_val=>internal_sine); 
U1: entity triangle_tbl port map(addr=>address, tri_val=>internal_tri); 
U2: entity square_tbl port map(addr=>address, square_val=>internal_sqr); 

    process (std_logic_vector'(ws1, ws0)) 
    begin 
     case ws_combo is 
      when "01" => wave_out<=internal_sine; 
      when "10" => wave_out<=internal_tri; 
      when "11" => wave_out<=internal_sqr; 
      when others =>wave_out<=(others => '-'); 
     end case; 
    end process; 


end choose_arch;` 

每當我嘗試編譯,我得到以下錯誤:

  1. 標識符/關鍵字預期(用於加工線)
  2. 關鍵字預計年底(用於「10」行時)
  3. 預期設計單位聲明(與關鍵字錯誤相同的行)

修復了這個問題

+0

下次考慮使用更具描述性的標題。 – simon 2013-04-25 06:21:58

回答

0

就目前來看,這有很多問題,主要是相當基本的語法。

儘管看起來您可能認爲ws0和ws1的組合被視爲ws_combo,但您還沒有做任何事情來告訴合成器,因此它將ws_combo視爲未定義。

至少據我所知,您不能像過去那樣在過程敏感性列表中組合信號。靈敏度列表是告訴這個過程響應的外部信號,而不是其他的。

您沒有定義wave_out(除非它也在您的實體聲明中)。

您沒有internal_sineinternal_triinternal_sqr的定義。在不知道wave_out的類型的情況下很難猜出它們應該是什麼類型。

作爲一個臨時的想法,我已經修復了一些語法錯誤,添加了一個聲明ws0,ws1和wave_out的實體聲明,然後將wave_out設置爲適合我給定類型的值它(在這種情況下,只需要二進制輸入並生成格雷碼輸出)。

entity controller1 is 
port (
    ws1 : in std_logic; 
    ws0 : in std_logic; 
    wave_out : out std_logic_vector(1 downto 0) 
); 
end; 

architecture whatever of controller1 is 
begin 
impl: process(ws0, ws1) 
    begin 
     case std_logic_vector'(ws1,ws0) is 
      when "01" => wave_out<="01"; 
      when "10" => wave_out<="11"; 
      when "11" => wave_out<="10"; 
      when others =>wave_out<=(others => '-'); 
     end case; 
    end process; 
end whatever; 

當然,這也需要爲std_logicstd_logic_vector典型libraryusing獲得的聲明,但這些添加的合成器似乎接受它。當然,其他一些合成器(我用Synplify檢查過它)可能會發現我錯過的一個問題,但我認爲這可能至少涵蓋了大部分顯而易見的問題。

+0

好的,我修好了。謝謝! – 2013-04-25 00:53:02

0

你在這一行中用std_logic_vector'試圖實現什麼?

process (std_logic_vector'(ws1, ws0)) 

如果你只需要改變,對於更多傳統

process (ws1, ws0) 

我想它會有所幫助。


但我相信ws_combo就像

ws_combo = ws1&ws0; 

一個信號,以便

process (ws_combo) 

會更好。