www.pudn.com > codeofvhdl2006.rar > BCD.VHD


--bcd.vhd 1 digits bcd adder/subtractor 
library ieee ; 
use ieee.std_logic_1164.all; 
use work.components.all; 
entity bcd is 
port( 
  a : in std_logic_vector(3 downto 0);--被加/減數 
  b : in std_logic_vector(3 downto 0);--加/減數 
  ci : in std_logic;--進位輸入,減法模式時為'0' 
  sel : in std_logic;--加/減法模式選擇,0=>加法,1=>減法 
  co : out std_logic;--進位輸出 
  sum : out std_logic_vector(3 downto 0));--和 
end bcd; 
architecture behavior of bcd is  
  signal b2 : std_logic_vector(3 downto 0);--加/減取9補結果 
begin 
  u0: com9s port map (b,sel,b2);--取9補數電路 
  u1: bcdadd port map (a,b2,ci,co,sum);--bcd加法器 
end behavior;