From bf2c4cb8098717b7f833de553bf3a47db58dc9c5 Mon Sep 17 00:00:00 2001 From: lacour Date: Wed, 5 Mar 2008 16:51:38 +0000 Subject: Separation between computation and acquisition of frame_measurement : Add bitloading.h, bitloading.c ; clean frame_measurement ; Adapt tests. Change any functions and variables name. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1567 017c9cb6-072f-447c-8318-d5b54f68fe89 --- ce/test/rx/general/host-Makefile | 5 +- ce/test/rx/general/src/test_bitloading.c | 217 +++++++++++++++++++++ ce/test/rx/general/src/test_frame_measurement.c | 240 +----------------------- ce/test/rx/general/src/test_rx.c | 1 + ce/test/rx/general/src/test_sar_integration.c | 1 + ce/test/rx/general/target-Makefile | 2 +- ce/test/rx/host_linux_sparc/Makefile | 2 +- ce/test/rx/maximus/Makefile | 2 +- ce/test/rx/tonemap_refresh/Makefile | 2 +- 9 files changed, 235 insertions(+), 237 deletions(-) create mode 100755 ce/test/rx/general/src/test_bitloading.c (limited to 'ce/test') diff --git a/ce/test/rx/general/host-Makefile b/ce/test/rx/general/host-Makefile index 3febc79e5d..78e6298c00 100755 --- a/ce/test/rx/general/host-Makefile +++ b/ce/test/rx/general/host-Makefile @@ -14,13 +14,16 @@ test_cei_param_host_linux_i386_MODULES = lib mac/common ce ce/test/common ce/tes HOST_PROGRAMS += test_fm_host_linux_i386 test_fm_host_linux_i386_SOURCES = test_frame_measurement.c test_fm_host_linux_i386_MODULES = lib mac/common ce ce/test/common ce/test/common/ecos_overide/cyg/kernel +HOST_PROGRAMS += test_bitloading_host_linux_i386 +test_bitloading_host_linux_i386_SOURCES = test_bitloading.c +test_bitloading_host_linux_i386_MODULES = lib mac/common ce ce/test/common ce/test/common/ecos_overide/cyg/kernel #HOST_PROGRAMS += test_speed_host_linux_i386 #test_speed_host_linux_i386_SOURCES = test_speed.c #test_speed_host_linux_i386_MODULES = lib mac/common ce ce/test/common -ce_MODULE_SOURCES = cei_param.c frame_measurement.c +ce_MODULE_SOURCES = cei_param.c frame_measurement.c bitloading.c ce_test_common_MODULE_SOURCES = print_utils.c gaussian.c mac_common_MODULE_SOURCES = tonemap.c tonemask.c store.c mfs.c sta.c diff --git a/ce/test/rx/general/src/test_bitloading.c b/ce/test/rx/general/src/test_bitloading.c new file mode 100755 index 0000000000..f4f8f3f12c --- /dev/null +++ b/ce/test/rx/general/src/test_bitloading.c @@ -0,0 +1,217 @@ +/* Cesar project {{{ + * + * Copyright (C) 2007 Spidcom + * + * <<>> + * + * }}} */ +/** + * \file ./src/test_tx.c + * \brief « brief description » + * \ingroup « module » + * + * « long description » + */ + + +#include "common/std.h" +#include "lib/bitstream.h" +#include "mac/common/tonemap.h" +#include "ce/test/common/print_utils.h" +#include "ce/inc/bitloading.h" +#include "lib/rnd.h" +#include "ce/test/common/gaussian.h" +#include "lib/test.h" + +lib_rnd_t rnd; + +void +test_is_time_noise_stable (test_t t) +{ + test_begin (t, "is_time_noise_stable") + { + int i,j,k; + phy_chandata_t *test = (phy_chandata_t *) blk_alloc_desc (); + test->type = PHY_CHANDATA_TYPE_NRJ_SYMBOL; + test->size = 113 ; + double var; + double sigma_lambda=0.00; + uint stable_nb=0; + for (k = 1 ; k < 20; k++) + { + sigma_lambda += 0.01; + stable_nb = 0; + for (j=0; j<100; j++) + { + lib_rnd_init (&rnd, j); + phy_noise_t *data = (phy_noise_t *) test->blk.data; + for (i=0; i<113; i++) + { + int l = 2*UND_CODE; + var = lib_rnd_gaussian (&rnd, l, sigma_lambda*l); + if (var < 0) var = 2*l-var; + if (var > MAX_UND_CODE) var = 2*l -var; + if (var < 0) var = 0; + if (var > MAX_UND_CODE) var = MAX_UND_CODE; + *(data++) = (int) (var); + } + if (bitloading_mpdu_noise_stability (test)) stable_nb++; + + } + test_fail_if (k < 10 && stable_nb < 80 ); + test_fail_if (k > 10 && stable_nb > 20 ); + test_fail_if (k == 10 && (stable_nb < 20 || stable_nb > 80) ); + } + blk_release_desc ((blk_t *) test); + } test_end; +} + +void +test_noise2mod (test_t t) +{ + test_begin (t, "noise to modulation") + { + uint accu = 1 ; // DSP provides directly the average + uint noise_CODE; + uint mod; + uint mod_measurement; + frame_measurement_init (); + bitloading_update_threshold (accu, 1); + for (noise_CODE=0; noise_CODE<=UND_CODE; noise_CODE++) + { + mod_measurement = 1; // ONLY THR-QPSK TODO others + { + mod = bitloading_noise2mod (noise_CODE); + if (mod == 7 ) test_verbose_print ("mod = %d : %d <= %d?", mod, noise_CODE, THR3[mod_measurement][mod-1]); + if (mod == 0 ) test_verbose_print ("mod = %d : %d > %d?", mod, noise_CODE, THR3[mod_measurement][mod]); + if (mod != 0 && mod != 7 ) test_verbose_print ("mod = %d : %d E ]%d,%d]?", mod, noise_CODE, THR3[mod_measurement][mod], THR3[mod_measurement][mod-1]); + if (mod == 7 ) test_fail_if (noise_CODE > accu*THR3[mod_measurement][mod-1]); + else + { + test_fail_if (noise_CODE <= accu*THR3[mod_measurement][mod]); + if (mod != 0) test_fail_if (noise_CODE > accu*THR3[mod_measurement][mod-1]); + } + } + } + } test_end; +} + +void +test_compute_worst_tonemap (test_t t) +{ + test_begin (t, "update or new worst tonemap") + { + uint c; + + phy_chandata_t *b, *l; + phy_chandata_t *freq_noise = (phy_chandata_t *) blk_alloc_desc_range (PHY_CHANDATA_NRJ_BLK_NB, (blk_t **) &l); + tonemap_t *tm = NULL; + + l->blk.next = NULL; + l->last = 1; + + int carrier_uninit = PHY_CARRIER_NB; + int carrier_init = 0; + int carrier_index = -1; + int k=0; + uint noise1[PHY_CARRIER_NB]; + for (b = freq_noise; b; b = (phy_chandata_t *) b->blk.next) + { + if (carrier_uninit > 128) b->size = 128; + else b->size = carrier_uninit; + b->type = PHY_CHANDATA_TYPE_NRJ; + phy_noise_t *data = (phy_noise_t *) b->blk.data; + for (c=0; ctmdma_desc_head->data, BLK_SIZE, BITSTREAM_READ); + for (c=0; c< PHY_CARRIER_NB; c++) + { + if (c == 1024) + { + bitstream_init(&stream, tm->tmdma_desc_head->next->data, BLK_SIZE, BITSTREAM_READ); + } + uint mod; + bitstream_access (&stream, &mod, 4); + uint noise = noise1[c]; + if (mod == 0) test_fail_if (noise < THR3[1][0]); + if (mod == 7) test_fail_if (noise > THR3[1][6]); + if (mod>0 && mod<7) + { + test_fail_if (noise > THR3[1][mod-1]); + test_fail_if (noise <= THR3[1][mod]); + } + } + + lib_rnd_init (&rnd, 23); + + carrier_uninit = PHY_CARRIER_NB; + carrier_init = 0; + carrier_index = -1; + uint noise2[PHY_CARRIER_NB]; + for (b = freq_noise; b; b = (phy_chandata_t *) b->blk.next) + { + phy_noise_t *data = (phy_noise_t *) b->blk.data; + for (c=0; ctmdma_desc_head->data, BLK_SIZE, BITSTREAM_READ); + for (c=0; c< PHY_CARRIER_NB; c++) + { + if (c == 1024) + { + bitstream_init(&stream, tm->tmdma_desc_head->next->data, BLK_SIZE, BITSTREAM_READ); + } + uint mod; + bitstream_access (&stream, &mod, 4); + uint noise = noise2[c]; if (noise1[c]>noise2[c]) noise = noise1[c]; + if (mod == 0) test_fail_if (noise < THR3[1][0]); + if (mod == 7) test_fail_if (noise > THR3[1][6]); + if (mod>0 && mod<7) + { + test_fail_if (noise > THR3[1][mod-1]); + test_fail_if (noise <= THR3[1][mod]); + } + } + blk_release_desc_range ((blk_t *) freq_noise,(blk_t *) l); + blk_t *f = tm->tmdma_desc_head; + blk_release_desc_range (f, f->next); + tm = NULL; + + } test_end; +} + +int +main (int argc, char **argv) +{ + test_t test; + frame_measurement_init(); + test_init (test, argc, argv); + test_case_begin (test, "CE-computation"); + test_is_time_noise_stable (test); + test_noise2mod (test); + test_compute_worst_tonemap (test); + test_result (test); + return (test_nb_failed (test) == 0 ? 0 : 1); +} + diff --git a/ce/test/rx/general/src/test_frame_measurement.c b/ce/test/rx/general/src/test_frame_measurement.c index fdab1bfa0d..96f8fe5b82 100755 --- a/ce/test/rx/general/src/test_frame_measurement.c +++ b/ce/test/rx/general/src/test_frame_measurement.c @@ -15,212 +15,19 @@ #include "common/std.h" -#include "lib/bitstream.h" #include "mac/common/tonemap.h" #include "ce/test/common/print_utils.h" - #include "lib/rnd.h" -#include "ce/test/common/gaussian.h" #include "lib/test.h" +//#include "ce/inc/frame_measurement.h" lib_rnd_t rnd; -int affect; -int delay_unit; - -void -test_is_time_noise_stable (test_t t) -{ - test_begin (t, "is_time_noise_stable") - { - int i,j,k; - phy_chandata_t *test = (phy_chandata_t *) blk_alloc_desc (); - test->type = PHY_CHANDATA_TYPE_NRJ_SYMBOL; - test->size = 113 ; - double var; - double sigma_lambda=0.00; - uint stable_nb=0; - for (k = 1 ; k < 20; k++) - { - sigma_lambda += 0.01; - stable_nb = 0; - for (j=0; j<100; j++) - { - lib_rnd_init (&rnd, j); - phy_noise_t *data = (phy_noise_t *) test->blk.data; - for (i=0; i<113; i++) - { - //my_print (" %d ", (int)(100.0*sigma_lambda)); - int l = 2*UND_CODE; - var = lib_rnd_gaussian (&rnd, l, sigma_lambda*l); - //printf ("var = %lf\n", var); - if (var < 0) var = 2*l-var; - if (var > MAX_UND_CODE) var = 2*l -var; - if (var < 0) var = 0; - if (var > MAX_UND_CODE) var = MAX_UND_CODE; - //my_print ("%x\n",(int) var); - *(data++) = (int) (var); - } - //print_buffer (test->blk.data, 128*4); - if (is_time_noise_stable (test)) stable_nb++; - - } - //test_verbose_print (" %d%% stable for s/l=0.01*%d", stable_nb, k); - test_fail_if (k < 10 && stable_nb < 80 ); - test_fail_if (k > 10 && stable_nb > 20 ); - test_fail_if (k == 10 && (stable_nb < 20 || stable_nb > 80) ); - } - blk_release_desc ((blk_t *) test); - } test_end; -} - -void -test_noise2mod (test_t t) -{ - test_begin (t, "noise to modulation") - { - uint accu = 1 ; // DSP provides directly the average - uint noise_CODE; - uint mod; - uint mod_measurement; - frame_measurement_init (); - update_threshold (accu, 1); - for (noise_CODE=0; noise_CODE<=UND_CODE; noise_CODE++) - { - //for (mod_measurement=0; mod_measurement<7;mod_measurement++) - mod_measurement = 1; // ONLY THR-QPSK TODO others - { - mod = noise2mod (noise_CODE); - if (mod == 7 ) test_verbose_print ("mod = %d : %d <= %d?", mod, noise_CODE, THR3[mod_measurement][mod-1]); - if (mod == 0 ) test_verbose_print ("mod = %d : %d > %d?", mod, noise_CODE, THR3[mod_measurement][mod]); - if (mod != 0 && mod != 7 ) test_verbose_print ("mod = %d : %d E ]%d,%d]?", mod, noise_CODE, THR3[mod_measurement][mod], THR3[mod_measurement][mod-1]); - if (mod == 7 ) test_fail_if (noise_CODE > accu*THR3[mod_measurement][mod-1]); - else - { - test_fail_if (noise_CODE <= accu*THR3[mod_measurement][mod]); - if (mod != 0) test_fail_if (noise_CODE > accu*THR3[mod_measurement][mod-1]); - } - } - } - } test_end; -} - -void -test_compute_worst_tonemap (test_t t) -{ - test_begin (t, "update or new worst tonemap") - { - uint c; - - phy_chandata_t *b, *l; - phy_chandata_t *freq_noise = (phy_chandata_t *) blk_alloc_desc_range (PHY_CHANDATA_NRJ_BLK_NB, (blk_t **) &l); - tonemap_t *tm = NULL; - - l->blk.next = NULL; - l->last = 1; - - int carrier_uninit = PHY_CARRIER_NB; - int carrier_init = 0; - int carrier_index = -1; - int k=0; - uint noise1[PHY_CARRIER_NB]; - for (b = freq_noise; b; b = (phy_chandata_t *) b->blk.next) - { - if (carrier_uninit > 128) b->size = 128; - else b->size = carrier_uninit; - b->type = PHY_CHANDATA_TYPE_NRJ; - phy_noise_t *data = (phy_noise_t *) b->blk.data; - for (c=0; ctmdma_desc_head->data, BLK_SIZE, BITSTREAM_READ); - for (c=0; c< PHY_CARRIER_NB; c++) - { - if (c == 1024) - { - bitstream_init(&stream, tm->tmdma_desc_head->next->data, BLK_SIZE, BITSTREAM_READ); - } - uint mod; - bitstream_access (&stream, &mod, 4); - uint noise = noise1[c]; - //ce_print ("test : mod = %d, noise=%d E [%d,%d[?\n",mod, noise, THR3[1][mod-1], THR3[1][mod]); - if (mod == 0) test_fail_if (noise < THR3[1][0]); - if (mod == 7) test_fail_if (noise > THR3[1][6]); - if (mod>0 && mod<7) - { - test_fail_if (noise > THR3[1][mod-1]); - test_fail_if (noise <= THR3[1][mod]); - } - } - //ce_print_tonemap (tm); - - lib_rnd_t rnd; - lib_rnd_init (&rnd, 23); - - carrier_uninit = PHY_CARRIER_NB; - carrier_init = 0; - carrier_index = -1; - uint noise2[PHY_CARRIER_NB]; - for (b = freq_noise; b; b = (phy_chandata_t *) b->blk.next) - { - phy_noise_t *data = (phy_noise_t *) b->blk.data; - for (c=0; ctmdma_desc_head->data, BLK_SIZE, BITSTREAM_READ); - for (c=0; c< PHY_CARRIER_NB; c++) - { - if (c == 1024) - { - bitstream_init(&stream, tm->tmdma_desc_head->next->data, BLK_SIZE, BITSTREAM_READ); - } - uint mod; - bitstream_access (&stream, &mod, 4); - uint noise = noise2[c]; if (noise1[c]>noise2[c]) noise = noise1[c]; - //ce_print ("test : mod = %d, noise=%d E [%d,%d[?\n",mod, noise, THR3[1][mod-1], THR3[1][mod]); - if (mod == 0) test_fail_if (noise < THR3[1][0]); - if (mod == 7) test_fail_if (noise > THR3[1][6]); - if (mod>0 && mod<7) - { - test_fail_if (noise > THR3[1][mod-1]); - test_fail_if (noise <= THR3[1][mod]); - } - } - blk_release_desc_range ((blk_t *) freq_noise,(blk_t *) l); - blk_t *f = tm->tmdma_desc_head; - blk_release_desc_range (f, f->next); - tm = NULL; - - } test_end; -} void test_alloc_release (test_t test) { test_begin (test, "frame_measurement allocation and release") { - //blk_print_memory (); test_fail_unless (blk_check_memory ()); } test_end; } @@ -228,8 +35,6 @@ test_alloc_release (test_t test) void sar_fill_ber (pb_measurement_list_t *first, uint n, uint ber_init_value) { - //my_print ("sar fill %d pb in buffer @0x%x started from %d\n", - // n, first, ber_init_value); uint i; u32 *wrdata = (u32 *) first->data; uint offset = first->pb_nb; @@ -257,11 +62,9 @@ test_frame_measurement_ber_add (test_t t) { uint sar_call_nb, pb_nb_per_call; for (sar_call_nb=1; sar_call_nb < MAX_PB; sar_call_nb++) - //sar_call_nb =1; { uint max_pb_nb_per_call = MAX_PB / sar_call_nb; for (pb_nb_per_call=1; pb_nb_per_call0) comp++; test_fail_if (cpt != comp); frame_measurement_release (fm); - //frame_measurement_print (fm); } } } test_end; @@ -353,7 +153,6 @@ test_frame_measurement_noise_add (test_t t) } for (i=0; itype_head[i]; while (chandata) { @@ -364,7 +163,6 @@ test_frame_measurement_noise_add (test_t t) test_fail_if (*(data+j) != i*j); } int last = chandata->last; - //my_print ("last = %d\n", last); chandata = (phy_chandata_t *) chandata->blk.next; if (!chandata) test_fail_if (last == 0); else test_fail_if (last == 1); @@ -388,11 +186,9 @@ test_frame_measurement_add (test_t t) int i; for (i=0; i 5 ) { - //my_print (" one more\n"); pbproc_rx_params_t *rx_params = (pbproc_rx_params_t *) blk_alloc(); pb_measurement_list_t **f,**l; f = l = NULL; @@ -403,21 +199,15 @@ test_frame_measurement_add (test_t t) nb_frame_added++; nb_frame_measurement++; } - else - { - //my_print ("cancelled\n"); - } } else { if (nb_frame_measurement == 0) { - //my_print (" no more frame\n"); test_fail_if (fm_number != 0); } else { - //my_print (" one less\n"); frame_measurement_t *first = frame_measurement_get_next (); int test = first->rx_params->preamble_ntb; test_fail_if (test != (nb_frame_added - nb_frame_measurement)); @@ -430,7 +220,6 @@ test_frame_measurement_add (test_t t) { frame_measurement_t *first = frame_measurement_get_next (); int test = first->rx_params->preamble_ntb; - //my_print (" test= %d <-> (%d - %d)\n",test, nb_frame_added, nb_frame_measurement); test_fail_if (test != (nb_frame_added - nb_frame_measurement)); frame_measurement_release (first); nb_frame_measurement--; @@ -443,26 +232,13 @@ int main (int argc, char **argv) { test_t test; - //dbg_fatal_try_begin - { - frame_measurement_init(); - test_init (test, argc, argv); - - test_case_begin (test, "CE-computation"); - test_is_time_noise_stable (test); - test_noise2mod (test); - test_compute_worst_tonemap (test); - test_case_begin (test, "CE-frame measurement management"); - test_frame_measurement_ber_add (test); - test_frame_measurement_noise_add (test); - test_frame_measurement_add (test); - test_alloc_release (test); - } - //dbg_fatal_try_catch (const char *fatal_message) - { - //my_print ("assertion failure... %s \n",fatal_message); - } - //dbg_fatal_try_end; + frame_measurement_init(); + test_init (test, argc, argv); + test_case_begin (test, "CE-frame measurement management"); + test_frame_measurement_ber_add (test); + test_frame_measurement_noise_add (test); + test_frame_measurement_add (test); + test_alloc_release (test); test_result (test); return (test_nb_failed (test) == 0 ? 0 : 1); } diff --git a/ce/test/rx/general/src/test_rx.c b/ce/test/rx/general/src/test_rx.c index 8f77c51deb..8d5654154f 100755 --- a/ce/test/rx/general/src/test_rx.c +++ b/ce/test/rx/general/src/test_rx.c @@ -25,6 +25,7 @@ #include "lib/trace.h" #include "mac/common/ntb.h" #include "ce/inc/trace.h" +#include "ce/inc/bitloading.h" lib_rnd_t rnd; test_t test; diff --git a/ce/test/rx/general/src/test_sar_integration.c b/ce/test/rx/general/src/test_sar_integration.c index a4db2a1602..0d31cf2d55 100755 --- a/ce/test/rx/general/src/test_sar_integration.c +++ b/ce/test/rx/general/src/test_sar_integration.c @@ -23,6 +23,7 @@ #include "mac/common/ntb.h" #include "ce/inc/trace.h" #include "hal/phy/phy.h" +#include "ce/inc/bitloading.h" #define FRAME_PRIORITY 10 cyg_thread frame_thread; diff --git a/ce/test/rx/general/target-Makefile b/ce/test/rx/general/target-Makefile index f88db9a399..b34e0ac597 100644 --- a/ce/test/rx/general/target-Makefile +++ b/ce/test/rx/general/target-Makefile @@ -17,7 +17,7 @@ test_sar_target_ecos_synth_MODULES = lib mac/sar ce mac/common mac/sar/bridgedma mac_pbproc_MODULE_SOURCES = mfs.c -ce_MODULE_SOURCES = cei_param.c frame_measurement.c rx.c trace.c +ce_MODULE_SOURCES = bitloading.c cei_param.c frame_measurement.c rx.c trace.c ce_test_common_MODULE_SOURCES = print_utils.c VARIANT = target diff --git a/ce/test/rx/host_linux_sparc/Makefile b/ce/test/rx/host_linux_sparc/Makefile index 178da8a77b..9dba358e66 100755 --- a/ce/test/rx/host_linux_sparc/Makefile +++ b/ce/test/rx/host_linux_sparc/Makefile @@ -10,7 +10,7 @@ HOST_PROGRAMS = test_speed_host_linux_sparc test_speed_host_linux_sparc_SOURCES = test_speed.c test_speed_host_linux_sparc_MODULES = lib mac/common ce ce/test/common -ce_MODULE_SOURCES = cei_param.c frame_measurement.c +ce_MODULE_SOURCES = cei_param.c frame_measurement.c bitloading.c ce_test_common_MODULE_SOURCES = print_utils.c include $(BASE)/common/make/top.mk diff --git a/ce/test/rx/maximus/Makefile b/ce/test/rx/maximus/Makefile index 6508095d21..67c5d5b5b9 100644 --- a/ce/test/rx/maximus/Makefile +++ b/ce/test/rx/maximus/Makefile @@ -9,7 +9,7 @@ TARGET_PROGRAMS = test_rx test_rx_SOURCES = test_rx.c test_rx_MODULES=lib host mac/common hal/phy/maximus mac/sar ce ce/test/rx/maximus/overide/mac/pbproc ce/test/rx/general/overide/cp/interf ce/test/common -ce_MODULE_SOURCES = cei_param.c frame_measurement.c rx.c trace.c +ce_MODULE_SOURCES = cei_param.c frame_measurement.c rx.c trace.c bitloading.c include $(BASE)/common/make/top.mk diff --git a/ce/test/rx/tonemap_refresh/Makefile b/ce/test/rx/tonemap_refresh/Makefile index fe6c7dd9d9..c8353c0248 100644 --- a/ce/test/rx/tonemap_refresh/Makefile +++ b/ce/test/rx/tonemap_refresh/Makefile @@ -12,7 +12,7 @@ test_tonemaps_refresh_target_ecos_synth_SOURCES = test_tonemaps_refresh.c test_tonemaps_refresh_target_ecos_synth_MODULES = lib mac/common ce ce/test/common ce/test/rx/general/overide/cp/interf -ce_MODULE_SOURCES = cei_param.c frame_measurement.c rx.c trace.c +ce_MODULE_SOURCES = cei_param.c frame_measurement.c rx.c trace.c bitloading.c ce_test_common_MODULE_SOURCES = print_utils.c -- cgit v1.2.3