📄 addmulsgn.vhd
字号:
--------------------------------------------------------------------------------- Title : Signed adder-multiplier-- Project : VHDL Library of Arithmetic Units--------------------------------------------------------------------------------- File : AddMulSgn.vhd-- Author : Reto Zimmermann <zimmi@iis.ee.ethz.ch>-- Company : Integrated Systems Laboratory, ETH Zurich-- Date : 1997/11/19--------------------------------------------------------------------------------- Copyright (c) 1998 Integrated Systems Laboratory, ETH Zurich--------------------------------------------------------------------------------- Description :-- Adder-multiplier for signed numbers (Brown). First adds two numbers, then-- multiplies the result with the multiplicand. Can be used for multiplication-- with an input operand in carry-save number format. Result is only valid if-- sum does not overflow.-------------------------------------------------------------------------------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 AddMulSgn is generic (widthX : positive := 8; -- word width of XS, XC (<= widthY) widthY : positive := 8; -- word width of Y speed : speedType := fast); -- performance parameter port (XS, XC : in std_logic_vector(widthX-1 downto 0); -- multipliers Y : in std_logic_vector(widthY-1 downto 0); -- multiplicand P : out std_logic_vector(widthX+widthY-1 downto 0)); -- productend AddMulSgn;-------------------------------------------------------------------------------architecture Behavioral of AddMulSgn is signal XSuns, XCuns : signed(widthX-1 downto 0); -- signed signal Yuns : signed(widthY-1 downto 0); -- signed signal Puns : signed(widthX+widthY-1 downto 0); -- signedbegin -- type conversion: std_logic_vector -> signed XSuns <= signed(XS); XCuns <= signed(XC); Yuns <= signed(Y); -- addition and multiplication Puns <= (XSuns + XCuns) * Yuns; -- type conversion: signed -> std_logic_vector P <= std_logic_vector(Puns);end Behavioral;-------------------------------------------------------------------------------architecture Structural of AddMulSgn is -- partial products signal PP : std_logic_vector((widthX+1)*(widthX+widthY)-1 downto 0); -- intermediate sum/carry bits signal ST, CT : std_logic_vector(widthX+widthY-1 downto 0); begin -- generation of partial products ppGen : AddMulPPGenSgn generic map (widthX, widthY) port map (XS, XC, Y, PP); -- carry-save addition of partial products csvAdd : AddMopCsv generic map (widthX+widthY, widthX+1, speed) port map (PP, ST, CT); -- final carry-propagate addition cpAdd : Add generic map (widthX+widthY, speed) port map (ST, CT, P);end Structural;-------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -