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

Subversion Repositories yac

[/] [yac/] [trunk/] [rtl/] [vhdl/] [cordic_iterative_int.vhd] - Diff between revs 7 and 13

Show entire file | Details | Blame | View Log

Rev 7 Rev 13
Line 90... Line 90...
 
 
   constant MAX_A_WIDTH : natural := 34;
   constant MAX_A_WIDTH : natural := 34;
 
 
   -- Internal angle width
   -- Internal angle width
   constant A_WIDTH_I : natural := A_WIDTH+2;
   constant A_WIDTH_I : natural := A_WIDTH+2;
<<<<<<< HEAD
 
<<<<<<< HEAD
 
<<<<<<< HEAD
 
=======
 
>>>>>>> Updated C and RTL model as well as the documentation
 
 
 
=======
 
 
 
>>>>>>> Removed some bugs regarding pre-rotation and negative numbers in the wb wrapper
 
 
 
   constant SQRT2_REAL  : real    := 1.4142135623730951454746218587388284504413604;
   constant SQRT2_REAL  : real    := 1.4142135623730951454746218587388284504413604;
   constant PI_REAL     : real    := 3.1415926535897931159979634685441851615905762;
   constant PI_REAL     : real    := 3.1415926535897931159979634685441851615905762;
   constant PI          : integer := natural( round( PI_REAL    * real( 2**( A_WIDTH-1  ) ) ) );
   constant PI          : integer := natural( round( PI_REAL    * real( 2**( A_WIDTH-1  ) ) ) );
   constant PI_H        : integer := natural( round( PI_REAL    * real( 2**( A_WIDTH-2  ) ) ) );
   constant PI_H        : integer := natural( round( PI_REAL    * real( 2**( A_WIDTH-2  ) ) ) );
   constant SQRT2       : integer := natural( round( SQRT2_REAL * real( 2**( XY_WIDTH-1 ) ) ) );
   constant SQRT2       : integer := natural( round( SQRT2_REAL * real( 2**( XY_WIDTH-1 ) ) ) );
   constant XY_MAX      : integer := natural( 2**( XY_WIDTH-1)-1);
   constant XY_MAX      : integer := natural( 2**( XY_WIDTH-1)-1);
 
 
<<<<<<< HEAD
 
=======
 
 
 
   constant PI_REAL : real    := 3.1415926535897931159979634685441851615905762;
 
   constant PI      : integer := natural( PI_REAL * real( 2**( A_WIDTH-1 ) ) + 0.5 );
 
   constant PI_H    : integer := natural( PI_REAL * real( 2**( A_WIDTH-2 ) ) + 0.5 );
 
>>>>>>> initial commit
 
=======
 
>>>>>>> Updated C and RTL model as well as the documentation
 
 
 
   constant XY_WIDTH_G : natural := XY_WIDTH + GUARD_BITS;
   constant XY_WIDTH_G : natural := XY_WIDTH + GUARD_BITS;
 
 
 
 
 
 
Line 237... Line 220...
               state.mode     <= mode_i;
               state.mode     <= mode_i;
               state.x        <= resize( signed( x_i ), state.x'length );
               state.x        <= resize( signed( x_i ), state.x'length );
               state.y        <= resize( signed( y_i ), state.y'length );
               state.y        <= resize( signed( y_i ), state.y'length );
               state.a        <= resize( signed( a_i ), state.a'length );
               state.a        <= resize( signed( a_i ), state.a'length );
               state.i        <= ( others => '0' );
               state.i        <= ( others => '0' );
<<<<<<< HEAD
 
 
 
<<<<<<< HEAD
 
<<<<<<< HEAD
 
            elsif state.st = ST_INIT then
 
               -- 
 
               -- initialization state
 
               --    -> do initial rotation (alignment)
 
               --    -> check special situations / miss-configurations (TODO)
 
               --
 
 
 
=======
 
            -- 
 
            -- initialization state
 
            --    -> do initial rotation (alignment)
 
            --    -> check special situations / miss-configurations (TODO)
 
            --
 
            elsif state.st = ST_INIT then
 
>>>>>>> initial commit
 
=======
 
=======
 
               state.alst     <= ( others => '0' );
               state.alst     <= ( others => '0' );
               state.ylst     <= ( others => '0' );
               state.ylst     <= ( others => '0' );
>>>>>>> Removed some bugs regarding pre-rotation and negative numbers in the wb wrapper
 
            elsif state.st = ST_INIT then
            elsif state.st = ST_INIT then
               -- 
               -- 
               -- initialization state
               -- initialization state
               --    -> do initial rotation (alignment)
               --    -> do initial rotation (alignment)
               --    -> check special situations / miss-configurations (TODO)
               --    -> check special situations / miss-configurations (TODO)
               --
               --
 
 
>>>>>>> Updated C and RTL model as well as the documentation
 
               state.st       <= ST_ROTATE;
               state.st       <= ST_ROTATE;
               state.do_shift <= '1';
               state.do_shift <= '1';
 
 
 
 
<<<<<<< HEAD
 
<<<<<<< HEAD
 
<<<<<<< HEAD
 
               if state.mode( 1 downto 0 ) = VAL_MODE_HYP then
 
                  -- if we do a hyperbolic rotation, we start with 1
 
=======
 
               -- if we do a hyperbolic rotation, we start with 1
 
               if state.mode( 1 downto 0 ) = VAL_MODE_HYP then
 
>>>>>>> initial commit
 
=======
 
               if state.mode( 1 downto 0 ) = VAL_MODE_HYP then
 
                  -- if we do a hyperbolic rotation, we start with 1
 
>>>>>>> Updated C and RTL model as well as the documentation
 
                  state.i(0) <= '1';
 
               end if;
 
 
 
 
 
 
 
 
 
<<<<<<< HEAD
 
<<<<<<< HEAD
 
               if     state.mode( I_FLAG_VEC_ROT ) = '0'
 
=======
 
              if state.mode( 1 downto 0 ) = VAL_MODE_HYP then
              if state.mode( 1 downto 0 ) = VAL_MODE_HYP then
                 -- if we do a hyperbolic rotation, we start with 1
                 -- if we do a hyperbolic rotation, we start with 1
                 state.i(0) <= '1';
                 state.i(0) <= '1';
              end if;
              end if;
 
 
Line 317... Line 254...
                     state.x_sum  <= state.x;
                     state.x_sum  <= state.x;
                     state.y_sum  <= state.y;
                     state.y_sum  <= state.y;
                     state.st     <= ST_DONE;
                     state.st     <= ST_DONE;
 
 
              elsif     state.mode( I_FLAG_VEC_ROT ) = '0'
              elsif     state.mode( I_FLAG_VEC_ROT ) = '0'
>>>>>>> Removed some bugs regarding pre-rotation and negative numbers in the wb wrapper
 
                  and state.mode( 1 downto 0 )   =  VAL_MODE_CIR  then
                  and state.mode( 1 downto 0 )   =  VAL_MODE_CIR  then
                  -- circular vector mode
                  -- circular vector mode
 
 
                  if state.a < - PI_H then
                  if state.a < - PI_H then
                     -- move from third quadrant to first
                     -- move from third quadrant to first
                     state.a <= state.a + PI;
                     state.a <= state.a + PI;
                     state.x <= - state.x;
                     state.x <= - state.x;
                     state.y <= - state.y;
                     state.y <= - state.y;
                  elsif state.a > PI_H then
                  elsif state.a > PI_H then
                     -- move from second quadrant to fourth
                     -- move from second quadrant to fourth
=======
 
               -- circular vector mode
 
               if     state.mode( FLAG_VEC_ROT ) = '0'
 
=======
 
               if     state.mode( I_FLAG_VEC_ROT ) = '0'
 
>>>>>>> Updated C and RTL model as well as the documentation
 
                  and state.mode( 1 downto 0 )   =  VAL_MODE_CIR  then
 
                  -- circular vector mode
 
 
 
                  if state.a < - PI_H then
 
                     -- move from third quadrant to first
 
                     state.a <= state.a + PI;
 
                     state.x <= - state.x;
 
                     state.y <= - state.y;
 
                  elsif state.a > PI_H then
 
<<<<<<< HEAD
 
>>>>>>> initial commit
 
=======
 
                     -- move from second quadrant to fourth
 
>>>>>>> Updated C and RTL model as well as the documentation
 
                     state.a <= state.a - PI;
                     state.a <= state.a - PI;
                     state.x <= - state.x;
                     state.x <= - state.x;
                     state.y <= - state.y;
                     state.y <= - state.y;
                  end if;
                  end if;
 
 
<<<<<<< HEAD
 
<<<<<<< HEAD
 
               elsif   state.mode( I_FLAG_VEC_ROT ) = '1'
 
                   and state.mode( 1 downto 0 )   = VAL_MODE_CIR then
 
                  -- circular rotation mode
 
 
 
                  if state.x = 0 and state.y = 0 then
 
                     -- zero-input
 
                     state.a  <= ( others => '0' );
 
                     state.y  <= ( others => '0' );
 
                     state.st <= ST_DONE;
 
 
 
                  elsif state.x = XY_MAX and state.y = XY_MAX then
 
                     -- all-max 1
 
                     state.a  <= resize( angular_lut( 0, state.mode( 1 downto 0 ), A_WIDTH ), A_WIDTH_I );
 
                     state.x  <= to_signed( SQRT2, state.x'length );
 
                     state.y  <= (others => '0' );
 
                     state.st <= ST_DONE;
 
                  elsif state.x = -XY_MAX and state.y = -XY_MAX then
 
                     -- all-max 2
 
                     state.a  <= resize( angular_lut( 0, state.mode( 1 downto 0 ), A_WIDTH ), A_WIDTH_I ) - PI;
 
                     state.x  <= to_signed( SQRT2, state.x'length );
 
                     state.y  <= (others => '0' );
 
                     state.st <= ST_DONE;
 
                  elsif state.x = XY_MAX and state.y = -XY_MAX then
 
                     -- all-max 3
 
                     state.a  <= resize( -angular_lut( 0, state.mode( 1 downto 0 ), A_WIDTH ), A_WIDTH_I );
 
                     state.x  <= to_signed( SQRT2, state.x'length );
 
                     state.y  <= (others => '0' );
 
                     state.st <= ST_DONE;
 
                  elsif state.x = -XY_MAX and state.y = XY_MAX then
 
                     -- all-max 4
 
                     state.a  <= PI-  resize( angular_lut( 0, state.mode( 1 downto 0 ), A_WIDTH ), A_WIDTH_I );
 
                     state.x  <= to_signed( SQRT2, state.x'length );
 
                     state.y  <= (others => '0' );
 
                     state.st <= ST_DONE;
 
 
 
                  elsif state.x = 0 and state.y > 0 then
 
                     -- fixed rotation of pi/2
 
                     state.a  <= to_signed( PI_H, state.a'length );
 
                     state.x  <= state.y;
 
                     state.y  <= ( others => '0' );
 
                     state.st<= ST_DONE;
 
                  elsif state.x = 0 and state.y < 0 then
 
                     -- fixed rotation of -pi/2
 
                     state.a  <= to_signed( -PI_H, state.a'length );
 
                     state.x  <= -state.y;
 
                     state.y  <= ( others => '0' );
 
                     state.st<= ST_DONE;
 
 
 
                  elsif state.x < 0 and state.y >= 0 then
 
                     -- move from second quadrant to fourth
 
                     state.x <= - state.x;
 
                     state.y <= - state.y;
 
                     state.a <= to_signed(  PI, state.a'length );
 
                  elsif state.x < 0 and state.y < 0 then
 
                     -- move from third quadrant to first
 
                     state.x <= - state.x;
 
                     state.y <= - state.y;
 
                     state.a <= to_signed( -PI, state.a'length );
 
                  else
 
                     state.a <= ( others => '0' );
 
                  end if;
 
               elsif   state.mode( I_FLAG_VEC_ROT ) = '1'
               elsif   state.mode( I_FLAG_VEC_ROT ) = '1'
                   and state.mode( 1 downto 0 )   = VAL_MODE_LIN then
 
                  -- linear rotation mode
 
                  if state.x < 0 then
 
                     state.x <= - state.x;
 
                     state.y <= - state.y;
 
                  end if;
 
                  state.a <= to_signed( 0, state.a'length );
 
=======
 
               -- circular rotation mode
 
               elsif   state.mode( FLAG_VEC_ROT ) = '1'
 
=======
 
               elsif   state.mode( I_FLAG_VEC_ROT ) = '1'
 
>>>>>>> Updated C and RTL model as well as the documentation
 
                   and state.mode( 1 downto 0 )   = VAL_MODE_CIR then
                   and state.mode( 1 downto 0 )   = VAL_MODE_CIR then
                  -- circular rotation mode
                  -- circular rotation mode
 
 
                  if state.y = 0 then
                  if state.y = 0 then
                     -- zero-input
                     -- zero-input
Line 493... Line 333...
                  else
                  else
                     state.a <= ( others => '0' );
                     state.a <= ( others => '0' );
                  end if;
                  end if;
               elsif   state.mode( I_FLAG_VEC_ROT ) = '1'
               elsif   state.mode( I_FLAG_VEC_ROT ) = '1'
                   and state.mode( 1 downto 0 )   = VAL_MODE_LIN then
                   and state.mode( 1 downto 0 )   = VAL_MODE_LIN then
<<<<<<< HEAD
 
 
 
                     if state.x < 0 then
 
                        state.x <= - state.x;
 
                        state.y <= - state.y;
 
                     end if;
 
                     state.a <= to_signed( 0, state.a'length );
 
>>>>>>> initial commit
 
=======
 
                  -- linear rotation mode
                  -- linear rotation mode
 
 
                  if state.x < 0 then
                  if state.x < 0 then
                     state.x <= - state.x;
                     state.x <= - state.x;
                     state.y <= - state.y;
                     state.y <= - state.y;
                  end if;
                  end if;
                  state.a <= to_signed( 0, state.a'length );
                  state.a <= to_signed( 0, state.a'length );
>>>>>>> Updated C and RTL model as well as the documentation
 
 
 
               end if;
               end if;
 
 
 
 
 
 
Line 530... Line 360...
            --
            --
            --
            --
            elsif state.st = ST_ROTATE then
            elsif state.st = ST_ROTATE then
 
 
               -- get the sign
               -- get the sign
<<<<<<< HEAD
 
<<<<<<< HEAD
 
               if state.mode( I_FLAG_VEC_ROT )  = '0' then
               if state.mode( I_FLAG_VEC_ROT )  = '0' then
=======
 
               if state.mode( FLAG_VEC_ROT )  = '0' then
 
>>>>>>> initial commit
 
=======
 
               if state.mode( I_FLAG_VEC_ROT )  = '0' then
 
>>>>>>> Updated C and RTL model as well as the documentation
 
                  if state.a < 0 then
                  if state.a < 0 then
                     sign := '0';
                     sign := '0';
                  else
                  else
                     sign := '1';
                     sign := '1';
                  end if;
                  end if;
Line 608... Line 430...
                     state.x_sh <= - SHIFT_RIGHT( state.x, to_integer( state.i ) );
                     state.x_sh <= - SHIFT_RIGHT( state.x, to_integer( state.i ) );
 
 
                  end if;
                  end if;
 
 
                  -- abort condition
                  -- abort condition
<<<<<<< HEAD
 
<<<<<<< HEAD
 
                  if(   state.mode( I_FLAG_VEC_ROT ) = '0' and
 
                        state.a = 0 ) then
 
                     state.st <= ST_RM_GAIN;
 
                     state.i  <= ( others => '0' );
 
                  elsif(   state.mode( I_FLAG_VEC_ROT ) = '0' and
 
                        state.a = state.alst ) then
 
                     state.st <= ST_RM_GAIN;
 
                     state.i  <= ( others => '0' );
 
                  elsif(   state.mode( I_FLAG_VEC_ROT ) = '1' and
 
                        state.y = 0 ) then
 
                     state.st <= ST_RM_GAIN;
 
                     state.i  <= ( others => '0' );
 
                  elsif(   state.mode( I_FLAG_VEC_ROT ) = '1' and
 
=======
 
                  if(   state.mode( FLAG_VEC_ROT ) = '0' and
 
                        ( state.a = 0 or state.a = -1 ) ) then
 
=======
 
                  if(   state.mode( I_FLAG_VEC_ROT ) = '0' and
                  if(   state.mode( I_FLAG_VEC_ROT ) = '0' and
                        state.a = 0 ) then
                        state.a = 0 ) then
>>>>>>> Updated C and RTL model as well as the documentation
 
                     state.st <= ST_RM_GAIN;
                     state.st <= ST_RM_GAIN;
                     state.i  <= ( others => '0' );
                     state.i  <= ( others => '0' );
                  elsif(   state.mode( I_FLAG_VEC_ROT ) = '0' and
                  elsif(   state.mode( I_FLAG_VEC_ROT ) = '0' and
                        state.a = state.alst ) then
                        state.a = state.alst ) then
                     state.st <= ST_RM_GAIN;
                     state.st <= ST_RM_GAIN;
                     state.i  <= ( others => '0' );
                     state.i  <= ( others => '0' );
                  elsif(   state.mode( I_FLAG_VEC_ROT ) = '1' and
                  elsif(   state.mode( I_FLAG_VEC_ROT ) = '1' and
                        state.y = 0 ) then
                        state.y = 0 ) then
                     state.st <= ST_RM_GAIN;
                     state.st <= ST_RM_GAIN;
                     state.i  <= ( others => '0' );
                     state.i  <= ( others => '0' );
<<<<<<< HEAD
 
                  elsif(   state.mode( FLAG_VEC_ROT ) = '1' and
 
>>>>>>> initial commit
 
=======
 
                  elsif(   state.mode( I_FLAG_VEC_ROT ) = '1' and
                  elsif(   state.mode( I_FLAG_VEC_ROT ) = '1' and
>>>>>>> Updated C and RTL model as well as the documentation
 
                        ( state.y = state.ylst ) ) then
                        ( state.y = state.ylst ) ) then
                     state.st <= ST_RM_GAIN;
                     state.st <= ST_RM_GAIN;
                     state.i  <= ( others => '0' );
                     state.i  <= ( others => '0' );
                  end if;
                  end if;
 
 

powered by: WebSVN 2.1.0

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