【发布时间】:2021-04-21 18:51:23
【问题描述】:
我一直在尝试编写一个添加单个位的组合电路。当我模拟我的代码时,我从我的临时寄存器中得到未知值(“U”)。我正在添加我的代码以供参考。如果我遗漏了什么或者我的逻辑是错误的,请纠正我。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity serial_adder is
Port ( a : in std_logic;
b : in std_logic;
c : in std_logic;
d : in std_logic;
e : in std_logic;
f : in std_logic;
g : in std_logic;
h : in std_logic;
sum : out std_logic_vector (3 downto 0));
end serial_adder;
architecture Behavioral of serial_adder is
signal temp1, temp2, temp3, temp4 : std_logic_vector (1 downto 0);
signal temp5, temp6, temp9 : std_logic_vector (2 downto 0);
signal temp7, temp8 :std_logic_vector (1 downto 0);
begin
process (a,b,c,d,e,f,g,h)
begin
temp1(0) <= a or b;
temp2(0) <= c or d;
temp3(0) <= e or f;
temp4(0) <= g or h;
temp7 <= temp1 or temp2;
temp8 <= temp3 or temp4;
temp9 <= temp5 or temp6;
if (a = b and temp1(0) /= a) then
temp1(1) <= not temp1(0);
else
temp1(1) <= '0';
end if;
if (c = d and temp2(0) /= c) then
temp2(1) <= not temp2(0);
else
temp2(1) <= '0';
end if;
if (e = f and temp3(0) /= e) then
temp3(1) <= not temp3(0);
else
temp3(1) <= '0';
end if;
if (g = h and temp4(0) /= g) then
temp4(1) <= not temp4(0);
else
temp4(1) <='0';
end if;
if (temp1(1) = temp2(1) and temp7(1) /= temp1(1)) then
temp5 <= ('1' ,temp7(1), temp7(0));
end if;
if (temp3(1) = temp4(1) and temp8 (1) /= temp3(1)) then
temp6 <= ('1' ,temp8(1), temp8(0));
end if;
if (temp5(2) = temp6(2) and temp9(2) /= temp5(2)) then
sum <= ('1', temp9(2), temp9(1), temp9(0));
end if;
end process;
end Behavioral;
【问题讨论】:
-
你的模拟是做什么的?
-
结果是 U,所有温度信号都显示 U 值。我添加了模拟图像。
-
在进程暂停之前,信号不会更新。如果你需要一个在赋值后立即更新的数据对象,你需要一个变量。
-
但是进程外的变量应该是共享的吧?
-
你只有一个进程,没有其他并发语句。外面是什么?请注意,在您的进程中评估 temp1、temp2、temp3、temp4、temp5、temp6、temp7、temp8 和 temp9 时,它们都不在进程敏感度列表中。添加这些将无济于事,您还有logic problems。