【发布时间】:2018-06-07 17:24:40
【问题描述】:
library IEEE;
use IEEE.std_logic_1164.all;
entity doorlock is
port( reset : in std_logic;
enable : in std_logic;
password : in std_logic_vector (7 downto 0);
door : out std_logic_vector (7 downto 0);
lock : out std_logic;
alarm : out std_logic;
turnoff : out std_logic);
end doorlock;
--password is 10(decimal no.) which is 00010000(binary no.)
architecture DDL of doorlock is
signal err_count : integer range 0 to 5 := 0;
begin
lock <= '0' when (reset = '0');
alarm <= '0' when (reset = '0');
turnoff <= '0' when (reset = '0');
door <= "00000000" when (reset = '0');
lock <= '0' when (enable <= '0');
process(password)
begin
if (password = "-------1") then
door <= "00000000";
elsif (password = "------10") then
door <= "00000001";
elsif (password = "-----100") then
door <= "00000011";
elsif (password = "----1000") then
door <= "00000111";
elsif (password = "---00000") then
door <= "00001111";
elsif (password = "--110000") then
door <= "00011111";
elsif (password = "-1010000") then
door <= "00111111";
elsif (password = "10010000") then
door <= "01111111";
elsif (password = "00010000") then
door <= "11111111";
end if;
err_count <= err_count + 1;
end process;
alarm <= '1' when (err_count = 3);
turnoff <= '1' when (err_count = 5);
lock <= '1' when (door = "11111111" and turnoff = '0' and alarm = '0');
end DDL;
我为我的家庭作业制作了这个代码来制作数字门锁。 而这一行在我编译时有错误。
lock <= '1' when (door = "11111111" and turnoff = '0' and alarm = '0');
错误如下所示
** 错误:D:\modelsim\Door.vhd(53): 无法读取输出“警报”。
VHDL 2008 允许读取输出。 通过使用 -2008 编译启用此功能。
** 错误:D:\modelsim\Door.vhd(53): 无法读取输出“门”。
VHDL 2008 允许读取输出。 通过使用 -2008 编译启用此功能。
** 错误:D:\modelsim\Door.vhd(53): 无法读取输出“关闭”。
VHDL 2008 允许读取输出。 通过使用 -2008 编译启用此功能。
** 错误:D:\modelsim\Door.vhd(55): VHDL 编译器正在退出
我不知道为什么会这样,请帮帮我
【问题讨论】:
-
错误消息说明了整个故事:一个输出端口从您的模块中出来,无法读取。您只能读取输入端口和信号。您可以为
door、alarm和turnoff定义内部信号并将它们分配给输出端口,或者使用允许读取输出端口的VHDL-2008。 -
将编译器设置为 VHDL-2008 模式,或开始使用中间信号。
-
附言。如果您要使用 VHDL-2008,请考虑使用
case?语句而不是这个 if-elsif-elsif-etc。结构。 -
哦,您的信号有多个驱动程序。请考虑使用时钟并将所有作业放在一个进程中。
-
@JHBonarius 你刚刚在你的 cmets 中写下了整个答案。你为什么不写他们的答案?
标签: compilation vhdl