关于为 4 值逻辑 VHDL 获取 "X"es 的警告

Warning about getting "X"es for 4-valued logic VHDL

我收到警告,算术运算具有 X,因此结果将始终为 X,尽管我正在将信号初始化为 0s。有人可以帮忙吗?

N.B。 Z_countRC_count_var

我得到 X
--RC counter
LIBRARY ieee ;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_unsigned.all;

Entity RC_counter2 is
    Port(load, Cplus, Cminus : In Std_logic;
        X: In std_logic_vector (3 downto 0) :="0000";
        Z_count: Out std_logic_vector (3 downto 0) :="0000");
end Entity;

Architecture behav of RC_counter2 is
    signal RC_count_var: std_logic_vector(3 downto 0):="0000";
    Begin
    process(Cplus, load)
        --variable RC_count_var: std_logic_vector(3 downto 0):="0000";

        Begin
            if load = '1' then
                RC_count_var <= X;
            end if;

            if (Cplus'EVENT and Cplus = '1') then
                RC_count_var <= RC_count_var + 1;
            else
                RC_count_var <= RC_count_var;
            end if;

        end process;

    process(Cminus, load)
        Begin

          if load = '1' then
                      RC_count_var <= X;
              end if;

         if (Cminus'EVENT and Cminus = '1') then
                    RC_count_var <= RC_count_var - 1; 
             else
                    RC_count_var <=RC_count_var;
             end if;

    end process;
 Z_count <= RC_count_var;
 end Architecture; 

RC_Count_var 的值变得无效,因为它有多个冲突的驱动程序。

在VHDL 中,只要在多个进程中分配一个信号,就意味着多个驱动程序。这些通常不支持合成,也不完全推荐。为确保您没有多个驱动程序,只需在单个进程中对信号进行所有分配即可。

此外,虽然没有完全错误或有问题,但我建议您修改以下代码:

if load = '1' then
    RC_count_var <= X;
end if;

if (Cplus'EVENT and Cplus = '1') then
    RC_count_var <= RC_count_var + 1;
else
    RC_count_var <= RC_count_var;
end if;

这并没有提供多个驱动程序,但有几个问题。首先,在进程中对同一信号的连续分配会覆盖之前的分配。因此,如果 cplus 上升且 load'1',则不会加载该值。使用 elsifelse 会更好更简洁。此外,综合目标通常不支持异步加载。异步 set/reset 没问题,但异步加载到值 X,在您的情况下,可能有问题。