簡體   English   中英

“等待”語句 VHDL 附近出現未知語法錯誤

[英]Unknown syntax error near "wait for" statement VHDL

我的測試平台代碼中的“等待”語句產生了語法錯誤,我無法追蹤錯誤的來源來修復它。 它產生的錯誤是:

Error: Syntax error near 'wait' Error: type error near ns; current type time; expected type void Error: 'ns' is not a subprogram

我不明白這一點,因為包括教科書中使用waitwait for語句的示例的所有示例都與我使用的完全相同。

我一直在查看這個測試台文件,試圖找出這個語法錯誤是什么。 我無法確定它是否在我的代碼中使用了不正確的類型,或者缺少標點符號或什么。 這應該只是一個 state 機器的測試平台,它將在加、減、乘之間切換。 A & B 是 4 位輸入,SEL 是一個按鈕,當它是 1 時 state 變化,CLK 使用上升沿傳遞任何變化。 結果是 8 位 output。

我什至無法運行模擬來測試實體和架構,因為當我嘗試在 Vivado 上運行模擬時,由於等待語句附近的語法,它不會。 對於上下文,在下面的代碼片段中,Vivado 唯一帶下划線的問題是wait for 10ns; 線。 如果我將其格式化為wait for 10 ns; 它產生相同的錯誤。

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity HW9_TB is

end HW9_TB;

architecture Behavioral of HW9_TB is

    component HW9 is
    Port ( A : in signed (3 downto 0);
           B : in signed (3 downto 0);
           SEL : in STD_LOGIC;
           Q : out STD_LOGIC_VECTOR (1 downto 0);
           Result : out signed (7 downto 0);
           CLK : in STD_LOGIC);
    end component;

    signal A : signed (3 downto 0) := "0000";
    signal B : signed (3 downto 0) := "0000";
    signal SEL : std_logic := '0';
    signal CLK : std_logic := '0';

begin

    T1 : HW9 PORT MAP (
        A => A, B => B, SEL => SEL, CLK => CLK);
        
-- A=0, B=0, SEL=0, CLK=0
    A <=    "0000";     
    B <=    "0000"; 
    SEL <=  '0';    
    CLK <=  '0';    
    wait for 10ns;

您的代碼中有兩個錯誤:

  1. wait是只允許在process中使用的順序語句,但你把它寫成並發語句。 想想它在流程之外應該意味着什么? 所有並發語句都是並行執行的。
  2. 時間的單位需要用空格與值分開。

您的問題的簡化和更正版本是:

entity TB is
end TB;

architecture Behavioral of TB is
begin
    --wait for 10 ns; -- Produces an error message, because not allowed here.

    process
    begin
        wait for 10 ns; -- Here it is allowed.
    end process;
end Behavioral;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM