Z
Zaki
Guest
Hello,
I want to design an ALU with signed and unsigned addition.
The problem is the overflow:
SIGNAL Sum : STD_LOGIC_VECTOR( 8 DOWNTO 0 );
SIGNAL ALU_output_mux : STD_LOGIC_VECTOR( 7 DOWNTO 0 );
SIGNAL Ainput, Binput : STD_LOGIC_VECTOR( 7 DOWNTO 0 );
Sum <= unsigned('0' & Ainput) + unsigned('0' & Binput);
ALU_output_mux <= Sum(7 DOWNTO 0) ;
Overflow <= Sum(8);
Overflow would be '1' when Sum is bigger than 255.
This works for unsigned addition well but I need that overflow for signed
values.
Why I cant write:
Overflow <= '1' when (Sum >= 128 or Sum < 127) else
'0';
Can someone help me?
Thx
I want to design an ALU with signed and unsigned addition.
The problem is the overflow:
SIGNAL Sum : STD_LOGIC_VECTOR( 8 DOWNTO 0 );
SIGNAL ALU_output_mux : STD_LOGIC_VECTOR( 7 DOWNTO 0 );
SIGNAL Ainput, Binput : STD_LOGIC_VECTOR( 7 DOWNTO 0 );
Sum <= unsigned('0' & Ainput) + unsigned('0' & Binput);
ALU_output_mux <= Sum(7 DOWNTO 0) ;
Overflow <= Sum(8);
Overflow would be '1' when Sum is bigger than 255.
This works for unsigned addition well but I need that overflow for signed
values.
Why I cant write:
Overflow <= '1' when (Sum >= 128 or Sum < 127) else
'0';
Can someone help me?
Thx