| 1 |
2 |
bigsascha3 |
----------------------------------------------------------------------------------
|
| 2 |
|
|
-- Company:
|
| 3 |
|
|
-- Engineer:
|
| 4 |
|
|
--
|
| 5 |
|
|
-- Create Date: 16:31:58 02/02/2013
|
| 6 |
|
|
-- Design Name:
|
| 7 |
|
|
-- Module Name: dsp_unit - Behavioral
|
| 8 |
|
|
-- Project Name:
|
| 9 |
|
|
-- Target Devices:
|
| 10 |
|
|
-- Tool versions:
|
| 11 |
|
|
-- Description:
|
| 12 |
|
|
--
|
| 13 |
|
|
-- Dependencies:
|
| 14 |
|
|
--
|
| 15 |
|
|
-- Revision:
|
| 16 |
|
|
-- Revision 0.01 - File Created
|
| 17 |
|
|
-- Additional Comments:
|
| 18 |
|
|
--
|
| 19 |
|
|
----------------------------------------------------------------------------------
|
| 20 |
|
|
library IEEE;
|
| 21 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
| 22 |
|
|
|
| 23 |
|
|
Library UNISIM;
|
| 24 |
|
|
use UNISIM.vcomponents.all;
|
| 25 |
|
|
|
| 26 |
|
|
-- Uncomment the following library declaration if using
|
| 27 |
|
|
-- arithmetic functions with Signed or Unsigned values
|
| 28 |
|
|
--use IEEE.NUMERIC_STD.ALL;
|
| 29 |
|
|
|
| 30 |
|
|
-- Uncomment the following library declaration if instantiating
|
| 31 |
|
|
-- any Xilinx primitives in this code.
|
| 32 |
|
|
--library UNISIM;
|
| 33 |
|
|
--use UNISIM.VComponents.all;
|
| 34 |
|
|
|
| 35 |
|
|
entity dsp_unit is
|
| 36 |
|
|
generic (MULT_REG : natural := 1;
|
| 37 |
|
|
MULT_STRING : string := "MULT_S");
|
| 38 |
|
|
port (clk, rst : in std_logic;
|
| 39 |
|
|
a : in std_logic_vector(23 downto 0);
|
| 40 |
|
|
b : in std_logic_vector (16 downto 0);
|
| 41 |
|
|
c : in std_logic_vector (32 downto 0);
|
| 42 |
|
|
comp : in std_logic; -- 1 for a*b > c ; 0 for a*b <=c
|
| 43 |
|
|
sub : in std_logic;
|
| 44 |
|
|
acc : in std_logic; -- 0 for add; 1 for accumulate
|
| 45 |
|
|
p: out std_logic_vector (35 downto 0);
|
| 46 |
|
|
pattern_detect : out std_logic;
|
| 47 |
|
|
ovf, udf : out std_logic);
|
| 48 |
|
|
end dsp_unit;
|
| 49 |
|
|
|
| 50 |
|
|
architecture Behavioral of dsp_unit is
|
| 51 |
|
|
|
| 52 |
|
|
signal one : std_logic;
|
| 53 |
|
|
signal zero : std_logic;
|
| 54 |
|
|
|
| 55 |
|
|
signal opmode : std_logic_vector (6 downto 0);
|
| 56 |
|
|
signal alumode : std_logic_vector (3 downto 0);
|
| 57 |
|
|
signal carry_in : std_logic;
|
| 58 |
|
|
|
| 59 |
|
|
signal a_input : std_logic_vector (29 downto 0);
|
| 60 |
|
|
signal b_input : std_logic_vector (17 downto 0);
|
| 61 |
|
|
signal c_input : std_logic_vector (47 downto 0);
|
| 62 |
|
|
signal p_output: std_logic_vector (47 downto 0);
|
| 63 |
|
|
|
| 64 |
|
|
begin
|
| 65 |
|
|
|
| 66 |
|
|
one <= '1';
|
| 67 |
|
|
zero <= '0';
|
| 68 |
|
|
|
| 69 |
|
|
|
| 70 |
|
|
opmode <= "0110101" when acc = '0' else
|
| 71 |
|
|
"0100101";
|
| 72 |
|
|
|
| 73 |
|
|
alumode <= "0000" when sub = '0' else
|
| 74 |
|
|
"0011" when (sub = '1' and comp = '0') else
|
| 75 |
|
|
"0001";
|
| 76 |
|
|
|
| 77 |
|
|
carry_in <= '1' when (sub = '1' and comp = '1') else
|
| 78 |
|
|
'0';
|
| 79 |
|
|
|
| 80 |
|
|
p <= p_output (35 downto 0);
|
| 81 |
|
|
|
| 82 |
|
|
a_input (29 downto 24) <= (others =>'0');
|
| 83 |
|
|
a_input (23 downto 0) <= a;
|
| 84 |
|
|
|
| 85 |
|
|
b_input (17) <= '0';
|
| 86 |
|
|
b_input (16 downto 0) <= b;
|
| 87 |
|
|
|
| 88 |
|
|
c_input (47 downto 33) <= (others =>'0');
|
| 89 |
|
|
c_input (32 downto 0) <= c;
|
| 90 |
|
|
|
| 91 |
|
|
DSP48E_inst : DSP48E
|
| 92 |
|
|
generic map (
|
| 93 |
|
|
ACASCREG => 1, -- Number of pipeline registers between
|
| 94 |
|
|
-- A/ACIN input and ACOUT output, 0, 1, or 2
|
| 95 |
|
|
ALUMODEREG => 1, -- Number of pipeline registers on ALUMODE input, 0 or 1
|
| 96 |
|
|
AREG => 1, -- Number of pipeline registers on the A input, 0, 1 or 2
|
| 97 |
|
|
AUTORESET_PATTERN_DETECT => FALSE, -- Auto-reset upon pattern detect, TRUE or FALSE
|
| 98 |
|
|
AUTORESET_PATTERN_DETECT_OPTINV => "MATCH", -- Reset if "MATCH" or "NOMATCH"
|
| 99 |
|
|
A_INPUT => "DIRECT", -- Selects A input used, "DIRECT" (A port) or "CASCADE" (ACIN port)
|
| 100 |
|
|
BCASCREG => 1, -- Number of pipeline registers between B/BCIN input and BCOUT output, 0, 1, or 2
|
| 101 |
|
|
BREG => 1, -- Number of pipeline registers on the B input, 0, 1 or 2
|
| 102 |
|
|
B_INPUT => "DIRECT", -- Selects B input used, "DIRECT" (B port) or "CASCADE" (BCIN port)
|
| 103 |
|
|
CARRYINREG => 1, -- Number of pipeline registers for the CARRYIN input, 0 or 1
|
| 104 |
|
|
CARRYINSELREG => 1, -- Number of pipeline registers for the CARRYINSEL input, 0 or 1
|
| 105 |
|
|
CREG => 1, -- Number of pipeline registers on the C input, 0 or 1
|
| 106 |
|
|
MASK => "000000000000000000000000000000000000000000000000", -- 48-bit Mask value for pattern detect
|
| 107 |
|
|
--change from 2 pipeline stages for DSP or 1 pipeline stage for DSP
|
| 108 |
|
|
MREG => MULT_REG, -- Number of multiplier pipeline registers, 0 or 1
|
| 109 |
|
|
|
| 110 |
|
|
MULTCARRYINREG => 1, -- Number of pipeline registers for multiplier carry in bit, 0 or 1
|
| 111 |
|
|
OPMODEREG => 1, -- Number of pipeline registers on OPMODE input, 0 or 1
|
| 112 |
|
|
PATTERN =>"000000000000000000000000000000000000000000000000", -- 48-bit Pattern match for pattern detect
|
| 113 |
|
|
PREG => 1, -- Number of pipeline registers on the P output, 0 or 1
|
| 114 |
|
|
SIM_MODE => "SAFE", -- Simulation: "SAFE" vs "FAST", see "Synthesis and Simulation
|
| 115 |
|
|
-- Design Guide" for details
|
| 116 |
|
|
SEL_MASK => "MASK", -- Select mask value between the "MASK" value or the value on the "C" port
|
| 117 |
|
|
SEL_PATTERN => "PATTERN", -- Select pattern value between the "PATTERN" value or the value on the "C" port
|
| 118 |
|
|
SEL_ROUNDING_MASK => "SEL_MASK", -- "SEL_MASK", "MODE1", "MODE2"
|
| 119 |
|
|
USE_MULT => MULT_STRING, -- Select multiplier usage, "MULT" (MREG => 0),
|
| 120 |
|
|
-- "MULT_S" (MREG => 1), "NONE" (not using multiplier)
|
| 121 |
|
|
USE_PATTERN_DETECT => "PATDET", -- Enable pattern detect, "PATDET", "NO_PATDET"
|
| 122 |
|
|
USE_SIMD => "ONE48") -- SIMD selection, "ONE48", "TWO24", "FOUR12"
|
| 123 |
|
|
port map (
|
| 124 |
|
|
ACOUT => open, -- 30-bit A port cascade output
|
| 125 |
|
|
BCOUT => open, -- 18-bit B port cascade output
|
| 126 |
|
|
CARRYCASCOUT => open, -- 1-bit cascade carry output
|
| 127 |
|
|
CARRYOUT => open, -- 4-bit carry output
|
| 128 |
|
|
MULTSIGNOUT => open, -- 1-bit multiplier sign cascade output
|
| 129 |
|
|
OVERFLOW => ovf, -- 1-bit overflow in add/acc output
|
| 130 |
|
|
P => p_output, -- 48-bit output
|
| 131 |
|
|
PATTERNBDETECT => open ,-- 1-bit active high pattern bar detect output
|
| 132 |
|
|
PATTERNDETECT => pattern_detect , -- 1-bit active high pattern detect output
|
| 133 |
|
|
PCOUT => open, -- 48-bit cascade output
|
| 134 |
|
|
UNDERFLOW => udf, -- 1-bit active high underflow in add/acc output
|
| 135 |
|
|
A => a_input, -- 30-bit A data input
|
| 136 |
|
|
ACIN => (others=>'0'), -- 30-bit A cascade data input
|
| 137 |
|
|
ALUMODE => alumode, -- 4-bit ALU control input
|
| 138 |
|
|
B => b_input, -- 18-bit B data input
|
| 139 |
|
|
BCIN => (others=>'0'), -- 18-bit B cascade input
|
| 140 |
|
|
C => c_input, -- 48-bit C data input
|
| 141 |
|
|
CARRYCASCIN => '0', -- 1-bit cascade carry input
|
| 142 |
|
|
CARRYIN => carry_in, -- 1-bit carry input signal
|
| 143 |
|
|
CARRYINSEL => "000", -- 3-bit carry select input
|
| 144 |
|
|
CEA1 => one, -- 1-bit active high clock enable input for 1st stage A registers
|
| 145 |
|
|
CEA2 => one, -- 1-bit active high clock enable input for 2nd stage A registers
|
| 146 |
|
|
CEALUMODE => one, -- 1-bit active high clock enable input for ALUMODE registers
|
| 147 |
|
|
CEB1 => one, -- 1-bit active high clock enable input for 1st stage B registers
|
| 148 |
|
|
CEB2 => one, -- 1-bit active high clock enable input for 2nd stage B registers
|
| 149 |
|
|
CEC => one, -- 1-bit active high clock enable input for C registers
|
| 150 |
|
|
CECARRYIN => one, -- 1-bit active high clock enable input for CARRYIN register
|
| 151 |
|
|
CECTRL => one, -- 1-bit active high clock enable input for OPMODE and carry registers
|
| 152 |
|
|
CEM => one, -- 1-bit active high clock enable input for multiplier registers
|
| 153 |
|
|
CEMULTCARRYIN => one, -- 1-bit active high clock enable for multiplier carry in register
|
| 154 |
|
|
CEP => one, -- 1-bit active high clock enable input for P registers
|
| 155 |
|
|
CLK => clk, -- Clock input
|
| 156 |
|
|
MULTSIGNIN => zero, -- 1-bit multiplier sign input
|
| 157 |
|
|
OPMODE => opmode, -- 7-bit operation mode input
|
| 158 |
|
|
PCIN => (others=>'0'), -- 48-bit P cascade input
|
| 159 |
|
|
RSTA => rst, -- 1-bit reset input for A pipeline registers
|
| 160 |
|
|
RSTALLCARRYIN => rst, -- 1-bit reset input for carry pipeline registers
|
| 161 |
|
|
RSTALUMODE => rst, -- 1-bit reset input for ALUMODE pipeline registers
|
| 162 |
|
|
RSTB => rst, -- 1-bit reset input for B pipeline registers
|
| 163 |
|
|
RSTC => rst, -- 1-bit reset input for C pipeline registers
|
| 164 |
|
|
RSTCTRL => rst, -- 1-bit reset input for OPMODE pipeline registers
|
| 165 |
|
|
RSTM => rst, -- 1-bit reset input for multiplier registers
|
| 166 |
|
|
RSTP => rst -- 1-bit reset input for P pipeline registers
|
| 167 |
|
|
);
|
| 168 |
|
|
|
| 169 |
|
|
|
| 170 |
|
|
|
| 171 |
|
|
end Behavioral;
|
| 172 |
|
|
|