Subversion Repositories svn.mios

Rev

Rev 1 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 tk 1
#!/usr/bin/perl
2
 
3
$tick_rate = 1E-3;
4
 
5
printf "const unsigned int eg_add_table[256] = {\r\n";
6
 
7
printf "  %5d, // %3d: %6.3f s\r\n", 0, 0, 0;
8
 
9
for($x=1; $x<256; ++$x)
10
{
11
  # TIME = (32768 / ADD) * TICK_RATE
12
  # TIME = (32768 * TICK_RATE) / ADD
13
  # -> ADD = (32768 * TICK_RATE) / TIME
14
 
15
  my $tim = x * 0.0030 + exp(0.00002*$x*$x)-1;
16
  my $add = int((32768 * $tick_rate) / $tim);
17
  if( $add >= 32768 ) { $add = 32768; $tim = 1E-3; }
18
  $effective_tim = (32768 / $add) * $tick_rate;
19
  printf "  %5d, // %3d: %6.3f s\r\n", $add, $x, $effective_tim;
20
}
21
 
22
printf "};\r\n";
23