永发信息网

vhdl程序设计1个4位加减法器

答案:1  悬赏:60  手机版
解决时间 2021-04-07 22:46
  • 提问者网友:蔚蓝的太阳
  • 2021-04-06 22:43
vhdl程序设计1个4位加减法器
最佳答案
  • 五星知识达人网友:酒醒三更
  • 2021-04-06 23:33
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity subadd4 is
port(sub:in std_logic;
a,b:in std_logic_vector(3 downto 0);
s:buffer std_logic_vector(3 downto 0);
co:buffer std_logic);
end entity subadd4;
architecture behav of subadd4 is
signal temp:std_logic_vector(4 downto 0);
begin
process(sub,a,b)
begin
if sub='0' then
temp(4 downto 0)<=('0'&a)+('0'&b);
else
temp(4 downto 0)<=('0'&a)-('0'&b);
end if;
end process;
s<=temp(3 downto 0);
co<=temp(4);
end behav;
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯