📄 addcfast.vhd
字号:
--------------------------------------------------------------------------------- Title : Parallel-prefix adder with fast carry-in, carry-out-- Project : VHDL Library of Arithmetic Units--------------------------------------------------------------------------------- File : AddCfast.vhd-- Author : Reto Zimmermann <zimmi@iis.ee.ethz.ch>-- Company : Integrated Systems Laboratory, ETH Zurich-- Date : 1997/11/04--------------------------------------------------------------------------------- Copyright (c) 1998 Integrated Systems Laboratory, ETH Zurich--------------------------------------------------------------------------------- Description :-- Binary adder using parallel-prefix carry-lookahead logic with:-- - fast carry-in (CI)-- - carry-out (CO)-------------------------------------------------------------------------------library ieee;use ieee.std_logic_1164.all;library synergy; use synergy.signed_arith.all;library arith_lib;use arith_lib.arith_lib.all;-------------------------------------------------------------------------------entity AddCfast is generic (width : positive := 8; -- word width speed : speedType := fast); -- performance parameter port (A, B : in std_logic_vector(width-1 downto 0); -- operands CI : in std_logic; -- carry in S : out std_logic_vector(width-1 downto 0); -- sum CO : out std_logic); -- carry outend AddCfast;-------------------------------------------------------------------------------architecture Behavioral of AddCfast is signal Auns, Buns, CIuns, Suns : unsigned(width downto 0);begin -- type conversion: std_logic_vector -> unsigned Auns <= conv_unsigned(A, width+1); Buns <= conv_unsigned(B, width+1); CIuns <= (0 => CI, others => '0'); -- addition Suns <= Auns + Buns + CIuns; -- type conversion: unsigned -> std_logic_vector S <= std_logic_vector(Suns(width-1 downto 0)); CO <= Suns(width);end Behavioral;-------------------------------------------------------------------------------architecture Structural of AddCfast is signal GI, PI : std_logic_vector(width-1 downto 0); -- prefix gen./prop. in signal GO, PO : std_logic_vector(width-1 downto 0); -- prefix gen./prop. out signal PT : std_logic_vector(width-1 downto 0); -- adder propagate tempbegin -- calculate prefix input generate/propagate signals GI <= A and B; PI <= A or B; -- calculate adder propagate signals (PT = A xor B) PT <= not GI and PI; -- calculate prefix output generate/propagate signals with fast carry-in prefix : PrefixAndOrCfast generic map (width, speed) port map (GI, PI, CI, GO, PO); -- calculate sum and carry-out bits S <= PT xor GO(width-2 downto 0) & CI; CO <= GO(width-1);end Structural;-------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -