📄 test_sum.c
字号:
/*************************************************************************** sum_test.c - Testing the summation-module ------------------- begin : 2003 authors : ineiti emails : linus.gasser@epfl.ch ***************************************************************************//*************************************************************************** Changes ------- date - name - description 03/01/20 - ineiti - 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. * * * ***************************************************************************/char desc[] ="Description:\n""Simulates a multi-user environment, where each user has it's own\n""spreading sequence and sends at the same time instant. At the other\n""end of the chain, each user recovers its test-phrase, thanks to\n""the orthogonality of the spreading-sequences.\n""This should output 8 times the test-phrase.\n\n";#include "spc.h"#include "std.h"#include "chain.h"#define DBG_LVL 0#define MAX_SUM 8#define S_LENGTH 8unsigned int sequences[] = { 0xffff, 0xaaaa, 0xcccc, 0x9999, 0xf0f0, 0xa5a5, 0xc3c3, 0x9696, 0xff00, 0xaa55, 0xcc33, 0x9966, 0xf00f, 0xa55a, 0xc33c, 0x9669 };struct chain_t *test_chain, *sum_chain[MAX_SUM], *sink_chain[MAX_SUM];void *start_it( void *arg ) { swr_sdb_id sum, rand[MAX_SUM], mod, despread, spread, sink, block; int i; test_chain = swr_chain_create( NEW_SPC_VAR( "sum_symbol_complex", sum ), NEW_SPC( "midamble" ), NEW_SPC( "rrc" ), NEW_SPC_VAR( "block", block ), NEW_SPC( "matched_filter" ), NEW_SPC_VAR( "despread", despread ), CHAIN_END ); swr_sdb_set_config_int( block, "size", 20000 ); swr_sdb_set_config_double( block, "sigma", 0 ); for ( i=0; i<MAX_SUM; i++ ) { PR_DBG( 4, "Creating sum_chain[%i]\n", i ); sum_chain[i] = swr_chain_create( NEW_SPC_VAR( "rndstr", rand[i] ), NEW_SPC_VAR( "mapper", mod ), NEW_SPC_VAR( "spread", spread ), OLD_SPC_IN( sum, i ), CHAIN_END ); swr_sdb_set_config_int( spread, "factor", S_LENGTH ); swr_sdb_set_config_int( spread, "sequence", sequences[i] ); swr_sdb_set_config_int( mod, "amplitude", 32000 / MAX_SUM ); sink_chain[i] = swr_chain_create( OLD_SPC_OUT( despread, i ), NEW_SPC( "slicer" ), NEW_SPC_VAR( "sink", sink ), CHAIN_END ); swr_sdb_set_config_int_array( despread, "factor00", i, S_LENGTH ); swr_sdb_set_config_int_array( despread, "sequence00", i, sequences[i] ); swr_sdb_set_config_int( sink, "flag", 1 ); } for ( i=0; i<MAX_SUM; i++ ) { PR_DBG( 4, "Sending user-msg to rand[%i]\n", i ); swr_sdb_send_msg( rand[i], SUBS_MSG_USER, NULL, -1 ); } 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 ) { int i; swr_thread_free( &start, NULL ); for ( i=0; i<MAX_SUM; i++ ) { swr_chain_destroy( sum_chain[i] ); swr_chain_destroy( sink_chain[i] ); } 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 + -