📄 muladduns.vhd
字号:
--------------------------------------------------------------------------------- Title : Unsigned multiplier-adder-- Project : VHDL Library of Arithmetic Units--------------------------------------------------------------------------------- File : MulAddUns.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 :-- Multiplier-adder for unsigned numbers (Brown). First multiplies two numbers,-- then adds an additional operand to the result.-------------------------------------------------------------------------------library ieee;use ieee.std_logic_1164.all;use ieee.numeric_std.all;library arith_lib;use arith_lib.arith_lib.all;-------------------------------------------------------------------------------entity MulAddUns is generic (widthX : positive := 8; -- word width of XS, XC (<= widthY) widthY : positive := 8; -- word width of Y widthA : positive := 20; -- word width of A (>= widthX+widthY) speed : speedType := fast); -- performance parameter port (X : in std_logic_vector(widthX-1 downto 0); -- multiplier Y : in std_logic_vector(widthY-1 downto 0); -- multiplicand A : in std_logic_vector(widthA-1 downto 0); -- augend P : out std_logic_vector(widthA-1 downto 0)); -- productend MulAddUns;-------------------------------------------------------------------------------architecture Behavioral of MulAddUns is signal Xuns : unsigned(widthX-1 downto 0); -- unsigned signal Yuns : unsigned(widthY-1 downto 0); -- unsigned signal Auns : unsigned(widthA-1 downto 0); -- unsigned signal Puns : unsigned(widthA-1 downto 0); -- unsignedbegin -- type conversion: std_logic_vector -> unsigned Xuns <= unsigned(X); Yuns <= unsigned(Y); Auns <= unsigned(A); -- multiplication and addition Puns <= (Xuns * Yuns) + Auns; -- type conversion: unsigned -> std_logic_vector P <= std_logic_vector(Puns);end Behavioral;-------------------------------------------------------------------------------architecture Structural of MulAddUns is -- partial products signal PP : std_logic_vector(widthX*(widthX+widthY)-1 downto 0); -- intermediate sum/carry bits signal ST1, CT1, ST2, CT2 : std_logic_vector(widthA-1 downto 0); begin -- generation of partial products ppGen : MulPPGenUns generic map (widthX, widthY) port map (X, Y, PP); -- carry-save addition of partial products csvAdd1 : AddMopCsv generic map (widthX+widthY, widthX, speed) port map (PP, ST1(widthX+widthY-1 downto 0), CT1(widthX+widthY-1 downto 0)); -- extend--synopsys_bug ST1(widthA-1 downto widthX+widthY) <= (others => '0');--synopsys_bug CT1(widthA-1 downto widthX+widthY) <= (others => '0'); synopsys_bug : for i in widthA-1 downto widthX+widthY generate ST1(i) <= '0'; CT1(i) <= '0'; end generate synopsys_bug; -- carry-save addition of augend csvAdd2 : AddCsv generic map (widthA) port map (A, CT1, ST1, ST2, CT2); -- final carry-propagate addition cpAdd : Add generic map (widthA, speed) port map (ST2, CT2, P);end Structural;-------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -