我在二進制乘法電路中爲寄存器(製作移位寄存器電路)寫了一段VHDL代碼。一旦我在Quartus II中分析它,就會顯示幾個語法錯誤。用於寄存器的VHDL代碼,用於二進制乘法電路
這是我的代碼:
ENTITY memory IS
PORT (can_load, can_shift, can_ad, sb_input, ab_input, UserInput : IN BIT;
Out_Bit, Z : OUT BIT);
END memory;
ARCHITECTURE logic OF memory IS
SIGNAL State: BIT := '0';
BEGIN
IF (can_load = '1') THEN
State <= UserInput;
ELSE
IF (can_ad = '1') THEN
Z <= State; --Z is the output that goes to the 4 bit adder
State <= ab_input;
END IF;
IF (can_shift = '1') THEN
Out_Bit <= State;
State <= sb_input;
END IF;
END IF;
END logic;
這是錯誤消息:
信息:********************** *********************************************
信息:運行Quartus II 64位分析&合成 信息:版本14.0.0構建200 06/17/2014 SJ網絡版 信息:正在處理:Sun Oct 19 16:28:22 2014 Info:Versi on 14.0.0 Build 200 06/17/2014 SJ Web版 信息:正在處理:Sun 10月19日16:28:22 2014
信息:命令:quartus_map --read_settings_files = on --write_settings_files =關閉內存 - C內存
警告(20028):並行編譯未獲得許可,已被禁用
錯誤(10500):VHDL語法錯誤在memory.vhd(9)近文字 「IF」;錯誤(10500):memory.vhd(9)在文本附近發生VHDL語法錯誤「THEN」時出現「end」或「(」或標識符(「if」是保留關鍵字)或併發語句錯誤(10500) 「;期待」< =「
錯誤(10500):memory.vhd(11)在文本」ELSE「附近出現VHDL語法錯誤;期待」結束「,或」(「或標識符(」else「保留關鍵字),或併發語句
錯誤(10500):在memory.vhd(12)附近的文本 「THEN」 VHDL語法錯誤;需要 「< =」
錯誤(10500):VHDL語法memory.vhd錯誤(15)文字「IF」附近; (10500):在文本「THEN」附近的memory.vhd(16)處出現VHDL語法錯誤;或者(如果「if」是保留關鍵字)或「體系結構」。期望「< =」
錯誤(10500):memory.vhd(19)在文本「IF」附近的VHDL語法錯誤;期待 「;」,或標識符( 「如果」 是保留關鍵字),或 「結構」
信息(12021):實測值0設計單位,包括0的實體,在源文件memory.vhd
我已經檢查了幾本書的正確語法和代碼示例,但是我找不到我的錯誤在哪裏。
我也試圖帶走括號中的部分是這樣的:
IF (can_load = '1') THEN
有這樣的事情:
IF can_load = '1' THEN
但我結束了與大多數相同的語法錯誤。
我很感謝任何幫助解決這個問題。謝謝。
如果... THEN是一個順序語句。您正在架構的並行處理區域中使用它。在體系結構內的進程中使用它。 – 2014-10-20 00:09:23
謝謝你,我做到了,它工作。我不知道我不能在程序之外使用IF ... THEN。 – DAVID 2014-10-22 03:04:03