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

Subversion Repositories yac

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /yac/trunk/rtl
    from Rev 5 to Rev 7
    Reverse comparison

Rev 5 → Rev 7

/vhdl/cordic_iterative_tb.vhd
80,10 → 80,10
signal rst : std_logic;
signal nrst : std_logic;
 
constant XY_WIDTH : natural := 25;
constant A_WIDTH : natural := 25;
constant GUARD_BITS : natural := 2;
constant RM_GAIN : natural := 5;
constant XY_WIDTH : natural := 8;
constant A_WIDTH : natural := 8;
constant GUARD_BITS : natural := 2;
constant RM_GAIN : natural := 3;
component cordic_iterative_int is
generic(
XY_WIDTH : natural := 12;
117,7 → 117,6
signal a_o : std_logic_vector( A_WIDTH+2-1 downto 0 );
 
 
 
begin
 
 
139,10 → 138,10
rst <= '0';
wait;
end process;
 
 
 
 
dut : cordic_iterative_int
generic map (
XY_WIDTH => XY_WIDTH ,
188,7 → 187,7
variable err_cnt : integer := 0;
variable stim_cnt : integer := 0;
begin
 
err_cnt := 0;
 
--
217,7 → 216,6
 
while ( not endfile( test_pattern_file ) )loop
 
 
wait until en='1';
wait for clk_T;
 
254,14 → 252,15
<<<<<<< HEAD
<<<<<<< HEAD
integer'image( stim_cnt ) & ": Serial Cordic Failed: expected x result:"
& integer'image( tmp_value(5) ) & ", but got:"
& integer'image( to_integer( signed( x_ex ) ) );
& integer'image( tmp_value(3) ) & ", but got:"
& integer'image( to_integer( signed( x_o ) ) );
assert y_ex = y_o report
integer'image( stim_cnt ) & ": Serial Cordic Failed: expected y result:"
& integer'image( tmp_value(6) ) & ", but got:"
& integer'image( to_integer( signed( y_ex ) ) );
& integer'image( tmp_value(4) ) & ", but got:"
& integer'image( to_integer( signed( y_o ) ) );
assert a_ex = a_o report
integer'image( stim_cnt ) & ": Serial Cordic Failed: expected a result:"
<<<<<<< HEAD
=======
" Serial Cordic Failed: expected x result:"
=======
282,11 → 281,15
>>>>>>> Updated C and RTL model as well as the documentation
& integer'image( tmp_value(7) ) & ", but got:"
& integer'image( to_integer( signed( a_ex ) ) );
=======
& integer'image( tmp_value(5) ) & ", but got:"
& integer'image( to_integer( signed( a_o ) ) );
>>>>>>> Removed some bugs regarding pre-rotation and negative numbers in the wb wrapper
err_cnt := err_cnt + 1;
writeline( error_pattern_file, input_line_bak );
 
end if;
 
wait for CLK_T * 5;
 
end loop;
303,7 → 306,7
wait for clk_T * 10;
en <= '1';
wait for clk_T * 1000;
 
end process;
 
 
/vhdl/cordic_iterative_wb.vhd
299,7 → 299,7
b3_trans <= WB_NO_BURST;
ack_r <= '0';
else
 
cti_r <= cti_i;
bte_r <= bte_i;
 
318,7 → 318,7
 
-- start of burst
b3_trans <= WB_BURST;
 
elsif burst_end = '1' then
 
-- end of burst
325,7 → 325,7
b3_trans <= WB_NO_BURST;
 
elsif b3_trans = WB_BURST then
 
-- during burst
 
end if;
386,7 → 386,7
wr_p : process( clk_i, rst_i )
variable MEM_START : integer;
begin
 
if clk_i'event and clk_i='1' then
if rst_i = '1' then
MEM <= ( others => ( others => '0' ) );
437,20 → 437,20
state.st <= ST_WAIT;
end if;
 
 
-- single cordic calculation is done:
-- save the result and start the next one or
-- go back to idle
if state.st = ST_WAIT and cordic_done = '1' then
MEM_START := to_integer( state.cnt & "00" ); -- state.cnt * 4
MEM( MEM_START+0 ) <= ( others => '0' );
MEM( MEM_START+1 ) <= ( others => '0' );
MEM( MEM_START+2 ) <= ( others => '0' );
MEM( MEM_START+0 ) <= ( others => cordic_x_o( cordic_x_o'high ));
MEM( MEM_START+1 ) <= ( others => cordic_y_o( cordic_y_o'high ) );
MEM( MEM_START+2 ) <= ( others => cordic_a_o( cordic_a_o'high ) );
MEM( MEM_START+0 )( cordic_x_o'range ) <= cordic_x_o;
MEM( MEM_START+1 )( cordic_y_o'range ) <= cordic_y_o;
MEM( MEM_START+2 )( cordic_a_o'range ) <= cordic_a_o;
 
 
if state.cnt = 0 then
 
-- go back to IDLE
465,7 → 465,7
state.st <= ST_START;
state.cnt <= state.cnt-1;
end if;
 
end if;
 
end if;
/vhdl/cordic_iterative_int.vhd
84,7 → 84,7
 
 
architecture BEHAVIORAL of cordic_iterative_int is
 
-- log2( max-iteration )
constant L2_MAX_I : natural := 8;
 
94,15 → 94,19
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 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 );
constant SQRT2 : integer := natural( SQRT2_REAL * real( 2**( XY_WIDTH-1 ) ) + 0.5 );
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 SQRT2 : integer := natural( round( SQRT2_REAL * real( 2**( XY_WIDTH-1 ) ) ) );
constant XY_MAX : integer := natural( 2**( XY_WIDTH-1)-1);
 
<<<<<<< HEAD
135,12 → 139,12
alst : signed( A_WIDTH_I -1 downto 0 );
i : signed( L2_MAX_I -1 downto 0 );
do_shift : std_logic;
done : std_logic;
repeate : std_logic;
end record state_t;
signal state : state_t;
 
 
 
---------------------------------------
-- Auto-generated function
-- by matlab (see c_octave/cordic_iterative_code.m)
222,13 → 226,12
alst => ( others => '0' ),
mode => ( others => '0' ),
i => ( others => '0' ),
done => '0',
do_shift => '0',
repeate => '0'
);
 
elsif en = '1' then
 
if state.st = ST_IDLE and start = '1' then
state.st <= ST_INIT;
state.mode <= mode_i;
236,6 → 239,7
state.y <= resize( signed( y_i ), state.y'length );
state.a <= resize( signed( a_i ), state.a'length );
state.i <= ( others => '0' );
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
255,6 → 259,10
elsif state.st = ST_INIT then
>>>>>>> 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
--
-- initialization state
269,6 → 277,7
 
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
if state.mode( 1 downto 0 ) = VAL_MODE_HYP then
-- if we do a hyperbolic rotation, we start with 1
=======
288,6 → 297,29
<<<<<<< HEAD
<<<<<<< HEAD
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
-- circular vector mode
 
403,49 → 435,50
and state.mode( 1 downto 0 ) = VAL_MODE_CIR then
-- circular rotation mode
 
if state.x = 0 and state.y = 0 then
if state.y = 0 then
-- zero-input
state.a <= ( others => '0' );
state.y <= ( others => '0' );
state.st <= ST_DONE;
state.x_sum <= state.x;
state.y_sum <= state.y;
state.a <= ( 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;
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.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;
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.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;
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.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;
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.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;
state.x_sum <= state.y;
state.y_sum <= ( others => '0' );
state.a <= to_signed( PI_H, state.a'length );
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;
state.x_sum <= -state.y;
state.y_sum <= ( others => '0' );
state.a <= to_signed( -PI_H, state.a'length );
state.st <= ST_DONE;
 
elsif state.x < 0 and state.y >= 0 then
-- move from second quadrant to fourth
472,6 → 505,7
>>>>>>> initial commit
=======
-- linear rotation mode
 
if state.x < 0 then
state.x <= - state.x;
state.y <= - state.y;
523,8 → 557,10
 
 
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
 
-- circular case
572,7 → 608,6
state.x_sh <= - SHIFT_RIGHT( state.x, to_integer( state.i ) );
 
end if;
state.do_shift <= '0';
 
-- abort condition
<<<<<<< HEAD
638,9 → 673,9
end if;
 
 
 
 
 
--
-- removal of the cordic gain
--
649,7 → 684,6
-- calculate the RM_GAIN steps
if state.i = (RM_GAIN) then
state.st <= ST_DONE;
state.done <= '1';
state.i <= ( others => '0' );
else
state.i <= state.i + 1;
662,8 → 696,6
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 );
else
-- TODO merge ST_DONE and state.done
state.done <= '1';
state.st <= ST_DONE;
state.x_sum <= state.x;
state.y_sum <= state.y;
672,7 → 704,6
 
elsif state.st = ST_DONE then
state.st <= ST_IDLE;
state.done <= '0';
end if;
-- end states
 
686,7 → 717,7
-- end clk
 
end process;
done <= state.done ;
done <= '1' when state.st = ST_DONE else '0';
x_o <= std_logic_vector( state.x_sum );
y_o <= std_logic_vector( state.y_sum );
a_o <= std_logic_vector( state.a );

powered by: WebSVN 2.1.0

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