From 80939396e6e1970fe0c1ecfa4a9734d00ab8ed31 Mon Sep 17 00:00:00 2001 From: lacour Date: Tue, 5 Feb 2008 09:05:14 +0000 Subject: Move rx tests in rx/general. (test.h relative to compilation directory) rxce_t added in rxce functions. tonemaps refresh management added in rxce process. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1362 017c9cb6-072f-447c-8318-d5b54f68fe89 --- ce/test/rx/Makefile | 26 -- ce/test/rx/Makefile_HOST_LINUX_SPARC | 25 -- ce/test/rx/Makefile_TARGET | 23 -- ce/test/rx/config_test.h | 1 - ce/test/rx/ecos.ecc.sh | 5 - ce/test/rx/general/Makefile | 26 ++ ce/test/rx/general/Makefile_HOST_LINUX_SPARC | 25 ++ ce/test/rx/general/Makefile_TARGET | 24 ++ ce/test/rx/general/ecos.ecc.sh | 5 + ce/test/rx/general/overide/cp/interf/Module | 1 + ce/test/rx/general/overide/cp/interf/interf.h | 32 ++ ce/test/rx/general/overide/cp/interf/src/interf.c | 28 ++ ce/test/rx/general/src/test_cei.c | 84 ++++ ce/test/rx/general/src/test_cei_param.c | 86 ++++ ce/test/rx/general/src/test_frame_measurement.c | 469 ++++++++++++++++++++++ ce/test/rx/general/src/test_rx.c | 279 +++++++++++++ ce/test/rx/general/src/test_sar_integration.c | 303 ++++++++++++++ ce/test/rx/general/src/test_speed.c | 193 +++++++++ ce/test/rx/general/src/test_spoc.c | 97 +++++ ce/test/rx/general/src/test_spoc_opt.c | 346 ++++++++++++++++ ce/test/rx/general/test.h | 18 + ce/test/rx/overide/cp/interf/Module | 1 - ce/test/rx/overide/cp/interf/interf.h | 32 -- ce/test/rx/overide/cp/interf/src/interf.c | 28 -- ce/test/rx/src/test_cei.c | 84 ---- ce/test/rx/src/test_cei_param.c | 86 ---- ce/test/rx/src/test_frame_measurement.c | 469 ---------------------- ce/test/rx/src/test_rx.c | 279 ------------- ce/test/rx/src/test_sar_integration.c | 303 -------------- ce/test/rx/src/test_speed.c | 193 --------- ce/test/rx/src/test_spoc.c | 97 ----- ce/test/rx/src/test_spoc_opt.c | 346 ---------------- 32 files changed, 2016 insertions(+), 1998 deletions(-) delete mode 100755 ce/test/rx/Makefile delete mode 100755 ce/test/rx/Makefile_HOST_LINUX_SPARC delete mode 100644 ce/test/rx/Makefile_TARGET delete mode 100755 ce/test/rx/ecos.ecc.sh create mode 100755 ce/test/rx/general/Makefile create mode 100755 ce/test/rx/general/Makefile_HOST_LINUX_SPARC create mode 100644 ce/test/rx/general/Makefile_TARGET create mode 100755 ce/test/rx/general/ecos.ecc.sh create mode 100644 ce/test/rx/general/overide/cp/interf/Module create mode 100755 ce/test/rx/general/overide/cp/interf/interf.h create mode 100755 ce/test/rx/general/overide/cp/interf/src/interf.c create mode 100755 ce/test/rx/general/src/test_cei.c create mode 100755 ce/test/rx/general/src/test_cei_param.c create mode 100755 ce/test/rx/general/src/test_frame_measurement.c create mode 100755 ce/test/rx/general/src/test_rx.c create mode 100755 ce/test/rx/general/src/test_sar_integration.c create mode 100644 ce/test/rx/general/src/test_speed.c create mode 100644 ce/test/rx/general/src/test_spoc.c create mode 100644 ce/test/rx/general/src/test_spoc_opt.c create mode 100644 ce/test/rx/general/test.h delete mode 100644 ce/test/rx/overide/cp/interf/Module delete mode 100755 ce/test/rx/overide/cp/interf/interf.h delete mode 100755 ce/test/rx/overide/cp/interf/src/interf.c delete mode 100755 ce/test/rx/src/test_cei.c delete mode 100755 ce/test/rx/src/test_cei_param.c delete mode 100755 ce/test/rx/src/test_frame_measurement.c delete mode 100755 ce/test/rx/src/test_rx.c delete mode 100755 ce/test/rx/src/test_sar_integration.c delete mode 100644 ce/test/rx/src/test_speed.c delete mode 100644 ce/test/rx/src/test_spoc.c delete mode 100644 ce/test/rx/src/test_spoc_opt.c (limited to 'ce/test/rx') diff --git a/ce/test/rx/Makefile b/ce/test/rx/Makefile deleted file mode 100755 index 241507cdb5..0000000000 --- a/ce/test/rx/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -BASE = ../../.. - -INCLUDES=ce/test/rx - -EXTRA_HOST_LDFLAGS=-lm -HOST_PROGRAMS = test_cei_host_linux_i386 -test_cei_host_linux_i386_SOURCES = test_cei.c -test_cei_host_linux_i386_MODULES = lib mac/common ce ce/test/common -HOST_PROGRAMS += test_cei_param_host_linux_i386 -test_cei_param_host_linux_i386_SOURCES = test_cei_param.c -test_cei_param_host_linux_i386_MODULES = lib mac/common ce ce/test/common -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 - -#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_test_common_MODULE_SOURCES = print_utils.c gaussian.c -mac_common_MODULE_SOURCES = tonemap.c tonemask.c store.c mfs.c sta.c - -include $(BASE)/common/make/top.mk - diff --git a/ce/test/rx/Makefile_HOST_LINUX_SPARC b/ce/test/rx/Makefile_HOST_LINUX_SPARC deleted file mode 100755 index 8af6f9fec5..0000000000 --- a/ce/test/rx/Makefile_HOST_LINUX_SPARC +++ /dev/null @@ -1,25 +0,0 @@ -BASE = ../../.. - -CC=sparc-linux-gcc -INCLUDES=ce/test/rx - -#EXTRA_HOST_CFLAGS=-O3 -EXTRA_HOST_LDFLAGS=-lm -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 - -HOST_PROGRAMS += test_spoc_host_linux_sparc -test_spoc_host_linux_sparc_SOURCES = test_spoc.c -HOST_PROGRAMS += test_spoc_opt_host_linux_sparc -test_spoc_opt_host_linux_sparc_SOURCES = test_spoc_opt.c - -#HOST_PROGRAMS += test_cei_host_linux_sparc -#test_cei_host_linux_sparc_SOURCES = test_cei.c -#test_cei_host_linux_sparc_MODULES = lib mac/common ce ce/test/common - -ce_MODULE_SOURCES = cei_param.c frame_measurement.c -ce_test_common_MODULE_SOURCES = print_utils.c - -include $(BASE)/common/make/top.mk - diff --git a/ce/test/rx/Makefile_TARGET b/ce/test/rx/Makefile_TARGET deleted file mode 100644 index a51ec37e4c..0000000000 --- a/ce/test/rx/Makefile_TARGET +++ /dev/null @@ -1,23 +0,0 @@ -BASE = ../../.. - -INCLUDES = ce/test/rx -INCLUDES += ce/test/rx/overide - -#COV = y -ECOS = y - -TARGET_PROGRAMS=test_rx_target_ecos_synth -test_rx_target_ecos_synth_SOURCES = test_rx.c -test_rx_target_ecos_synth_MODULES = lib mac/common ce ce/test/common ce/test/rx/overide/cp/interf -TARGET_PROGRAMS += test_sar_target_ecos_synth -test_sar_target_ecos_synth_SOURCES = test_sar_integration.c -test_sar_target_ecos_synth_MODULES = lib mac/sar ce mac/common mac/sar/bridgedma mac/pbproc mac/sar/test ce/test/common ce/test/rx/overide/cp/interf -mac_pbproc_MODULE_SOURCES = mfs.c - - -ce_MODULE_SOURCES = cei_param.c frame_measurement.c rx.c trace.c -ce_test_common_MODULE_SOURCES = print_utils.c - - -include $(BASE)/common/make/top.mk - diff --git a/ce/test/rx/config_test.h b/ce/test/rx/config_test.h index 0927b0848e..b8272fe735 100644 --- a/ce/test/rx/config_test.h +++ b/ce/test/rx/config_test.h @@ -17,5 +17,4 @@ //#define CE_DBG - #endif /* __config_test_h */ diff --git a/ce/test/rx/ecos.ecc.sh b/ce/test/rx/ecos.ecc.sh deleted file mode 100755 index 2443d0e40f..0000000000 --- a/ce/test/rx/ecos.ecc.sh +++ /dev/null @@ -1,5 +0,0 @@ -config=${1:-ecos-gen.ecc} -ecosconfig --config=$config new linux default -cat >> $config <<'EOF' -EOF -ecosconfig --config=$config check diff --git a/ce/test/rx/general/Makefile b/ce/test/rx/general/Makefile new file mode 100755 index 0000000000..85f63ce6f5 --- /dev/null +++ b/ce/test/rx/general/Makefile @@ -0,0 +1,26 @@ +BASE = ../../../.. + +INCLUDES=ce/test/rx + +EXTRA_HOST_LDFLAGS=-lm +HOST_PROGRAMS = test_cei_host_linux_i386 +test_cei_host_linux_i386_SOURCES = test_cei.c +test_cei_host_linux_i386_MODULES = lib mac/common ce ce/test/common +HOST_PROGRAMS += test_cei_param_host_linux_i386 +test_cei_param_host_linux_i386_SOURCES = test_cei_param.c +test_cei_param_host_linux_i386_MODULES = lib mac/common ce ce/test/common +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 + +#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_test_common_MODULE_SOURCES = print_utils.c gaussian.c +mac_common_MODULE_SOURCES = tonemap.c tonemask.c store.c mfs.c sta.c + +include $(BASE)/common/make/top.mk + diff --git a/ce/test/rx/general/Makefile_HOST_LINUX_SPARC b/ce/test/rx/general/Makefile_HOST_LINUX_SPARC new file mode 100755 index 0000000000..8af6f9fec5 --- /dev/null +++ b/ce/test/rx/general/Makefile_HOST_LINUX_SPARC @@ -0,0 +1,25 @@ +BASE = ../../.. + +CC=sparc-linux-gcc +INCLUDES=ce/test/rx + +#EXTRA_HOST_CFLAGS=-O3 +EXTRA_HOST_LDFLAGS=-lm +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 + +HOST_PROGRAMS += test_spoc_host_linux_sparc +test_spoc_host_linux_sparc_SOURCES = test_spoc.c +HOST_PROGRAMS += test_spoc_opt_host_linux_sparc +test_spoc_opt_host_linux_sparc_SOURCES = test_spoc_opt.c + +#HOST_PROGRAMS += test_cei_host_linux_sparc +#test_cei_host_linux_sparc_SOURCES = test_cei.c +#test_cei_host_linux_sparc_MODULES = lib mac/common ce ce/test/common + +ce_MODULE_SOURCES = cei_param.c frame_measurement.c +ce_test_common_MODULE_SOURCES = print_utils.c + +include $(BASE)/common/make/top.mk + diff --git a/ce/test/rx/general/Makefile_TARGET b/ce/test/rx/general/Makefile_TARGET new file mode 100644 index 0000000000..8a39e502d6 --- /dev/null +++ b/ce/test/rx/general/Makefile_TARGET @@ -0,0 +1,24 @@ +BASE = ../../../.. + +INCLUDES = ce/test/rx/ +INCLUDES += ce/test/rx/general +INCLUDES += ce/test/rx/general/overide + +#COV = y +ECOS = y + +TARGET_PROGRAMS=test_rx_target_ecos_synth +test_rx_target_ecos_synth_SOURCES = test_rx.c +test_rx_target_ecos_synth_MODULES = lib mac/common ce ce/test/common ce/test/rx/general/overide/cp/interf +TARGET_PROGRAMS += test_sar_target_ecos_synth +test_sar_target_ecos_synth_SOURCES = test_sar_integration.c +test_sar_target_ecos_synth_MODULES = lib mac/sar ce mac/common mac/sar/bridgedma mac/pbproc mac/sar/test ce/test/common ce/test/rx/general/overide/cp/interf +mac_pbproc_MODULE_SOURCES = mfs.c + + +ce_MODULE_SOURCES = cei_param.c frame_measurement.c rx.c trace.c +ce_test_common_MODULE_SOURCES = print_utils.c + + +include $(BASE)/common/make/top.mk + diff --git a/ce/test/rx/general/ecos.ecc.sh b/ce/test/rx/general/ecos.ecc.sh new file mode 100755 index 0000000000..2443d0e40f --- /dev/null +++ b/ce/test/rx/general/ecos.ecc.sh @@ -0,0 +1,5 @@ +config=${1:-ecos-gen.ecc} +ecosconfig --config=$config new linux default +cat >> $config <<'EOF' +EOF +ecosconfig --config=$config check diff --git a/ce/test/rx/general/overide/cp/interf/Module b/ce/test/rx/general/overide/cp/interf/Module new file mode 100644 index 0000000000..5950fd7d38 --- /dev/null +++ b/ce/test/rx/general/overide/cp/interf/Module @@ -0,0 +1 @@ +SOURCES := interf.c diff --git a/ce/test/rx/general/overide/cp/interf/interf.h b/ce/test/rx/general/overide/cp/interf/interf.h new file mode 100755 index 0000000000..57e74ddb84 --- /dev/null +++ b/ce/test/rx/general/overide/cp/interf/interf.h @@ -0,0 +1,32 @@ +#ifndef cp_interf_interf_h +#define cp_interf_interf_h +/* Cesar project {{{ + * + * Copyright (C) 2007 Spidcom + * + * <<>> + * + * }}} */ +/** + * \file ./overide/cp/cp.h + * \brief « brief description » + * \ingroup « module » + * + * « long description » + */ + +#include "mac/sar/inc/sar_mf.h" + +u8 buf[SAR_MSDU_PAYLOAD_MAX_SIZE]; + +BEGIN_DECLS + +u8 * +interf_give_buf (void); + +void +interf_send (u8 *buf, uint len, uint dtei, uint priority); + +END_DECLS + +#endif /* cp_interf_interf_h */ diff --git a/ce/test/rx/general/overide/cp/interf/src/interf.c b/ce/test/rx/general/overide/cp/interf/src/interf.c new file mode 100755 index 0000000000..a804861c83 --- /dev/null +++ b/ce/test/rx/general/overide/cp/interf/src/interf.c @@ -0,0 +1,28 @@ +/* Cesar project {{{ + * + * Copyright (C) 2007 Spidcom + * + * <<>> + * + * }}} */ +/** + * \file ./overide/cp/src/cp.c + * \brief « brief description » + * \ingroup « module » + * + * « long description » + */ +#include "common/std.h" +#include "cp/interf/interf.h" + +u8 * +interf_give_buf (void) +{ + return buf; +} + +void +interf_send (u8 *buf, uint len, uint dtei, uint priority) +{ + return; +} diff --git a/ce/test/rx/general/src/test_cei.c b/ce/test/rx/general/src/test_cei.c new file mode 100755 index 0000000000..e60c7b45a1 --- /dev/null +++ b/ce/test/rx/general/src/test_cei.c @@ -0,0 +1,84 @@ +/* Cesar project {{{ + * + * Copyright (C) 2007 Spidcom + * + * <<>> + * + * }}} */ +/** + * \file ./src/test_cei.c + * \brief « brief description » + * \ingroup « module » + * + * « long description » + */ +#include "common/std.h" +#define RXCE +#define TXCE +#include "ce/inc/cei.h" +#include "lib/test.h" +#include "mac/common/tonemask.h" +#include "ce/test/common/tonemap_utils.h" + +void +test_exchange (test_t test, tonemaps_t *rx_tms, tonemaps_t *tx_tms, + u8 *mask, uint tmi, uint max_rnd, uint offset) +{ + u8 buffer[1536]; + int i; for (i=0; i<1536; i++) buffer[i]=0; + cei_param_t param; + param.tms = rx_tms; + param.new_tmi = tmi; + create_tm (rx_tms, mask, tmi, max_rnd, offset); + ce_print_tonemaps (rx_tms); + cei_tonemaps_to_mme (¶m, buffer, mask); + ce_print_buffer (buffer, 512); + cei_decoding (tx_tms, CM_CHAN_EST_IND, buffer, mask); + ce_print_tonemaps (tx_tms); + compare_tonemaps (test, rx_tms, tx_tms, mask); +} + +int +main (int argc, char **argv) +{ + int i; + u8 mask[(PHY_CARRIER_NB+7)/8]; + for (i=0; i<(PHY_CARRIER_NB+7)/8; i++) mask[i] = 0xFF; + mask[i-1] = ((1<<(PHY_CARRIER_NB%8))-1); + test_t test; + lib_rnd_init (&rnd, 12); + test_init (test, argc, argv); + tonemaps_t *rx_tms = tonemaps_alloc(); + tonemaps_t *tx_tms = tonemaps_alloc(); + test_case_begin (test, "CE-cei-full mask"); + + test_exchange (test, rx_tms, tx_tms, mask, 0, 3, 1); + test_exchange (test, rx_tms, tx_tms, mask, 1, 2, 6); + test_exchange (test, rx_tms, tx_tms, mask, 2, 1, 3); + test_exchange (test, rx_tms, tx_tms, mask, 3, 0, 3); + + tonemaps_release (rx_tms); + tonemaps_release (tx_tms); + test_begin (test, "check alloc/free") + { + test_fail_unless (blk_check_memory()); + } test_end; + + rx_tms = tonemaps_alloc(); + tx_tms = tonemaps_alloc(); + tonemask_default (mask); + test_case_begin (test, "CE-cei-default mask"); + test_exchange (test, rx_tms, tx_tms, mask, 0, 3, 1); + test_exchange (test, rx_tms, tx_tms, mask, 1, 2, 6); + test_exchange (test, rx_tms, tx_tms, mask, 2, 1, 3); + test_exchange (test, rx_tms, tx_tms, mask, 3, 0, 3); + tonemaps_release (rx_tms); + tonemaps_release (tx_tms); + test_begin (test, "check alloc/free") + { + test_fail_unless (blk_check_memory()); + } test_end; + test_result (test); + return (test_nb_failed (test) == 0 ? 0 : 1); +} + diff --git a/ce/test/rx/general/src/test_cei_param.c b/ce/test/rx/general/src/test_cei_param.c new file mode 100755 index 0000000000..66a869d4d2 --- /dev/null +++ b/ce/test/rx/general/src/test_cei_param.c @@ -0,0 +1,86 @@ +/* Cesar project {{{ + * + * Copyright (C) 2007 Spidcom + * + * <<>> + * + * }}} */ +/** + * \file ./src/test_tx.c + * \brief « brief description » + * \ingroup « module » + * + * « long description » + */ + + +#include "common/std.h" +#include "ce/test/common/print_utils.h" +#include "ce/inc/cei_param.h" + +#include "lib/rnd.h" +#include "lib/test.h" + +lib_rnd_t rnd; + +void +test_cei_param (test_t test, uint read_percent) +{ + test_begin (test, "test_cei_param") + { + int n; + //test_debug_print ("%d%% of read %d%% of write ", read_percent, 100-read_percent); + lib_rnd_init (&rnd, 23); + //cei_param_t cei_param; + cei_param_fifo_init (); + cei_param_t cei_param; + cei_param.tms = NULL; + cei_param.new_tmi = 0; + cei_param.old_tmi = 0; + cei_param.priority = 0xFF; + cei_param.dtei = 0xFF; + uint cpt = 0; + for (n=0; n<1000; n++) + { + uint alea = lib_rnd_uniform (&rnd, 100); + //my_print ("%d\n" ,alea); + test_fail_if (cpt>CEI_WANTED_MAX); + if (alea > read_percent) + { + //my_print (" get %d <=> %d\n", cpt, cei_param_fifo.number); + uint reader_index = cei_param_fifo.reader_index; + test_fail_if (cpt != cei_param_fifo.number); + cei_param_t *param = cei_param_get (); + //if (!param) my_print ("param = NULL\n"); + test_fail_if (!param && cpt!=0); + if (param) + { + //my_print ("%d <==> %d\n", reader_index, 0); + test_fail_if (reader_index != param->priority); + cpt--; + } + } + else + { + //my_print (" add\n"); + cei_param.priority = cei_param_fifo.writer_index; + if (cei_param_add (&cei_param)) cpt++; + } + } + } test_end; +} + +int +main (int argc, char **argv) +{ + test_t test; + test_init (test, argc, argv); + test_case_begin (test, "CE-mme 75% of read"); + test_cei_param (test, 75); + test_case_begin (test, "CE-mme 25% of read"); + test_cei_param (test, 25); + test_case_begin (test, "CE-mme 50% of read"); + test_cei_param (test, 50); + 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 new file mode 100755 index 0000000000..fdab1bfa0d --- /dev/null +++ b/ce/test/rx/general/src/test_frame_measurement.c @@ -0,0 +1,469 @@ +/* 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 "lib/rnd.h" +#include "ce/test/common/gaussian.h" +#include "lib/test.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; +} + +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; + uint cpt = offset; + for (i=0; inext); + first = first->next; + wrdata = (u32 *) first->data; + first->pb_nb = 0; + cpt=0; + } + *(wrdata+cpt) = i+ber_init_value; + first->pb_nb++; + cpt++; + } +} + +void +test_frame_measurement_ber_add (test_t t) +{ + test_begin (t, "add ber") + { + 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_callber_measurement; + u32 *rddata = (u32 *) rd->data; + test_fail_if (!fm); + test_fail_if (!rd); + uint k=0; + uint cpt = 1; + do + { + for (i=0; ipb_nb) && *(rddata+i)!=k); + k++; + } + if (rd->next) + { + rd = rd->next; + rddata = (u32 *) rd->data; + cpt++; + } + else + { + test_fail_if (rd != last_ber); + rd = rd->next; + } + } while (rd); + uint comp = (N*pb_nb_to_add)/(BLK_SIZE/4); + if ((N*pb_nb_to_add)%(BLK_SIZE/4) >0) comp++; + test_fail_if (cpt != comp); + frame_measurement_release (fm); + //frame_measurement_print (fm); + } + } + } test_end; +} + +phy_chandata_t * +chandata_init (int type) +{ + phy_chandata_t *last; + phy_chandata_t *chandata = (phy_chandata_t *) blk_alloc_desc_range ( + CHANDATA_TYPE_BLK_NB[type], (blk_t **) &last); + chandata->type = type; + last->blk.next = NULL; + phy_chandata_t *ch = chandata; + while (ch) + { + uint i; + phy_noise_t * data = (phy_noise_t *) ch->blk.data; + for (i=0; ilast = 0; + ch->type = type; + ch = (phy_chandata_t *) ch->blk.next; + } + last->last = 1; + return (chandata); +} + +void +test_frame_measurement_noise_add (test_t t) +{ + test_begin (t, "add noise") + { + uint i; + pbproc_rx_params_t *rx_params = (pbproc_rx_params_t *) blk_alloc(); + bool b = frame_measurement_append (rx_params, 0, NULL, NULL, NULL); + if (b) + { + frame_measurement_t *fm = frame_measurement_get_next(); + for (i=1; itype_head[i]; + while (chandata) + { + phy_noise_t *data = (phy_noise_t *) chandata->blk.data; + uint j; + for (j=0; jlast; + //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); + } + } + frame_measurement_release (fm); + } + } test_end; +} + +void +test_frame_measurement_add (test_t t) +{ + test_begin (t, "add/remove frame measurement") + { + lib_rnd_init (&rnd, 23); + int nb_frame_added = 0; + int nb_frame_measurement = 0; + int alea ; + int N = 1000; + 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; + bool b = frame_measurement_append (rx_params, 0, f, l, NULL); + if (b) + { + rx_params->preamble_ntb = nb_frame_added; + 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)); + frame_measurement_release (first); + nb_frame_measurement--; + } + } + } + while (nb_frame_measurement > 0) + { + 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--; + } + test_fail_if (frame_measurement_get_next()); + } test_end; +} + +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; + 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 new file mode 100755 index 0000000000..5818c18dcb --- /dev/null +++ b/ce/test/rx/general/src/test_rx.c @@ -0,0 +1,279 @@ +/* Cesar project {{{ + * + * Copyright (C) 2007 Spidcom + * + * <<>> + * + * }}} */ +/** + * \file ./src/test_tx.c + * \brief « brief description » + * \ingroup « module » + * + * « long description » + */ +#include "common/std.h" +#include "cyg/hal/hal_intr.h" +#include "ce/inc/rx.h" +#include "mac/common/tonemap.h" +#include "ce/test/common/print_utils.h" +#include "ce/test/rx/inc/test_rx.h" +#include "lib/bitstream.h" +#include "lib/rnd.h" +#include "lib/test.h" +#include "cp/interf/interf.h" +#include "lib/trace.h" +#include "mac/common/ntb.h" +#include "ce/inc/trace.h" + +lib_rnd_t rnd; +test_t test; +phy_t *phy_ctx; +rxce_t *rxce_ctx; + + +#define FRAME_PRIORITY 10 +cyg_thread frame_thread; +cyg_handle_t frame_handle; +unsigned char frame_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL]; + +#define RXCE_PRIORITY 14 +cyg_thread rxce_thread; +cyg_handle_t rxce_handle; +unsigned char rxce_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL]; + +uint noise[PHY_CARRIER_NB]; +uint false_bit_nb[MAX_PB]; + +struct test_status_t +{ + mac_store_t *mac_store_ctx; + sta_t *sta; + uint sound_nb; + uint null_ber_frame_nb; + uint date; +}; +typedef struct test_status_t test_status_t; +test_status_t status; + +struct frame_t +{ + bool sound; + uint sound_reason_code; + uint pb_nb; + pbproc_rx_params_t *rx_params; + uint *noise; + uint *false_bit_nb; +}; +typedef struct frame_t frame_t; + + +bool next_scf; + +void +pbproc_rxce_init (pbproc_need_scf_cb_t need_scf) +{ + need_scf_cb = need_scf; +} + +void +pbproc_scf (void) +{ + //my_print ("pbproc scf\n"); + next_scf = true; +} + +void +over_pbproc_init (void) +{ + next_scf = false; +} + +bool +pbproc_send_scf (void) +{ + ce_print ("\t\t\t\t ACK with scf = %d\n", next_scf); + bool ret = next_scf; + next_scf = false; + return (ret); +} + +void +sar_noise_new (pbproc_rx_params_t *rx_params, uint noise[], uint symbol_nb) +{ + //my_print ("sar noise new\n"); + uint i; + uint lambda = 0; + phy_chandata_t *time_noise; + time_noise = (phy_chandata_t *) blk_alloc_desc(); + time_noise->blk.next = NULL; + time_noise->last = 0; + time_noise->type = PHY_CHANDATA_TYPE_NRJ_SYMBOL; + phy_noise_t *time_data = (phy_noise_t *) time_noise->blk.data; + phy_chandata_t *freq_noise, *last; + freq_noise = (phy_chandata_t *) blk_alloc_desc_range (PHY_CHANDATA_NRJ_BLK_NB, (blk_t **) &last); + freq_noise->type = PHY_CHANDATA_TYPE_NRJ; + phy_chandata_t * ch = freq_noise; + phy_noise_t *freq_data = (phy_noise_t *) ch->blk.data; + for (i=0; itype = PHY_CHANDATA_TYPE_NRJ; + ch->last = 0; + if ( (i%(BLK_SIZE/(sizeof(phy_noise_t))) == 0) && (i!=0) ) + { + ch = (phy_chandata_t *) ch->blk.next; + freq_data = (phy_noise_t *) ch->blk.data; + } + //my_print ("writing %d @(0x%x + %d)\n",i, freq_data, (i%(BLK_SIZE/2))); + * (freq_data+(i%(BLK_SIZE/sizeof(phy_noise_t)))) = noise[i]; + lambda+=noise[i]; + } + lambda = lambda/PHY_CARRIER_NB; + last->last = 1; + last->blk.next = NULL; + for (i=0; iblk.next = (blk_t *) freq_noise; + //chandata_print (time_noise); + ce_print ("\t\t\t\t ADD NOISES\n"); + sar_mpdu_measurement_cb (rxce_ctx, rx_params, 0, NULL, NULL, (pb_t *) time_noise); + //my_print ("\t\t\t\t ADD FREQ NOISE\n"); + //sar_mpdu_measurement_cb (NULL, rx_params, 0, NULL, NULL, (pb_t *) freq_noise); +} + +void +frame_new (frame_t *frame) +{ + uint symbol_nb = 0; + frame->rx_params->preamble_ntb = status.date; + if (frame->sound) + { + symbol_nb = 19; + status.date += (19); + status.sound_nb++; + need_scf_cb (frame->rx_params->tei, frame->sound_reason_code); + cyg_thread_delay (symbol_nb/19); + sar_noise_new (frame->rx_params, frame->noise, symbol_nb); + } + else + { + ; + } +} + +void +frame_process (cyg_addrword_t data) +{ + mac_store_sta_add (status.mac_store_ctx, 1); + status.sta = mac_store_sta_get (status.mac_store_ctx, 1); + status.sound_nb = 0; + test_case_begin (test, "CE-rxce_process with noise reception"); + test_begin (test, "rxce test1") + { + uint j; + uint nb_frame = 0; + uint worst[PHY_CARRIER_NB]; + + cyg_thread_delay (1); + lib_rnd_init (&rnd, 12); + do + { + frame_t *frame = blk_alloc(); + pbproc_rx_params_t *rx_params = blk_alloc (); + frame->sound = true; + frame->sound_reason_code = 0xFD; + frame->pb_nb = 0; + frame->rx_params = rx_params; + frame->rx_params->tei = 1; + for (j=0; jnoise = noise; + frame_new (frame); + nb_frame++; + test_fail_if (status.sta->rxce.stable_ROBO_nbrx_tonemaps->default_tmi != TONEMAP_INDEX_INITIAL_START); + test_fail_if (status.sta->rxce.stable_ROBO_nb>FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && status.sta->rx_tonemaps->default_tmi == TONEMAP_INDEX_INITIAL_START); + blk_release (frame); + } while (!pbproc_send_scf ()); + bitstream_t stream; + bitstream_init (&stream, status.sta->rx_tonemaps->tm[status.sta->rx_tonemaps->default_tmi]->tmdma_desc_head->data, BLK_SIZE, BITSTREAM_READ); + for (j=0; jrx_tonemaps->tm[status.sta->rx_tonemaps->default_tmi]->tmdma_desc_head->next->data, BLK_SIZE, BITSTREAM_READ); + } + uint mod; + bitstream_access (&stream, &mod, 4); + if (mod==0) + { + test_fail_if (worst[j] <=THR3[1][0]); + } + else + { + if (mod==7) + { + test_fail_if (worst[j] > THR3[1][6]); + } + else + { + test_fail_if (worst[j]<=THR3[1][mod] || worst[j]>THR3[1][mod-1]); + } + } + + } + } test_end; + // rxce_process can end to process and free pending frames. + cyg_thread_delay (1); + + blk_release (status.sta); + mac_store_sta_remove (status.mac_store_ctx, 1); + mac_store_uninit (status.mac_store_ctx); + blk_release (phy_ctx); + rxce_trace_print(rxce_ctx); + rxce_trace_uninit (rxce_ctx); + trace_uninit(); + test_begin (test, "check alloc/free") + { + test_fail_unless (blk_check_memory()); + } test_end; + test_result (test); + HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1); +} + +void +cyg_user_start (int argc, char **argv) +{ + trace_init(); + phy_ctx = blk_alloc(); + test_init (test, argc, argv); + mac_config_t mac_config; + tonemask_default ((u8 *)(&(mac_config.tonemask_info.tonemask))); + status.mac_store_ctx = mac_store_init (); + mac_ntb_init (phy_ctx, &mac_config); + rxce_ctx = rxce_init (status.mac_store_ctx, &mac_config); + over_pbproc_init (); + pbproc_rxce_init (pbproc_need_scf_cb); + + cyg_thread_create (RXCE_PRIORITY, &rxce_process, (cyg_addrword_t) rxce_ctx, "rxce", + rxce_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL, + &rxce_handle, &rxce_thread); + cyg_thread_create (FRAME_PRIORITY, &frame_process, 0, "frame_test", + frame_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL, + &frame_handle, &frame_thread); + + + //my_print ("launch rxce process\n"); + cyg_thread_resume (rxce_handle); + + //my_print ("launch frame process\n"); + cyg_thread_resume (frame_handle); +} + diff --git a/ce/test/rx/general/src/test_sar_integration.c b/ce/test/rx/general/src/test_sar_integration.c new file mode 100755 index 0000000000..fab5e5016b --- /dev/null +++ b/ce/test/rx/general/src/test_sar_integration.c @@ -0,0 +1,303 @@ +/* Cesar project {{{ + * + * Copyright (C) 2007 Spidcom + * + * <<>> + * + * }}} */ +/** + * \file ce/test/rx/sar_integration.c + * \brief Use sar callback for Channel estimation. + * \ingroup ce + * + */ +#include "common/std.h" +#include "cyg/hal/hal_intr.h" +#include "lib/test.h" +#include "mac/sar/sar.h" +#include "ce/inc/rx.h" +#include "mac/common/pb.h" // PB header initialisation +#include "ce/test/common/print_utils.h" +#include "cp/interf/interf.h" +//#include "mac/sar/inc/trace.h" +#include "mac/common/ntb.h" +#include "ce/inc/trace.h" +#include "hal/phy/phy.h" + +#define FRAME_PRIORITY 10 +cyg_thread frame_thread; +cyg_handle_t frame_handle; +unsigned char frame_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL]; +#define RXCE_PRIORITY 14 +cyg_thread rxce_thread; +cyg_handle_t rxce_handle; +unsigned char rxce_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL]; + +test_t test; +mac_store_t *mac_store_ctx; +mac_config_t mac_config; +rxce_t *rxce_ctx; +phy_t *phy; + +u32 +phy_date (phy_t *phy) +{ + return (cyg_current_time()); +} + +void +pbproc_scf (void) +{ + ce_print("pbproc_scf()\n"); +} + +void +emul_reassembly (int pb_nb, uint date, pbproc_rx_params_t **rx_params, + pb_t **f, pb_t **l, phy_chandata_t **noise) +{ + uint i, j; + if (pb_nb > 0) + { + *f = (pb_t *) blk_alloc_desc_range (pb_nb,(blk_t **)l); + (*l)->next = NULL; + phy_pb_rx_t *p = (phy_pb_rx_t *) *f; + for (i=0; i<(uint) pb_nb; i++) + { + p->pb_measurement.ber = i; + ((pb_t *)p)->header.vpbf = 0; + p = (phy_pb_rx_t *) p->blk.next; + } + } + else + { + *f = *l = NULL; + } + + phy_chandata_t *l_noise, *p_noise; + phy_chandata_t *f_noise = (phy_chandata_t *) blk_alloc_desc_range (PHY_CHANDATA_NRJ_BLK_NB, (blk_t **)&l_noise); + p_noise = f_noise; + phy_noise_t *data; + for (i=0; ilast = 1; + p_noise->blk.next = NULL; + dbg_assert (i == (PHY_CHANDATA_NRJ_BLK_NB-1)); + } + else + { + p_noise->last = 0; + } + p_noise->type = PHY_CHANDATA_TYPE_NRJ; + data = (phy_noise_t *) p_noise->blk.data; + for (j=0; jblk.next; + } + + *noise = (phy_chandata_t *) blk_alloc_desc (); + data = (phy_noise_t *) (*noise)->blk.data; + for (j=0; jtype = PHY_CHANDATA_TYPE_NRJ_SYMBOL; + (*noise)->last = 0; + (*noise)->blk.next =(blk_t *) f_noise; + + *rx_params = blk_alloc(); + (*rx_params)->preamble_ntb = date; + (*rx_params)->tei = 1; + (*rx_params)->lid = 1; +} +void +run_one_reassembly (sar_t *sar_ctx, uint pb_nb) +{ + pbproc_rx_params_t *rx_params; + pb_t *f, *l; + phy_chandata_t *noise; + + //my_print ("\n"); + emul_reassembly (pb_nb, 0x00, &rx_params, &f, &l, &noise); + //my_print ("pbproc-pb-noise-rxparam : allocated = %d, freed = %d released = %d referenced = %d\n", blk_allocated, blk_freed, blk_released, blk_referenced); + sar_mpdu_add (sar_ctx, NULL, NULL, rx_params, f, l, pb_nb, (pb_t *) noise); + //my_print ("sar_mpdu_added : allocated = %d, freed = %d released = %d referenced = %d\n", blk_allocated, blk_freed, blk_released, blk_referenced); + blk_release (rx_params); // pbproc can erase it. + //my_print ("release pbproc_rx_params : allocated = %d, freed = %d released = %d referenced = %d\n", blk_allocated, blk_freed, blk_released, blk_referenced); + sar_launch (sar_ctx); + //my_print ("sar_launch : allocated = %d, freed = %d released = %d referenced = %d\n", blk_allocated, blk_freed, blk_released, blk_referenced); +} + +void +START (sar_t **sar_ctx, sta_t **sta, ca_t **ca) +{ + pbproc_t *pbproc_ctx = pbproc_init (&mac_config, mac_store_ctx); + *ca = (ca_t *) blk_alloc(); + *sar_ctx = sar_init (mac_store_ctx, pbproc_ctx, *ca); + sar_init_measure_context (*sar_ctx, rxce_ctx); + sar_init_measurement_cb (*sar_ctx, &sar_mpdu_measurement_cb); + mac_store_sta_add (mac_store_ctx, 1); + *sta = mac_store_sta_get (mac_store_ctx, 1); +} + +void +END (sar_t *sar_ctx, sta_t *sta, ca_t *ca) +{ + //sta_uninit (sta); + //sar_trace_print (sar_ctx); + blk_release (sta); // release reference to sta added by mac_store_mfs_get in START. + dbg_check (mac_store_sta_remove (mac_store_ctx, 1)); + blk_release (ca); + sar_uninit (sar_ctx); +} + +void +frame_process (cyg_addrword_t data) +{ + + sar_t *sar_ctx; + sta_t *sta; + ca_t *ca; + int n; + int tmi_null; + int tmp_exists; + + test_case_begin (test, "One sound frame"); + START (&sar_ctx, &sta, &ca); + run_one_reassembly (sar_ctx, 0); + cyg_thread_delay (1); //rxce can process + test_begin (test, "check rxce status") + { + test_fail_if (sta->rx_tonemaps->default_tmi != TONEMAP_INDEX_INITIAL_START); + test_fail_if (!sta->rxce.tm_in_build); + } test_end; + END (sar_ctx, sta, ca); + + test_case_begin (test, "One 1-PB frame"); + START (&sar_ctx, &sta, &ca); + run_one_reassembly (sar_ctx, 1); + cyg_thread_delay (1); //rxce can process + test_begin (test, "check rxce status") + { + test_fail_if (sta->rx_tonemaps->default_tmi != TONEMAP_INDEX_INITIAL_START); + test_fail_if (!sta->rxce.tm_in_build); + } test_end; + END (sar_ctx, sta, ca); + + test_case_begin (test, "One 200-PB frame"); + START (&sar_ctx, &sta, &ca); + run_one_reassembly (sar_ctx, 200); + cyg_thread_delay (1); //rxce can process + test_begin (test, "check rxce status") + { + test_fail_if (sta->rx_tonemaps->default_tmi != TONEMAP_INDEX_INITIAL_START); + test_fail_if (!sta->rxce.tm_in_build); + } test_end; + END (sar_ctx, sta, ca); + + test_case_begin (test, "Several sound frames processed one by one"); + START (&sar_ctx, &sta, &ca); + test_begin (test, "check rxce status") + { + for (n=0; nrx_tonemaps->default_tmi == TONEMAP_INDEX_INITIAL_START; + tmp_exists = (int) sta->rxce.tm_in_build; + test_fail_if (n=FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmi_null); + test_fail_if (n==FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmp_exists); + test_fail_if (n>FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmp_exists); + } + } test_end; + END (sar_ctx, sta, ca); + + test_case_begin (test, "Several sound frames and rxce late"); + START (&sar_ctx, &sta, &ca); + test_begin (test, "check rxce status") + { + for (n=0; nrxce.measurement_computed_nb-1; + tmi_null = sta->rx_tonemaps->default_tmi == TONEMAP_INDEX_INITIAL_START; + tmp_exists = (int) sta->rxce.tm_in_build; + //my_print ("%d, tmi_null=%d, tmp_exists=%d\n",frame_nb, tmi_null, tmp_exists); + test_fail_if (frame_nb=FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmi_null); + test_fail_if (frame_nb==FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmp_exists); + test_fail_if (frame_nb>FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmp_exists); + } + if (n == FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP ) + { + cyg_thread_delay (1); //rxce can process + uint frame_nb = sta->rxce.measurement_computed_nb-1; + tmi_null = sta->rx_tonemaps->default_tmi == TONEMAP_INDEX_INITIAL_START; + tmp_exists = (int) sta->rxce.tm_in_build; + //my_print ("%d, tmi_null=%d, tmp_exists=%d\n",frame_nb, tmi_null, tmp_exists); + test_fail_if (frame_nb=FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmi_null); + test_fail_if (frame_nb==FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmp_exists); + test_fail_if (frame_nb>FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmp_exists); + } + if (n == FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP + 5 -1 ) + { + cyg_thread_delay (1); //rxce can process + uint frame_nb = sta->rxce.measurement_computed_nb-1; + tmi_null = sta->rx_tonemaps->default_tmi == TONEMAP_INDEX_INITIAL_START; + tmp_exists = (int) sta->rxce.tm_in_build; + //my_print ("%d, tmi_null=%d, tmp_exists=%d\n",frame_nb, tmi_null, tmp_exists); + test_fail_if (frame_nb=FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmi_null); + test_fail_if (frame_nb==FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmp_exists); + test_fail_if (frame_nb>FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmp_exists); + } + cyg_thread_delay (1); //rxce can process + } + } test_end; + END (sar_ctx, sta, ca); + + mac_store_uninit (mac_store_ctx); + rxce_trace_print (rxce_ctx); + rxce_trace_uninit (rxce_ctx); + trace_uninit(); + blk_release (phy); + test_begin (test, "check alloc/free") + { + test_fail_unless (blk_check_memory()); + } test_end; + test_result (test); + HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1); +} + +void +cyg_user_start (int argc, char **argv) + { + test_init (test, argc, argv); + trace_init(); + phy = (phy_t *) blk_alloc(); + mac_ntb_init (phy, &mac_config); + + tonemask_default ((u8 *)(&(mac_config.tonemask_info.tonemask))); + mac_store_ctx = mac_store_init (); + rxce_ctx = rxce_init (mac_store_ctx, &mac_config); + cyg_thread_create (RXCE_PRIORITY, &rxce_process,(cyg_addrword_t) rxce_ctx, "rxce", + rxce_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL, + &rxce_handle, &rxce_thread); + cyg_thread_resume (rxce_handle); + cyg_thread_create (FRAME_PRIORITY, &frame_process, 0, "frame_test", + frame_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL, + &frame_handle, &frame_thread); + cyg_thread_resume (frame_handle); + +} + + diff --git a/ce/test/rx/general/src/test_speed.c b/ce/test/rx/general/src/test_speed.c new file mode 100644 index 0000000000..210b082cc3 --- /dev/null +++ b/ce/test/rx/general/src/test_speed.c @@ -0,0 +1,193 @@ +/* Cesar project {{{ + * + * Copyright (C) 2007 Spidcom + * + * <<>> + * + * }}} */ +/** + * \file ./src/test_speed.c + * \brief « brief description » + * \ingroup « module » + * + * « long description » + */ + +#include "common/std.h" +#include "sys/time.h" +#include "stdio.h" +#include "string.h" +#include "ce/inc/frame_measurement.h" +#include "mac/common/tonemap.h" +#include "ce/test/common/print_utils.h" +#include "lib/bitstream.h" +#define RXCE +#include "ce/inc/cei.h" +#include "math.h" + + +int +main (int argc, char **argv) +{ + struct timeval tv0, tv1; + double test_d; + int r; + double flottant = 0.123456789; + double res = flottant; + double x=0; + + gettimeofday (&tv0, NULL); + for (r=-10000; r<10000; r++) + { + x = (double)(M_PI*r)/ 10000.0; + for (test_d=0; test_d<100; test_d++) + { + res = test_d * x; + } + } + gettimeofday (&tv1, NULL); + printf ("test duration [nothing] %d \n", (int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); + gettimeofday (&tv0, NULL); + for (r=-10000; r<10000; r++) + { + x = (double)(M_PI*r)/ 10000.0; + for (test_d=0; test_d<100; test_d++) + { + res = test_d / x; + } + } + gettimeofday (&tv1, NULL); + printf ("test duration [div : dble/dble] %d \n", (int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); + gettimeofday (&tv0, NULL); + for (r=-10000; r<10000; r++) + { + x = (double)(M_PI*r)/ 10000.0; + for (test_d=0; test_d<100; test_d++) + { + res = sin (x); + } + } + gettimeofday (&tv1, NULL); + printf ("test duration [sin (dble)] %d \n", (int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); + + uint word = 0x76543210; + uint i, test; + int nibble; + bitstream_t stream_writer; + gettimeofday (&tv0, NULL); + gettimeofday (&tv1, NULL); + printf ("getitmeofday duration %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); + gettimeofday (&tv0, NULL); + for (test=0; test<1000; test++) + { + word = 0; + for (i=0; i<8; i++) + { + nibble = i+1; + word = (word >> 4) | (nibble << 28); + } + } + gettimeofday (&tv1, NULL); + printf ("nibble to u32 duration test1 %d /1000\n",(int) (tv1.tv_usec - tv0.tv_usec)); + + gettimeofday (&tv0, NULL); + for (test=0; test<1000; test++) + { + word = 0; + for (i=0; i<8; i++) + { + nibble = i+1; + word = word | (nibble << (i<<2)); + } + } + gettimeofday (&tv1, NULL); + printf ("nibble to u32 duration test2 %d /1000\n",(int) (tv1.tv_usec - tv0.tv_usec)); + + frame_measurement_init (); + + uint noise = 0; + gettimeofday (&tv0, NULL); + update_threshold (1, 1); + for (i=0; i<1536; i++) + { + noise2mod (noise); + } + gettimeofday (&tv1, NULL); + printf ("noise2mod duration --worst : %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); + + noise = 10000; + gettimeofday (&tv0, NULL); + update_threshold (1, 1); + for (i=0; i<1536; i++) + { + noise2mod (noise); + + } + gettimeofday (&tv1, NULL); + printf ("noise2mod duration --best : %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); + + + gettimeofday (&tv0, NULL); + blk_t *blk = blk_alloc_desc (); + gettimeofday (&tv1, NULL); + printf ("first blk allocation duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); + blk_release_desc (blk); + gettimeofday (&tv0, NULL); + blk = blk_alloc_desc (); + gettimeofday (&tv1, NULL); + printf ("second blk allocation duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); + blk_release_desc (blk); + + blk_t *blk_last; + gettimeofday (&tv0, NULL); + blk_t *blk_first = blk_alloc_desc_range (10, &blk_last); + gettimeofday (&tv1, NULL); + printf ("multi-blk allocation duration (10) : %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); + blk_release_desc_range (blk_first, blk_last); + + + phy_chandata_t *last, *browser; + phy_chandata_t *first = (phy_chandata_t *) blk_alloc_desc_range (PHY_CHANDATA_NRJ_BLK_NB, (blk_t **) &last); + last->last = 1; + last->blk.next = NULL; + browser = first; + noise = 0; + int j, k=0; + u32 * data = (u32 * ) browser->blk.data; + for (i=0; iblk.next); + if (browser) data = (u32 * ) browser->blk.data; + } + tonemap_t *worst_tonemap = NULL; + gettimeofday (&tv0, NULL); + compute_worst_tonemap (&worst_tonemap, first); + gettimeofday (&tv1, NULL); + printf ("default tonemap computation duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); + ce_print_tonemap (worst_tonemap); + blk_release_desc_range ((blk_t *) first, (blk_t *)last); + + u8 buf[1536]; + for (i=0; i<1536; i++) buf[i] = 0x00; + u8 mask[(PHY_CARRIER_NB+7)/8]; + for (i=0; i<(PHY_CARRIER_NB+7)/8; i++) mask[i] = 0xFF; + mask[i-1] = ((1<<(PHY_CARRIER_NB%8))-1); + uint entry_nb; + gettimeofday (&tv0, NULL); + for (test=0; test<100; test++) + { + bitstream_init (&stream_writer, buf, 1518, BITSTREAM_WRITE); + entry_nb = cei_encode_tm (&stream_writer, worst_tonemap->tmdma_desc_head, mask); + } + gettimeofday (&tv1, NULL); + printf ("cei building duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); + + tonemap_free (worst_tonemap); + return 0; +} + diff --git a/ce/test/rx/general/src/test_spoc.c b/ce/test/rx/general/src/test_spoc.c new file mode 100644 index 0000000000..44790ec09e --- /dev/null +++ b/ce/test/rx/general/src/test_spoc.c @@ -0,0 +1,97 @@ +/* Cesar project {{{ + * + * Copyright (C) 2007 Spidcom + * + * <<>> + * + * }}} */ +/** + * \file ./src/test_speed.c + * \brief « brief description » + * \ingroup « module » + * + * « long description » + */ + +#include "common/std.h" +#include "sys/time.h" +#include "math.h" +#include "stdio.h" + +#define Pmin 74 +#define N0 1155 +#define Pmax (Pmin + N0 - 1) + +double reg_alpha[41]; +double reg_beta[41]; +double reg_bloc2[21]; +double reg_a0, reg_c0; + +void +spoc_update (double rho) +{ + int k; + double pirho = M_PI*rho; + double x = pirho * Pmin; + double xp = pirho * Pmax; + double s, sp; + double den = (xp - x); + + double x0 = 2*M_PI*1536*rho; + + for (k=-10; k<=10; k++) + { + reg_bloc2[k+10] = sin(x0+k*M_PI)/(x0+k*M_PI); + } + + double tmp1 = sin (x)/x; + double tmp2 = x*x; + reg_a0 = (sin(xp)/xp - tmp1)/(xp*xp - tmp2); + reg_c0 = tmp1 - reg_a0*tmp2; + + for (k=1; k<=20; k++) + { + x += (M_PI + pirho); + xp += M_PI; + s = sin (x) /x; + sp = sin (xp) /xp; + den -= pirho; + reg_beta[k+20] = (sp-s)/(den); + reg_alpha[k+20] = s - reg_beta[k+20]*x; + } + x = pirho * Pmin; + xp = pirho * Pmax; + den = (xp -x); + for (k=1; k<=20; k++) + { + xp -= (M_PI + pirho); + x -= M_PI; + s = sin (x) /x; + sp = sin (xp) /xp; + den -= pirho; + reg_beta[20-k] = (sp-s)/(den); + reg_alpha[20-k] = s - reg_beta[20-k]*x; + } +} + + +int +main (int argc, char **argv) +{ + struct timeval tv0, tv1; + double rho = 300e-6; + int t; + + gettimeofday (&tv0, NULL); + for (t=0; t<1; t++) spoc_update (rho); + gettimeofday (&tv1, NULL); + printf ("duration spoc2 : %d\n",(int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); + + gettimeofday (&tv0, NULL); + for (t=0; t<1000; t++) spoc_update (rho); + gettimeofday (&tv1, NULL); + printf ("duration 1000*spoc2 : %d\n",(int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); + + return 0; +} + diff --git a/ce/test/rx/general/src/test_spoc_opt.c b/ce/test/rx/general/src/test_spoc_opt.c new file mode 100644 index 0000000000..31bef0ef87 --- /dev/null +++ b/ce/test/rx/general/src/test_spoc_opt.c @@ -0,0 +1,346 @@ +/* Cesar project {{{ + * + * Copyright (C) 2007 Spidcom + * + * <<>> + * + * }}} */ + + +#include "common/std.h" +#include "sys/time.h" +#include "math.h" +#include "stdio.h" +#include +#include "ce/inc/frame_measurement.h" +#include "mac/common/tonemap.h" + +//#define SINC_STORAGE +//#define COMPARE + +double kaiser[10] = { 0.9905, 0.9622, 0.9164, 0.8546, 0.7792, 0.6929, 0.5989, 0.5005, 0.4011, 0.304 }; + +#define Pmin 74 +#define N0 1155 +#define Pmax (Pmin + N0 - 1) + +//typedef int spoc_prec_t; +typedef float spoc_prec_t; +//typedef double spoc_prec_t; // en flottant sinx/x avec x=0.1ppm retourne 1 + +spoc_prec_t reg_alpha[41]; +spoc_prec_t reg_beta[41]; +spoc_prec_t reg_a0, reg_c0; + +int alpha[3]={372, 1140, -3072}; +spoc_prec_t reg_bloc2[21][3]; + +#ifdef COMPARE +double reg_alpha_2[41]; +double reg_beta_2[41]; +double reg_a0_2, reg_c0_2; +double reg_bloc2_2[21][3]; +#endif + +#ifdef SINC_STORAGE +spoc_prec_t tmp_sinc[41]; +spoc_prec_t tmp_sinc_2[41]; +spoc_prec_t tmp_sincp[41]; +spoc_prec_t tmp_sincp_2[41]; +#endif + +inline void +spoc_bloc2 (int n, spoc_prec_t pirho) +{ + spoc_prec_t xp = alpha[n]*pirho; + spoc_prec_t xm = xp; + spoc_prec_t s = sin (xp); + int sign = -1; + int k; + + for (k=1; k<=10; k++) + { + xp += M_PI; + xm -= M_PI; + reg_bloc2[k+10][n] = kaiser[k-1] * sign*s/xp; + reg_bloc2[10-k][n] = kaiser[k-1] * sign*s/xm; + sign = -sign; + } +} + +inline void +spoc_update (spoc_prec_t rho) +{ + int k; + spoc_prec_t x; + spoc_prec_t xp; + spoc_prec_t s; + spoc_prec_t pirho; + pirho = M_PI * rho; + + spoc_prec_t abs_rho = rho; + if (abs_rho < 0 ) abs_rho = -abs_rho; + if (abs_rho>=0.01*1e-6) + { + spoc_prec_t spr; + spoc_prec_t cpr; + spoc_prec_t sp; + spoc_prec_t c; + spoc_prec_t zs; + spoc_prec_t den; + spoc_prec_t den0, sin0, sinp0, xp0, x0; + + + spr = sin (pirho); + cpr = cos (pirho); + x0 = x = pirho * Pmin; + xp0 = xp = pirho * Pmax; + //s = sin(x); + sinp0 = sp = sin(xp0); + c = cos(x); + sin0 = zs = sin(x); + den0 = den = (xp - x); + + reg_bloc2[10][0] = sin (alpha[0]*pirho)/(alpha[0]*pirho); + reg_bloc2[10][1] = sin (alpha[1]*pirho)/(alpha[1]*pirho); + reg_bloc2[10][2] = sin (alpha[2]*pirho)/(alpha[2]*pirho); + + //spoc_prec_t tmp1 = zs/x; + //spoc_prec_t tmp2 = x*x; + //reg_a0 = (sp/xp - tmp1)/(xp*xp - tmp2); + //reg_c0 = tmp1 - reg_a0*tmp2; + reg_a0 = (sp/xp - zs/x)/(xp*xp - x*x); + //reg_a0 = rho; + reg_c0 = zs/x - reg_a0*x*x; + + for (k=1; k<=20; k++) + { + x += (M_PI + pirho); + xp += M_PI; + s = -zs * cpr - c * spr; + c = zs * spr - c * cpr; + sp = -sp; + den -= pirho; + + zs = s/x; +#ifdef SINC_STORAGE + tmp_sinc[k+20] = zs; + tmp_sincp[k+20] = sp/xp; +#endif + reg_beta[k+20] = (sp/xp - zs)/den; + reg_alpha[k+20] = zs - reg_beta[k+20]*x; + + zs = s; + } + x = x0; + xp = xp0; + s = sin0; + c = cos(xp); + zs = sinp0; + den = den0; + for (k=1; k<=20; k++) + { + xp -= (M_PI + pirho); + x -= M_PI; + sp = -zs * cpr + c * spr; + c = -zs * spr - c * cpr; + s = -s; + den -= pirho; + + zs = sp/xp; +#ifdef SINC_STORAGE + tmp_sinc[20-k] = s/x; + tmp_sincp[20-k] = zs; +#endif + //printf ("%05.10g-%05.10g=%05.10g\n", zs, s/x, zs - s/x); + reg_beta[20-k] = (zs - s/x)/den; + reg_alpha[20-k] = zs - reg_beta[20-k]*xp; + + zs = sp; + } + } + else + { + reg_bloc2[10][0] = 1-((alpha[0]*pirho)*(alpha[0]*pirho))/6; + reg_bloc2[10][1] = 1-((alpha[1]*pirho)*(alpha[1]*pirho))/6; + reg_bloc2[10][2] = 1-((alpha[2]*pirho)*(alpha[2]*pirho))/6; + reg_a0 = -1.0/6; + reg_c0 = 1; + int sign = 1; + x = 0; + for (k=1; k<=20; k++) + { + x += M_PI; + reg_beta[k+20] = -sign/x; + reg_alpha[k+20] = sign; + reg_beta[20-k] = sign/x; + reg_alpha[20-k] = sign; + sign = -sign; + } + } + /** SPOC BLOC_2 */ + spoc_bloc2 (0, pirho); + spoc_bloc2 (1, pirho); + spoc_bloc2 (2, pirho); + } + +#ifdef COMPARE +void +spoc_update2 (double rho) +{ + int k,i; + double pirho = M_PI*rho; + double x = pirho * Pmin; + double xp = pirho * Pmax; + double s, sp; + double den = (xp - x); + + for (i=0; i<3; i++) + { + double x0 = alpha[i]*pirho; + for (k=-10; k<=10; k++) + { + double kk = 1; + if (k<0) kk = kaiser[-k-1]; + if (k>0) kk = kaiser[k-1]; + reg_bloc2_2[k+10][i] = kk * sin(x0+k*M_PI)/(x0+k*M_PI); + } + } + + double tmp1 = sin (x)/x; + double tmp2 = x*x; + reg_a0_2 = (sin(xp)/xp - tmp1)/(xp*xp - tmp2); + reg_c0_2 = tmp1 - reg_a0_2*tmp2; + + for (k=1; k<=20; k++) + { + x += (M_PI + pirho); + xp += M_PI; + s = sin (x) /x; + sp = sin (xp) /xp; + den -= pirho; +#ifdef SINC_STORAGE + tmp_sinc_2[k+20] = s; + tmp_sincp_2[k+20] = sp; +#endif + reg_beta_2[k+20] = (sp-s)/(den); + reg_alpha_2[k+20] = s - reg_beta_2[k+20]*x; + } + x = pirho * Pmin; + xp = pirho * Pmax; + den = (xp -x); + for (k=1; k<=20; k++) + { + xp -= (M_PI + pirho); + x -= M_PI; + s = sin (x) /x; + sp = sin (xp) /xp; +#ifdef SINC_STORAGE + tmp_sinc_2[20-k] = s; + tmp_sincp_2[20-k] = sp; +#endif + den -= pirho; + reg_beta_2[20-k] = (sp-s)/(den); + reg_alpha_2[20-k] = s - reg_beta_2[20-k]*x; + } +} +#endif + +void +get_error (double a, double b, double *error) +{ + if (a > b) + { + if ((a-b)>*error) *error = (a-b); + } + else + { + if ((b-a)>*error) *error = (b-a); + } +} + +int +main (int argc, char **argv) +{ + struct timeval tv0, tv1; + int test_rho = 0; + int t; + //int regv = sparc_leon3_get_cache_ctrl_reg(); + //printf("cache ctrl reg = 0x%x\n", regv); + + gettimeofday (&tv0, NULL); + gettimeofday (&tv1, NULL); + //printf ("first blk allocation duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); + + double error = 0; + + for (test_rho=-30000; test_rho <= 30000; test_rho++) + //for (test_rho=-500; test_rho < 500; test_rho++) + //for (test_rho=22540; test_rho < 22541; test_rho++) + { + double rho = test_rho * 1e-8; + + //gettimeofday (&tv0, NULL); + //for (t=0; t<1; t++) + // sin (rho)/rho; + //gettimeofday (&tv1, NULL); + //printf ("duration first sin : %d\n",(int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); + //get_error (0,0, &error); + //gettimeofday (&tv0, NULL); + //for (t=0; t<1; t++) + spoc_update (rho); + //gettimeofday (&tv1, NULL); + //printf ("duration 1000 spoc1 : %d\n",(int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); + + //rho = 00.0*1e-6; + //gettimeofday (&tv0, NULL); + //for (t=0; t<1; t++) + // spoc_update (rho); + //gettimeofday (&tv1, NULL); + //printf ("duration 1*spoc1 : %d\n",(int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); +#ifdef COMPARE + //for (t=0; t<1; t++) + spoc_update2 (rho); + + int k; + for (k=-10; k<=10; k++) + { + //printf ("bloc2[%d] = %05.10g <==> %05.10g, diff=%05.10g\n", k, reg_bloc2[k+10][0], reg_bloc2_2[k+10][0], reg_bloc2[k+10][0] - reg_bloc2_2[k+10][0]); + get_error (reg_bloc2[k+10][0], reg_bloc2_2[k+10][0], &error); + //printf ("bloc2[%d] = %05.10g <==> %05.10g, diff=%05.10g\n", k, reg_bloc2[k+10][1], reg_bloc2_2[k+10][1], reg_bloc2[k+10][1] - reg_bloc2_2[k+10][1]); + get_error (reg_bloc2[k+10][1], reg_bloc2_2[k+10][1], &error); + //printf ("bloc2[%d] = %05.10g <==> %05.10g, diff=%05.10g\n", k, reg_bloc2[k+10][2], reg_bloc2_2[k+10][2], reg_bloc2[k+10][2] - reg_bloc2_2[k+10][2]); + get_error (reg_bloc2[k+10][2], reg_bloc2_2[k+10][2], &error); + } + for (k=-20; k<20; k++) + { + if (k==0) + { + get_error( reg_a0, reg_a0_2, &error); + get_error( reg_c0, reg_c0_2, &error); + //printf ("a0 = %05.10g <==> %05.10g, diff=%05.10g\n", reg_a0, reg_a0_2, reg_a0 - reg_a0_2); + //printf ("c0 = %05.10g <==> %05.10g, diff=%05.10g\n", reg_c0, reg_c0_2, reg_c0 - reg_c0_2); + + } + else + { +#ifdef SINC_STORAGE + printf ("sinc[%d]=%05.10g <==> %05.10g, diff=%05.10g\n", k, tmp_sinc[k+20], tmp_sinc_2[k+20], tmp_sinc[k+20] - tmp_sinc_2[k+20]); + printf ("sincp[%d]=%05.10g <==> %05.10g, diff=%05.10g\n", k, tmp_sincp[k+20], tmp_sincp_2[k+20], tmp_sincp[k+20] - tmp_sincp_2[k+20]); +#endif + get_error (reg_beta[k+20], reg_beta_2[k+20], &error); + //printf ("pente[%d]=%05.10g <==> %05.10g, diff=%05.10g\n", k, reg_beta[k+20], reg_beta_2[k+20], reg_beta[k+20] - reg_beta_2[k+20]); + get_error (reg_alpha[k+20], reg_alpha_2[k+20], &error); + //printf ("ordo[%d]=%05.10g <==> %05.10g, diff=%05.10g\n\n", k, reg_alpha[k+20], reg_alpha_2[k+20], reg_alpha[k+20] - reg_alpha_2[k+20]); + } + + } +#endif + printf ("%d %05.18g %05.18g\n", test_rho, reg_a0, reg_c0); + error = 0; + } + //printf ("worst of worst error = %05.12g\n", error); + + return 0; +} + diff --git a/ce/test/rx/general/test.h b/ce/test/rx/general/test.h new file mode 100644 index 0000000000..9c5c1a8431 --- /dev/null +++ b/ce/test/rx/general/test.h @@ -0,0 +1,18 @@ +#ifndef test_h +#define test_h +/* Cesar project {{{ + * + * Copyright (C) 2008 Spidcom + * + * <<>> + * + * }}} */ +/** + * \file test.h + * \brief « brief description » + * \ingroup « module » + * + * « long description » + */ +#define GENERAL_TEST +#endif /* test_h */ diff --git a/ce/test/rx/overide/cp/interf/Module b/ce/test/rx/overide/cp/interf/Module deleted file mode 100644 index 5950fd7d38..0000000000 --- a/ce/test/rx/overide/cp/interf/Module +++ /dev/null @@ -1 +0,0 @@ -SOURCES := interf.c diff --git a/ce/test/rx/overide/cp/interf/interf.h b/ce/test/rx/overide/cp/interf/interf.h deleted file mode 100755 index 57e74ddb84..0000000000 --- a/ce/test/rx/overide/cp/interf/interf.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef cp_interf_interf_h -#define cp_interf_interf_h -/* Cesar project {{{ - * - * Copyright (C) 2007 Spidcom - * - * <<>> - * - * }}} */ -/** - * \file ./overide/cp/cp.h - * \brief « brief description » - * \ingroup « module » - * - * « long description » - */ - -#include "mac/sar/inc/sar_mf.h" - -u8 buf[SAR_MSDU_PAYLOAD_MAX_SIZE]; - -BEGIN_DECLS - -u8 * -interf_give_buf (void); - -void -interf_send (u8 *buf, uint len, uint dtei, uint priority); - -END_DECLS - -#endif /* cp_interf_interf_h */ diff --git a/ce/test/rx/overide/cp/interf/src/interf.c b/ce/test/rx/overide/cp/interf/src/interf.c deleted file mode 100755 index a804861c83..0000000000 --- a/ce/test/rx/overide/cp/interf/src/interf.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Cesar project {{{ - * - * Copyright (C) 2007 Spidcom - * - * <<>> - * - * }}} */ -/** - * \file ./overide/cp/src/cp.c - * \brief « brief description » - * \ingroup « module » - * - * « long description » - */ -#include "common/std.h" -#include "cp/interf/interf.h" - -u8 * -interf_give_buf (void) -{ - return buf; -} - -void -interf_send (u8 *buf, uint len, uint dtei, uint priority) -{ - return; -} diff --git a/ce/test/rx/src/test_cei.c b/ce/test/rx/src/test_cei.c deleted file mode 100755 index e60c7b45a1..0000000000 --- a/ce/test/rx/src/test_cei.c +++ /dev/null @@ -1,84 +0,0 @@ -/* Cesar project {{{ - * - * Copyright (C) 2007 Spidcom - * - * <<>> - * - * }}} */ -/** - * \file ./src/test_cei.c - * \brief « brief description » - * \ingroup « module » - * - * « long description » - */ -#include "common/std.h" -#define RXCE -#define TXCE -#include "ce/inc/cei.h" -#include "lib/test.h" -#include "mac/common/tonemask.h" -#include "ce/test/common/tonemap_utils.h" - -void -test_exchange (test_t test, tonemaps_t *rx_tms, tonemaps_t *tx_tms, - u8 *mask, uint tmi, uint max_rnd, uint offset) -{ - u8 buffer[1536]; - int i; for (i=0; i<1536; i++) buffer[i]=0; - cei_param_t param; - param.tms = rx_tms; - param.new_tmi = tmi; - create_tm (rx_tms, mask, tmi, max_rnd, offset); - ce_print_tonemaps (rx_tms); - cei_tonemaps_to_mme (¶m, buffer, mask); - ce_print_buffer (buffer, 512); - cei_decoding (tx_tms, CM_CHAN_EST_IND, buffer, mask); - ce_print_tonemaps (tx_tms); - compare_tonemaps (test, rx_tms, tx_tms, mask); -} - -int -main (int argc, char **argv) -{ - int i; - u8 mask[(PHY_CARRIER_NB+7)/8]; - for (i=0; i<(PHY_CARRIER_NB+7)/8; i++) mask[i] = 0xFF; - mask[i-1] = ((1<<(PHY_CARRIER_NB%8))-1); - test_t test; - lib_rnd_init (&rnd, 12); - test_init (test, argc, argv); - tonemaps_t *rx_tms = tonemaps_alloc(); - tonemaps_t *tx_tms = tonemaps_alloc(); - test_case_begin (test, "CE-cei-full mask"); - - test_exchange (test, rx_tms, tx_tms, mask, 0, 3, 1); - test_exchange (test, rx_tms, tx_tms, mask, 1, 2, 6); - test_exchange (test, rx_tms, tx_tms, mask, 2, 1, 3); - test_exchange (test, rx_tms, tx_tms, mask, 3, 0, 3); - - tonemaps_release (rx_tms); - tonemaps_release (tx_tms); - test_begin (test, "check alloc/free") - { - test_fail_unless (blk_check_memory()); - } test_end; - - rx_tms = tonemaps_alloc(); - tx_tms = tonemaps_alloc(); - tonemask_default (mask); - test_case_begin (test, "CE-cei-default mask"); - test_exchange (test, rx_tms, tx_tms, mask, 0, 3, 1); - test_exchange (test, rx_tms, tx_tms, mask, 1, 2, 6); - test_exchange (test, rx_tms, tx_tms, mask, 2, 1, 3); - test_exchange (test, rx_tms, tx_tms, mask, 3, 0, 3); - tonemaps_release (rx_tms); - tonemaps_release (tx_tms); - test_begin (test, "check alloc/free") - { - test_fail_unless (blk_check_memory()); - } test_end; - test_result (test); - return (test_nb_failed (test) == 0 ? 0 : 1); -} - diff --git a/ce/test/rx/src/test_cei_param.c b/ce/test/rx/src/test_cei_param.c deleted file mode 100755 index 66a869d4d2..0000000000 --- a/ce/test/rx/src/test_cei_param.c +++ /dev/null @@ -1,86 +0,0 @@ -/* Cesar project {{{ - * - * Copyright (C) 2007 Spidcom - * - * <<>> - * - * }}} */ -/** - * \file ./src/test_tx.c - * \brief « brief description » - * \ingroup « module » - * - * « long description » - */ - - -#include "common/std.h" -#include "ce/test/common/print_utils.h" -#include "ce/inc/cei_param.h" - -#include "lib/rnd.h" -#include "lib/test.h" - -lib_rnd_t rnd; - -void -test_cei_param (test_t test, uint read_percent) -{ - test_begin (test, "test_cei_param") - { - int n; - //test_debug_print ("%d%% of read %d%% of write ", read_percent, 100-read_percent); - lib_rnd_init (&rnd, 23); - //cei_param_t cei_param; - cei_param_fifo_init (); - cei_param_t cei_param; - cei_param.tms = NULL; - cei_param.new_tmi = 0; - cei_param.old_tmi = 0; - cei_param.priority = 0xFF; - cei_param.dtei = 0xFF; - uint cpt = 0; - for (n=0; n<1000; n++) - { - uint alea = lib_rnd_uniform (&rnd, 100); - //my_print ("%d\n" ,alea); - test_fail_if (cpt>CEI_WANTED_MAX); - if (alea > read_percent) - { - //my_print (" get %d <=> %d\n", cpt, cei_param_fifo.number); - uint reader_index = cei_param_fifo.reader_index; - test_fail_if (cpt != cei_param_fifo.number); - cei_param_t *param = cei_param_get (); - //if (!param) my_print ("param = NULL\n"); - test_fail_if (!param && cpt!=0); - if (param) - { - //my_print ("%d <==> %d\n", reader_index, 0); - test_fail_if (reader_index != param->priority); - cpt--; - } - } - else - { - //my_print (" add\n"); - cei_param.priority = cei_param_fifo.writer_index; - if (cei_param_add (&cei_param)) cpt++; - } - } - } test_end; -} - -int -main (int argc, char **argv) -{ - test_t test; - test_init (test, argc, argv); - test_case_begin (test, "CE-mme 75% of read"); - test_cei_param (test, 75); - test_case_begin (test, "CE-mme 25% of read"); - test_cei_param (test, 25); - test_case_begin (test, "CE-mme 50% of read"); - test_cei_param (test, 50); - test_result (test); - return (test_nb_failed (test) == 0 ? 0 : 1); -} diff --git a/ce/test/rx/src/test_frame_measurement.c b/ce/test/rx/src/test_frame_measurement.c deleted file mode 100755 index fdab1bfa0d..0000000000 --- a/ce/test/rx/src/test_frame_measurement.c +++ /dev/null @@ -1,469 +0,0 @@ -/* 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 "lib/rnd.h" -#include "ce/test/common/gaussian.h" -#include "lib/test.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; -} - -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; - uint cpt = offset; - for (i=0; inext); - first = first->next; - wrdata = (u32 *) first->data; - first->pb_nb = 0; - cpt=0; - } - *(wrdata+cpt) = i+ber_init_value; - first->pb_nb++; - cpt++; - } -} - -void -test_frame_measurement_ber_add (test_t t) -{ - test_begin (t, "add ber") - { - 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_callber_measurement; - u32 *rddata = (u32 *) rd->data; - test_fail_if (!fm); - test_fail_if (!rd); - uint k=0; - uint cpt = 1; - do - { - for (i=0; ipb_nb) && *(rddata+i)!=k); - k++; - } - if (rd->next) - { - rd = rd->next; - rddata = (u32 *) rd->data; - cpt++; - } - else - { - test_fail_if (rd != last_ber); - rd = rd->next; - } - } while (rd); - uint comp = (N*pb_nb_to_add)/(BLK_SIZE/4); - if ((N*pb_nb_to_add)%(BLK_SIZE/4) >0) comp++; - test_fail_if (cpt != comp); - frame_measurement_release (fm); - //frame_measurement_print (fm); - } - } - } test_end; -} - -phy_chandata_t * -chandata_init (int type) -{ - phy_chandata_t *last; - phy_chandata_t *chandata = (phy_chandata_t *) blk_alloc_desc_range ( - CHANDATA_TYPE_BLK_NB[type], (blk_t **) &last); - chandata->type = type; - last->blk.next = NULL; - phy_chandata_t *ch = chandata; - while (ch) - { - uint i; - phy_noise_t * data = (phy_noise_t *) ch->blk.data; - for (i=0; ilast = 0; - ch->type = type; - ch = (phy_chandata_t *) ch->blk.next; - } - last->last = 1; - return (chandata); -} - -void -test_frame_measurement_noise_add (test_t t) -{ - test_begin (t, "add noise") - { - uint i; - pbproc_rx_params_t *rx_params = (pbproc_rx_params_t *) blk_alloc(); - bool b = frame_measurement_append (rx_params, 0, NULL, NULL, NULL); - if (b) - { - frame_measurement_t *fm = frame_measurement_get_next(); - for (i=1; itype_head[i]; - while (chandata) - { - phy_noise_t *data = (phy_noise_t *) chandata->blk.data; - uint j; - for (j=0; jlast; - //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); - } - } - frame_measurement_release (fm); - } - } test_end; -} - -void -test_frame_measurement_add (test_t t) -{ - test_begin (t, "add/remove frame measurement") - { - lib_rnd_init (&rnd, 23); - int nb_frame_added = 0; - int nb_frame_measurement = 0; - int alea ; - int N = 1000; - 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; - bool b = frame_measurement_append (rx_params, 0, f, l, NULL); - if (b) - { - rx_params->preamble_ntb = nb_frame_added; - 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)); - frame_measurement_release (first); - nb_frame_measurement--; - } - } - } - while (nb_frame_measurement > 0) - { - 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--; - } - test_fail_if (frame_measurement_get_next()); - } test_end; -} - -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; - test_result (test); - return (test_nb_failed (test) == 0 ? 0 : 1); -} - diff --git a/ce/test/rx/src/test_rx.c b/ce/test/rx/src/test_rx.c deleted file mode 100755 index 03d0ac58cc..0000000000 --- a/ce/test/rx/src/test_rx.c +++ /dev/null @@ -1,279 +0,0 @@ -/* Cesar project {{{ - * - * Copyright (C) 2007 Spidcom - * - * <<>> - * - * }}} */ -/** - * \file ./src/test_tx.c - * \brief « brief description » - * \ingroup « module » - * - * « long description » - */ -#include "common/std.h" -#include "cyg/hal/hal_intr.h" -#include "ce/inc/rx.h" -#include "mac/common/tonemap.h" -#include "ce/test/common/print_utils.h" -#include "ce/test/rx/inc/test_rx.h" -#include "lib/bitstream.h" -#include "lib/rnd.h" -#include "lib/test.h" -#include "cp/interf/interf.h" -#include "lib/trace.h" -#include "mac/common/ntb.h" -#include "ce/inc/trace.h" - -lib_rnd_t rnd; -test_t test; -phy_t *phy_ctx; -rxce_t *rxce_ctx; - - -#define FRAME_PRIORITY 10 -cyg_thread frame_thread; -cyg_handle_t frame_handle; -unsigned char frame_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL]; - -#define RXCE_PRIORITY 14 -cyg_thread rxce_thread; -cyg_handle_t rxce_handle; -unsigned char rxce_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL]; - -uint noise[PHY_CARRIER_NB]; -uint false_bit_nb[MAX_PB]; - -struct test_status_t -{ - mac_store_t *mac_store_ctx; - sta_t *sta; - uint sound_nb; - uint null_ber_frame_nb; - uint date; -}; -typedef struct test_status_t test_status_t; -test_status_t status; - -struct frame_t -{ - bool sound; - uint sound_reason_code; - uint pb_nb; - pbproc_rx_params_t *rx_params; - uint *noise; - uint *false_bit_nb; -}; -typedef struct frame_t frame_t; - - -bool next_scf; - -void -pbproc_rxce_init (pbproc_need_scf_cb_t need_scf) -{ - need_scf_cb = need_scf; -} - -void -pbproc_scf (void) -{ - //my_print ("pbproc scf\n"); - next_scf = true; -} - -void -over_pbproc_init (void) -{ - next_scf = false; -} - -bool -pbproc_send_scf (void) -{ - ce_print ("\t\t\t\t ACK with scf = %d\n", next_scf); - bool ret = next_scf; - next_scf = false; - return (ret); -} - -void -sar_noise_new (pbproc_rx_params_t *rx_params, uint noise[], uint symbol_nb) -{ - //my_print ("sar noise new\n"); - uint i; - uint lambda = 0; - phy_chandata_t *time_noise; - time_noise = (phy_chandata_t *) blk_alloc_desc(); - time_noise->blk.next = NULL; - time_noise->last = 0; - time_noise->type = PHY_CHANDATA_TYPE_NRJ_SYMBOL; - phy_noise_t *time_data = (phy_noise_t *) time_noise->blk.data; - phy_chandata_t *freq_noise, *last; - freq_noise = (phy_chandata_t *) blk_alloc_desc_range (PHY_CHANDATA_NRJ_BLK_NB, (blk_t **) &last); - freq_noise->type = PHY_CHANDATA_TYPE_NRJ; - phy_chandata_t * ch = freq_noise; - phy_noise_t *freq_data = (phy_noise_t *) ch->blk.data; - for (i=0; itype = PHY_CHANDATA_TYPE_NRJ; - ch->last = 0; - if ( (i%(BLK_SIZE/(sizeof(phy_noise_t))) == 0) && (i!=0) ) - { - ch = (phy_chandata_t *) ch->blk.next; - freq_data = (phy_noise_t *) ch->blk.data; - } - //my_print ("writing %d @(0x%x + %d)\n",i, freq_data, (i%(BLK_SIZE/2))); - * (freq_data+(i%(BLK_SIZE/sizeof(phy_noise_t)))) = noise[i]; - lambda+=noise[i]; - } - lambda = lambda/PHY_CARRIER_NB; - last->last = 1; - last->blk.next = NULL; - for (i=0; iblk.next = (blk_t *) freq_noise; - //chandata_print (time_noise); - ce_print ("\t\t\t\t ADD NOISES\n"); - sar_mpdu_measurement_cb (NULL, rx_params, 0, NULL, NULL, (pb_t *) time_noise); - //my_print ("\t\t\t\t ADD FREQ NOISE\n"); - //sar_mpdu_measurement_cb (NULL, rx_params, 0, NULL, NULL, (pb_t *) freq_noise); -} - -void -frame_new (frame_t *frame) -{ - uint symbol_nb = 0; - frame->rx_params->preamble_ntb = status.date; - if (frame->sound) - { - symbol_nb = 19; - status.date += (19); - status.sound_nb++; - need_scf_cb (frame->rx_params->tei, frame->sound_reason_code); - cyg_thread_delay (symbol_nb/19); - sar_noise_new (frame->rx_params, frame->noise, symbol_nb); - } - else - { - ; - } -} - -void -frame_process (cyg_addrword_t data) -{ - mac_store_sta_add (status.mac_store_ctx, 1); - status.sta = mac_store_sta_get (status.mac_store_ctx, 1); - status.sound_nb = 0; - test_case_begin (test, "CE-rxce_process with noise reception"); - test_begin (test, "rxce test1") - { - uint j; - uint nb_frame = 0; - uint worst[PHY_CARRIER_NB]; - - cyg_thread_delay (1); - lib_rnd_init (&rnd, 12); - do - { - frame_t *frame = blk_alloc(); - pbproc_rx_params_t *rx_params = blk_alloc (); - frame->sound = true; - frame->sound_reason_code = 0xFD; - frame->pb_nb = 0; - frame->rx_params = rx_params; - frame->rx_params->tei = 1; - for (j=0; jnoise = noise; - frame_new (frame); - nb_frame++; - test_fail_if (status.sta->rxce.stable_ROBO_nbrx_tonemaps->default_tmi != TONEMAP_INDEX_INITIAL_START); - test_fail_if (status.sta->rxce.stable_ROBO_nb>FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && status.sta->rx_tonemaps->default_tmi == TONEMAP_INDEX_INITIAL_START); - blk_release (frame); - } while (!pbproc_send_scf ()); - bitstream_t stream; - bitstream_init (&stream, status.sta->rx_tonemaps->tm[status.sta->rx_tonemaps->default_tmi]->tmdma_desc_head->data, BLK_SIZE, BITSTREAM_READ); - for (j=0; jrx_tonemaps->tm[status.sta->rx_tonemaps->default_tmi]->tmdma_desc_head->next->data, BLK_SIZE, BITSTREAM_READ); - } - uint mod; - bitstream_access (&stream, &mod, 4); - if (mod==0) - { - test_fail_if (worst[j] <=THR3[1][0]); - } - else - { - if (mod==7) - { - test_fail_if (worst[j] > THR3[1][6]); - } - else - { - test_fail_if (worst[j]<=THR3[1][mod] || worst[j]>THR3[1][mod-1]); - } - } - - } - } test_end; - // rxce_process can end to process and free pending frames. - cyg_thread_delay (1); - - blk_release (status.sta); - mac_store_sta_remove (status.mac_store_ctx, 1); - mac_store_uninit (status.mac_store_ctx); - blk_release (phy_ctx); - rxce_trace_print(rxce_ctx); - rxce_trace_uninit (rxce_ctx); - trace_uninit(); - test_begin (test, "check alloc/free") - { - test_fail_unless (blk_check_memory()); - } test_end; - test_result (test); - HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1); -} - -void -cyg_user_start (int argc, char **argv) -{ - trace_init(); - phy_ctx = blk_alloc(); - test_init (test, argc, argv); - mac_config_t mac_config; - tonemask_default ((u8 *)(&(mac_config.tonemask_info.tonemask))); - status.mac_store_ctx = mac_store_init (); - mac_ntb_init (phy_ctx, &mac_config); - rxce_ctx = rxce_init (status.mac_store_ctx, &mac_config); - over_pbproc_init (); - pbproc_rxce_init (pbproc_need_scf_cb); - - cyg_thread_create (RXCE_PRIORITY, &rxce_process, 0, "rxce", - rxce_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL, - &rxce_handle, &rxce_thread); - cyg_thread_create (FRAME_PRIORITY, &frame_process, 0, "frame_test", - frame_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL, - &frame_handle, &frame_thread); - - - //my_print ("launch rxce process\n"); - cyg_thread_resume (rxce_handle); - - //my_print ("launch frame process\n"); - cyg_thread_resume (frame_handle); -} - diff --git a/ce/test/rx/src/test_sar_integration.c b/ce/test/rx/src/test_sar_integration.c deleted file mode 100755 index 21a198d6f7..0000000000 --- a/ce/test/rx/src/test_sar_integration.c +++ /dev/null @@ -1,303 +0,0 @@ -/* Cesar project {{{ - * - * Copyright (C) 2007 Spidcom - * - * <<>> - * - * }}} */ -/** - * \file ce/test/rx/sar_integration.c - * \brief Use sar callback for Channel estimation. - * \ingroup ce - * - */ -#include "common/std.h" -#include "cyg/hal/hal_intr.h" -#include "lib/test.h" -#include "mac/sar/sar.h" -#include "ce/inc/rx.h" -#include "mac/common/pb.h" // PB header initialisation -#include "ce/test/common/print_utils.h" -#include "cp/interf/interf.h" -//#include "mac/sar/inc/trace.h" -#include "mac/common/ntb.h" -#include "ce/inc/trace.h" -#include "hal/phy/phy.h" - -#define FRAME_PRIORITY 10 -cyg_thread frame_thread; -cyg_handle_t frame_handle; -unsigned char frame_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL]; -#define RXCE_PRIORITY 14 -cyg_thread rxce_thread; -cyg_handle_t rxce_handle; -unsigned char rxce_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL]; - -test_t test; -mac_store_t *mac_store_ctx; -mac_config_t mac_config; -rxce_t *rxce_ctx; -phy_t *phy; - -u32 -phy_date (phy_t *phy) -{ - return (cyg_current_time()); -} - -void -pbproc_scf (void) -{ - ce_print("pbproc_scf()\n"); -} - -void -emul_reassembly (int pb_nb, uint date, pbproc_rx_params_t **rx_params, - pb_t **f, pb_t **l, phy_chandata_t **noise) -{ - uint i, j; - if (pb_nb > 0) - { - *f = (pb_t *) blk_alloc_desc_range (pb_nb,(blk_t **)l); - (*l)->next = NULL; - phy_pb_rx_t *p = (phy_pb_rx_t *) *f; - for (i=0; i<(uint) pb_nb; i++) - { - p->pb_measurement.ber = i; - ((pb_t *)p)->header.vpbf = 0; - p = (phy_pb_rx_t *) p->blk.next; - } - } - else - { - *f = *l = NULL; - } - - phy_chandata_t *l_noise, *p_noise; - phy_chandata_t *f_noise = (phy_chandata_t *) blk_alloc_desc_range (PHY_CHANDATA_NRJ_BLK_NB, (blk_t **)&l_noise); - p_noise = f_noise; - phy_noise_t *data; - for (i=0; ilast = 1; - p_noise->blk.next = NULL; - dbg_assert (i == (PHY_CHANDATA_NRJ_BLK_NB-1)); - } - else - { - p_noise->last = 0; - } - p_noise->type = PHY_CHANDATA_TYPE_NRJ; - data = (phy_noise_t *) p_noise->blk.data; - for (j=0; jblk.next; - } - - *noise = (phy_chandata_t *) blk_alloc_desc (); - data = (phy_noise_t *) (*noise)->blk.data; - for (j=0; jtype = PHY_CHANDATA_TYPE_NRJ_SYMBOL; - (*noise)->last = 0; - (*noise)->blk.next =(blk_t *) f_noise; - - *rx_params = blk_alloc(); - (*rx_params)->preamble_ntb = date; - (*rx_params)->tei = 1; - (*rx_params)->lid = 1; -} -void -run_one_reassembly (sar_t *sar_ctx, uint pb_nb) -{ - pbproc_rx_params_t *rx_params; - pb_t *f, *l; - phy_chandata_t *noise; - - //my_print ("\n"); - emul_reassembly (pb_nb, 0x00, &rx_params, &f, &l, &noise); - //my_print ("pbproc-pb-noise-rxparam : allocated = %d, freed = %d released = %d referenced = %d\n", blk_allocated, blk_freed, blk_released, blk_referenced); - sar_mpdu_add (sar_ctx, NULL, NULL, rx_params, f, l, pb_nb, (pb_t *) noise); - //my_print ("sar_mpdu_added : allocated = %d, freed = %d released = %d referenced = %d\n", blk_allocated, blk_freed, blk_released, blk_referenced); - blk_release (rx_params); // pbproc can erase it. - //my_print ("release pbproc_rx_params : allocated = %d, freed = %d released = %d referenced = %d\n", blk_allocated, blk_freed, blk_released, blk_referenced); - sar_launch (sar_ctx); - //my_print ("sar_launch : allocated = %d, freed = %d released = %d referenced = %d\n", blk_allocated, blk_freed, blk_released, blk_referenced); -} - -void -START (sar_t **sar_ctx, sta_t **sta, ca_t **ca) -{ - pbproc_t *pbproc_ctx = pbproc_init (&mac_config, mac_store_ctx); - *ca = (ca_t *) blk_alloc(); - *sar_ctx = sar_init (mac_store_ctx, pbproc_ctx, *ca); - sar_init_measure_context (*sar_ctx, NULL); - sar_init_measurement_cb (*sar_ctx, &sar_mpdu_measurement_cb); - mac_store_sta_add (mac_store_ctx, 1); - *sta = mac_store_sta_get (mac_store_ctx, 1); -} - -void -END (sar_t *sar_ctx, sta_t *sta, ca_t *ca) -{ - //sta_uninit (sta); - //sar_trace_print (sar_ctx); - blk_release (sta); // release reference to sta added by mac_store_mfs_get in START. - dbg_check (mac_store_sta_remove (mac_store_ctx, 1)); - blk_release (ca); - sar_uninit (sar_ctx); -} - -void -frame_process (cyg_addrword_t data) -{ - - sar_t *sar_ctx; - sta_t *sta; - ca_t *ca; - int n; - int tmi_null; - int tmp_exists; - - test_case_begin (test, "One sound frame"); - START (&sar_ctx, &sta, &ca); - run_one_reassembly (sar_ctx, 0); - cyg_thread_delay (1); //rxce can process - test_begin (test, "check rxce status") - { - test_fail_if (sta->rx_tonemaps->default_tmi != TONEMAP_INDEX_INITIAL_START); - test_fail_if (!sta->rxce.tm_in_build); - } test_end; - END (sar_ctx, sta, ca); - - test_case_begin (test, "One 1-PB frame"); - START (&sar_ctx, &sta, &ca); - run_one_reassembly (sar_ctx, 1); - cyg_thread_delay (1); //rxce can process - test_begin (test, "check rxce status") - { - test_fail_if (sta->rx_tonemaps->default_tmi != TONEMAP_INDEX_INITIAL_START); - test_fail_if (!sta->rxce.tm_in_build); - } test_end; - END (sar_ctx, sta, ca); - - test_case_begin (test, "One 200-PB frame"); - START (&sar_ctx, &sta, &ca); - run_one_reassembly (sar_ctx, 200); - cyg_thread_delay (1); //rxce can process - test_begin (test, "check rxce status") - { - test_fail_if (sta->rx_tonemaps->default_tmi != TONEMAP_INDEX_INITIAL_START); - test_fail_if (!sta->rxce.tm_in_build); - } test_end; - END (sar_ctx, sta, ca); - - test_case_begin (test, "Several sound frames processed one by one"); - START (&sar_ctx, &sta, &ca); - test_begin (test, "check rxce status") - { - for (n=0; nrx_tonemaps->default_tmi == TONEMAP_INDEX_INITIAL_START; - tmp_exists = (int) sta->rxce.tm_in_build; - test_fail_if (n=FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmi_null); - test_fail_if (n==FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmp_exists); - test_fail_if (n>FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmp_exists); - } - } test_end; - END (sar_ctx, sta, ca); - - test_case_begin (test, "Several sound frames and rxce late"); - START (&sar_ctx, &sta, &ca); - test_begin (test, "check rxce status") - { - for (n=0; nrxce.measurement_computed_nb-1; - tmi_null = sta->rx_tonemaps->default_tmi == TONEMAP_INDEX_INITIAL_START; - tmp_exists = (int) sta->rxce.tm_in_build; - //my_print ("%d, tmi_null=%d, tmp_exists=%d\n",frame_nb, tmi_null, tmp_exists); - test_fail_if (frame_nb=FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmi_null); - test_fail_if (frame_nb==FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmp_exists); - test_fail_if (frame_nb>FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmp_exists); - } - if (n == FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP ) - { - cyg_thread_delay (1); //rxce can process - uint frame_nb = sta->rxce.measurement_computed_nb-1; - tmi_null = sta->rx_tonemaps->default_tmi == TONEMAP_INDEX_INITIAL_START; - tmp_exists = (int) sta->rxce.tm_in_build; - //my_print ("%d, tmi_null=%d, tmp_exists=%d\n",frame_nb, tmi_null, tmp_exists); - test_fail_if (frame_nb=FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmi_null); - test_fail_if (frame_nb==FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmp_exists); - test_fail_if (frame_nb>FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmp_exists); - } - if (n == FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP + 5 -1 ) - { - cyg_thread_delay (1); //rxce can process - uint frame_nb = sta->rxce.measurement_computed_nb-1; - tmi_null = sta->rx_tonemaps->default_tmi == TONEMAP_INDEX_INITIAL_START; - tmp_exists = (int) sta->rxce.tm_in_build; - //my_print ("%d, tmi_null=%d, tmp_exists=%d\n",frame_nb, tmi_null, tmp_exists); - test_fail_if (frame_nb=FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmi_null); - test_fail_if (frame_nb==FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmp_exists); - test_fail_if (frame_nb>FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmp_exists); - } - cyg_thread_delay (1); //rxce can process - } - } test_end; - END (sar_ctx, sta, ca); - - mac_store_uninit (mac_store_ctx); - rxce_trace_print (rxce_ctx); - rxce_trace_uninit (rxce_ctx); - trace_uninit(); - blk_release (phy); - test_begin (test, "check alloc/free") - { - test_fail_unless (blk_check_memory()); - } test_end; - test_result (test); - HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1); -} - -void -cyg_user_start (int argc, char **argv) - { - test_init (test, argc, argv); - trace_init(); - phy = (phy_t *) blk_alloc(); - mac_ntb_init (phy, &mac_config); - - tonemask_default ((u8 *)(&(mac_config.tonemask_info.tonemask))); - mac_store_ctx = mac_store_init (); - rxce_ctx = rxce_init (mac_store_ctx, &mac_config); - cyg_thread_create (RXCE_PRIORITY, &rxce_process, 0, "rxce", - rxce_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL, - &rxce_handle, &rxce_thread); - cyg_thread_resume (rxce_handle); - cyg_thread_create (FRAME_PRIORITY, &frame_process, 0, "frame_test", - frame_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL, - &frame_handle, &frame_thread); - cyg_thread_resume (frame_handle); - -} - - diff --git a/ce/test/rx/src/test_speed.c b/ce/test/rx/src/test_speed.c deleted file mode 100644 index 210b082cc3..0000000000 --- a/ce/test/rx/src/test_speed.c +++ /dev/null @@ -1,193 +0,0 @@ -/* Cesar project {{{ - * - * Copyright (C) 2007 Spidcom - * - * <<>> - * - * }}} */ -/** - * \file ./src/test_speed.c - * \brief « brief description » - * \ingroup « module » - * - * « long description » - */ - -#include "common/std.h" -#include "sys/time.h" -#include "stdio.h" -#include "string.h" -#include "ce/inc/frame_measurement.h" -#include "mac/common/tonemap.h" -#include "ce/test/common/print_utils.h" -#include "lib/bitstream.h" -#define RXCE -#include "ce/inc/cei.h" -#include "math.h" - - -int -main (int argc, char **argv) -{ - struct timeval tv0, tv1; - double test_d; - int r; - double flottant = 0.123456789; - double res = flottant; - double x=0; - - gettimeofday (&tv0, NULL); - for (r=-10000; r<10000; r++) - { - x = (double)(M_PI*r)/ 10000.0; - for (test_d=0; test_d<100; test_d++) - { - res = test_d * x; - } - } - gettimeofday (&tv1, NULL); - printf ("test duration [nothing] %d \n", (int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); - gettimeofday (&tv0, NULL); - for (r=-10000; r<10000; r++) - { - x = (double)(M_PI*r)/ 10000.0; - for (test_d=0; test_d<100; test_d++) - { - res = test_d / x; - } - } - gettimeofday (&tv1, NULL); - printf ("test duration [div : dble/dble] %d \n", (int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); - gettimeofday (&tv0, NULL); - for (r=-10000; r<10000; r++) - { - x = (double)(M_PI*r)/ 10000.0; - for (test_d=0; test_d<100; test_d++) - { - res = sin (x); - } - } - gettimeofday (&tv1, NULL); - printf ("test duration [sin (dble)] %d \n", (int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); - - uint word = 0x76543210; - uint i, test; - int nibble; - bitstream_t stream_writer; - gettimeofday (&tv0, NULL); - gettimeofday (&tv1, NULL); - printf ("getitmeofday duration %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); - gettimeofday (&tv0, NULL); - for (test=0; test<1000; test++) - { - word = 0; - for (i=0; i<8; i++) - { - nibble = i+1; - word = (word >> 4) | (nibble << 28); - } - } - gettimeofday (&tv1, NULL); - printf ("nibble to u32 duration test1 %d /1000\n",(int) (tv1.tv_usec - tv0.tv_usec)); - - gettimeofday (&tv0, NULL); - for (test=0; test<1000; test++) - { - word = 0; - for (i=0; i<8; i++) - { - nibble = i+1; - word = word | (nibble << (i<<2)); - } - } - gettimeofday (&tv1, NULL); - printf ("nibble to u32 duration test2 %d /1000\n",(int) (tv1.tv_usec - tv0.tv_usec)); - - frame_measurement_init (); - - uint noise = 0; - gettimeofday (&tv0, NULL); - update_threshold (1, 1); - for (i=0; i<1536; i++) - { - noise2mod (noise); - } - gettimeofday (&tv1, NULL); - printf ("noise2mod duration --worst : %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); - - noise = 10000; - gettimeofday (&tv0, NULL); - update_threshold (1, 1); - for (i=0; i<1536; i++) - { - noise2mod (noise); - - } - gettimeofday (&tv1, NULL); - printf ("noise2mod duration --best : %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); - - - gettimeofday (&tv0, NULL); - blk_t *blk = blk_alloc_desc (); - gettimeofday (&tv1, NULL); - printf ("first blk allocation duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); - blk_release_desc (blk); - gettimeofday (&tv0, NULL); - blk = blk_alloc_desc (); - gettimeofday (&tv1, NULL); - printf ("second blk allocation duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); - blk_release_desc (blk); - - blk_t *blk_last; - gettimeofday (&tv0, NULL); - blk_t *blk_first = blk_alloc_desc_range (10, &blk_last); - gettimeofday (&tv1, NULL); - printf ("multi-blk allocation duration (10) : %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); - blk_release_desc_range (blk_first, blk_last); - - - phy_chandata_t *last, *browser; - phy_chandata_t *first = (phy_chandata_t *) blk_alloc_desc_range (PHY_CHANDATA_NRJ_BLK_NB, (blk_t **) &last); - last->last = 1; - last->blk.next = NULL; - browser = first; - noise = 0; - int j, k=0; - u32 * data = (u32 * ) browser->blk.data; - for (i=0; iblk.next); - if (browser) data = (u32 * ) browser->blk.data; - } - tonemap_t *worst_tonemap = NULL; - gettimeofday (&tv0, NULL); - compute_worst_tonemap (&worst_tonemap, first); - gettimeofday (&tv1, NULL); - printf ("default tonemap computation duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); - ce_print_tonemap (worst_tonemap); - blk_release_desc_range ((blk_t *) first, (blk_t *)last); - - u8 buf[1536]; - for (i=0; i<1536; i++) buf[i] = 0x00; - u8 mask[(PHY_CARRIER_NB+7)/8]; - for (i=0; i<(PHY_CARRIER_NB+7)/8; i++) mask[i] = 0xFF; - mask[i-1] = ((1<<(PHY_CARRIER_NB%8))-1); - uint entry_nb; - gettimeofday (&tv0, NULL); - for (test=0; test<100; test++) - { - bitstream_init (&stream_writer, buf, 1518, BITSTREAM_WRITE); - entry_nb = cei_encode_tm (&stream_writer, worst_tonemap->tmdma_desc_head, mask); - } - gettimeofday (&tv1, NULL); - printf ("cei building duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); - - tonemap_free (worst_tonemap); - return 0; -} - diff --git a/ce/test/rx/src/test_spoc.c b/ce/test/rx/src/test_spoc.c deleted file mode 100644 index 44790ec09e..0000000000 --- a/ce/test/rx/src/test_spoc.c +++ /dev/null @@ -1,97 +0,0 @@ -/* Cesar project {{{ - * - * Copyright (C) 2007 Spidcom - * - * <<>> - * - * }}} */ -/** - * \file ./src/test_speed.c - * \brief « brief description » - * \ingroup « module » - * - * « long description » - */ - -#include "common/std.h" -#include "sys/time.h" -#include "math.h" -#include "stdio.h" - -#define Pmin 74 -#define N0 1155 -#define Pmax (Pmin + N0 - 1) - -double reg_alpha[41]; -double reg_beta[41]; -double reg_bloc2[21]; -double reg_a0, reg_c0; - -void -spoc_update (double rho) -{ - int k; - double pirho = M_PI*rho; - double x = pirho * Pmin; - double xp = pirho * Pmax; - double s, sp; - double den = (xp - x); - - double x0 = 2*M_PI*1536*rho; - - for (k=-10; k<=10; k++) - { - reg_bloc2[k+10] = sin(x0+k*M_PI)/(x0+k*M_PI); - } - - double tmp1 = sin (x)/x; - double tmp2 = x*x; - reg_a0 = (sin(xp)/xp - tmp1)/(xp*xp - tmp2); - reg_c0 = tmp1 - reg_a0*tmp2; - - for (k=1; k<=20; k++) - { - x += (M_PI + pirho); - xp += M_PI; - s = sin (x) /x; - sp = sin (xp) /xp; - den -= pirho; - reg_beta[k+20] = (sp-s)/(den); - reg_alpha[k+20] = s - reg_beta[k+20]*x; - } - x = pirho * Pmin; - xp = pirho * Pmax; - den = (xp -x); - for (k=1; k<=20; k++) - { - xp -= (M_PI + pirho); - x -= M_PI; - s = sin (x) /x; - sp = sin (xp) /xp; - den -= pirho; - reg_beta[20-k] = (sp-s)/(den); - reg_alpha[20-k] = s - reg_beta[20-k]*x; - } -} - - -int -main (int argc, char **argv) -{ - struct timeval tv0, tv1; - double rho = 300e-6; - int t; - - gettimeofday (&tv0, NULL); - for (t=0; t<1; t++) spoc_update (rho); - gettimeofday (&tv1, NULL); - printf ("duration spoc2 : %d\n",(int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); - - gettimeofday (&tv0, NULL); - for (t=0; t<1000; t++) spoc_update (rho); - gettimeofday (&tv1, NULL); - printf ("duration 1000*spoc2 : %d\n",(int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); - - return 0; -} - diff --git a/ce/test/rx/src/test_spoc_opt.c b/ce/test/rx/src/test_spoc_opt.c deleted file mode 100644 index 31bef0ef87..0000000000 --- a/ce/test/rx/src/test_spoc_opt.c +++ /dev/null @@ -1,346 +0,0 @@ -/* Cesar project {{{ - * - * Copyright (C) 2007 Spidcom - * - * <<>> - * - * }}} */ - - -#include "common/std.h" -#include "sys/time.h" -#include "math.h" -#include "stdio.h" -#include -#include "ce/inc/frame_measurement.h" -#include "mac/common/tonemap.h" - -//#define SINC_STORAGE -//#define COMPARE - -double kaiser[10] = { 0.9905, 0.9622, 0.9164, 0.8546, 0.7792, 0.6929, 0.5989, 0.5005, 0.4011, 0.304 }; - -#define Pmin 74 -#define N0 1155 -#define Pmax (Pmin + N0 - 1) - -//typedef int spoc_prec_t; -typedef float spoc_prec_t; -//typedef double spoc_prec_t; // en flottant sinx/x avec x=0.1ppm retourne 1 - -spoc_prec_t reg_alpha[41]; -spoc_prec_t reg_beta[41]; -spoc_prec_t reg_a0, reg_c0; - -int alpha[3]={372, 1140, -3072}; -spoc_prec_t reg_bloc2[21][3]; - -#ifdef COMPARE -double reg_alpha_2[41]; -double reg_beta_2[41]; -double reg_a0_2, reg_c0_2; -double reg_bloc2_2[21][3]; -#endif - -#ifdef SINC_STORAGE -spoc_prec_t tmp_sinc[41]; -spoc_prec_t tmp_sinc_2[41]; -spoc_prec_t tmp_sincp[41]; -spoc_prec_t tmp_sincp_2[41]; -#endif - -inline void -spoc_bloc2 (int n, spoc_prec_t pirho) -{ - spoc_prec_t xp = alpha[n]*pirho; - spoc_prec_t xm = xp; - spoc_prec_t s = sin (xp); - int sign = -1; - int k; - - for (k=1; k<=10; k++) - { - xp += M_PI; - xm -= M_PI; - reg_bloc2[k+10][n] = kaiser[k-1] * sign*s/xp; - reg_bloc2[10-k][n] = kaiser[k-1] * sign*s/xm; - sign = -sign; - } -} - -inline void -spoc_update (spoc_prec_t rho) -{ - int k; - spoc_prec_t x; - spoc_prec_t xp; - spoc_prec_t s; - spoc_prec_t pirho; - pirho = M_PI * rho; - - spoc_prec_t abs_rho = rho; - if (abs_rho < 0 ) abs_rho = -abs_rho; - if (abs_rho>=0.01*1e-6) - { - spoc_prec_t spr; - spoc_prec_t cpr; - spoc_prec_t sp; - spoc_prec_t c; - spoc_prec_t zs; - spoc_prec_t den; - spoc_prec_t den0, sin0, sinp0, xp0, x0; - - - spr = sin (pirho); - cpr = cos (pirho); - x0 = x = pirho * Pmin; - xp0 = xp = pirho * Pmax; - //s = sin(x); - sinp0 = sp = sin(xp0); - c = cos(x); - sin0 = zs = sin(x); - den0 = den = (xp - x); - - reg_bloc2[10][0] = sin (alpha[0]*pirho)/(alpha[0]*pirho); - reg_bloc2[10][1] = sin (alpha[1]*pirho)/(alpha[1]*pirho); - reg_bloc2[10][2] = sin (alpha[2]*pirho)/(alpha[2]*pirho); - - //spoc_prec_t tmp1 = zs/x; - //spoc_prec_t tmp2 = x*x; - //reg_a0 = (sp/xp - tmp1)/(xp*xp - tmp2); - //reg_c0 = tmp1 - reg_a0*tmp2; - reg_a0 = (sp/xp - zs/x)/(xp*xp - x*x); - //reg_a0 = rho; - reg_c0 = zs/x - reg_a0*x*x; - - for (k=1; k<=20; k++) - { - x += (M_PI + pirho); - xp += M_PI; - s = -zs * cpr - c * spr; - c = zs * spr - c * cpr; - sp = -sp; - den -= pirho; - - zs = s/x; -#ifdef SINC_STORAGE - tmp_sinc[k+20] = zs; - tmp_sincp[k+20] = sp/xp; -#endif - reg_beta[k+20] = (sp/xp - zs)/den; - reg_alpha[k+20] = zs - reg_beta[k+20]*x; - - zs = s; - } - x = x0; - xp = xp0; - s = sin0; - c = cos(xp); - zs = sinp0; - den = den0; - for (k=1; k<=20; k++) - { - xp -= (M_PI + pirho); - x -= M_PI; - sp = -zs * cpr + c * spr; - c = -zs * spr - c * cpr; - s = -s; - den -= pirho; - - zs = sp/xp; -#ifdef SINC_STORAGE - tmp_sinc[20-k] = s/x; - tmp_sincp[20-k] = zs; -#endif - //printf ("%05.10g-%05.10g=%05.10g\n", zs, s/x, zs - s/x); - reg_beta[20-k] = (zs - s/x)/den; - reg_alpha[20-k] = zs - reg_beta[20-k]*xp; - - zs = sp; - } - } - else - { - reg_bloc2[10][0] = 1-((alpha[0]*pirho)*(alpha[0]*pirho))/6; - reg_bloc2[10][1] = 1-((alpha[1]*pirho)*(alpha[1]*pirho))/6; - reg_bloc2[10][2] = 1-((alpha[2]*pirho)*(alpha[2]*pirho))/6; - reg_a0 = -1.0/6; - reg_c0 = 1; - int sign = 1; - x = 0; - for (k=1; k<=20; k++) - { - x += M_PI; - reg_beta[k+20] = -sign/x; - reg_alpha[k+20] = sign; - reg_beta[20-k] = sign/x; - reg_alpha[20-k] = sign; - sign = -sign; - } - } - /** SPOC BLOC_2 */ - spoc_bloc2 (0, pirho); - spoc_bloc2 (1, pirho); - spoc_bloc2 (2, pirho); - } - -#ifdef COMPARE -void -spoc_update2 (double rho) -{ - int k,i; - double pirho = M_PI*rho; - double x = pirho * Pmin; - double xp = pirho * Pmax; - double s, sp; - double den = (xp - x); - - for (i=0; i<3; i++) - { - double x0 = alpha[i]*pirho; - for (k=-10; k<=10; k++) - { - double kk = 1; - if (k<0) kk = kaiser[-k-1]; - if (k>0) kk = kaiser[k-1]; - reg_bloc2_2[k+10][i] = kk * sin(x0+k*M_PI)/(x0+k*M_PI); - } - } - - double tmp1 = sin (x)/x; - double tmp2 = x*x; - reg_a0_2 = (sin(xp)/xp - tmp1)/(xp*xp - tmp2); - reg_c0_2 = tmp1 - reg_a0_2*tmp2; - - for (k=1; k<=20; k++) - { - x += (M_PI + pirho); - xp += M_PI; - s = sin (x) /x; - sp = sin (xp) /xp; - den -= pirho; -#ifdef SINC_STORAGE - tmp_sinc_2[k+20] = s; - tmp_sincp_2[k+20] = sp; -#endif - reg_beta_2[k+20] = (sp-s)/(den); - reg_alpha_2[k+20] = s - reg_beta_2[k+20]*x; - } - x = pirho * Pmin; - xp = pirho * Pmax; - den = (xp -x); - for (k=1; k<=20; k++) - { - xp -= (M_PI + pirho); - x -= M_PI; - s = sin (x) /x; - sp = sin (xp) /xp; -#ifdef SINC_STORAGE - tmp_sinc_2[20-k] = s; - tmp_sincp_2[20-k] = sp; -#endif - den -= pirho; - reg_beta_2[20-k] = (sp-s)/(den); - reg_alpha_2[20-k] = s - reg_beta_2[20-k]*x; - } -} -#endif - -void -get_error (double a, double b, double *error) -{ - if (a > b) - { - if ((a-b)>*error) *error = (a-b); - } - else - { - if ((b-a)>*error) *error = (b-a); - } -} - -int -main (int argc, char **argv) -{ - struct timeval tv0, tv1; - int test_rho = 0; - int t; - //int regv = sparc_leon3_get_cache_ctrl_reg(); - //printf("cache ctrl reg = 0x%x\n", regv); - - gettimeofday (&tv0, NULL); - gettimeofday (&tv1, NULL); - //printf ("first blk allocation duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec)); - - double error = 0; - - for (test_rho=-30000; test_rho <= 30000; test_rho++) - //for (test_rho=-500; test_rho < 500; test_rho++) - //for (test_rho=22540; test_rho < 22541; test_rho++) - { - double rho = test_rho * 1e-8; - - //gettimeofday (&tv0, NULL); - //for (t=0; t<1; t++) - // sin (rho)/rho; - //gettimeofday (&tv1, NULL); - //printf ("duration first sin : %d\n",(int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); - //get_error (0,0, &error); - //gettimeofday (&tv0, NULL); - //for (t=0; t<1; t++) - spoc_update (rho); - //gettimeofday (&tv1, NULL); - //printf ("duration 1000 spoc1 : %d\n",(int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); - - //rho = 00.0*1e-6; - //gettimeofday (&tv0, NULL); - //for (t=0; t<1; t++) - // spoc_update (rho); - //gettimeofday (&tv1, NULL); - //printf ("duration 1*spoc1 : %d\n",(int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec))); -#ifdef COMPARE - //for (t=0; t<1; t++) - spoc_update2 (rho); - - int k; - for (k=-10; k<=10; k++) - { - //printf ("bloc2[%d] = %05.10g <==> %05.10g, diff=%05.10g\n", k, reg_bloc2[k+10][0], reg_bloc2_2[k+10][0], reg_bloc2[k+10][0] - reg_bloc2_2[k+10][0]); - get_error (reg_bloc2[k+10][0], reg_bloc2_2[k+10][0], &error); - //printf ("bloc2[%d] = %05.10g <==> %05.10g, diff=%05.10g\n", k, reg_bloc2[k+10][1], reg_bloc2_2[k+10][1], reg_bloc2[k+10][1] - reg_bloc2_2[k+10][1]); - get_error (reg_bloc2[k+10][1], reg_bloc2_2[k+10][1], &error); - //printf ("bloc2[%d] = %05.10g <==> %05.10g, diff=%05.10g\n", k, reg_bloc2[k+10][2], reg_bloc2_2[k+10][2], reg_bloc2[k+10][2] - reg_bloc2_2[k+10][2]); - get_error (reg_bloc2[k+10][2], reg_bloc2_2[k+10][2], &error); - } - for (k=-20; k<20; k++) - { - if (k==0) - { - get_error( reg_a0, reg_a0_2, &error); - get_error( reg_c0, reg_c0_2, &error); - //printf ("a0 = %05.10g <==> %05.10g, diff=%05.10g\n", reg_a0, reg_a0_2, reg_a0 - reg_a0_2); - //printf ("c0 = %05.10g <==> %05.10g, diff=%05.10g\n", reg_c0, reg_c0_2, reg_c0 - reg_c0_2); - - } - else - { -#ifdef SINC_STORAGE - printf ("sinc[%d]=%05.10g <==> %05.10g, diff=%05.10g\n", k, tmp_sinc[k+20], tmp_sinc_2[k+20], tmp_sinc[k+20] - tmp_sinc_2[k+20]); - printf ("sincp[%d]=%05.10g <==> %05.10g, diff=%05.10g\n", k, tmp_sincp[k+20], tmp_sincp_2[k+20], tmp_sincp[k+20] - tmp_sincp_2[k+20]); -#endif - get_error (reg_beta[k+20], reg_beta_2[k+20], &error); - //printf ("pente[%d]=%05.10g <==> %05.10g, diff=%05.10g\n", k, reg_beta[k+20], reg_beta_2[k+20], reg_beta[k+20] - reg_beta_2[k+20]); - get_error (reg_alpha[k+20], reg_alpha_2[k+20], &error); - //printf ("ordo[%d]=%05.10g <==> %05.10g, diff=%05.10g\n\n", k, reg_alpha[k+20], reg_alpha_2[k+20], reg_alpha[k+20] - reg_alpha_2[k+20]); - } - - } -#endif - printf ("%d %05.18g %05.18g\n", test_rho, reg_a0, reg_c0); - error = 0; - } - //printf ("worst of worst error = %05.12g\n", error); - - return 0; -} - -- cgit v1.2.3