From 8ea67f463dea793611002ed802e6bf51d50d7efc Mon Sep 17 00:00:00 2001 From: Jalil Chemseddine Date: Thu, 15 Nov 2012 14:22:16 +0100 Subject: cesar/ce/rx/bl: update script to handle new polynomials BER vs NSR, refs #2560 --- cesar/ce/rx/bitloading/src/import_poly_coeff.pl | 203 ++++++++++++++++++------ 1 file changed, 155 insertions(+), 48 deletions(-) diff --git a/cesar/ce/rx/bitloading/src/import_poly_coeff.pl b/cesar/ce/rx/bitloading/src/import_poly_coeff.pl index f69796f78f..ef4d12201c 100644 --- a/cesar/ce/rx/bitloading/src/import_poly_coeff.pl +++ b/cesar/ce/rx/bitloading/src/import_poly_coeff.pl @@ -3,8 +3,9 @@ # Load polynomial coefficients from the TNS team. ### # It should be done by hand, using the folowing commands: -# perl ce/rx/bitloading/src/import_poly_nsr.pl < Polynomes_BERinq_vs_NSRq_normalises.m +# perl ce/rx/bitloading/src/import_poly_coeff.pl Polynomes_BERinq_vs_NSRq_normalises.m BitAllocationNSRLines.m # http://stestephe/svn/spidcom_digital_svn/projects/DSP_350/DSP_chain/SW/Bit_Loading/BER_vs_NSR/Polynomes_BERinq_vs_NSRq_normalises.m +# http://stestephe/svn/spidcom_digital_svn/projects/DSP_350/DSP_chain/SW/Bit_Loading/BitAllocationNSRLines.m # Output of this script should be placed in ce/rx/bitloading/src/ber.c. ##### @@ -20,20 +21,40 @@ my %fec_rate = ( "1/2" => 0, "16/21" => 1); my $leaf_re = qr/{[^}]+}/; # A set: a set of many some polynomials with their coefficients. my $set_re = qr/(?:$leaf_re\s*,\s*)*$leaf_re/; +# A leaf: a set of coefficients (new format). +my $leaf_new = qr/[^\]]+/; +#identifiers for BitAllocationNSRLines.m +my $new_input_file = 0; +my $new_params = 0; +#identifier for Polynomes_BERinq_vs_NSRq_normalises.m +my $old_input_file = 0; # Decode input data. sub process { my ($name, $value) = @_; - # Support both formats. + # Support all formats. die "bad format" unless $value =~ /^{\s*{\s*($set_re)\s*}\s*,\s*{\s*($set_re)\s*}\s*}$/ - || $value =~ /^{\s*($leaf_re)\s*,\s*($leaf_re)\s*}$/; + || $value =~ /^{\s*($leaf_re)\s*,\s*($leaf_re)\s*}$/ + || $value =~ /\[($leaf_new)\]/; + + if ($new_input_file == 1 ) + { + # This is for render part + $new_params = 1; + my ($fec1621, $fec12) = ($1, $1); + $values[$fec_rate{"16/21"}]->{$name} = [ $fec1621 =~ /$leaf_new/g ]; + $values[$fec_rate{"1/2"}]->{$name} = [ $fec12 =~ /$leaf_new/g ]; + } # File from the TNS team are organised in the following way: firsts # coefficients are FEC rate 16/21, second ones are for FEC rate 1/2. - my ($fec1621, $fec12) = ($1, $2); - $values[$fec_rate{"16/21"}]->{$name} = [ $fec1621 =~ /$leaf_re/g ]; - $values[$fec_rate{"1/2"}]->{$name} = [ $fec12 =~ /$leaf_re/g ]; + else + { + my ($fec1621, $fec12) = ($1, $2); + $values[$fec_rate{"16/21"}]->{$name} = [ $fec1621 =~ /$leaf_re/g ]; + $values[$fec_rate{"1/2"}]->{$name} = [ $fec12 =~ /$leaf_re/g ]; + } } # Render in C decoded data. @@ -45,50 +66,113 @@ sub render {\n"; # Select one FEC rate. my $rate = $fec_rate{"16/21"}; + # For each modulation. - for my $i (1, 2, 3, 4, 6, 8, 10) + if ( $new_params == 0) { - # Get arrays. - my @polys = @{$values[$rate]->{'poly' . $i}}; - my @enss = @{$values[$rate]->{'ens' . $i}}; - # Count number of polynomials. - my $poly_count = @polys; - # Add "ll" at end of each number and count number of occurence. - my @counts; - push @counts, (s/(-?\d+)/ $1ll/g - 1) for @polys; - # Convert ens (to remove continuous values). - my $enss = join ', ', @enss; - $enss =~ y/{}//d; - @enss = split /\s*,\s*/, $enss; - my @ens = shift @enss; - my $ff = 1; - for (@enss) + for my $i (1, 2, 3, 4, 6, 8, 10) { - if ($ff) - { - push @ens, $_; - } - else - { - die "non consecutive ensemble" unless $_ == $ens[-1] + 1; - } - $ff = !$ff; + # Get arrays. + my @polys = @{$values[$rate]->{'poly' . $i}}; + my @enss = @{$values[$rate]->{'ens' . $i}}; + # Count number of polynomials. + my $poly_count = @polys; + # Add "ll" at end of each number and count number of occurence. + my @counts; + push @counts, (s/(-?\d+)/ $1ll/g - 1) for @polys; + # Convert ens (to remove continuous values). + my $enss = join ', ', @enss; + $enss =~ y/{}//d; + @enss = split /\s*,\s*/, $enss; + my @ens = shift @enss; + my $ff = 1; + for (@enss) + { + if ($ff) + { + push @ens, $_; + } + else + { + die "non consecutive ensemble" unless $_ == $ens[-1] + 1; + } + $ff = !$ff; + } + # Cosmetic changes. + s/(\})/ $1/ for @polys; + # Render. + local $" = ', '; + print " { + $poly_count, + { @counts }, + { + @polys, + }, + { @ens }, + }, + " } - # Cosmetic changes. - s/(\})/ $1/ for @polys; - # Render. - local $" = ', '; - print " { - $poly_count, - { @counts }, + print "};\n"; + } + else + { + for my $i (1, 2, 3, 5, 6, 8, 10) { - @polys, - }, - { @ens }, - }, -" + # Get arrays. + my @a_poly_part = @{$values[$rate]->{'a' . $i}}; + my @b_poly_part = @{$values[$rate]->{'b' . $i}}; + my @enss = @{$values[$rate]->{'x' . $i}}; + + # Add "ll" at end of each number and count number of occurence. + my @counts; + push @counts, (s/(-?\d+)/ $1ll/g ) for @a_poly_part; + push @counts, (s/(-?\d+)/ $1ll/g ) for @b_poly_part; + die "non consecutive polynom part" if $counts[0] != $counts[1] ; + # Convert ens (to remove continuous values). + my $enss = join ', ', @enss; + $enss =~ y/{}//d; + @enss = split /\s*,\s*/, $enss; + my @ens; + my $ff = 1; + for (@enss) + { + if ($ff) + { + push @ens, $_; + $ff = !$ff; + } + else + { + push @ens, ($_-1); + } + } + $a_poly_part[0] =~ s/ //g; + $b_poly_part[0] =~ s/ //g; + my @a_poly_part_tab = split(',',$a_poly_part[0]); + my @b_poly_part_tab = split(',',$b_poly_part[0]); + my $poly_count = @a_poly_part_tab; + my @polys; + my @poly_order; + for(my $j = 0; $j < $poly_count; $j++) + { + push @polys, "\n { $a_poly_part_tab[$j], $b_poly_part_tab[$j]}"; + push @poly_order, "1"; + } + + # Cosmetic changes. + s/(\})/ $1/ for @polys; + # Render. + local $" = ','; + print " { + $poly_count, + { @poly_order }, + {@polys, + }, + { @ens }, + },\n" + } + print "};\n"; } - print "};\n"; # BER consign coefficients. # For each project (AV, EoC). @@ -99,7 +183,7 @@ sub render local $" = ', '; print "\nstatic const s64\n"; print "ce_rx_bl_ber_consign_coefs_" . $lp . "[PHY_FEC_RATE_NB]"; - print "[CE_RX_BL_BER_POLY_MAX_DEGREE] = {\n"; + print "[CE_RX_BL_BER_POLY_MAX_DEGREE] =\n{\n"; my @count; # For each rate. for my $rate (sort values %fec_rate) @@ -121,6 +205,8 @@ sub render } } +$old_input_file = 1; + while (<>) { # Remove uneeded stuff from imput. @@ -135,14 +221,35 @@ while (<>) defined $prev and $_ = $prev . ' ' . $_; undef $prev; # If continued: + if (/^function/) + { + $new_input_file = 1; + $old_input_file = 0; + next; + } + if (/^return/) + { + $new_input_file = 0; + $old_input_file = 1; + next; + } + if (/^end/ or /^else/ or /^for/ or /^global/) + { + next; + } if (/[^;]$/) { $prev = $_; next; } - # Decode. - die "invalid format, stoping" unless (/^([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.+)\s*;$/); - process ($1, $2); + # new polynome identifier + if ((/^[abx][0-9]/ and $new_input_file == 1 ) or $old_input_file == 1 ) + { + # Decode. + die "invalid format, stoping" unless (/^([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.+)\s*;$/); + process ($1, $2); + } + } die "unexpected end of file, stoping" if defined $prev; -- cgit v1.2.3