VHDL 未解析信号有多个来源

问题描述 投票:0回答:1

祝你早安或晚安!我目前在设计这个基本火灾报警系统时面临着挑战。具体细节如下:

该配置包括 2 个输入和 5 个输出。输入标识如下: F:火灾传感器 T:激活剂

输出标记为: Y:气体 我:火花 答:报警 BL:蓝色LED YL:黄色 LED

以下是与输入和输出相关的操作: 当F设置时:黄色LED亮起 当F清零时:黄色LED熄灭 当T清零时:无动作,蓝色LED保持熄灭 当 T 设置时:它会触发以下任务并激活蓝色 LED:

模式 1 - 正常: T 激活后,延迟 Td 后,I 和 Y 被激活。当检测到来自 F 的信号时,输出 I 被禁用。在此模式下,A 被停用,F 被监视 Tv 的持续时间。

模式 2 - 锁定: T 激活后,延迟 Td 后,I 和 Y 被激活。如果在Tv的监控时间内没有检测到F的信号,则系统切换到锁定模式。当 Tv 结束时,I 和 Y 停用,A 激活。

模式 3 - 模拟: 如果控制器在 I 和 Y 之前(Td 期间)检测到 F,则进入此模式,这意味着在 F 被清除之前控制器不会启动任务。”

下面是我的初级代码,您可以看到:

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

entity FireAlarm is
    Port (
        clk, reset, F, T : in STD_LOGIC;
        YL, BL, A, I : out STD_LOGIC;
        mode : out STD_LOGIC_VECTOR(1 downto 0)
    );
end FireAlarm;

architecture Behavioral of FireAlarm is
    type State is (Idle, Normal, Lock, Simulation);
    signal current_state, next_state : State;
    signal timer_count : integer := 0;
    constant Td : integer := 100;  -- Delay for T in clock cycles
    constant Tv : integer := 200;  -- Check time for F in clock cycles

begin

    process(clk, reset)
    begin
        if reset = '1' then
            current_state <= Idle;
            timer_count <= 0;
        elsif rising_edge(clk) then
            current_state <= next_state;

            if timer_count > 0 then
                timer_count <= timer_count - 1;
            end if;

            -- Update timer_count in the synchronous process
            case current_state is
                when Normal | Lock =>
                    if timer_count > 0 then
                        timer_count <= timer_count - 1;
                    end if;
                when others =>
                    -- No need to update timer_count for other states
                    null;
            end case;
        end if;
    end process;

    process(F, T, current_state)
    begin
        mode <= (others => '0');  -- Initialize mode vector

        case current_state is
            when Idle =>
                if T = '1' and F = '0' then
                    next_state <= Normal;
                    timer_count <= Td;
                else
                    next_state <= Idle;
                end if;

            when Normal =>
                YL <= '1';
                BL <= '1';
                I <= '1';

                if T = '0' and F = '1' then
                    I <= '0';
                    timer_count <= Tv;
                    next_state <= Idle;
                else
                    next_state <= Normal;
                end if;

            when Lock =>
                YL <= '0';
                BL <= '0';
                A <= '1';
                I <= '0';

                if T = '0' and F = '1' then
                    timer_count <= Tv;
                    next_state <= Idle;
                else
                    next_state <= Lock;
                end if;

            when Simulation =>
                YL <= '0';
                BL <= '0';
                A <= '0';
                I <= '0';

                if T = '1' and F = '0' then
                    next_state <= Normal;
                    timer_count <= Td;
                else
                    next_state <= Simulation;
                end if;

            when others =>
                next_state <= Idle;
        end case;
    end process;

end Behavioral;

这是我使用 ALTERA MODELSIM 2012 时遇到的错误:

Error: C:/Users/user/Desktop/work/Firealarm v1/main.vhd(17): Nonresolved signal 'timer_count' has multiple sources.
  Drivers:
    C:/Users/user/Desktop/work/Firealarm v1/main.vhd(23):Process line__23
       Driven at:
          C:/Users/user/Desktop/work/Firealarm v1/main.vhd(27)
    C:/Users/user/Desktop/work/Firealarm v1/main.vhd(48):Process line__48
       Driven at:
          C:/Users/user/Desktop/work/Firealarm v1/main.vhd(56)
** Error: C:/Users/user/Desktop/work/Firealarm v1/main.vhd(105): VHDL Compiler exiting

我试图研究这些错误,但以我目前的理解水平(在本例中较低)找不到任何可以做的事情。任何帮助将不胜感激。谢谢你。

vhdl
1个回答
0
投票

是的,基本问题是信号是由两个独立的进程驱动的。现在,一个架构内可以有多个进程,但每个信号最多只能从其中一个分配。在第一个过程中,有一条注释:“无需为其他状态更新timer_count”。然而,情况似乎并非如此,因为在下面,它根据 current_state 被分配了不同的值。我可能会将timer_count 的分配移至第一个,重新创建执行所述分配所需满足的条件。

© www.soinside.com 2019 - 2024. All rights reserved.