用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