N
Nemesis
Guest
Hi all,
I have to implement a 24 bit signed adder. I have two 2's
complement numbers on 24, and I'd like to get their sum on 25 bit signed
(2's complement). I already tried the Xilinx IP Adder core, but I'd like
to implement this adder in VHDL.
I wrote this module:
**********************************************************************
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_SIGNED.ALL;
entity adder24 is
port (
A : in STD_LOGIC_VECTOR(23 downto 0);
B : in STD_LOGIC_VECTOR(23 downto 0);
CLK : in STD_LOGIC;
RESET : in STD_LOGIC;
OUTPUT : out STD_LOGIC_VECTOR(24 downto 0)
);
end adder24;
architecture Behavioral of adder24 is
begin
----------------------------------------------------------------
process (CLK,RESET)
variable A_INT : SIGNED (23 downto 0);
variable B_INT : SIGNED (23 downto 0);
variable OUTPUT_VAR : SIGNED (24 downto 0);
begin
if RESET='1' then
OUTPUT <= "0000000000000000000000000";
elsif CLK='1' and CLK'event then
A_INT :=SIGNED(A);
B_INT :=SIGNED(B);
OUTPUT_VAR := A_INT + B_INT;
OUTPUT <= STD_LOGIC_VECTOR(OUTPUT_VAR);
end if;
end process;
----------------------------------------------------------------
end Behavioral;
**********************************************************************
I'm able to synthesize it (I get a warning on the OUTPUT_VAR size) but
modelsim returns me this error:
Length of actual is 24. Length of expected is 25.
so I can't simulate it.
How can I write a 24bit adder with a 25bit output, and with input and
output signed?
--
Proofread carefully to see if you any words out.
|\ | |HomePage : http://nem01.altervista.org
| \|emesis |XPN (my nr): http://xpn.altervista.org
I have to implement a 24 bit signed adder. I have two 2's
complement numbers on 24, and I'd like to get their sum on 25 bit signed
(2's complement). I already tried the Xilinx IP Adder core, but I'd like
to implement this adder in VHDL.
I wrote this module:
**********************************************************************
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_SIGNED.ALL;
entity adder24 is
port (
A : in STD_LOGIC_VECTOR(23 downto 0);
B : in STD_LOGIC_VECTOR(23 downto 0);
CLK : in STD_LOGIC;
RESET : in STD_LOGIC;
OUTPUT : out STD_LOGIC_VECTOR(24 downto 0)
);
end adder24;
architecture Behavioral of adder24 is
begin
----------------------------------------------------------------
process (CLK,RESET)
variable A_INT : SIGNED (23 downto 0);
variable B_INT : SIGNED (23 downto 0);
variable OUTPUT_VAR : SIGNED (24 downto 0);
begin
if RESET='1' then
OUTPUT <= "0000000000000000000000000";
elsif CLK='1' and CLK'event then
A_INT :=SIGNED(A);
B_INT :=SIGNED(B);
OUTPUT_VAR := A_INT + B_INT;
OUTPUT <= STD_LOGIC_VECTOR(OUTPUT_VAR);
end if;
end process;
----------------------------------------------------------------
end Behavioral;
**********************************************************************
I'm able to synthesize it (I get a warning on the OUTPUT_VAR size) but
modelsim returns me this error:
Length of actual is 24. Length of expected is 25.
so I can't simulate it.
How can I write a 24bit adder with a 25bit output, and with input and
output signed?
--
Proofread carefully to see if you any words out.
|\ | |HomePage : http://nem01.altervista.org
| \|emesis |XPN (my nr): http://xpn.altervista.org