vhdl - 在 VHDL 中添加单个位
问题描述
我一直在尝试编写一个添加单个位的组合电路。当我模拟我的代码时,我从我的临时寄存器中获得了未知值(“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”,因为该进程从未被访问过。
根据您的灵敏度列表,该过程仅在输入信号上执行
process (a,b,c,d,e,f,g,h)
考虑到这一点,这些信号都没有改变要完成的过程的价值。
在您的测试台中尝试更改其中一个信号的输入值,并且应该执行该过程以更改输出值。
推荐阅读
- flutter - Flutter中TextField的当前焦点位置
- flutter - flutter_blue 如何停止连接()?
- excel - 如何使用 VBA 在 Excel 中打印所有子和父标记和值
- android-studio - 更改名称 APK Android Studio
- angular - Angular ngNativeValidate 不适用于primeng 下拉菜单
- java - 通过 RoomDB 使用 RecyclerView 和 LiveData 搜索功能
- javascript - Discord.JS - 使用角色将 Discord 中的用户移动到您的 VC
- php - 使用/不使用 CASE 语句时,Oracle NVL 返回不一致的结果
- kubernetes - Kubernetes 内部 socket.io 连接
- javascript - node.js – 检查单词是否在前一个单词中添加/更改了字母