1 ------------------------------------------------------------------------------- 2 -- File : DspAddSub.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2013-07-12 5 -- Last update: 2013-07-12 6 ------------------------------------------------------------------------------- 7 -- Description: Example of VHDL inferred DSP resources for Adder/Subtracter 8 ------------------------------------------------------------------------------- 9 -- This file is part of 'SLAC Firmware Standard Library'. 10 -- It is subject to the license terms in the LICENSE.txt file found in the 11 -- top-level directory of this distribution and at: 12 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. 13 -- No part of 'SLAC Firmware Standard Library', including this file, 14 -- may be copied, modified, propagated, or distributed except according to 15 -- the terms contained in the LICENSE.txt file. 16 ------------------------------------------------------------------------------- 19 use ieee.std_logic_1164.
all;
20 use ieee.std_logic_unsigned.
all;
21 use ieee.std_logic_arith.
all;
26 --! @ingroup xilinx_general 51 constant A_FORMAT_C : sl := ite((A_TYPE_G = "signed"), '1', '0');
52 constant B_FORMAT_C : sl := ite((B_TYPE_G = "signed"), '1', '0');
53 constant S_FORMAT_C : sl := ite((S_TYPE_G = "signed"), '1', '0');
59 signal aIn : slv((A_WIDTH_G-1) downto 0) := (others => '0');
60 signal bIn : slv((B_WIDTH_G-1) downto 0) := (others => '0');
61 signal sOut : slv((S_WIDTH_G-1) downto 0) := (others => '0');
62 signal qOut : OutputArray := (others => (others => '0'));
65 attribute use_dsp48 : ;
66 attribute use_dsp48 of sOut : signal is "yes";
72 report "A_TYPE_G must be either unsigned or signed" 76 report "B_TYPE_G must be either unsigned or signed" 80 report "S_TYPE_G must be either unsigned or signed" 82 -- S_WIDTH_G range check 84 report "S_WIDTH_G must be A_WIDTH_G, A_WIDTH_G+1, B_WIDTH_G, or B_WIDTH_G+1" 87 --force the input A to be unsigned 92 end generate Input_A_Mapping_Gen;
94 --force the input B to be unsigned 99 end generate Input_B_Mapping_Gen;
101 -- zero latency DSP48 process 102 process(aIn,
add, bIn)
113 --convert output S to desired unsigned or signed format 115 Output_S_Mapping_Gen : 117 qOut(0)(i) <= sOut(i);
118 end generate Output_S_Mapping_Gen;
120 --check if we need to generate registers 125 if rising_edge(clk) then 127 qOut(i+1) <= qOut(i) after TPD_G;
131 end generate Latency_Gen;
133 --map the output S with respect to LATENCY_G
LATENCY_Ginteger range 0 to 2:= 0
S_WIDTH_Ginteger range 2 to 48:= 2
in bslv(( B_WIDTH_G- 1) downto 0) :=( others => '0')
S_TYPE_Gstring := "unsigned"
out sslv(( S_WIDTH_G- 1) downto 0)
A_WIDTH_Ginteger range 2 to 48:= 2
B_WIDTH_Ginteger range 2 to 48:= 2
in aslv(( A_WIDTH_G- 1) downto 0) :=( others => '0')
B_TYPE_Gstring := "unsigned"
A_TYPE_Gstring := "unsigned"