📄 test_realhmimo.c
字号:
/*************************************************************************** test_realHmimo.c - tests the ChEst in a mimo-environment ------------------- begin : 17 Jul 2003 authors : Selvavinayagam Gunabalan emails : Selvavinayagam.Gunabalan@epfl.ch ***************************************************************************//*************************************************************************** Changes ------- date - name - description 17/08/03 - Selva - Begin 04/03/03 - ineiti - added a small 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 a small chain for simulating a 2x2 MIMO-system. It then outputs\n""the estimated channel-coefficients of the 4 channels. As there are only\n""2x2 antennas, and the H-matrix is the identity matrix, only channel 1 and 2\n""have non-zero elements, and only on the diagonals. The amplitude of the\n""channel should be around 2048\n\n";#include "spc.h"#include "std.h"#define DBG_LVL 0struct 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, join, tsd, rcd, mid_rx[2]; int i; double a; 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( "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( "join", join ), NEW_SPC( "slicer" ), 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( join, 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 ); } swr_conn_add(tsd, 1,rcd, 1); PR( "Chains are set up\n" ); swr_sdb_set_config_double( block_mimo, "sigma", 0 ); 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 ); PR( "Sending first message\n" ); for (a = 0; a < 1; a += 1 ) { PR( "**********************************"); PR( "\nH = [ %g %g ; %g %g ]\n", a, 1-a, 1-a, a ); // Setting up the block swr_sdb_set_config_double( block_mimo, "a12", 1 - a ); swr_sdb_set_config_double( block_mimo, "a21", 1 - a ); swr_sdb_set_config_double( block_mimo, "a11", a ); swr_sdb_set_config_double( block_mimo, "a22", a ); swr_sdb_set_config_int( mid_rx[0], "num_of_antennas", 2); swr_sdb_set_config_int( mid_rx[1], "num_of_antennas", 2); // Sending a message to make things go swr_sdb_send_msg( src, SUBS_MSG_USER, NULL, -1 ); // Getting the channel and displaying it 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; for ( i = 0; i < 4 ; i++) { PR( "Channel %i has coefficients:\n", i ); PR( "Antenna 1: h(0) = ( %i + %ii ), h(1) = ( %i + %ii )\n", ch_est_ant1_ptr[16*i].real, ch_est_ant1_ptr[16*i].imag, ch_est_ant1_ptr[16*i+1].real, ch_est_ant1_ptr[16*i+1].imag); PR( "Antenna 2: h(0) = ( %i + %ii ), h(1) = ( %i + %ii )\n", ch_est_ant2_ptr[16*i].real, ch_est_ant2_ptr[16*i].imag, ch_est_ant2_ptr[16*i+1].real, ch_est_ant2_ptr[16*i+1].imag); } PR("Noise Variance ant 1 = [%i], ant 2 = [%i] ", swr_sdb_get_stats_int( mid_rx[0], "noise_var"), swr_sdb_get_stats_int( mid_rx[1], "noise_var")); } 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 + -