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

Subversion Repositories yac

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

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 4 Rev 7
Line 92... Line 92...
 
 
   -- 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
<<<<<<< HEAD
 
<<<<<<< HEAD
=======
=======
>>>>>>> Updated C and RTL model as well as the documentation
>>>>>>> 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( PI_REAL    * real( 2**( A_WIDTH-1 ) ) + 0.5 );
   constant PI          : integer := natural( round( PI_REAL    * real( 2**( A_WIDTH-1  ) ) ) );
   constant PI_H        : integer := natural( PI_REAL    * real( 2**( A_WIDTH-2 ) ) + 0.5 );
   constant PI_H        : integer := natural( round( PI_REAL    * real( 2**( A_WIDTH-2  ) ) ) );
   constant SQRT2       : integer := natural( SQRT2_REAL * real( 2**( XY_WIDTH-1 ) ) + 0.5 );
   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
<<<<<<< HEAD
=======
=======
 
 
Line 133... Line 137...
      a_tmp    : signed( A_WIDTH_I      -1 downto 0 );
      a_tmp    : signed( A_WIDTH_I      -1 downto 0 );
      ylst     : signed( XY_WIDTH_G     -1 downto 0 );
      ylst     : signed( XY_WIDTH_G     -1 downto 0 );
      alst     : signed( A_WIDTH_I      -1 downto 0 );
      alst     : signed( A_WIDTH_I      -1 downto 0 );
      i        : signed( L2_MAX_I       -1 downto 0 );
      i        : signed( L2_MAX_I       -1 downto 0 );
      do_shift : std_logic;
      do_shift : std_logic;
      done     : std_logic;
 
      repeate  : std_logic;
      repeate  : std_logic;
   end record state_t;
   end record state_t;
   signal state : state_t;
   signal state : state_t;
 
 
 
 
 
 
   ---------------------------------------
   ---------------------------------------
   -- Auto-generated function 
   -- Auto-generated function 
   -- by matlab (see c_octave/cordic_iterative_code.m)
   -- by matlab (see c_octave/cordic_iterative_code.m)
   function angular_lut( n : integer; mode : std_logic_vector; ANG_WIDTH : natural ) return signed is
   function angular_lut( n : integer; mode : std_logic_vector; ANG_WIDTH : natural ) return signed is
      variable result : signed( ANG_WIDTH-1 downto 0 );
      variable result : signed( ANG_WIDTH-1 downto 0 );
Line 220... Line 224...
                           a_tmp    => ( others => '0' ),
                           a_tmp    => ( others => '0' ),
                           ylst     => ( others => '0' ),
                           ylst     => ( others => '0' ),
                           alst     => ( others => '0' ),
                           alst     => ( others => '0' ),
                           mode     => ( others => '0' ),
                           mode     => ( others => '0' ),
                           i        => ( others => '0' ),
                           i        => ( others => '0' ),
                           done     => '0',
 
                           do_shift => '0',
                           do_shift => '0',
                           repeate  => '0'
                           repeate  => '0'
                           );
                           );
 
 
         elsif en = '1' then
         elsif en = '1' then
Line 234... Line 237...
               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
<<<<<<< HEAD
<<<<<<< HEAD
            elsif state.st = ST_INIT then
            elsif state.st = ST_INIT then
               -- 
               -- 
Line 253... Line 257...
            --    -> check special situations / miss-configurations (TODO)
            --    -> check special situations / miss-configurations (TODO)
            --
            --
            elsif state.st = ST_INIT then
            elsif state.st = ST_INIT then
>>>>>>> initial commit
>>>>>>> initial commit
=======
=======
 
=======
 
               state.alst     <= ( 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)
Line 267... Line 275...
               state.do_shift <= '1';
               state.do_shift <= '1';
 
 
 
 
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
 
<<<<<<< HEAD
               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
=======
=======
               -- 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
               if state.mode( 1 downto 0 ) = VAL_MODE_HYP then
Line 286... Line 295...
 
 
 
 
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
               if     state.mode( I_FLAG_VEC_ROT ) = '0'
               if     state.mode( I_FLAG_VEC_ROT ) = '0'
 
=======
 
              if state.mode( 1 downto 0 ) = VAL_MODE_HYP then
 
                 -- if we do a hyperbolic rotation, we start with 1
 
                 state.i(0) <= '1';
 
              end if;
 
 
 
 
 
 
 
              if state.mode( I_FLAG_VEC_ROT ) = '1' and state.y = 0 then
 
                     -- zero-input
 
                     state.x_sum  <= state.x;
 
                     state.y_sum  <= state.y;
 
                     state.a      <= ( others => '0' );
 
                     state.st     <= ST_DONE;
 
 
 
              elsif state.mode( I_FLAG_VEC_ROT ) = '0' and state.a = 0 then
 
                     -- nothing to do, a is zero
 
                     state.x_sum  <= state.x;
 
                     state.y_sum  <= state.y;
 
                     state.st     <= ST_DONE;
 
 
 
              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
Line 401... Line 433...
               elsif   state.mode( I_FLAG_VEC_ROT ) = '1'
               elsif   state.mode( I_FLAG_VEC_ROT ) = '1'
>>>>>>> Updated C and RTL model as well as the documentation
>>>>>>> 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.x = 0 and state.y = 0 then
                  if state.y = 0 then
                     -- zero-input
                     -- zero-input
 
                     state.x_sum  <= state.x;
 
                     state.y_sum  <= state.y;
                     state.a  <= ( others => '0' );
                     state.a  <= ( others => '0' );
                     state.y  <= ( others => '0' );
 
                     state.st <= ST_DONE;
                     state.st <= ST_DONE;
 
 
                  elsif state.x = XY_MAX and state.y = XY_MAX then
                  elsif state.x = XY_MAX and state.y = XY_MAX then
                     -- all-max 1
                     -- all-max 1
 
                     state.x_sum  <= to_signed( SQRT2, state.x'length );
 
                     state.y_sum  <= (others => '0' );
                     state.a  <= resize( angular_lut( 0, state.mode( 1 downto 0 ), A_WIDTH ), A_WIDTH_I );
                     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;
                     state.st <= ST_DONE;
                  elsif state.x = -XY_MAX and state.y = -XY_MAX then
                  elsif state.x = -XY_MAX and state.y = -XY_MAX then
                     -- all-max 2
                     -- all-max 2
 
                     state.x_sum  <= to_signed( SQRT2, state.x'length );
 
                     state.y_sum  <= (others => '0' );
                     state.a  <= resize( angular_lut( 0, state.mode( 1 downto 0 ), A_WIDTH ), A_WIDTH_I ) - PI;
                     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;
                     state.st <= ST_DONE;
                  elsif state.x = XY_MAX and state.y = -XY_MAX then
                  elsif state.x = XY_MAX and state.y = -XY_MAX then
                     -- all-max 3
                     -- all-max 3
 
                     state.x_sum  <= to_signed( SQRT2, state.x'length );
 
                     state.y_sum  <= (others => '0' );
                     state.a  <= resize( -angular_lut( 0, state.mode( 1 downto 0 ), A_WIDTH ), A_WIDTH_I );
                     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;
                     state.st <= ST_DONE;
                  elsif state.x = -XY_MAX and state.y = XY_MAX then
                  elsif state.x = -XY_MAX and state.y = XY_MAX then
                     -- all-max 4
                     -- all-max 4
 
                     state.x_sum  <= to_signed( SQRT2, state.x'length );
 
                     state.y_sum  <= (others => '0' );
                     state.a  <= PI-  resize( angular_lut( 0, state.mode( 1 downto 0 ), A_WIDTH ), A_WIDTH_I );
                     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;
                     state.st <= ST_DONE;
 
 
                  elsif state.x = 0 and state.y > 0 then
                  elsif state.x = 0 and state.y > 0 then
                     -- fixed rotation of pi/2
                     -- fixed rotation of pi/2
 
                     state.x_sum  <= state.y;
 
                     state.y_sum  <= ( others => '0' );
                     state.a  <= to_signed( PI_H, state.a'length );
                     state.a  <= to_signed( PI_H, state.a'length );
                     state.x  <= state.y;
 
                     state.y  <= ( others => '0' );
 
                     state.st<= ST_DONE;
                     state.st<= ST_DONE;
                  elsif state.x = 0 and state.y < 0 then
                  elsif state.x = 0 and state.y < 0 then
                     -- fixed rotation of -pi/2
                     -- fixed rotation of -pi/2
 
                     state.x_sum  <= -state.y;
 
                     state.y_sum  <= ( others => '0' );
                     state.a  <= to_signed( -PI_H, state.a'length );
                     state.a  <= to_signed( -PI_H, state.a'length );
                     state.x  <= -state.y;
 
                     state.y  <= ( others => '0' );
 
                     state.st<= ST_DONE;
                     state.st<= ST_DONE;
 
 
                  elsif state.x < 0 and state.y >= 0 then
                  elsif state.x < 0 and state.y >= 0 then
                     -- move from second quadrant to fourth
                     -- move from second quadrant to fourth
                     state.x <= - state.x;
                     state.x <= - state.x;
Line 470... Line 503...
                     end if;
                     end if;
                     state.a <= to_signed( 0, state.a'length );
                     state.a <= to_signed( 0, state.a'length );
>>>>>>> initial commit
>>>>>>> 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 );
Line 521... Line 555...
               end if;
               end if;
 
 
 
 
 
 
               if state.do_shift = '1' then
               if state.do_shift = '1' then
                  -- get the angle, do the shifting and set the right angle
                  state.do_shift <= '0';
 
 
 
                  -- get the angle, do the shifting and set the correct angle
 
 
                  if sign = '1' then
                  if sign = '1' then
 
 
                     -- circular case
                     -- circular case
                     if state.mode( 1 downto 0 ) = VAL_MODE_CIR then
                     if state.mode( 1 downto 0 ) = VAL_MODE_CIR then
Line 570... Line 606...
 
 
                     end if;
                     end if;
                     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;
                  state.do_shift <= '0';
 
 
 
                  -- abort condition
                  -- abort condition
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
                  if(   state.mode( I_FLAG_VEC_ROT ) = '0' and
                  if(   state.mode( I_FLAG_VEC_ROT ) = '0' and
Line 647... Line 682...
            elsif state.st = ST_RM_GAIN then
            elsif state.st = ST_RM_GAIN then
               -- we need RM_GAIN+1 cycles to 
               -- we need RM_GAIN+1 cycles to 
               -- calculate the RM_GAIN steps
               -- calculate the RM_GAIN steps
               if state.i = (RM_GAIN) then
               if state.i = (RM_GAIN) then
                 state.st   <= ST_DONE;
                 state.st   <= ST_DONE;
                 state.done <= '1';
 
                   state.i <= ( others => '0' );
                   state.i <= ( others => '0' );
               else
               else
                   state.i  <= state.i + 1;
                   state.i  <= state.i + 1;
               end if;
               end if;
 
 
Line 660... Line 694...
                  mult_0_61( state.y, state.y_sh, state.y_sum, to_integer( state.i ), RM_GAIN );
                  mult_0_61( state.y, state.y_sh, state.y_sum, to_integer( state.i ), RM_GAIN );
               elsif state.mode( 1 downto 0 ) = VAL_MODE_HYP then
               elsif state.mode( 1 downto 0 ) = VAL_MODE_HYP then
                  mult_0_21( state.x, state.x_sh, state.x_sum, to_integer( state.i ), RM_GAIN );
                  mult_0_21( state.x, state.x_sh, state.x_sum, to_integer( state.i ), RM_GAIN );
                  mult_0_21( state.y, state.y_sh, state.y_sum, to_integer( state.i ), RM_GAIN );
                  mult_0_21( state.y, state.y_sh, state.y_sum, to_integer( state.i ), RM_GAIN );
               else
               else
                  -- TODO  merge ST_DONE and state.done
 
                  state.done <= '1';
 
                  state.st    <= ST_DONE;
                  state.st    <= ST_DONE;
                  state.x_sum <= state.x;
                  state.x_sum <= state.x;
                  state.y_sum <= state.y;
                  state.y_sum <= state.y;
               end if;
               end if;
 
 
 
 
            elsif state.st = ST_DONE then
            elsif state.st = ST_DONE then
               state.st    <= ST_IDLE;
               state.st    <= ST_IDLE;
               state.done  <= '0';
 
            end if;
            end if;
            -- end states
            -- end states
 
 
 
 
 
 
Line 684... Line 715...
 
 
      end if;
      end if;
      -- end clk
      -- end clk
 
 
   end process;
   end process;
   done        <=                   state.done   ;
   done        <= '1' when state.st = ST_DONE else '0';
   x_o         <= std_logic_vector( state.x_sum );
   x_o         <= std_logic_vector( state.x_sum );
   y_o         <= std_logic_vector( state.y_sum );
   y_o         <= std_logic_vector( state.y_sum );
   a_o         <= std_logic_vector( state.a );
   a_o         <= std_logic_vector( state.a );
 
 
end architecture BEHAVIORAL;
end architecture BEHAVIORAL;

powered by: WebSVN 2.1.0

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