我試圖定義VHDL的功能,但我得到VHDL功能無法編譯
Error: tst.vhd(4): near "subtype": syntax error
這是這是第一次,我在VHDL和我的編碼代碼
subtype word10 is bit_vector(9 downto 0);
subtype word8 is bit_vector(7 downto 0);
function tst (input : in word10) return word10 is
variable tmp : word10;
-- code here
begin
return tmp;
end tst;
entity tester is
end;
architecture tst of tester is
begin
end;
不能弄清楚錯誤是什麼。
任何想法?
如果我繞過'subtype'事情。 'function tst(input:in bit_vector(9 downto 0))return bit_vector(7 downto 0)is'我得到了類似的關於函數的錯誤。我正在爲fpga編寫此代碼,因此您認爲它可能不起作用?我很困惑。 '錯誤:tst.vhd(4):附近「功能」:語法error' – kechapito 2012-04-18 13:11:06
你應該避免一切都像在VHDL的功能,因爲它沒有像C.使用'entities'端口聲明和'architecture'的行爲申報,僅此而已。並且要小心諸如'wait'等語句,因爲這些語句不能合成。一本好的(最好的IMO)書籍:Peter Ashenden設計的VHDL指南。 – 2012-04-18 13:16:18
我將實施VHDL加密算法,我需要類似的功能,否則代碼將變得相當混亂。我閱讀了有關組件,但我認爲這不是我需要的。 – kechapito 2012-04-18 14:51:00