📄 test_mapper.c
字号:
/*************************************************************************** test_modulator.c - Module for testing the mapper ------------------- begin : 2003-02 authors : Linus Gasser emails : ineiti ***************************************************************************//*************************************************************************** Changes ------- date - name - description 03/02/26 - ineiti - begin 03/10/10 - proud - added n-ary mappers and slicers 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 simulation of the mapper and slicer used in the software-radio.\n""Different configurations are tested: {2,4,8,16}-{QAM,PSK} with both\n""automatic gain adjustement of the slicer or with help from the channel-\n""estimation module. Every time, the result should be the test-phrase.\n\n";#include "spc.h"#include "std.h"#define DBG_LVL 0struct chain_t *test_chain;void *start_it( void *arg ) { swr_sdb_id source, block, sink, slicer, mapper, mafi;#if 1 test_chain = swr_chain_create( NEW_SPC_VAR( "source", source ), NEW_SPC( "mapper" ), NEW_SPC( "slicer" ), NEW_SPC_VAR( "sink", sink ), CHAIN_END ); PR( "Setting block-size to 10000\n" ); swr_sdb_set_config_int( sink, "flag", 1 ); swr_sdb_set_config_int( sink, "size", 100 ); PR( "Sending throught the small chain\n" ); swr_sdb_send_msg( source, SUBS_MSG_USER, NULL, -1 );#endif #if 1 if ( test_chain ){ swr_chain_destroy( test_chain ); } PR( "Making 2nd chain\n" ); test_chain = swr_chain_create( NEW_SPC_VAR( "source", source ), NEW_SPC( "mapper" ), NEW_SPC( "midamble" ), NEW_SPC( "rrc" ), NEW_SPC_VAR( "block", block ), NEW_SPC( "matched_filter" ), NEW_SPC( "slicer" ), NEW_SPC_VAR( "sink", sink ), CHAIN_END ); PR( "Setting block-size to 10000\n" ); swr_sdb_set_config_int( block, "size", 10000 ); PR( "Setting flag of sink to 1\n" ); swr_sdb_set_config_int( sink, "flag", 1 ); PR( "Sending through the complete chain\n" ); swr_sdb_send_msg( source, SUBS_MSG_USER, NULL, -1 );#endif #if 1 if ( test_chain ){ swr_chain_destroy( test_chain ); } PR( "Making 3rd chain\n" ); test_chain = swr_chain_create( NEW_SPC_VAR( "source", source ), NEW_SPC_VAR( "mapper", mapper ), NEW_SPC( "midamble" ), NEW_SPC( "rrc" ), NEW_SPC_VAR( "block", block ), NEW_SPC_VAR( "matched_filter",mafi ), NEW_SPC_VAR( "slicer",slicer ), NEW_SPC_VAR( "sink", sink ), CHAIN_END ); PR( "Setting block-size to 10000\n" ); swr_sdb_set_config_int( block, "size", 10000 ); swr_sdb_set_config_double( block, "sigma", 10 ); PR( "Setting flag of sink to 1\n" ); swr_sdb_set_config_int( sink, "flag", 1 ); PR( "\nSetting bit-per-symbol to 4\n" ); swr_sdb_set_config_int( mapper, "bits_per_symbol", 4); swr_sdb_set_config_int( slicer, "bits_per_symbol", 4); PR( "Setting symbol-type to PAM\n" ); swr_sdb_set_config_int( mapper, "symbol_type", 1); swr_sdb_set_config_int( slicer, "symbol_type", 1); PR( "Sending through the complete chain\n" ); swr_sdb_send_msg( source, SUBS_MSG_USER, NULL, -1 ); PR( "Setting bit-per-symbol to 3\n" ); swr_sdb_set_config_int( mapper, "bits_per_symbol", 3); swr_sdb_set_config_int( slicer, "bits_per_symbol", 3); swr_sdb_send_msg( source, SUBS_MSG_USER, NULL, -1 ); PR( "Setting bit-per-symbol to 2\n" ); swr_sdb_set_config_int( mapper, "bits_per_symbol", 2); swr_sdb_set_config_int( slicer, "bits_per_symbol", 2); swr_sdb_send_msg( source, SUBS_MSG_USER, NULL, -1 ); PR( "Setting bit-per-symbol to 1\n" ); swr_sdb_set_config_int( mapper, "bits_per_symbol", 1); swr_sdb_set_config_int( slicer, "bits_per_symbol", 1); swr_sdb_send_msg( source, SUBS_MSG_USER, NULL, -1 ); PR( "Setting bit-per-symbol to 2\n" ); swr_sdb_set_config_int( mapper, "bits_per_symbol", 2); swr_sdb_set_config_int( slicer, "bits_per_symbol", 2); swr_sdb_send_msg( source, SUBS_MSG_USER, NULL, -1 ); PR( "Setting bit-per-symbol to 3\n" ); swr_sdb_set_config_int( mapper, "bits_per_symbol", 3); swr_sdb_set_config_int( slicer, "bits_per_symbol", 3); swr_sdb_send_msg( source, SUBS_MSG_USER, NULL, -1 ); #endif#if 1 if ( test_chain ){ swr_chain_destroy( test_chain ); } PR( "Making 4th chain\n" ); test_chain = swr_chain_create( NEW_SPC_VAR( "source", source ), NEW_SPC_VAR( "mapper", mapper ), NEW_SPC( "midamble" ), NEW_SPC( "rrc" ), NEW_SPC_VAR( "block", block ), NEW_SPC_VAR( "matched_filter",mafi ), NEW_SPC_VAR( "slicer",slicer ), NEW_SPC_VAR( "sink", sink ), CHAIN_END ); PR( "Setting block-size to 10000\n" ); swr_sdb_set_config_int( block, "size", 10000 ); swr_sdb_set_config_double( block, "sigma", 10 ); PR( "Setting flag of sink to 1\n" ); swr_sdb_set_config_int( sink, "flag", 1 ); PR( "Setting symbol-type to PAM\n" ); swr_sdb_set_config_int( mapper, "symbol_type", 1); swr_sdb_set_config_int( slicer, "symbol_type", 1); PR( "Setting bit-per-symbol to 4\n" ); swr_sdb_set_config_int( mapper, "bits_per_symbol", 2); swr_sdb_set_config_int( slicer, "bits_per_symbol", 2 ); PR("Setting mafi_id to -1(don't use signal amplitude from mafi) \n"); swr_sdb_set_config_int(slicer, "mafi_id", -1); PR( "Sending through the complete chain\n" ); swr_sdb_send_msg( source, SUBS_MSG_USER, NULL, -1 ); PR("Setting mafi_id to %d (use signal amplitude from mafi) \n",mafi); swr_sdb_set_config_int(slicer, "mafi_id", mafi); PR( "Sending through the complete chain\n" ); swr_sdb_send_msg( source, SUBS_MSG_USER, NULL, -1 ); PR("Setting mafi_id to -1(don't use signal amplitude from mafi) \n"); swr_sdb_set_config_int(slicer, "mafi_id", -1); swr_sdb_send_msg( source, SUBS_MSG_USER, NULL, -1 ); PR( "Setting bit-per-symbol to 3\n" ); swr_sdb_set_config_int( mapper, "bits_per_symbol", 3); swr_sdb_set_config_int( slicer, "bits_per_symbol", 3); PR( "Sending through the complete chain\n" ); swr_sdb_send_msg( source, SUBS_MSG_USER, NULL, -1 );#endif 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 + -