⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_convolution.c

📁 This a framework to test new ideas in transmission technology. Actual development is a LDPC-coder in
💻 C
字号:
/***************************************************************************              test_convolution.c  -  Module for testing convolutional coding                            -------------------    begin                :  03/12/10    authors              :  Roman Hofer    emails               :  roman.hofer@epfl.ch ***************************************************************************//***************************************************************************                                 Changes                                 ------- date - name - description 04/03/03 - ineiti - added a 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 test for the convolutional Code.\n""It uses a random source, an encoder, a very simple channel simulation\n""which introduces biterrors, a decoder and a sink.\n""You should see errors appearing at a BER of around 0.05\n\n";#include "spc.h"#include "std.h"#define DBG_LVL 4struct chain_t *test_chain;// also nice (n,k,m)=(7,5,8) and REG_STATUS polys[] = {0x3f,0xad,0x06,0xf1,0x7a,0xa5,0x49};// also nice (n,k,m)=(2,1,4) REG_STATUS polys[] = {0x0f,0x0d};// also nice (n,k,m)=(4,2,4) REG_STATUS polys[] = {0x0f,0x0d,0x08,0x03};int cfg_n=2;int cfg_k=1;int cfg_m=8;int cfg_trunclength=100;int cfg_truncblock=50;unsigned int polys[] = {0x37,0x73};double ber;void *start_it( void *arg ) {  int data_bits = 512*8;  swr_sdb_id rnd, conv_send, biterror, conv_rcv, test_send, test_rcv;  test_chain = swr_chain_create(NEW_SPC_VAR( "random", rnd ),                                NEW_SPC_VAR( "test_data_send", test_send ),                                NEW_SPC_VAR( "convolution_send", conv_send ),                                NEW_SPC_VAR( "biterror", biterror ),                                NEW_SPC_VAR( "convolution_rcv", conv_rcv ),                                NEW_SPC_VAR( "test_data_rcv", test_rcv ),                                CHAIN_END );  swr_conn_add( test_send, 1,                test_rcv, 1 );  // Clear the error counter each time  swr_sdb_set_config_int( test_rcv, "mode", 1 );  //Configure size of the test_data_rcv  swr_sdb_set_config_int( test_rcv, "size", data_bits / 8 );  PR_DBG( 3, "Starting\n" );  //Configure source  swr_sdb_set_config_int( rnd, "seed", 0x1234 );  //Configure encoder  swr_sdb_set_config_int( conv_send, "cfg_n", cfg_n );  swr_sdb_set_config_int( conv_send, "cfg_k", cfg_k );  swr_sdb_set_config_int( conv_send, "cfg_m", cfg_m );  swr_sdb_set_config_pointer( conv_send, "cfg_polys", polys );  //Configure decoder  swr_sdb_set_config_int( conv_rcv, "cfg_n", cfg_n );  swr_sdb_set_config_int( conv_rcv, "cfg_k", cfg_k );  swr_sdb_set_config_int( conv_rcv, "cfg_m", cfg_m );  swr_sdb_set_config_int( conv_rcv, "cfg_trunclength", cfg_trunclength );  swr_sdb_set_config_int( conv_rcv, "cfg_truncblock", cfg_truncblock );  swr_sdb_set_config_pointer( conv_rcv, "cfg_polys", polys );	//polynomes, must  for ( ber = 0; ber <= 0.1; ber += 0.01 ) {    //Configure channel    swr_sdb_set_config_double( biterror, "ber", ber );	//errorbrob 2%    //Now activate the conv_send module    call_module( rnd );    PR( "BER: %g, Errors: %g\n", ber,        ((double)swr_sdb_get_stats_int( test_rcv, "error" )) / data_bits );  }  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 + -