📄 test_ldpc2fold.c
字号:
/*************************************************************************** test_ldpc2fold.c - A first test of the 2-fold LDPC code ------------------- begin : 01 Sept 2003 authors : Nicolae Chiurtu emails : Nicolae.Chiurtu@epfl.ch ***************************************************************************//*************************************************************************** Changes ------- date - name - description 01/09/03 - Nicou - Begin 04/03/03 - ineiti - added a short comment **************************************************************************//*************************************************************************** * * * 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. * * * ***************************************************************************/#include "spc.h"#include "std.h"#define DBG_LVL 0char desc[] ="Description:\n""Sets up a chain that represents a 2x2 MIMO system. The H-matrix is\n""[ 1 0.1 ; 0.1 1 ] and the sigma is increased from one example to the\n""next. The first two runs should give 0 errors, while the 3 last runs\n""should show some errors at last.\n\n";struct chain_t *test_chain, *test_chain_2;void *start_it( void *arg ) { swr_sdb_id mid[2],src,block_mimo,rrc[2]; swr_sdb_id split, tsd, rcd, mid_rx[2],encoder,decoder; double a; double a11,a12,a21,a22; int i; block_t ch_est_ant1, ch_est_ant2; SYMBOL_COMPLEX *ch_est_ant1_ptr, *ch_est_ant2_ptr; PR( "Setting up main-chain\n" ); // This chain simulates a simple 2x2 MIMO without LDPC test_chain = swr_chain_create(NEW_SPC_VAR( "random", src ), NEW_SPC_VAR( "test_data_send", tsd), NEW_SPC_VAR( "ldpc_encode_2fold", encoder), NEW_SPC( "mapper"), NEW_SPC_VAR( "split", split ), NEW_SPC_VAR( "chest_send", mid[ 0 ] ), NEW_SPC_VAR( "rrc", rrc[ 0 ] ), NEW_SPC_VAR( "block_mimo", block_mimo), NEW_SPC( "rrc_rcv" ), NEW_SPC_VAR( "chest_rcv", mid_rx[ 0 ] ), NEW_SPC_VAR( "ldpc_decode_2fold", decoder), NEW_SPC_VAR( "test_data_rcv", rcd ), CHAIN_END ); PR( "Setting up second chain\n" ); test_chain_2 = swr_chain_create( OLD_SPC_OUT( split, 1 ), NEW_SPC_VAR( "chest_send", mid[ 1 ] ), NEW_SPC_VAR( "rrc", rrc[ 1 ] ), OLD_SPC_IN_OUT( block_mimo, 1, 1 ), NEW_SPC( "rrc_rcv" ), NEW_SPC_VAR( "chest_rcv", mid_rx[ 1 ] ), OLD_SPC_IN( decoder, 1), CHAIN_END ); for ( i=0; i<2; i++ ){ swr_sdb_set_config_int( mid[ i ], "circ_ext", 0 ); swr_sdb_set_config_int( mid_rx[ i ], "circ_ext", 0 ); } PR( "Chains are set up\n" ); swr_sdb_set_config_int( block_mimo, "size", 2560*4 ); swr_sdb_set_config_int( mid[1], "index", 1 ); swr_sdb_set_config_int( rcd, "mode", 1 ); swr_sdb_set_config_int( decoder, "chest1", mid_rx[0] ); swr_sdb_set_config_int( decoder, "chest2", mid_rx[1] ); swr_sdb_set_config_int( encoder, "ldpc_code_id", 1 ); swr_sdb_set_config_int( decoder, "ldpc_code_id", 1 ); swr_sdb_set_config_int( decoder, "iterations", 12 ); swr_sdb_set_config_int( decoder, "iterations_left", 2 ); swr_sdb_set_config_int( decoder, "iterations_right", 1 ); PR( "Connecting the test_data modules\n" ); swr_conn_add(tsd, 1,rcd, 1); //swr_sdb_set_config_int( snk, "flag", 1 ); //dump PR( "Sending first message\n" ); for (a = 0; a < 5; a ++ ) { swr_sdb_set_config_double( block_mimo, "sigma", 250 + 20 * a ); a11 = 1; a12 = .1; a21 = .1; a22 = 1; PR( "**********************************"); PR( "\nH = [ %g %g ; %g %g ]\n", a11, a12, a21, a22 ); swr_sdb_set_config_double( block_mimo, "a12", a12 ); swr_sdb_set_config_double( block_mimo, "a21", a21 ); swr_sdb_set_config_double( block_mimo, "a11", a11 ); swr_sdb_set_config_double( block_mimo, "a22", a22 ); swr_sdb_set_config_int( mid_rx[0], "num_of_antennas", 2); swr_sdb_set_config_int( mid_rx[1], "num_of_antennas", 2); swr_sdb_send_msg( src, SUBS_MSG_USER, NULL, -1 ); PR( "Total data: %i, Errors: %i\n", swr_sdb_get_stats_int( rcd, "total" ), swr_sdb_get_stats_int( rcd, "error" ) ); ch_est_ant1 = swr_sdb_get_stats_block( mid_rx[0], "channel" ); ch_est_ant2 = swr_sdb_get_stats_block( mid_rx[1], "channel" ); ch_est_ant1_ptr = ch_est_ant1.data; ch_est_ant2_ptr = ch_est_ant2.data; PR("Noise Variance ant 1 = [%i], ant 2 = [%i] \n", swr_sdb_get_stats_int( mid_rx[0], "noise_var"), swr_sdb_get_stats_int( mid_rx[1], "noise_var")); } // swr_chain_destroy( test_chain ); 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_2 ); 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 + -