📄 mapper.c
字号:
/*****************************************************************************//* FIle Name : mapper.c *//* Description : WiMax OFDM Subcarrier modulation mapper for Encoder *//* author : miffie *//* Date : oct/31/05 *//* Copyright (c) 2005 miffie All rights reserved. *//*****************************************************************************/char pilot_bool( char sc ) { //pilot_bool//if sc == one of pilots return one,//otherwise return zero ;static pilot_sc[] = { -88, -63, -38, -13, 13, 38, 63, 88 } ;char ii , bool; bool=0 ; for(ii=0;ii<8;ii++) { if(sc==pilot_sc[ii]) bool = 1 ; } return(bool) ;} //boolstruct complexset mapper (struct binaryset datain, char Nbpsc, char index, short *pilot_shifter ) {int ii , pp ;char shifter ;char tmp1 ;char wk ;struct complexset cset ;struct complex *top ;char *p ;static char bpsk_map[] = {1, -1 } ;static char qpsk_map[] = {1, -1 } ;static char qam16_map[] = {1, 3, -1, -3 } ; //Gray codedstatic char qam64_map[] = {3, 1, 5, 7, -3, -1, -5, -7 } ; //Gray codedstatic double Kmod_bpsk = 1 ; static double Kmod_qpsk = 0.70710678 ; //1/(sqrt (2)) ; static double Kmod_qam16 = 0.31622777 ;static double Kmod_qam64 = 0.15430335 ;char mask[256] ; //Main if ((top = (struct complex *)malloc(256*sizeof(struct complex)) ) == NULL) { PRINTF( " malloc failed in mapper.c\n") ; } //fail else { //allocated //OFDM randomizer wk = *pilot_shifter & 0x1 ; *pilot_shifter = pilot_randomizer( *pilot_shifter ) ; PRINTF("mapper size=%d index=%x wk=%d\n", datain.size, index, wk ) ; //mask mask_sc(&mask[0], index ) ; p= datain.data ; //process each subcarrier for(ii=-128;ii<128;ii++) { //each subcarrier if ((mask[ii+128])&(pilot_bool(ii))) { //pilot //pilot subcarriers if ((ii==-63)|(ii==-13)|(ii==13)|(ii==38)) { //DL //if ((ii==-63)|(ii==-13)) { //UL top[ii+128].realp = (wk) ? 1 : -1 ; top[ii+128].image = 0 ; } else { // top[ii+128 ].realp = (wk) ? -1 : 1 ; top[ii+128 ].image = 0 ; } // } //pilot else if(mask[ii+128]) { //enabled switch ( Nbpsc ) { //switch case 1: { //BPSK tmp1 = (*p++) ; top[ii+128].realp = bpsk_map[ tmp1 ] * Kmod_bpsk; top[ii+128].image = 0 ; break ; } //BPSK case 2: { //QPSK tmp1 = (*p++) ; top[ii+128].realp = qpsk_map[ tmp1 ] * Kmod_qpsk; tmp1 = (*p++) ; top[ii+128].image = qpsk_map[ tmp1 ] * Kmod_qpsk; break ; } //QPSK case 4: { //16QAM tmp1 = (*p++<<1) ; tmp1 += (*p++) ; //printf("subcarrier (%d) %d ", ii, tmp1 ) ; top[ii+128].realp = qam16_map[ tmp1 ] * Kmod_qam16 ; tmp1 = (*p++<<1) ; tmp1 += (*p++) ; //printf(" %d\n", tmp1 ) ; top[ii+128].image = qam16_map[ tmp1 ] * Kmod_qam16 ; break ; } //16QAM default: { //64QAM tmp1 = (*p++<<2) ; tmp1 += (*p++<<1) ; tmp1 += (*p++) ; top[ii+128].realp = qam64_map[ tmp1 ] * Kmod_qam64 ; tmp1 = (*p++<<2) ; tmp1 += (*p++<<1) ; tmp1 += (*p++) ; top[ii+128].image = qam64_map[ tmp1 ] * Kmod_qam64 ; break ; } //64QAM }//switch }//enabled else { //masked top[ii+128].realp = 0 ; top[ii+128].image = 0 ; } //masked } //each subcarrier }//allocated cset.size = 256 ; cset.data = top ; free( datain.data ) ; return ( cset ) ;} //mapper
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -