📄 negc.vhd
字号:
--------------------------------------------------------------------------------- Title : Parallel-prefix 2's complementer, conditional-- Project : VHDL Library of Arithmetic Units--------------------------------------------------------------------------------- File : NegC.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 :-- Conditional 2's complementer using parallel-prefix propagate-lookahead-- logic.-------------------------------------------------------------------------------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 NegC is generic (width : positive := 8; -- word width speed : speedType := fast); -- performance parameter port (A : in std_logic_vector(width-1 downto 0); -- operand Neg : in std_logic; -- negation enable Z : out std_logic_vector(width-1 downto 0)); -- resultend NegC;-------------------------------------------------------------------------------architecture Behavioral of NegC is signal Auns, Zuns : unsigned(width-1 downto 0); -- unsignedbegin -- type conversion: std_logic_vector -> unsigned Auns <= unsigned(A); -- complement Zuns <= 0 - Auns when Neg = '1' else Auns; -- type conversion: unsigned -> std_logic_vector Z <= std_logic_vector(Zuns);end Behavioral;-------------------------------------------------------------------------------architecture Structural of NegC is signal AI : std_logic_vector(width downto 0); -- A inverted signal PO : std_logic_vector(width downto 0); -- prefix propagate outbegin -- invert A for complement and attach carry-in AI <= (A xor (width-1 downto 0 => Neg)) & Neg; -- calculate prefix output propagate signal prefix : PrefixAnd generic map (width+1, speed) port map (AI, PO); -- calculate result bits Z <= AI(width downto 1) xor PO(width-1 downto 0);end Structural;-------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -