VHDL:意外IF的问题

Hen*_*kka 0 vhdl

您好我正在尝试在xilinx ISE环境中学习VHDL,我无法使用此代码,我不知道为什么.我尝试使用/不使用ands的单引号,但没有任何作用.有人可以帮帮我吗?

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

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

entity teh_3 is
    Port ( thermo_input : in  STD_LOGIC_VECTOR(3 DOWNTO 0);
           too_hot : out  STD_LOGIC;
           too_cold : out  STD_LOGIC;
           just_right : out  STD_LOGIC);
end teh_3;

architecture Behavioral of teh_3 is

begin

IF thermo_input < "1000" THEN
  too_cold <='1' and
  too_hot <='0' and
  just_right <='0';
ELSIF thermo_input > "1011" THEN 
    too_hot <='1' and
    too_cold <='0' and
    just_right <='0';
ELSIF thermo_input > "0111" THEN 
  just_right <='1' and
  too_hot <='0' and
  too_cold <='0';
ELSE
  just_right <='0' and
  too_hot <='0' and
  too_cold <='0';
END IF;
Run Code Online (Sandbox Code Playgroud)

结束行为;

ERROR:HDLParsers:164 - "/home/student/kokeilu/kokeil.vhd" Line 40. parse error, unexpected IF

谢谢!

Mar*_*son 5

从根本上说,如果不在流程之外,则不能使用.

另外,请不要使用std_logic_arith,请使用numeric_std- http://parallelpoints.com/node/3


修复,制作流程或使用patrick建议的正确组合语法.

您目前拥有它的方式必须是组合过程,因此请小心将所有输入都放在灵敏度列表中或使用新的VHDL-2008 process(all)语法.取决于您使用的ISE版本是否支持.

或者使它成为一个同步过程 - 这就是大多数FPGA编写代码的方式.

clk向实体添加输入,然后将if/elsif/else代码放入同步过程中:

process (clk)
begin
  if thermo_input < "1000" then
   .... etc
end process;
Run Code Online (Sandbox Code Playgroud)

最后,您不会使用AND同时发生几件事情:

IF thermo_input < "1000" THEN
  too_cold <='1'; -- semicolons here, not ANDs!
  too_hot <='0';
  just_right <='0';
Run Code Online (Sandbox Code Playgroud)

是正确的方法!