URL
https://opencores.org/ocsvn/yac/yac/trunk
Subversion Repositories yac
Compare Revisions
- This comparison shows the changes necessary to convert path
/yac
- from Rev 3 to Rev 4
- ↔ Reverse comparison
Rev 3 → Rev 4
/trunk/lgpl-3.0.txt
File deleted
/trunk/rtl/vhdl/cordic_iterative_pkg.vhd
62,6 → 62,7
|
|
<<<<<<< HEAD |
<<<<<<< HEAD |
constant I_FLAG_VEC_ROT : natural := 3; -- bit index |
constant I_FLAG_ATAN_3 : natural := 2; -- bit index (for future usage) |
======= |
68,6 → 69,10
constant FLAG_VEC_ROT : natural := 3; -- bit index |
constant FLAG_ATAN_3 : natural := 2; -- bit index |
>>>>>>> initial commit |
======= |
constant I_FLAG_VEC_ROT : natural := 3; -- bit index |
constant I_FLAG_ATAN_3 : natural := 2; -- bit index (for future usage) |
>>>>>>> Updated C and RTL model as well as the documentation |
constant VAL_MODE_CIR : std_logic_vector( 1 downto 0 ) := "00"; -- value |
constant VAL_MODE_LIN : std_logic_vector( 1 downto 0 ) := "01"; -- value |
constant VAL_MODE_HYP : std_logic_vector( 1 downto 0 ) := "10"; -- value |
/trunk/rtl/vhdl/cordic_iterative_tb.vhd
252,6 → 252,7
a_ex /= a_o then |
assert x_ex = x_o report |
<<<<<<< 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 ) ) ); |
263,15 → 264,22
integer'image( stim_cnt ) & ": Serial Cordic Failed: expected a result:" |
======= |
" Serial Cordic Failed: expected x result:" |
======= |
integer'image( stim_cnt ) & ": Serial Cordic Failed: expected x result:" |
>>>>>>> Updated C and RTL model as well as the documentation |
& integer'image( tmp_value(5) ) & ", but got:" |
& integer'image( to_integer( signed( x_ex ) ) ); |
assert y_ex = y_o report |
" Serial Cordic Failed: expected y result:" |
integer'image( stim_cnt ) & ": Serial Cordic Failed: expected y result:" |
& integer'image( tmp_value(6) ) & ", but got:" |
& integer'image( to_integer( signed( y_ex ) ) ); |
assert a_ex = a_o report |
<<<<<<< HEAD |
" Serial Cordic Failed: expected a result:" |
>>>>>>> initial commit |
======= |
integer'image( stim_cnt ) & ": Serial Cordic Failed: expected a result:" |
>>>>>>> Updated C and RTL model as well as the documentation |
& integer'image( tmp_value(7) ) & ", but got:" |
& integer'image( to_integer( signed( a_ex ) ) ); |
err_cnt := err_cnt + 1; |
/trunk/rtl/vhdl/cordic_iterative_int.vhd
93,6 → 93,9
-- Internal angle width |
constant A_WIDTH_I : natural := A_WIDTH+2; |
<<<<<<< HEAD |
<<<<<<< HEAD |
======= |
>>>>>>> Updated C and RTL model as well as the documentation |
|
|
constant SQRT2_REAL : real := 1.4142135623730951454746218587388284504413604; |
102,6 → 105,7
constant SQRT2 : integer := natural( SQRT2_REAL * real( 2**( XY_WIDTH-1 ) ) + 0.5 ); |
constant XY_MAX : integer := natural( 2**( XY_WIDTH-1)-1); |
|
<<<<<<< HEAD |
======= |
|
constant PI_REAL : real := 3.1415926535897931159979634685441851615905762; |
108,6 → 112,8
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; |
|
232,6 → 238,7
state.i <= ( others => '0' ); |
|
<<<<<<< HEAD |
<<<<<<< HEAD |
elsif state.st = ST_INIT then |
-- |
-- initialization state |
247,11 → 254,21
-- |
elsif state.st = ST_INIT then |
>>>>>>> initial commit |
======= |
elsif state.st = ST_INIT then |
-- |
-- initialization state |
-- -> do initial rotation (alignment) |
-- -> check special situations / miss-configurations (TODO) |
-- |
|
>>>>>>> Updated C and RTL model as well as the documentation |
state.st <= ST_ROTATE; |
state.do_shift <= '1'; |
|
|
<<<<<<< HEAD |
<<<<<<< HEAD |
if state.mode( 1 downto 0 ) = VAL_MODE_HYP then |
-- if we do a hyperbolic rotation, we start with 1 |
======= |
258,6 → 275,10
-- 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; |
|
265,6 → 286,7
|
|
<<<<<<< HEAD |
<<<<<<< HEAD |
if state.mode( I_FLAG_VEC_ROT ) = '0' |
and state.mode( 1 downto 0 ) = VAL_MODE_CIR then |
-- circular vector mode |
279,16 → 301,23
======= |
-- 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 |
|
-- move from third quadrant to first |
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; |
-- move from second quadrant to fourth |
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.x <= - state.x; |
state.y <= - state.y; |
295,6 → 324,7
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 |
367,28 → 397,72
======= |
-- 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 |
-- circular rotation mode |
|
-- move from second quadrant to fourth |
if state.x < 0 and state.y > 0 then |
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 ); |
-- move from third quadrant to first |
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 ); |
-- y=0 condition |
elsif state.x < 0 and state.y = 0 then |
state.a <= to_signed( PI, state.a'length ); |
state.st<= ST_DONE; |
else |
state.a <= ( others => '0' ); |
end if; |
-- linear rotation mode |
elsif state.mode( FLAG_VEC_ROT ) = '1' |
elsif state.mode( I_FLAG_VEC_ROT ) = '1' |
and state.mode( 1 downto 0 ) = VAL_MODE_LIN then |
<<<<<<< HEAD |
|
if state.x < 0 then |
state.x <= - state.x; |
396,6 → 470,14
end if; |
state.a <= to_signed( 0, state.a'length ); |
>>>>>>> initial commit |
======= |
-- 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 ); |
>>>>>>> Updated C and RTL model as well as the documentation |
|
end if; |
|
417,10 → 499,14
|
-- get the sign |
<<<<<<< HEAD |
<<<<<<< HEAD |
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 |
sign := '0'; |
else |
490,6 → 576,7
|
-- abort condition |
<<<<<<< HEAD |
<<<<<<< HEAD |
if( state.mode( I_FLAG_VEC_ROT ) = '0' and |
state.a = 0 ) then |
state.st <= ST_RM_GAIN; |
506,18 → 593,26
======= |
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 |
state.a = 0 ) then |
>>>>>>> Updated C and RTL model as well as the documentation |
state.st <= ST_RM_GAIN; |
state.i <= ( others => '0' ); |
elsif( state.mode( FLAG_VEC_ROT ) = '0' and |
( state.a = state.alst ) ) then |
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( FLAG_VEC_ROT ) = '1' and |
( state.y = 0 or state.y = -1 ) ) then |
elsif( state.mode( I_FLAG_VEC_ROT ) = '1' and |
state.y = 0 ) then |
state.st <= ST_RM_GAIN; |
state.i <= ( others => '0' ); |
<<<<<<< HEAD |
elsif( state.mode( FLAG_VEC_ROT ) = '1' and |
>>>>>>> initial commit |
======= |
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.st <= ST_RM_GAIN; |
state.i <= ( others => '0' ); |
/trunk/c_octave/cordic_iterative.c
60,10 → 60,14
|
/* enable debug output */ |
<<<<<<< HEAD |
<<<<<<< HEAD |
#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 */ |
85,6 → 89,7
|
|
<<<<<<< HEAD |
<<<<<<< HEAD |
======= |
|
long long int ov_check( long long int * value, long long int length ) |
102,6 → 107,8
|
|
>>>>>>> initial commit |
======= |
>>>>>>> Updated C and RTL model as well as the documentation |
void cordic_int( long long int x_i, |
long long int y_i, |
long long int a_i, |
125,11 → 132,16
long long int *a, |
int mode, |
<<<<<<< HEAD |
<<<<<<< HEAD |
int A_WIDTH, |
int XY_WIDTH ); |
======= |
int A_WIDTH ); |
>>>>>>> initial commit |
======= |
int A_WIDTH, |
int XY_WIDTH ); |
>>>>>>> Updated C and RTL model as well as the documentation |
void cordic_int_rm_gain( long long int *x, |
long long int *y, |
int mode, |
259,10 → 271,14
long long int s; |
int ov; |
<<<<<<< HEAD |
<<<<<<< HEAD |
int it = 0; |
======= |
int it; |
>>>>>>> initial commit |
======= |
int it = 0; |
>>>>>>> Updated C and RTL model as well as the documentation |
|
|
|
273,6 → 289,7
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 ) ) |
{ |
|
284,10 → 301,19
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 ) ) |
{ |
>>>>>>> Updated C and RTL model as well as the documentation |
|
cordic_int_rm_gain( &x_i, &y_i, mode, RM_GAIN ); |
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 ); |
} |
>>>>>>> Updated C and RTL model as well as the documentation |
|
*x_o = x_i; |
*y_o = y_i; |
307,11 → 333,16
long long int *a, |
int mode, |
<<<<<<< HEAD |
<<<<<<< HEAD |
int A_WIDTH, |
int XY_WIDTH ) |
======= |
int A_WIDTH ) |
>>>>>>> initial commit |
======= |
int A_WIDTH, |
int XY_WIDTH ) |
>>>>>>> Updated C and RTL model as well as the documentation |
{ |
int already_done = 0; |
|
319,6 → 350,7
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 ); |
<<<<<<< HEAD |
<<<<<<< HEAD |
|
long long int XY_MAX = pow( 2, XY_WIDTH-1 )-1; |
|
330,6 → 362,14
|
cordic_int_dbg( *x, *y, *a, mode, 0, "before init" ); |
>>>>>>> initial commit |
======= |
|
long long int XY_MAX = pow( 2, XY_WIDTH-1 )-1; |
|
cordic_int_dbg( *x, *y, *a, mode, 0, "before init" ); |
|
|
>>>>>>> Updated C and RTL model as well as the documentation |
/* Circular rotation mode */ |
if( 0 == ( mode & C_FLAG_VEC_ROT ) && |
C_MODE_CIR == ( mode & C_MODE_MSK ) ) |
365,6 → 405,9
C_MODE_CIR == ( mode & C_MODE_MSK ) ) |
{ |
<<<<<<< HEAD |
<<<<<<< HEAD |
======= |
>>>>>>> Updated C and RTL model as well as the documentation |
|
if( *x == 0 && *y == 0 ) |
{ |
434,9 → 477,12
#endif |
} |
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; |
*y = -*y; |
443,6 → 489,7
*a = PI; |
#if PRINT_DEBUG > 0 |
<<<<<<< HEAD |
<<<<<<< HEAD |
PRINT("pre-rotation from second to the fourth quadrant\n" ); |
#endif |
} |
453,6 → 500,12
} |
else if( *x < 0 && *y < 0 ) |
>>>>>>> initial commit |
======= |
PRINT("pre-rotation from second to the fourth quadrant\n" ); |
#endif |
} |
else if( *x < 0 && *y < 0 ) |
>>>>>>> Updated C and RTL model as well as the documentation |
{ |
*x = -*x; |
*y = -*y; |
459,6 → 512,7
*a = -PI; |
#if PRINT_DEBUG > 0 |
<<<<<<< HEAD |
<<<<<<< HEAD |
PRINT("pre-rotation from third to first quadrand\n" ); |
#endif |
} |
472,6 → 526,11
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 |
*a = 0; |
} |
489,10 → 548,14
|
cordic_int_dbg( *x, *y, *a, mode, 0, "after init" ); |
<<<<<<< HEAD |
<<<<<<< HEAD |
return already_done; |
======= |
|
>>>>>>> initial commit |
======= |
return already_done; |
>>>>>>> Updated C and RTL model as well as the documentation |
} |
|
|
610,10 → 673,14
/* abort condition */ |
if( ( mode & C_FLAG_VEC_ROT ) == 0 && |
<<<<<<< HEAD |
<<<<<<< HEAD |
( *a == 0 /* || *a == -1 */ ) ) |
======= |
( *a == 0 || *a == -1 ) ) |
>>>>>>> initial commit |
======= |
( *a == 0 /* || *a == -1 */ ) ) |
>>>>>>> Updated C and RTL model as well as the documentation |
break; |
if( ( mode & C_FLAG_VEC_ROT ) == 0 && |
( *a == alst ) ) |
621,10 → 688,14
|
if( ( mode & C_FLAG_VEC_ROT ) != 0 && |
<<<<<<< HEAD |
<<<<<<< HEAD |
( *y == 0 /*|| *y == -1 */ ) ) |
======= |
( *y == 0 || *y == -1 ) ) |
>>>>>>> initial commit |
======= |
( *y == 0 /*|| *y == -1 */ ) ) |
>>>>>>> Updated C and RTL model as well as the documentation |
break; |
if( ( mode & C_FLAG_VEC_ROT ) != 0 && |
( *y == ylst ) ) |
/trunk/c_octave/cordic_iterative_code.m
69,11 → 69,16
K0 = 0.607252935009; |
K1 = 0.207497067763; |
<<<<<<< HEAD |
<<<<<<< HEAD |
%prod( sqrt( 1-2.^(-2 .* [ 1 : 100000 ] ) ) ) |
|
======= |
>>>>>>> initial commit |
======= |
%prod( sqrt( 1-2.^(-2 .* [ 1 : 100000 ] ) ) ) |
|
>>>>>>> Updated C and RTL model as well as the documentation |
|
signs = get_rm_gain_shifts( K0, 30 ); |
print_rm_gain_code( fid, signs, K0, 1, 1, 0 ); |
|
88,10 → 93,14
|
MAX_A_WIDTH = 32; |
<<<<<<< HEAD |
<<<<<<< HEAD |
print_angular_lut( fid, MAX_A_WIDTH ); |
======= |
print_angular_lut( fid, MAX_A_WIDTH ) |
>>>>>>> initial commit |
======= |
print_angular_lut( fid, MAX_A_WIDTH ); |
>>>>>>> Updated C and RTL model as well as the documentation |
|
|
fclose( fid ); |
203,10 → 212,14
|
for y = 1 : length( tmp2 ) |
<<<<<<< HEAD |
<<<<<<< HEAD |
fprintf( fid, '%c ( x >> %d ) ', tmp2{ y }, index( y ) ); |
======= |
fprintf( fid, '%c ( x >> %d ) ', tmp2{ y }, index( y ) ) |
>>>>>>> initial commit |
======= |
fprintf( fid, '%c ( x >> %d ) ', tmp2{ y }, index( y ) ); |
>>>>>>> Updated C and RTL model as well as the documentation |
end |
fprintf( fid, '; break; /* error: %.10f */ \n', err ); |
else |
/trunk/c_octave/cordic_iterative_test.m
21,6 → 21,9
%%%% implementation. %%%% |
%%%% %%%% |
<<<<<<< HEAD |
<<<<<<< HEAD |
======= |
>>>>>>> Updated C and RTL model as well as the documentation |
%%%% Three tests are implemented: %%%% |
%%%% - Random test values %%%% |
%%%% - Linear increasing values %%%% |
29,17 → 32,24
%%%% %%%% |
%%%% Please do 'mex cordic_iterative.c' to create %%%% |
%%%% the cordic_iterative.mex. %%%% |
<<<<<<< HEAD |
======= |
>>>>>>> initial commit |
======= |
>>>>>>> Updated C and RTL model as well as the documentation |
%%%% %%%% |
%%%%% %%%%% |
%%%% %%%% |
%%%% TODO %%%% |
<<<<<<< HEAD |
<<<<<<< HEAD |
%%%% The linear test is not complete %%%% |
======= |
%%%% Some documentation and function description %%%% |
>>>>>>> initial commit |
======= |
%%%% The linear test is not complete %%%% |
>>>>>>> Updated C and RTL model as well as the documentation |
%%%% %%%% |
%%%% %%%% |
%%%% %%%% |
67,6 → 77,7
%%%% %%%% |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
<<<<<<< HEAD |
<<<<<<< HEAD |
function cordic_iterative_test( ) |
|
|
75,17 → 86,12
|
|
|
======= |
>>>>>>> Updated C and RTL model as well as the documentation |
function cordic_iterative_test( ) |
% |
% |
% Please do 'mex cordic_iterative.c' to create |
% the cordic_iterative.mex |
% |
% |
% |
% |
|
|
|
>>>>>>> initial commit |
% global flags/values, they are static |
% through the whole script and defined below |
120,6 → 126,7
% open test file |
tb_fid = fopen( './tb_data.txt', 'w' ); |
<<<<<<< HEAD |
<<<<<<< HEAD |
%tb_fid = 0; |
|
|
197,13 → 204,51
0, 0, ... |
'Limit Value Test' ); |
======= |
======= |
%tb_fid = 0; |
|
>>>>>>> Updated C and RTL model as well as the documentation |
|
|
|
|
% |
% run test, which uses random values |
run_random_test( N_TESTS, tb_fid ); |
% |
% run tests, which test limits |
run_limit_test( tb_fid ); |
% |
% run linear value test |
run_linear_test( 1000, tb_fid ); |
|
% close file |
fclose( tb_fid ); |
if tb_fid > 0 |
fclose( tb_fid ); |
end |
|
end |
|
|
|
|
function run_limit_test( tb_fid ) |
%RUN_LIMIT_TEST Test the range limit |
% |
% run_limit_test( fid ) |
% |
% This function is used to generate a test pattern |
% with values, which are at the range limit. |
% This values are then processed by the fixed-point YAC |
% implementation. All input and outputs are logged into |
% a testbench pattern file. |
% |
% The argument fid is the file-descriptor of the testbench pattern |
% file. |
% |
|
|
<<<<<<< HEAD |
>>>>>>> initial commit |
|
end |
237,7 → 282,43
[ atanh_res, sqrt_res, atanh_err, sqrt_err, it_6 ] = catanh( data_a_h, data_b_h, tb_fid ); |
[ sinh_res, cosh_res, sinh_err, cosh_err, it_7 ] = csinhcosh( data_c_h, tb_fid ); |
|
======= |
data_a = [ 0 1 0 1 -1 0 -1 1 -1 ]; |
data_b = [ 0 0 1 1 0 -1 -1 -1 1 ]; |
|
data_c = [ 0 0 0 0 0 0 0 0 0 ... |
1 1 1 1 1 1 1 1 1 ... |
-1 -1 -1 -1 -1 -1 -1 -1 -1 ]; |
|
data_d = data_a * pi; |
|
data_a_div = [ 0.5 ,1 -0.5, -1, -0.5, -1 ]; |
data_b_div = [ 1 ,1, 1, 1, -1, -1 ]; |
|
[ ~, ~, atan_err, abs_err, it_1 ] = ccart2pol( data_a, data_b, tb_fid ); |
[ ~, ~, sin_err, cos_err, it_2 ] = cpol2cart( data_d, data_b, tb_fid ); |
[ ~, ~, x_err, y_err, it_3 ] = crot( [ data_a, data_a, data_a], ... |
[ data_b, data_b, data_b], ... |
data_c, tb_fid ); |
[ ~, div_err, it_4 ] = cdiv( data_a_div, data_b_div, tb_fid ); |
[ ~, mul_err, it_5 ] = cmul( data_a, data_b, tb_fid ); |
|
print_result_info( ... |
atan_err, it_1, ... |
abs_err, it_1, ... |
sin_err, it_2, ... |
cos_err, it_2, ... |
x_err, it_3, ... |
y_err, it_3, ... |
div_err, it_4, ... |
mul_err, it_5, ... |
0, 0, ... |
0, 0, ... |
0, 0, ... |
0, 0, ... |
'Limit Value Test' ); |
>>>>>>> Updated C and RTL model as well as the documentation |
|
figure; plot( data_b_h, atanh_res ); title( 'atanh' ); |
figure; plot( data_b_h, atanh_err ); title( 'atanh-error' ); |
figure; plot( data_c_h, sinh_res, data_c_h, cosh_res ); title( 'sinh and cosh' ); |
246,6 → 327,7
|
|
|
<<<<<<< HEAD |
function run_random_test( N_TESTS, tb_fid ) |
%RUN_RANDOM_TEST Generates a random test pattern |
% |
256,12 → 338,28
% These values are then processed by the fixed-point YAC |
% implementation. All input and outputs are logged into |
% a testbench pattern file. |
======= |
function run_linear_test( N_TESTS, tb_fid ) |
%RUN_LINEAR_TEST Generates a linear test pattern |
% |
% run_linear_test( N, fid ) |
% |
% This function is used to generate linear increasing test |
% values. |
% These values are then processed by the fixed-point YAC |
% implementation. All input and outputs are logged into |
% a testbench pattern file. In addition, the result is plotted. |
% |
% NOTE: only the hyperbolic functions are processed at the moment. |
% This function needs to be extended in future. |
>>>>>>> Updated C and RTL model as well as the documentation |
% |
% |
% The argument fid is the file-descriptor of the testbench pattern |
% file. The argument N defines the number of values, which are processed. |
% |
% |
<<<<<<< HEAD |
data_a = -1 + 2 .* rand( 1, N_TESTS ); |
data_b = -1 + 2 .* rand( 1, N_TESTS ); |
data_c = -1 + 2 .* rand( 1, N_TESTS ); |
268,11 → 366,49
data_d = -pi + 2*pi .* rand( 1, N_TESTS ); |
======= |
function run_random_test( N_TESTS, tb_fid ) |
======= |
|
data_a_h = ones( 1, N_TESTS ); |
data_b_h = linspace( -1, 1, N_TESTS ) * 0.78; |
data_c_h = linspace( -1, 1, N_TESTS ); |
[ atanh_res, sqrt_res, atanh_err, sqrt_err, it_6 ] = catanh( data_a_h, data_b_h, tb_fid ); |
[ sinh_res, cosh_res, sinh_err, cosh_err, it_7 ] = csinhcosh( data_c_h, tb_fid ); |
|
|
figure; plot( data_b_h, atanh_res ); title( 'atanh' ); |
figure; plot( data_b_h, atanh_err ); title( 'atanh-error' ); |
figure; plot( data_c_h, sinh_res, data_c_h, cosh_res ); title( 'sinh and cosh' ); |
figure; plot( data_c_h, sinh_err, data_c_h, cosh_err ); title( 'sinh and cosh errors' ); |
end |
|
|
>>>>>>> Updated C and RTL model as well as the documentation |
|
function run_random_test( N_TESTS, tb_fid ) |
%RUN_RANDOM_TEST Generates a random test pattern |
% |
% run_random_test( N, fid ) |
% |
% This function is used to generate random test |
% values (uniform distributed). |
% These values are then processed by the fixed-point YAC |
% implementation. All input and outputs are logged into |
% a testbench pattern file. |
% |
% |
% The argument fid is the file-descriptor of the testbench pattern |
% file. The argument N defines the number of values, which are processed. |
% |
% |
data_a = -1 + 2 .* rand( 1, N_TESTS ); |
data_b = -1 + 2 .* rand( 1, N_TESTS ); |
<<<<<<< HEAD |
|
>>>>>>> initial commit |
======= |
data_c = -1 + 2 .* rand( 1, N_TESTS ); |
data_d = -pi + 2*pi .* rand( 1, N_TESTS ); |
>>>>>>> Updated C and RTL model as well as the documentation |
% adapat data for division |
data_a_div = data_a; |
data_b_div = data_b; |
282,15 → 418,22
|
data_a_h = ones( size( data_a ) ); |
<<<<<<< HEAD |
<<<<<<< HEAD |
data_b_h = data_b .* 0.80694; %0.78; |
======= |
data_b_h = data_b .* 0.78; |
>>>>>>> initial commit |
======= |
data_b_h = data_b .* 0.80694; %0.78; |
>>>>>>> Updated C and RTL model as well as the documentation |
|
|
|
[ ~, ~, atan_err, abs_err, it_1 ] = ccart2pol( data_a, data_b, tb_fid ); |
<<<<<<< HEAD |
<<<<<<< HEAD |
======= |
>>>>>>> Updated C and RTL model as well as the documentation |
[ ~, ~, sin_err, cos_err, it_2 ] = cpol2cart( data_d, data_b, tb_fid ); |
[ ~, ~, x_err, y_err, it_3 ] = crot( data_a, data_b, data_c, tb_fid ); |
[ ~, div_err, it_4 ] = cdiv( data_a_div, data_b_div, tb_fid ); |
330,6 → 473,7
sinh_err, sinh_it, ... |
cosh_err, cosh_it, ... |
title ) |
<<<<<<< HEAD |
|
fprintf( ' ___________________________________________________________________\n' ); |
fprintf( ' %s\n', title); |
356,22 → 500,26
[ ~, mul_err, it_4 ] = cmul( data_a, data_b, tb_fid ); |
[ ~, ~, atanh_err, sqrt_err, it_5 ] = catanh( data_a_h, data_b_h, tb_fid ); |
[ ~, ~, sinh_err, cosh_err, it_6 ] = csinhcosh( data_a, tb_fid ); |
======= |
>>>>>>> Updated C and RTL model as well as the documentation |
|
fprintf( ' ___________________________________________________________________\n' ); |
fprintf( ' Random Value Test \n' ); |
fprintf( ' %s\n', title); |
fprintf( ' -----+-------------------+--------------------+-------------------\n' ); |
fprintf( ' | max error | mean error | max iterations \n' ); |
fprintf( ' atan | % .14f | % .14f | %.5f \n', max( atan_err ), mean( atan_err ), max( it_1 ) ); |
fprintf( ' abs | % .14f | % .14f | %.5f \n', max( abs_err ), mean( abs_err ), max( it_1 ) ); |
fprintf( ' sin | % .14f | % .14f | %.5f \n', max( sin_err ), mean( sin_err ), max( it_2 ) ); |
fprintf( ' cos | % .14f | % .14f | %.5f \n', max( cos_err ), mean( cos_err ), max( it_2 ) ); |
fprintf( ' div | % .14f | % .14f | %.5f \n', max( div_err ), mean( div_err ), max( it_3 ) ); |
fprintf( ' mul | % .14f | % .14f | %.5f \n', max( mul_err ), mean( mul_err ), mean( it_4 ) ); |
fprintf( ' atanh| % .14f | % .14f | %.5f \n', max( atanh_err), mean( atanh_err ), mean( it_5 ) ); |
fprintf( ' sinh | % .14f | % .14f | %.5f \n', max( sinh_err ), mean( sinh_err ), mean( it_6 ) ); |
fprintf( ' cosh | % .14f | % .14f | %.5f \n', max( cosh_err ), mean( cosh_err ), mean( it_6 ) ); |
fprintf( ' atan | % .14f | % .14f | %.5f \n', max( atan_err ), mean( atan_err ), max( atan_it ) ); |
fprintf( ' abs | % .14f | % .14f | %.5f \n', max( abs_err ), mean( abs_err ), max( abs_it ) ); |
fprintf( ' sin | % .14f | % .14f | %.5f \n', max( sin_err ), mean( sin_err ), max( sin_it ) ); |
fprintf( ' cos | % .14f | % .14f | %.5f \n', max( cos_err ), mean( cos_err ), max( cos_it ) ); |
fprintf( ' x | % .14f | % .14f | %.5f \n', max( x_err ), mean( x_err ), max( x_it ) ); |
fprintf( ' y | % .14f | % .14f | %.5f \n', max( y_err ), mean( y_err ), max( y_it ) ); |
fprintf( ' div | % .14f | % .14f | %.5f \n', max( div_err ), mean( div_err ), max( div_it ) ); |
fprintf( ' mul | % .14f | % .14f | %.5f \n', max( mul_err ), mean( mul_err ), max( mul_it ) ); |
fprintf( ' atanh| % .14f | % .14f | %.5f \n', max( atanh_err ), mean( atanh_err ), max( atanh_it ) ); |
fprintf( ' sqrt | % .14f | % .14f | %.5f \n', max( sqrt_err ), mean( sqrt_err ), max( sqrt_it ) ); |
fprintf( ' sinh | % .14f | % .14f | %.5f \n', max( sinh_err ), mean( sinh_err ), max( sinh_it ) ); |
fprintf( ' cosh | % .14f | % .14f | %.5f \n', max( cosh_err ), mean( cosh_err ), max( cosh_it ) ); |
|
|
end |
>>>>>>> initial commit |
|
378,6 → 526,7
|
|
|
|
function [sinh_res, cosh_res, sinh_err, cosh_err, it ]= csinhcosh( th, fid ) |
global C_FLAG_VEC_ROT C_FLAG_ATAN_3 C_MODE_CIRC C_MODE_LIN C_MODE_HYP |
global XY_WIDTH ANGLEWIDTH GUARDBITS RM_GAIN |
539,6 → 688,9
|
|
<<<<<<< HEAD |
<<<<<<< HEAD |
======= |
>>>>>>> Updated C and RTL model as well as the documentation |
function [x_res, y_res, x_err, y_err, it ] = crot( x, y, th, fid ) |
% |
% does a multiplication with exp( th * i ) |
584,6 → 736,7
% does the Matlab equivalent pol2cart |
% |
|
<<<<<<< HEAD |
======= |
|
|
590,6 → 743,8
|
function [sin_res, cos_res, sin_err, cos_err, it ]= cpol2cart( th, r, fid ) |
>>>>>>> initial commit |
======= |
>>>>>>> Updated C and RTL model as well as the documentation |
global C_FLAG_VEC_ROT C_FLAG_ATAN_3 C_MODE_CIRC C_MODE_LIN C_MODE_HYP |
global XY_WIDTH ANGLEWIDTH GUARDBITS RM_GAIN |
|
598,6 → 753,7
ai = round( th .* (2^(ANGLEWIDTH-1)-1) ); |
|
<<<<<<< HEAD |
<<<<<<< HEAD |
mode = C_MODE_CIRC; |
|
======= |
608,6 → 764,10
|
% cordic version |
>>>>>>> initial commit |
======= |
mode = C_MODE_CIRC; |
|
>>>>>>> Updated C and RTL model as well as the documentation |
[ rcos rsin ra, it ] = cordic_iterative( ... |
xi, ... |
yi, ... |
636,9 → 796,13
|
|
<<<<<<< HEAD |
<<<<<<< HEAD |
|
======= |
>>>>>>> initial commit |
======= |
|
>>>>>>> Updated C and RTL model as well as the documentation |
function [atan_res, abs_res, atan_err, abs_err, it ] = ccart2pol( x, y, fid ) |
|
global C_FLAG_VEC_ROT C_FLAG_ATAN_3 C_MODE_CIRC C_MODE_LIN C_MODE_HYP |
665,14 → 829,20
GUARDBITS, ... |
RM_GAIN ); |
<<<<<<< HEAD |
<<<<<<< HEAD |
======= |
>>>>>>> Updated C and RTL model as well as the documentation |
% matlab version: |
m_th = atan2( y, x ); |
m_r = sqrt( x.^2 + y.^2 ); |
|
<<<<<<< HEAD |
======= |
% matlab version |
[m_th, m_r ] = cart2pol( x, y ); |
>>>>>>> initial commit |
======= |
>>>>>>> Updated C and RTL model as well as the documentation |
|
% comparison |
atan_res = ra ./ 2^( (ANGLEWIDTH)-1); |
681,10 → 851,15
abs_err = abs( m_r - abs_res ); |
|
<<<<<<< HEAD |
<<<<<<< HEAD |
% TODO: ATAN oder ATAN2 atan( 0 / x ) != atan2( 0, x )!!!! |
|
======= |
>>>>>>> initial commit |
======= |
% TODO: ATAN oder ATAN2 atan( 0 / x ) != atan2( 0, x )!!!! |
|
>>>>>>> Updated C and RTL model as well as the documentation |
% write TB data |
write_tb( fid, xi, yi, ai, rx, ry, ra, mode ) |
|
/trunk/README.txt
24,6 → 24,9
|
|
<<<<<<< HEAD |
<<<<<<< HEAD |
======= |
>>>>>>> Updated C and RTL model as well as the documentation |
Author(s): Christian Haettich |
Email feddischson@opencores.org |
|
91,8 → 94,11
|
|
|
<<<<<<< HEAD |
======= |
>>>>>>> initial commit |
======= |
>>>>>>> Updated C and RTL model as well as the documentation |
|
Files and folders: |
------------------ |
112,6 → 118,9
|
|
<<<<<<< HEAD |
<<<<<<< HEAD |
======= |
>>>>>>> Updated C and RTL model as well as the documentation |
|
|
[1] Andraka, Ray; A survey of CORDIC algorithms for FPGA based computers, 1989 |
122,5 → 131,8
http://www.eecs.berkeley.edu/newton/Classes/EE290sp99/lectures/ee290aSp996_1/cordic_chap24.pdf |
|
|
<<<<<<< HEAD |
======= |
>>>>>>> initial commit |
======= |
>>>>>>> Updated C and RTL model as well as the documentation |