VHDL:即使在架构声明部分中定义了内部信号,也未定义

问题描述

所以我一直在为VHDL课程做一些家庭作业,但我似乎无法理解这个问题。 这里的要点是创建在2的补码和无符号32位总线上均可使用的ALU的加法器/减法器,这就是为什么我有一个称为sub_mode(A-B = A +!B + 1)的条件的原因,激活后随身携带。 其余的不同输入和输出是不言自明的。 我的问题在于此类组件的测试平台,即使在体系结构的声明部分中初始化了进位和临时进位,最终仍显示未定义。我猜这是由于流程中的for循环将所有内容搞砸了。那是一个准确的猜测吗?如果可以,是否可以继续将两个位总线相加而不必完全创建由n个1位加法器组件组成的n位加法器?

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity add_sub is
port(
    a        : in  std_logic_vector(31 downto 0);
    b        : in  std_logic_vector(31 downto 0);
    sub_mode : in  std_logic;
    carry    : out std_logic;
    zero     : out std_logic;
    r        : out std_logic_vector(31 downto 0)
);
end add_sub;

architecture synth of add_sub is

signal cond_inv : std_logic_vector(31 downto 0);
signal carry_temp : std_logic_vector(32 downto 0) := (others => '0');
signal r_temp : std_logic_vector(31 downto 0) := (others => '0');

begin           
behave : process(a,b,sub_mode)
begin 
    if sub_mode = '1' then 
        cond_inv <= b xor x"ffffffff";
    else
        cond_inv <= b;
    end if; 
    carry_temp(0) <= sub_mode;
    for i in 0 to 31 loop
        r_temp(i) <= a(i) xor cond_inv(i) xor carry_temp(i);
        
        carry_temp(i+1) <= 
            (a(i) and cond_inv(i)) or
            (a(i) and carry_temp(i)) or
            (cond_inv(i)and carry_temp(i));
    end loop;
    if r_temp = x"00000000" then 
        zero <= '1';
    else 
        zero <= '0';
    end if;
    r <= r_temp;
    carry <= carry_temp(32);
end process behave;
end synth;

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...