📄 test_ldpc.c
字号:
/*************************************************************************** test_ldpc.c - a first LDPC test ------------------- begin : 2003 authors : Nicolae Chiurtu emails : nicolae.chiurtu@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""Makes up a small chain containing an LDPC-encoder and decoder, complete\n""with channel estimation and all. The output is supposed to give the\n""time spent for different LDPC-codes, as well as the well-known test-phrase.\n""A code 0.25, 0.5 and 0.75 respectiveley are used.\n\n";#include "spc.h"#include "std.h"#include "chain.h"#define DBG_LVL 4#define BYPASS 0struct chain_t *test_chain;void *start_it( void *arg ) { int i; swr_sdb_id rand, encode, mod, decode, sink, block, mafi_id;#if BYPASS swr_sdb_id demod;#endif test_chain = swr_chain_create( NEW_SPC_VAR( "source", rand ),#if !BYPASS NEW_SPC_VAR( "ldpc_encode", encode),#endif NEW_SPC_VAR( "mapper", mod ), NEW_SPC( "midamble" ), NEW_SPC( "rrc" ), NEW_SPC_VAR( "block", block ), NEW_SPC_VAR( "matched_filter", mafi_id ),#if BYPASS NEW_SPC_VAR( "slicer", demod ),#else NEW_SPC_VAR( "ldpc_decode", decode),#endif NEW_SPC_VAR( "sink", sink ), CHAIN_END ); // Initialise input-size of the sink. Necessary because we don't // have a STFA swr_sdb_set_config_int( sink, "flag", 1 ); swr_sdb_set_config_int( block, "size", 2560 * 4 ); swr_sdb_set_config_double( block, "sigma", 450 );#if 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( decode, "iterations", 30 ); 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 ); swr_sdb_send_msg( rand, SUBS_MSG_USER, NULL, -1 ); PR( "Encountered SNR is: %g\n", swr_sdb_get_stats_double( mafi_id, "snr" ) ); swr_sdb_show_profile( encode ); swr_sdb_show_profile( decode ); swr_sdb_clear_profile( encode ); swr_sdb_clear_profile( decode ); } // 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 + -