📄 rake_supp.c
字号:
break; } /* if */ } /* for j */ } /* if fingers[i].status */ } /* for i */ } /* if stable_taps */ } else { /* * First activation, no earlier finger allocation. * If channel response is shorter than amount of fingers * to use, allocate only 'channel_len' fingers. */ if (channel_len < nFingers) nFingers = channel_len; for (i=0; i < nFingers; i++) { fingers[i].status = 0; fingers[i].delay = channel_delays[ candidates[i] ]; fingers[i].amplitude = channel_amplitudes[ candidates[i] ]; fingers[i].weight = 1.0; fingers[i].fill_index = 0; fingers[i].combine_index = 0; fingers[i].nOutputs = 0; } /* for i */ init_flag = FALSE; } /* * Search minimum and maximum of tap delays. */ misc_data->min_delay = MAX_MULTIPATH_DELAY; misc_data->max_delay = 0; for (i=0; i < nFingers; i++) { if (fingers[i].delay > misc_data->max_delay) misc_data->max_delay = fingers[i].delay; if (fingers[i].delay < misc_data->min_delay) misc_data->min_delay = fingers[i].delay; } /* for */ return;} /* wcdma_rake_finger_alloc *//* -------------------------------------------------------------------- *//* * Function: wcdma_rake_symbol_direct * Desc.: Despreads all direct input samples for one finger. * * Note: * All the available symbols are despreaded for a finger. * Due to the previous sentence, there may be different * amount of output symbols for combining. */int wcdma_rake_symbol_direct( int finger_id, /* IN: id number of current finger */ double input[], /* IN: input received samples */ int in_len, /* IN: length of input vector */ int code[], /* IN: spreading code */ int code_len, /* IN: length of spreading code */ finger_type *finger, /* IN/OUT: vector of finger data structures */ mem_chips_t *prev_samples) /* IN: old saved samples */{ int offset = finger->delay; /* * nSamples lasketaan vaarin. Jos delay on suurempi kuin symboli, * niin pitaa ottaa viive huomioon. */ int nSamples = in_len - (in_len % code_len); int add_index = finger->fill_index; int nSymbols = nSamples / code_len; int bufLength = FINGER_OUT_BUFFER; wcdma_soft_despread(input, nSamples, code, code_len, code_len, &(finger->output[0]), add_index, bufLength); /* * Advance fill index and output count for finger output ring buffer. */ add_index = (add_index + nSymbols) % bufLength; finger->fill_index = add_index; finger->nOutputs += nSymbols; return(0);} /* wcdma_rake_symbol_direct *//* -------------------------------------------------------------------- *//* * Function: wcdma_rake_symbol_delayed * Desc.: Despreads old samples in memory for one finger. * * Note: */int wcdma_rake_symbol_delayed( int finger_id, /* IN: id number of current finger */ double input[], /* IN: input received samples */ int in_len, /* IN: length of input vector */ int code[], /* IN: spreading code */ int code_len, /* IN: length of spreading code */ finger_type *finger, /* IN/OUT: vector of finger data structures */ mem_chips_t *prev_samples) /* IN: old saved samples */{ int nOldChips, nNewChips; double old_data_block[MAX_SPREADING_FACTOR]; int add_index = finger->fill_index; int nSymbols = 1; int bufLength = FINGER_OUT_BUFFER; /* * Calculate amount of old and new chips to despread. * Sum of old and new chips is one symbol. * If there are no old chips (code aligns with input data), * don't do anything. */ nOldChips = finger->old_chips; nNewChips = code_len - nOldChips; if (nOldChips == 0) return(0); memcpy(old_data_block, &(prev_samples->chips[(code_len - nOldChips)]), nOldChips * sizeof(double) ); memcpy(old_data_block+nOldChips, input, nNewChips * sizeof(double) ); wcdma_soft_despread(old_data_block, code_len, code, code_len, code_len, &(finger->output[0]), add_index, bufLength); /* * Advance fill index and output count for finger output ring buffer. */ add_index = (add_index + nSymbols) % bufLength; finger->fill_index = add_index; finger->nOutputs += nSymbols; return(0);} /* wcdma_rake_symbol_delayed *//* -------------------------------------------------------------------- *//* * Function: wcdma_rake_finger_memory_save * Desc.: Saves input samples for all fingers to one memory. * * Note: * The amount of samples to save is exactly one symbol * (length of spreading code); */int wcdma_rake_finger_memory_save( double input[], /* IN: input received samples */ int in_len, /* IN: input length */ int code_len, /* IN: spreading code length */ mem_chips_t *prev_samples) /* IN/OUT: old saved samples */{ memcpy(prev_samples->chips, &(input[in_len-code_len]), code_len * sizeof(double) ); return(0);} /* wcdma_rake_finger_memory_save *//* -------------------------------------------------------------------- *//* * Function: wcdma_rake_fingers_combine * Desc.: Saves input samples for all fingers to one memory. * * Note: */int wcdma_rake_fingers_combine( finger_type *fingers, /* IN: vector of finger data */ int nFingers, /* IN: number of fingers to combine */ double output[], /* OUT: output symbols */ int *nOutputs) /* OUT: length of output vector */{ int i, minSymbols, j, k, buf_length; double r_tmp; /* * Search number of symbols ready in all fingers. */ minSymbols = FINGER_OUT_BUFFER; for (i=0; i < nFingers; i++) { if (fingers[i].nOutputs < minSymbols) minSymbols = fingers[i].nOutputs; } /* for nFingers */ /* * Combine symbols. * Combine results only from the fingers on which tap amplitude * is above FINGER_ALLOC_THRESHOLD level. */ buf_length = FINGER_OUT_BUFFER; for (i=0; i < minSymbols; i++) { r_tmp = 0; for (j=0; j < nFingers; j++) { k = fingers[j].combine_index; if (fingers[j].amplitude > FINGER_ALLOC_THRESHOLD) { r_tmp += fingers[j].weight * /* optinal weight */ fingers[j].amplitude * /* relative amplitude (0-1) */ fingers[j].output[k]; /* despreaded finger output */ } fingers[j].combine_index = (fingers[j].combine_index + 1) % buf_length; } /* for nFingers */ output[i] = r_tmp; } /* for minSymbols */ /* * Correct amount of finger outputs in fingers. */ for (j=0; j < nFingers; j++) { fingers[j].nOutputs -= minSymbols; } /* for nFingers */ *nOutputs = minSymbols; return(0);} /* wcdma_rake_fingers_combine *//* -------------------------------------------------------------------- */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -