I wanted something similar but could not get the synthesis tool to generate the circuit, so I instantiated my own.. here it is, you can change the INIT values of the LUT to get what you want.
-- MUX_ADD_VECTOR - when ADD = '1' add O = A + B else O = C
----------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; library UNISIM; use UNISIM.vcomponents.all;
port (A : in std_logic_vector (WIDTH-1 downto 0); B : in std_logic_vector (WIDTH-1 downto 0); C : in std_logic_vector (WIDTH-1 downto 0); ADD : in std_logic; O : out std_logic_vector (WIDTH-1 downto 0));
end MUX_ADD_VECTOR;
architecture XILINX_virtex of MUX_ADD_VECTOR is component LUT4_L generic(INIT : bit_vector); port (LO : out STD_ULOGIC; I0 : in STD_ULOGIC; I1 : in STD_ULOGIC; I2 : in STD_ULOGIC; I3 : in STD_ULOGIC); end component;
component MUXCY_L port(LO : out STD_ULOGIC; CI : in STD_ULOGIC; DI : in STD_ULOGIC; S : in STD_ULOGIC); end component;
component XORCY port(O : out STD_ULOGIC; CI : in STD_ULOGIC; LI : in STD_ULOGIC); end component;
component MULT_AND port(LO : out STD_ULOGIC; I0 : in STD_ULOGIC; I1 : in STD_ULOGIC); end component;
Apparently the mapper tries many (or even all) factorizations of your logic but it does not reorder the circuit. Therefore, if you have an adder followed by a mux you get two levels of logic. You need to write down a formulation were the adder follows the remining logic:
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.