OpenCores
URL https://opencores.org/ocsvn/yac/yac/trunk

Subversion Repositories yac

[/] [yac/] [trunk/] [c_octave/] [cordic_iterative.c] - Diff between revs 11 and 13

Show entire file | Details | Blame | View Log

Rev 11 Rev 13
Line 60... Line 60...
#ifndef OR32_TARGET
#ifndef OR32_TARGET
 #include "mex.h"
 #include "mex.h"
#endif 
#endif 
 
 
/* enable debug output */
/* enable debug output */
<<<<<<< HEAD
 
<<<<<<< HEAD
 
#define PRINT_DEBUG        0
#define PRINT_DEBUG        0
=======
 
#define PRINT_DEBUG  0
 
>>>>>>> initial commit
 
=======
 
#define PRINT_DEBUG        0
 
>>>>>>> Updated C and RTL model as well as the documentation
 
 
 
/* #define CORDIC_ROUNDING    0.5 */
/* #define CORDIC_ROUNDING    0.5 */
#define CORDIC_ROUNDING    0.0
#define CORDIC_ROUNDING    0.0
 
 
 
 
Line 88... Line 80...
#ifndef OR32_TARGET
#ifndef OR32_TARGET
 #define PRINT  mexPrintf
 #define PRINT  mexPrintf
#endif
#endif
 
 
 
 
<<<<<<< HEAD
 
<<<<<<< HEAD
 
=======
 
 
 
long long int ov_check( long long int * value, long long int length )
 
{
 
   long long int mask = (1<<length)-1;
 
   long long int result = 0;
 
   long long int min = -((long long int)1<<length);
 
   long long int max =  ((long long int)1<<length);
 
   if( *value > max || *value < min )
 
       result = *value;
 
   /* *value &= mask; */
 
   return result;
 
}
 
 
 
 
 
 
 
>>>>>>> initial commit
 
=======
 
>>>>>>> Updated C and RTL model as well as the documentation
 
void cordic_int( long long int   x_i,
void cordic_int( long long int   x_i,
                 long long int   y_i,
                 long long int   y_i,
                 long long int   a_i,
                 long long int   a_i,
                 long long int * x_o,
                 long long int * x_o,
                 long long int * y_o,
                 long long int * y_o,
Line 131... Line 102...
                                   char*         msg );
                                   char*         msg );
int            cordic_int_init   ( long long int *x,
int            cordic_int_init   ( long long int *x,
                                   long long int *y,
                                   long long int *y,
                                   long long int *a,
                                   long long int *a,
                                   int           mode,
                                   int           mode,
<<<<<<< HEAD
 
<<<<<<< HEAD
 
                                   int           A_WIDTH,
 
                                   int           XY_WIDTH );
 
=======
 
                                   int           A_WIDTH );
 
>>>>>>> initial commit
 
=======
 
                                   int           A_WIDTH,
                                   int           A_WIDTH,
                                   int           XY_WIDTH );
                                   int           XY_WIDTH );
>>>>>>> Updated C and RTL model as well as the documentation
 
void           cordic_int_rm_gain( long long int *x,
void           cordic_int_rm_gain( long long int *x,
                                   long long int *y,
                                   long long int *y,
                                   int           mode,
                                   int           mode,
                                   int           rm_gain );
                                   int           rm_gain );
int            cordic_int_rotate(  long long int * x,
int            cordic_int_rotate(  long long int * x,
Line 270... Line 232...
   long long int x;
   long long int x;
   long long int y;
   long long int y;
   long long int a;
   long long int a;
   long long int s;
   long long int s;
   int ov;
   int ov;
<<<<<<< HEAD
 
<<<<<<< HEAD
 
   int it = 0;
   int it = 0;
=======
 
   int it;
 
>>>>>>> initial commit
 
=======
 
   int it = 0;
 
>>>>>>> Updated C and RTL model as well as the documentation
 
 
 
 
 
 
 
 
 
   /* total with, including guard bits */
   /* total with, including guard bits */
   int XY_WIDTH_G = XY_WIDTH + GUARD_BITS;
   int XY_WIDTH_G = XY_WIDTH + GUARD_BITS;
 
 
   cordic_int_dbg( x_i, y_i, a_i, mode, 0, "input" );
   cordic_int_dbg( x_i, y_i, a_i, mode, 0, "input" );
 
 
<<<<<<< HEAD
 
<<<<<<< HEAD
 
   if( !cordic_int_init( &x_i, &y_i, &a_i, mode, A_WIDTH, XY_WIDTH ) )
 
   {
 
 
 
      it = cordic_int_rotate( &x_i, &y_i, &a_i, mode, A_WIDTH );
 
 
 
      cordic_int_rm_gain( &x_i, &y_i, mode, RM_GAIN );
 
   }
 
=======
 
   cordic_int_init( &x_i, &y_i, &a_i, mode, A_WIDTH );
 
 
 
   it = cordic_int_rotate( &x_i, &y_i, &a_i, mode, A_WIDTH );
 
=======
 
   if( !cordic_int_init( &x_i, &y_i, &a_i, mode, A_WIDTH, XY_WIDTH ) )
   if( !cordic_int_init( &x_i, &y_i, &a_i, mode, A_WIDTH, XY_WIDTH ) )
   {
   {
>>>>>>> Updated C and RTL model as well as the documentation
 
 
 
      it = cordic_int_rotate( &x_i, &y_i, &a_i, mode, A_WIDTH );
      it = cordic_int_rotate( &x_i, &y_i, &a_i, mode, A_WIDTH );
 
 
<<<<<<< HEAD
 
>>>>>>> initial commit
 
=======
 
      cordic_int_rm_gain( &x_i, &y_i, mode, RM_GAIN );
      cordic_int_rm_gain( &x_i, &y_i, mode, RM_GAIN );
   }
   }
>>>>>>> Updated C and RTL model as well as the documentation
 
 
 
   *x_o  = x_i;
   *x_o  = x_i;
   *y_o  = y_i;
   *y_o  = y_i;
   *a_o  = a_i;
   *a_o  = a_i;
   *it_o = it;
   *it_o = it;
Line 332... Line 267...
 
 
int cordic_int_init( long long int *x,
int cordic_int_init( long long int *x,
                     long long int *y,
                     long long int *y,
                     long long int *a,
                     long long int *a,
                     int           mode,
                     int           mode,
<<<<<<< HEAD
 
<<<<<<< HEAD
 
                     int           A_WIDTH,
 
                     int           XY_WIDTH )
 
=======
 
                     int           A_WIDTH )
 
>>>>>>> initial commit
 
=======
 
                     int           A_WIDTH,
                     int           A_WIDTH,
                     int           XY_WIDTH )
                     int           XY_WIDTH )
>>>>>>> Updated C and RTL model as well as the documentation
 
{
{
   int already_done = 0;
   int already_done = 0;
 
 
 
 
   long long int PI   = ( long long int )( M_PI * pow( 2, A_WIDTH-1 ) + 0.5 );
   long long int PI   = ( long long int )( M_PI * pow( 2, A_WIDTH-1 ) + 0.5 );
   long long int PI_H = (long long int)(  M_PI * pow( 2, A_WIDTH-2 ) + 0.5  );
   long long int PI_H = (long long int)(  M_PI * pow( 2, A_WIDTH-2 ) + 0.5  );
<<<<<<< HEAD
 
<<<<<<< HEAD
 
<<<<<<< HEAD
 
 
 
   long long int XY_MAX = pow( 2, XY_WIDTH-1 )-1;
   long long int XY_MAX = pow( 2, XY_WIDTH-1 )-1;
 
 
   cordic_int_dbg( *x, *y, *a, mode, 0, "before init" );
   cordic_int_dbg( *x, *y, *a, mode, 0, "before init" );
 
 
 
 
=======
 
 
 
 
 
   cordic_int_dbg( *x, *y, *a, mode, 0, "before init" );
 
>>>>>>> initial commit
 
=======
 
 
 
=======
 
 
 
>>>>>>> Removed some bugs regarding pre-rotation and negative numbers in the wb wrapper
 
   long long int XY_MAX = pow( 2, XY_WIDTH-1 )-1;
 
 
 
   cordic_int_dbg( *x, *y, *a, mode, 0, "before init" );
 
 
 
 
 
<<<<<<< HEAD
 
>>>>>>> Updated C and RTL model as well as the documentation
 
=======
 
   if( 0 != ( mode &  C_FLAG_VEC_ROT ) && *y == 0 )
   if( 0 != ( mode &  C_FLAG_VEC_ROT ) && *y == 0 )
   {
   {
       already_done = 1;
       already_done = 1;
       *a = 0;
       *a = 0;
       #if PRINT_DEBUG > 0
       #if PRINT_DEBUG > 0
Line 392... Line 297...
       PRINT("zero angular input\n" );
       PRINT("zero angular input\n" );
       #endif
       #endif
       already_done = 1;
       already_done = 1;
   }
   }
 
 
>>>>>>> Removed some bugs regarding pre-rotation and negative numbers in the wb wrapper
 
   /* Circular rotation mode */
   /* Circular rotation mode */
   else if( 0          == ( mode &  C_FLAG_VEC_ROT )    &&
   else if( 0          == ( mode &  C_FLAG_VEC_ROT )    &&
       C_MODE_CIR == ( mode &  C_MODE_MSK     )  )
       C_MODE_CIR == ( mode &  C_MODE_MSK     )  )
   {
   {
 
 
Line 429... Line 333...
 
 
   /* circular vector mode */
   /* circular vector mode */
   else if ( 0          != ( mode &  C_FLAG_VEC_ROT )    &&
   else if ( 0          != ( mode &  C_FLAG_VEC_ROT )    &&
             C_MODE_CIR == ( mode &  C_MODE_MSK     )  )
             C_MODE_CIR == ( mode &  C_MODE_MSK     )  )
   {
   {
<<<<<<< HEAD
 
<<<<<<< HEAD
 
=======
 
>>>>>>> Updated C and RTL model as well as the documentation
 
 
 
      if( *x == XY_MAX && *y == XY_MAX )
      if( *x == XY_MAX && *y == XY_MAX )
      {
      {
         #if PRINT_DEBUG > 0
         #if PRINT_DEBUG > 0
         PRINT( "All max, skipping rotations 1\n" );
         PRINT( "All max, skipping rotations 1\n" );
Line 498... Line 398...
         #if PRINT_DEBUG > 0
         #if PRINT_DEBUG > 0
         PRINT( "Fixed value of -pi/2, skipping rotations\n" );
         PRINT( "Fixed value of -pi/2, skipping rotations\n" );
         #endif
         #endif
      }
      }
      else if( *x < 0  && *y >= 0 )
      else if( *x < 0  && *y >= 0 )
<<<<<<< HEAD
 
=======
 
      if( *x < 0 && *y > 0 )
 
>>>>>>> initial commit
 
=======
 
>>>>>>> Updated C and RTL model as well as the documentation
 
      {
      {
         *x = -*x;
         *x = -*x;
         *y = -*y;
         *y = -*y;
         *a =  PI;
         *a =  PI;
          #if PRINT_DEBUG > 0
          #if PRINT_DEBUG > 0
<<<<<<< HEAD
 
<<<<<<< HEAD
 
          PRINT("pre-rotation from second to the fourth quadrant\n" );
 
          #endif
 
      }
 
      else if( *x < 0 && *y <  0 )
 
=======
 
          PRINT("align from second quadrand\n" );
 
          #endif
 
      }
 
      else if( *x < 0 && *y < 0 )
 
>>>>>>> initial commit
 
=======
 
          PRINT("pre-rotation from second to the fourth quadrant\n" );
          PRINT("pre-rotation from second to the fourth quadrant\n" );
          #endif
          #endif
      }
      }
      else if( *x < 0 && *y <  0 )
      else if( *x < 0 && *y <  0 )
>>>>>>> Updated C and RTL model as well as the documentation
 
      {
      {
         *x = -*x;
         *x = -*x;
         *y = -*y;
         *y = -*y;
         *a = -PI;
         *a = -PI;
          #if PRINT_DEBUG > 0
          #if PRINT_DEBUG > 0
<<<<<<< HEAD
 
<<<<<<< HEAD
 
          PRINT("pre-rotation from third to first quadrand\n" );
          PRINT("pre-rotation from third to first quadrand\n" );
          #endif
          #endif
      }
      }
=======
 
          PRINT("align from third quadrand\n" );
 
          #endif
 
      }
 
      else if( *x < 0 && *y == 0 )
 
      {
 
         *a           = PI;
 
         already_done = 1;
 
      }
 
>>>>>>> initial commit
 
=======
 
          PRINT("pre-rotation from third to first quadrand\n" );
 
          #endif
 
      }
 
>>>>>>> Updated C and RTL model as well as the documentation
 
      else
      else
         *a = 0;
         *a = 0;
   }
   }
   /* linear vector mode */
   /* linear vector mode */
   else if ( 0          != ( mode &  C_FLAG_VEC_ROT )    &&
   else if ( 0          != ( mode &  C_FLAG_VEC_ROT )    &&
Line 567... Line 430...
         *y = -*y;
         *y = -*y;
      }
      }
      *a = 0;
      *a = 0;
   }
   }
   cordic_int_dbg( *x, *y, *a, mode, 0, "after init" );
   cordic_int_dbg( *x, *y, *a, mode, 0, "after init" );
<<<<<<< HEAD
 
<<<<<<< HEAD
 
   return already_done;
 
=======
 
 
 
>>>>>>> initial commit
 
=======
 
   return already_done;
   return already_done;
>>>>>>> Updated C and RTL model as well as the documentation
 
}
}
 
 
 
 
 
 
void cordic_int_dbg(  long long int x,
void cordic_int_dbg(  long long int x,
Line 692... Line 547...
      }
      }
      cordic_int_dbg( *x, *y, *a, mode, it, "after rotation" );
      cordic_int_dbg( *x, *y, *a, mode, it, "after rotation" );
 
 
      /* abort condition */
      /* abort condition */
      if( ( mode & C_FLAG_VEC_ROT  ) == 0 &&
      if( ( mode & C_FLAG_VEC_ROT  ) == 0 &&
<<<<<<< HEAD
 
<<<<<<< HEAD
 
          ( *a == 0 /* || *a == -1 */ ) )
 
=======
 
          ( *a == 0 || *a == -1 ) )
 
>>>>>>> initial commit
 
=======
 
          ( *a == 0 /* || *a == -1 */ ) )
          ( *a == 0 /* || *a == -1 */ ) )
>>>>>>> Updated C and RTL model as well as the documentation
 
          break;
          break;
      if( ( mode & C_FLAG_VEC_ROT  ) == 0 &&
      if( ( mode & C_FLAG_VEC_ROT  ) == 0 &&
          ( *a == alst ) )
          ( *a == alst ) )
          break;
          break;
 
 
      if( ( mode & C_FLAG_VEC_ROT  ) != 0 &&
      if( ( mode & C_FLAG_VEC_ROT  ) != 0 &&
<<<<<<< HEAD
 
<<<<<<< HEAD
 
          ( *y == 0 /*|| *y == -1 */ ) )
 
=======
 
          ( *y == 0 || *y == -1 ) )
 
>>>>>>> initial commit
 
=======
 
          ( *y == 0 /*|| *y == -1 */ ) )
          ( *y == 0 /*|| *y == -1 */ ) )
>>>>>>> Updated C and RTL model as well as the documentation
 
          break;
          break;
      if( ( mode & C_FLAG_VEC_ROT  ) != 0 &&
      if( ( mode & C_FLAG_VEC_ROT  ) != 0 &&
          ( *y == ylst ) )
          ( *y == ylst ) )
          break;
          break;
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.