00001 --**************************************************************
00002 --* *
00003 --* The source code for the ATLAS BCM "AAA" FPGA is made *
00004 --* available via the GNU General Public License (GPL) *
00005 --* unless otherwise stated below. *
00006 --* *
00007 --* In case of problems/questions/bug reports etc. please *
00008 --* contact michael.niegl@cern.ch *
00009 --* *
00010 --**************************************************************
00011
00012 --**************************************************************
00013 --* *
00014 --* $Source: /local/reps/bcmfpga/bcm_aaa/bcm_aaa/coin/addsub48.vhd,v $
00015 --* $Revision: 1.4.2.3 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 17:57:42 $ *
00019
00020
00021 --* *
00022 --**************************************************************
00023 --------------------------------------------------------------------------------
00024 -- Copyright (c) 2004 Xilinx, Inc.
00025 -- All Rights Reserved
00026 --------------------------------------------------------------------------------
00027 -- ____ ____
00028 -- / /\/ /
00029 -- /___/ \ / Vendor: Xilinx
00030 -- \ \ \/ Author: Latha Pillai, Advanced Product Group, Xilinx, Inc.
00031 -- \ \ Filename: ADDSUB48
00032 -- / / Date Last Modified: November 8, 2004
00033 -- /___/ /\ Date Created: June 23, 2004
00034 -- \ \ / \
00035 -- \___\/\___\
00036 --------------------------------------------------------------------------------
00037 --------------------------------------------------------------------------------
00038
00039 library ieee;
00040
00041 use ieee.std_logic_1164.all;
00042
00043 use ieee.numeric_std.all;
00044
00045 use ieee.std_logic_arith.all;
00046
00047 use ieee.std_logic_unsigned.all;
00048
00049 library unisim;
00050
00051 use unisim.vcomponents.all;
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 entity ADDSUB48 is
00063 port (
00064 CLK : in ;
00065 RST : in ;
00066 C_IN : in (6 downto 0);
00067 PC_IN : in (6 downto 0);
00068 RESULT : out (6 downto 0)
00069 );
00070 end entity ADDSUB48;
00071
00072
00073
00074
00075
00076
00077
00078
00079 architecture ADDSUB48_ARCH of ADDSUB48 is
00080 -----------------------------------------------------------------
00081 -----------------------------------------------------------------
00082
00083 --Signal Declarations:
00084 signal LOW_18bit : (17 downto 0);
00085 signal LOW_48bit : (47 downto 0);
00086 signal LOW_1bit : ;
00087 signal HIGH_1bit : ;
00088 signal CARRYINSEL_bit : (1 downto 0);
00089 signal c_i : (17 downto 0);
00090 signal pc_i : (47 downto 0);
00091
00092 signal OPMODE_bit : (6 downto 0);
00093 signal ADD_SUB : ;
00094 signal ADDSUB_OUT : (47 downto 0);
00095 signal res_i : (6 downto 0) := (others => '0');
00096 signal rout : (6 downto 0) := (others => '0');
00097
00098
00099 ------------------------------------------------------------------
00100 -- Architecture Section: instantiation block 1
00101
00102 begin
00103
00104 -- static assignments
00105 LOW_18bit <= "000000000000000000";
00106 LOW_48bit <= "000000000000000000000000000000000000000000000000";
00107 LOW_1bit <= '0';
00108 HIGH_1bit <= '1';
00109 CARRYINSEL_bit <= "00";
00110 OPMODE_bit <= "0110011";
00111 ADD_SUB <= '1'; -- 0 = add, 1 = sub
00112
00113 -- output assignments
00114 RESULT <= rout;
00115
00116 -- input assignments
00117 c_i <= LOW_48bit(17 downto 7) & C_IN;
00118 pc_i <= LOW_48bit(47 downto 7) & PC_IN;
00119
00120
00121
00122 DSP48_1 : DSP48 generic map (
00123 AREG => 0, -- Number of pipeline registers on the A input, 0, 1 or 2
00124 BREG => 0, -- Number of pipeline registers on the B input, 0, 1 or 2
00125 B_INPUT => "DIRECT", -- B input DIRECT from fabric
00126 --or CASCADE from another DSP48
00127 CARRYINREG => 0, -- Number of pipeline registers
00128 -- for the CARRYIN input, 0 or 1
00129 CARRYINSELREG => 0, -- Number of pipeline registers
00130 -- for the CARRYINSEL, 0 or 1
00131 CREG => 0, -- Number of pipeline registers on the C input, 0 or 1
00132 LEGACY_MODE => "MULT18X18S", -- Backward compatibility, NONE,
00133 -- MULT18X18 or MULT18X18S
00134 MREG => 1, -- Number of multiplier pipeline registers, 0 or 1
00135 OPMODEREG => 0, -- Number of pipeline registers on OPMODE input, 0 or 1
00136 PREG => 1, -- Number of pipeline registers on the P output, 0 or 1
00137 SUBTRACTREG => 0) -- Number of pipeline registers on the
00138 -- SUBTRACT input, 0 or 1
00139
00140 port map (
00141 A => LOW_18bit,
00142 B => c_i,
00143 C => pc_i,
00144 BCIN => LOW_18bit,
00145 PCIN => LOW_48bit,
00146 OPMODE => OPMODE_bit ,
00147 SUBTRACT => ADD_SUB,
00148 CARRYIN => LOW_1bit,
00149 CARRYINSEL => CARRYINSEL_bit,
00150 CLK => CLK,
00151 CEA => LOW_1bit,
00152 CEB => LOW_1bit,
00153 CEC => HIGH_1bit,
00154 CEP => HIGH_1bit,
00155 CEM => HIGH_1bit,
00156 CECTRL => LOW_1bit,
00157 CECARRYIN => LOW_1bit,
00158 CECINSUB => HIGH_1bit,
00159 RSTA => RST,
00160 RSTB => RST,
00161 RSTC => RST,
00162 RSTP => RST,
00163 RSTM => RST,
00164 RSTCTRL => RST,
00165 RSTCARRYIN => RST,
00166 BCOUT => open,
00167 P => ADDSUB_OUT ,
00168 PCOUT => open
00169 );
00170
00171 res_i <= ADDSUB_OUT(6 downto 0);
00172
00173
00174 process(res_i)
00175 variable r_i : (6 downto 0) := (others => '0');
00176 begin
00177 if res_i(6) = '1' then
00178 for i in 6 downto 0 loop
00179 r_i(i) := not(res_i(i));
00180 end loop;
00181 r_i := r_i + 1;
00182 else
00183 r_i := res_i;
00184 end if;
00185 rout <= r_i;
00186 end process;
00187
00188 end ADDSUB48_ARCH;