我一直在努力製作一個解碼器,我可以在多個實例中使用,只需更改輸入/輸出矢量大小的通用值即可。解碼器將「輸入」一位,基於輸入整數轉換的多個位置。解碼器本身工作正常。當我製作測試臺並編譯時,問題就會出現。 「n」 被使用的對象,但不聲明VHDL - 測試平臺 - 泛型
我已經添加下面的模型和試驗檯:導致:
錯誤(10482):在DECODER.vhd VHDL錯誤(41):
LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; USE IEEE.numeric_std.ALL; ENTITY DECODER IS --GENERIC (delay : delay_length := 0 ns); GENERIC (n : POSITIVE := 2); PORT (a : IN std_logic_vector(n-1 DOWNTO 0); x : OUT std_logic_vector(2**n-1 DOWNTO 0)); END ENTITY DECODER; ARCHITECTURE dflow OF DECODER IS CONSTANT x_out : BIT_VECTOR (2**n-1 DOWNTO 0) := (0 => '1', OTHERS => '0'); BEGIN x <= to_stdlogicvector(x_out sll to_integer(unsigned(a))); END ARCHITECTURE dflow; --test bench---------------------------------------- LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; USE IEEE.numeric_std.ALL; ENTITY TN2 IS END ENTITY TN2; ARCHITECTURE IO_TN2 OF TN2 IS COMPONENT DECODER IS --GENERIC (delay : delay_length := 0 ns); GENERIC (n : POSITIVE := 2); PORT (a : IN std_logic_vector(n-1 DOWNTO 0); x : OUT std_logic_vector(2**n-1 DOWNTO 0)); END COMPONENT DECODER; SIGNAL a : std_logic_vector (n-1 DOWNTO 0); --<-- USED BUT NOT DECLARED SIGNAL x : std_logic_vector (2**n-1 DOWNTO 0); BEGIN G1 : DECODER GENERIC MAP (n => 2) PORT MAP (a,x); a <= "00", "01" AFTER 1 NS, "10" AFTER 2 NS, "11" AFTER 3 NS, "00" AFTER 4 NS, "0Z" AFTER 5 NS; END ARCHITECTURE IO_TN2; CONFIGURATION CFG_DECODER OF TN2 IS FOR IO_TN2 FOR G1 : DECODER USE ENTITY work.DECODER(dflow) GENERIC MAP (n => 2) PORT MAP (a,x); END FOR; END FOR; END CONFIGURATION CFG_DECODER;
編譯器告訴我,我沒有聲明n,我認爲我在組件聲明中做過。我應該在哪裏申報? 第二個問題是我如何聲明多種泛型,例如 1通用於delay_length 1通用for n 我試着在模型實體中放置2個通用語句,但編譯器不認爲這是正確的。
一如既往非常感謝您的幫助。 d