⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_ldpc_count_error.c

📁 This a framework to test new ideas in transmission technology. Actual development is a LDPC-coder in
💻 C
字号:
/***************************************************************************              test_ldpc_count_error.c  -  Uses TestData to count the errors                            -------------------    begin                :  2003    authors              :  Linus Gasser    emails               :  linus.gasser@epfl.ch ***************************************************************************//***************************************************************************                                 Changes                                 ------- date - name - description 04/03/03 - ineiti - added a short description  **************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************/char desc[] ="Description:\n""This is a SISO ldpc-chain, that sends a random sequence using three\n""different codes: a rate 0.25, 0.5 and 0.75 respectively. For each of\n""these codes, the number of bits, errors and SNR are printed 4 times.\n""The SNRs should be comparable from one rate to the next, so it should\n""show that a rate 0.25 code achieves better results at lower SNRs\n""than a rate 0.75.\n\n";/** * This is a module to write a test for some sort of SPC. Usually * you just create one or two chains in here, and they will be * tested afterwards. */#include "spc.h"#include "std.h"#include "chain.h"#define DBG_LVL 4#define BYPASS_struct chain_t *test_chain;void *start_it( void *arg ) {  int i, sigma;  swr_sdb_id rand, encode, mod, decode, block, send_data, received_data, mafi_id, midamble;#ifdef BYPASS  swr_sdb_id demod;#endif  test_chain = swr_chain_create(                 NEW_SPC_VAR( "random", rand ),                 NEW_SPC_VAR( "test_data_send", send_data ),#ifndef BYPASS                 NEW_SPC_VAR( "ldpc_encode", encode),#endif                 NEW_SPC_VAR( "mapper", mod ),                 NEW_SPC_VAR( "midamble", midamble ),                 NEW_SPC( "rrc" ),                 NEW_SPC_VAR( "block", block ),                 NEW_SPC_VAR( "matched_filter", mafi_id ),#ifdef BYPASS                 NEW_SPC_VAR( "slicer", demod ),#else                 NEW_SPC_VAR( "ldpc_decode", decode),#endif                 NEW_SPC_VAR( "test_data_rcv", received_data ),                 CHAIN_END );  // Initialise input-size of the sink. Necessary because we don't  // have a STFA  // swr_sdb_set_config_int( block, "size", 2560 * 4 );  swr_conn_add(send_data, 1, received_data, 1);#ifdef BYPASS  PR( "Bypassing, just to show how it works w/o LDPC\n" );  swr_sdb_send_msg( rand, SUBS_MSG_USER, NULL, -1 );  return 0;#endif  swr_sdb_set_config_int( midamble, "amplitude", 16384 );  // divide by sqrt(2) because the qpsk is in the corners...  swr_sdb_set_config_int( mod, "amplitude", 16384 / 1.414 );  swr_sdb_set_config_int( decode, "iterations", 100 );  swr_sdb_set_config_int( decode, "channel_type", 2 );  // Here we take the channel_param from mafi. I.e.  a/variance  // is not 1/15 but computed in ldpc_decode with the values taken from midamble_rcv  swr_sdb_set_config_int( decode, "mafi", mafi_id );  for ( i=1; i<=3; i++ ) {    swr_sdb_set_config_int( encode, "ldpc_code_id", i );    swr_sdb_set_config_int( decode, "ldpc_code_id", i );    // Tell the random-module to produce a block of random-data which will    // be propagated to the encode and decode module and finish in the sink.    PR( "Sending with code %i\n", i );    for ( sigma=100; sigma <= 400; sigma += 100 ) {      swr_sdb_set_config_double( block, "sigma", sigma );      swr_sdb_set_config_int( received_data, "clear", 1 );      swr_sdb_send_msg( rand, SUBS_MSG_USER, NULL, -1 );      PR( "Transmitted %i bits and got %i errors with SNR =%g\n",          swr_sdb_get_stats_int( received_data, "total" ),          swr_sdb_get_stats_int( received_data, "error" ),          swr_sdb_get_stats_double(mafi_id, "snr") );    }  }  // After this call, the chain has been walked through  usleep( 1000000 );  return 0;}swr_spc_id_t spm_id;struct thread start;/** * This function is called upon "insmod" and is used to register the * different parts of the module to the SPM. */int um_module_init(void) {  PR_CL( desc );  test_chain = NULL;  if ( swr_thread_init( &start, start_it, NULL ) < 0 )    goto first_no_stack;  return 0;first_no_stack:  PR_DBG( 0, "Couldn't allocate stack\n" );  return -1;}void um_module_exit( void ) {  swr_thread_free( &start, NULL );  swr_chain_destroy( test_chain );}module_init( um_module_init );module_exit( um_module_exit );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -