Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

signed addition problems and overflows

Status
Not open for further replies.

kannan2590

Member level 4
Joined
Sep 1, 2012
Messages
77
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
india
Activity points
2,321
i have studied and understood signed additions concept when overflow will occur and not.if both numbers are negative and answer is positive then overflow will be there . but when i am imlementing fir filter in vhdl and the overflow occurs while signed addition is there any solution to detect that overflow and i want to get correct output samples without the overflow problem. is there any permanent solution or code in vhdl. so that i can get correct output sample considering the overflow bit . is there any need to write code for overflow detection while addition along with fir filter code in vhdl.
 

i want to get correct output samples without the overflow problem
Strictly spoken, you'll only get correct output samples by providing enough extra bits before adding the numbers. In some situations, result saturation to maximal respectively minimal signed value is wanted, If you use IEEE fixedpoint libraries, you'll get features like saturation without writing your own code.

Working with numeric_std library, a function can easily provide addition with saturation

Code:
FUNCTION SUM (X1,X2: SIGNED) RETURN SIGNED IS
VARIABLE S:SIGNED(X1'length-1 downto 0);
  BEGIN
    S:=X1+X2;
    IF X1>=0 AND X2>=0 AND S<0 THEN
      S:= (others => '1');
      S(S'left):='0';
    ELSIF X1<0 AND X2<0 AND S>=0 THEN
      S(S'left-1 downto 0):= (others => '0');
      S(S'left):='1';
    END IF;		
  RETURN S;
END;
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top