Technical discussions related to Analog Devices DSPs (including Blackfin, TigerSHARC, SHARC and ADSP-21xx DSPs).
|
Hi, Can anyone guide me how to implement reciprocal of a value. 1/x where x is an integer. Can I use approximation functions? Hari |
|
|
|
The code below was taken from one of the Analog Devices manuals and prettied
up a little. /************************************************************************** * * Float_Divide * Perform a floating point division of two numbers. * * Calling Parameters: * F0 = Numerator, * F1 = Denominator. * * Registers Modified: * F0, F7, F11, F12. * * Return Value: * F0 = F0/F1. * **************************************************************************/ Float_Divide: F11=2.0; F7=PASS F0, F12=F1; // Move numerator to F7, denominator to F12. F0=RECIPS F12; /*Get 4 bit seed R0=1/D*/ F12=F0*F12; /*D' = D*R0*/ F7=F0*F7, F0=F11-F12; /*F0=R1=2-D', F7=N*R0*/ F12=F0*F12; /*F12=D'=D'*R1*/ F7=F0*F7, F0=F11-F12; /*F7=N*R0*R1, F0=R2=2-D'*/ RTS (DB), F12=F0*F12; /*F12=D'=D'*R2*/ F7=F0*F7, F0=F11-F12; /*F7=N*R0*R1*R2, F0=R3=2-D'*/ F0=F0*F7; /*F0=N*R0*R1*R2*R3*/ ************************************************* Patrick Noffke QTI Color Registration Systems Sussex, WI ************************************************* ----- Original Message ----- From: "Hari Krishna Vuppaladhadiam" <> To: <> Sent: Wednesday, February 23, 2000 1:22 PM Subject: [adsp] Reciprocal function > Hi, > Can anyone guide me how to implement reciprocal of a value. > > 1/x where x is an integer. > > Can I use approximation functions? > > Hari |
|
Is there a source on Fixed Point Implementation for 1/x where x is an integer (16-bit)? Regards Hari -----Original Message----- From: Patrick Noffke <> To: <> Date: Wednesday, February 23, 2000 12:38 PM Subject: [adsp] Re: Reciprocal function >The code below was taken from one of the Analog Devices manuals and prettied up >a little. >/**************************************************************************< br /> >* >* Float_Divide >* Perform a floating point division of two numbers. >* >* Calling Parameters: >* F0 = Numerator, >* F1 = Denominator. >* >* Registers Modified: >* F0, F7, F11, F12. >* >* Return Value: >* F0 = F0/F1. >* >**************************************************************************/< br /> >Float_Divide: > F11=2.0; > F7=PASS F0, F12=F1; // Move numerator to F7, denominator to F12. > > F0=RECIPS F12; /*Get 4 bit seed R0=1/D*/ > F12=F0*F12; /*D' = D*R0*/ > F7=F0*F7, F0=F11-F12; /*F0=R1=2-D', F7=N*R0*/ > F12=F0*F12; /*F12=D'=D'*R1*/ > F7=F0*F7, F0=F11-F12; /*F7=N*R0*R1, F0=R2=2-D'*/ > RTS (DB), F12=F0*F12; /*F12=D'=D'*R2*/ > F7=F0*F7, F0=F11-F12; /*F7=N*R0*R1*R2, F0=R3=2-D'*/ > F0=F0*F7; /*F0=N*R0*R1*R2*R3*/ >************************************************* >Patrick Noffke >QTI Color Registration Systems >Sussex, WI >************************************************* >----- Original Message ----- >From: "Hari Krishna Vuppaladhadiam" <> >To: <> >Sent: Wednesday, February 23, 2000 1:22 PM >Subject: [adsp] Reciprocal function >> Hi, >> Can anyone guide me how to implement reciprocal of a value. >> >> 1/x where x is an integer. >> >> Can I use approximation functions? >> >> Hari > > > |
|
Hi, If you are using Sharc processor you can use the function Fn = RECIPS Fx Floating point representation of input in Fx is needed. Please refer to Manual of Sharc page B-39 for the description of the fuction. Regards, Anoop On Wed, 23 Feb 2000, Hari Krishna Vuppaladhadiam wrote: > Hi, > Can anyone guide me how to implement reciprocal of a value. > > 1/x where x is an integer. > > Can I use approximation functions? > > Hari > > ------------------------------------------------------------------------ > To Join: Send an email to > To Post: Send an email to > To Leave: Send an email to > Archives: http://www.egroups.com/group/adsp > Other Groups: http://www.dsprelated.com > > ------------------------------------------------------------------------ > *** Got Questions? Get Answers. Got Answers? Get Paid. *** > Sign up at Infomarco.com and you can win $30,000 cash or a trip to China. > http://click.egroups.com/1/1251/3/_/8508/_/951333883/ > > -- Create a poll/survey for your group! > -- http://www.egroups.com/vote?listname=adsp&m=1 |
|
Hi,
This code is from the Analog Devices application
book:
.MODULE Signed_SP_Divide;
{
Signed Single-Precision Divide Calling
Parameters
AF = MSW of dividend AY0 = LSW of dividend AX0 = 16-bit divisor Return Values
AY0 = 16-bit result Altered
Registers
AY0, AF Computation
Time
17 cycles }
.ENTRY sdivs;
sdivs: DIVS
AF,AX0; &
nbsp; &nb
sp; {Compute sign bit}
DIVQ AX0; DIVQ AX0; DIVQ AX0; {Compute 15 quotient bits} DIVQ AX0; DIVQ AX0; DIVQ AX0; DIVQ AX0; DIVQ AX0; DIVQ AX0; DIVQ AX0; DIVQ AX0; DIVQ AX0; DIVQ AX0; DIVQ AX0; DIVQ AX0; RTS; .ENDMOD;
Check out:
http://www.analog.com/techsupt/software/dsp/app_note/21xx_book.html
Regards,
Per Johan
>Is there a source on Fixed Point Implementation for 1/x where x is
an
>integer (16-bit)? >Regards >Hari -----Original Message----- >From: Patrick Noffke <p...@QTIWORLD.COM> >To: a...@eGroups.com <a...@eGroups.com> >Date: Wednesday, February 23, 2000 12:38 PM >Subject: [adsp] Re: Reciprocal function>The code below was taken from one of the Analog Devices manuals and prettied up >a little.>/******************************************************************** ****** >* >* Float_Divide >* Perform a floating point division of two numbers. >* >* Calling Parameters: >* F0 = Numerator, >* F1 = Denominator. >* >* Registers Modified: >* F0, F7, F11, F12. >* >* Return Value: >* F0 = F0/F1. >* >************************************************************************** / >Float_Divide: > F11=2.0; > F7=PASS F0, F12=F1; // Move numerator to F7, denominator to F12. > > F0=RECIPS F12; /*Get 4 bit seed R0=1/D*/ > F12=F0*F12; &nb sp; /*D' = D*R0*/ > F7=F0*F7, F0=F11-F12; /*F0=R1=2-D', F7=N*R0*/ > F12=F0*F12; &nb sp; /*F12=D'=D'*R1*/ > F7=F0*F7, F0=F11-F12; /*F7=N*R0*R1, F0=R2=2-D'*/ > RTS (DB), F12=F0*F12; /*F12=D'=D'*R2*/ > F7=F0*F7, F0=F11-F12; /*F7=N*R0*R1*R2, F0=R3=2-D'*/ > F0=F0*F7;   ; /*F0=N*R0*R1*R2*R3*/>************************************************* >Patrick Noffke >QTI Color Registration Systems >Sussex, WI >************************************************* >----- Original Message ----- >From: "Hari Krishna Vuppaladhadiam" <h...@chiplogic.com> >To: <a...@eGroups.com> >Sent: Wednesday, February 23, 2000 1:22 PM >Subject: [adsp] Reciprocal function>> Hi, >> Can anyone guide me how to implement reciprocal of a value. >> >> 1/x where x is an integer. >> >> Can I use approximation functions? >> >> Hari >> > ------------------------------------------------------------------------ To Join: Send an email to a...@egroups.com To Post: Send an email to a...@egroups.com To Leave: Send an email to a...@egroups.com Archives: http://www.egroups.com/group/adsp Other Groups: http://www.dsprelated.com ------------------------------------------------------------------------ -- Check out your group's private Chat room -- http://www.egroups.com/ChatPage?listName=adsp&m=1 Vennlig hilsen
Per Johan Vannebo Gemini Communication AS |