K
Klaus Kleiner
Guest
Hello
I have a Dual Field Adder Entity, which is controlled by the control signal
fsel: If fsel is high the the
cout port is always 0 the adder performs a XOR operation, else this Adder
performs a normal addition with carry and sum.
Now i have the following problem: I have got 1 bit control signal for the
fsel. But i have to combine this 1
bit signal with a 32 bit input with a nand operation. How can i do this in
VHDL? Because for a logic operation as nand both operands need to be the
same length. Is there a trick? hope someone can give me a hint
Thanks a lot
library ieee;
use ieee.std_logic_1164.all;
entity dual_adder is
port (cin: in std_ulogic_vector(31 downto 0);
sin: in std_ulogic_vector(31 downto 0);
pin: in std_ulogic_vector(31 downto 0);
fsel: in std_ulogic;
cout: out std_ulogic_vector(31 downto 0);
sout: out std_ulogic_vector(31 downto 0)
);
end dual_adder;
architecture structural of dual_adder is
signal cinout : std_ulogic_vector(31 downto 0);
signal sinout : std_ulogic_vector(31 downto 0);
signal pinout : std_ulogic_vector(31 downto 0);
signal orout : std_ulogic_vector(31 downto 0);
begin
cinout <= not (cin and sin and fsel);
sinout <= cin xnor sin;
pinout <= pin nand
--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
orout <= cinout or pinout;
cout <= orout nand cinout;
sout <= pin xnor sinout;
end structural;
I have a Dual Field Adder Entity, which is controlled by the control signal
fsel: If fsel is high the the
cout port is always 0 the adder performs a XOR operation, else this Adder
performs a normal addition with carry and sum.
Now i have the following problem: I have got 1 bit control signal for the
fsel. But i have to combine this 1
bit signal with a 32 bit input with a nand operation. How can i do this in
VHDL? Because for a logic operation as nand both operands need to be the
same length. Is there a trick? hope someone can give me a hint
Thanks a lot
library ieee;
use ieee.std_logic_1164.all;
entity dual_adder is
port (cin: in std_ulogic_vector(31 downto 0);
sin: in std_ulogic_vector(31 downto 0);
pin: in std_ulogic_vector(31 downto 0);
fsel: in std_ulogic;
cout: out std_ulogic_vector(31 downto 0);
sout: out std_ulogic_vector(31 downto 0)
);
end dual_adder;
architecture structural of dual_adder is
signal cinout : std_ulogic_vector(31 downto 0);
signal sinout : std_ulogic_vector(31 downto 0);
signal pinout : std_ulogic_vector(31 downto 0);
signal orout : std_ulogic_vector(31 downto 0);
begin
cinout <= not (cin and sin and fsel);
sinout <= cin xnor sin;
pinout <= pin nand
--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
orout <= cinout or pinout;
cout <= orout nand cinout;
sout <= pin xnor sinout;
end structural;