用VHDL语言描述全减器


 

                                                                     图一 全减器原理图

 图一是用VHDL语言描述全减器的原理图。全减器依然用到了例化语句。其程序如下:

library ieee;
use ieee.std_logic_1164.all;
entity f_jq is
port(x,y,sub_in:in std_logic;
diffr,sub_out:out std_logic
);
end;
architecture fjq of f_jq is
component BJQ
port(a,b:in std_logic;
d,s:out std_logic
);
end component;
component or2a
port(A,B:in std_logic;
C:out std_logic
);
end component;
signal net1,net2,net3 :std_logic;
begin
u1:BJQ port map(a=>x,b=>y,d=>net1,s=>net2);
u2:BJQ port map(a=>net1,b=>sub_in,d=>diffr,s=>net3);
u3:or2a port map(A=>net3,B=>net2,C=>sub_out);
end architecture fjq;

其中用到例化语句半减器,其程序如下:

library ieee;
use ieee.std_logic_1164.all;
entity BJQ is
port(a,b:in std_logic;
d,s:out std_logic
);
end;
architecture bhv of BJQ is
begin
d<=a xor b;
s<=(not a)and b;
end architecture bhv;

其半减器原理图如图二所示。

 

例化语句或门程序如下:

library ieee;
use ieee.std_logic_1164.all;
entity or2a is
port(
A,B:in std_logic;
C:out std_logic
);
end entity or2a;
architecture one of or2a is
begin
c<=a or b;
end architecture one;

其原理图如图三所示:

 

 对数电知识进行补充:

1、半减器真值表:

 

 有真值表可以知diff和s_out的逻辑表达式。

diff=x xor y;

s_out=(not x)and y;

2、全减器真值表:

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM