jkfade

Capsim Block Documentation

Short Description

This star models multipath fading channels for mobile radio applications.

Top
Input Connections
Port Type Name
0 float inPhaseIn
1 float quadPhaseIn
Top
Output Connections
Port Type Name
0 float inPhase
1 float quadPhase
Top
Parameters
Num Description Type Name Default Value
0 Number of points (preferably a power of 2) int npts 128
1 Doppler Spectrum, only Ez supported at this time. int type 0
2 Sampling Rate float fs 1.0
3 Carrier frequency float fc 1000e6
4 Vehicle Velocity, m/s float v 0
5 Power float p 1.0
6 Array of multipath delays microsec: number_of_paths t0 t1 ... array delays
7 Array of multipath powers: number_of_paths p0 p1 ... array powers
8 Number of Plane Waves arriving plane waves, N where N >=34 int numberArrivals 40
Top
States
Num Type Name Initial Value Description
0 int inbufs
1 int fftl
2 int fftexp
3 cap_fft_cpx* fftBuffer_P
4 cap_fft_cpx* inputBuffer_P
5 cap_fft_cfg cfg
6 cap_fft_cfg cfginv
7 cap_fft_cpx* outputBuffer_P
8 int inSampleCount
9 int samplesOutput
10 float wd
Top

Declarations


 

        int numberOfSamples;
        int i,j;
        float fd, lambda;
        double er,ei;
        float arg;
        float t;
        float env;
        float tsin,tcos;
        int     samples;
        float norm;



Top

Initialization Code



 

        inbufs = NO_INPUT_BUFFERS();
        /*
         * extract the exponent in npts=2**fftexp
         */
        fftexp = (int) (log((float)npts)/log(2.0)+0.5);
        fftl = 1 << fftexp;
        if (fftl > npts ) {
                    fftl = fftl/2;
                    fftexp -= 1;
        }
fprintf(stdout,"JKFADECAP_FFT:npts=%d fftl=%d\n",npts,fftl);
        cfg=cap_fft_alloc(fftl,0,NULL,NULL);
        cfginv=cap_fft_alloc(fftl,1,NULL,NULL);

        if (n_delays == 0 )
        {
                fprintf(stderr,"jkfade: number of delays must be >= 1 \n");
                return(1);
        }
        if (n_delays != n_powers)
        {
                fprintf(stderr,"jkfade: number of delays dont match powers \n");
                return(2);
        }
        if ((fftBuffer_P = (cap_fft_cpx*)calloc(fftl,sizeof(cap_fft_cpx))) == NULL)
        {
                fprintf(stderr,"jkfade: can't allocate work space \n");
                return(3);
        }
        if ((inputBuffer_P = (cap_fft_cpx*)calloc(fftl,sizeof(cap_fft_cpx))) == NULL)
        {
                fprintf(stderr,"jkfade: can't allocate work space \n");
                return(4);
        }
        if ((outputBuffer_P = (cap_fft_cpx*)calloc(fftl,sizeof(cap_fft_cpx))) == NULL)
        {
                fprintf(stderr,"jkfade: can't allocate work space \n");
                return(5);
        }
        /*
         * calculate maximum doppler shift
         */
        lambda= 3.e8/fc;
        fd= v/lambda;
        wd=2*PI*fd;
        inSampleCount=0;
        samplesOutput=0;




Top

Main Code



 

/*
 * input the samples. Collect fftl number of samples before processing
 */
for (numberOfSamples = MIN_AVAIL(); numberOfSamples > 0; --numberOfSamples) {

      IT_IN(0);
      IT_IN(1);
      /*
       * store samples in inputBuffer_P
       */
      inputBuffer_P[inSampleCount].r = inPhaseIn(0);
      inputBuffer_P[inSampleCount].i = quadPhaseIn(0);
      /*
       * keep track of the number of samples inputted up this point
       */
      inSampleCount++;
#if 1
      if(inSampleCount == fftl) {
        /*
         * fftl number of samples collected.
         * Compute fading channel amplitude.
         * Compute n_delays, the number of multipaths,  independent amplitudes.
         * This is done by changing the phase by an offset. See Jakes(1974).
         */
        for(j=0; j< n_delays; j++) {
           for(samples=0; samples < inSampleCount; samples++) {
              t=(float)samples/fs;
              /*
               * Compute complex mobile fading channel amplitude
               */
              er=0.0;
              ei=0.0;
              for(i=0; i
    
Top

Wrapup Code



 

        /*
         * free up allocated space
         */
        free((cap_fft_cpx*)fftBuffer_P);
        free((cap_fft_cpx*)inputBuffer_P);
        free((cap_fft_cpx*)outputBuffer_P);




Top

License



/*  Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks)
    Copyright (C) 1989-2017  Silicon DSP Corporation

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    http://www.silicondsp.com
    Silicon DSP  Corporation
    Las Vegas, Nevada
*/


Top

Description



 

/* jkfade.s */
/***********************************************************************
                             jkfade()
************************************************************************
This star models multipath fading channels for mobile radio
applications.
The star accepts a complex baseband equivalent input and produces
complex baseband equivalent samples.
The method is based on William C. Jakes, "Microwave Mobile Communications,"
John Wiley & Sons, 1974 in particular pp. 13-65.
Multipath is modeled using the technique presented by Nader Farahati,
"A Software Multipath Fading Channel Simulator", Technophone Limited,
July 1989. Nader Farahati is now with Scientific Generics, Cambridge
U.K. Each multipath is associated with a time delay. The time
delays are incorporated by transforming the problem into the frequency
domain.
This star first reads all samples, u(t), at its input. It then multiplies the
complex input samples by the complex fading channel amplitude with
doppler shift for path i,
ri(t),  and transforms them into the frequency domain, Yi(f).
The various delays are
incorporated by multiplying the frequency domain data, Yi(f), by
exp{-2PIj(fc+f)ti} where fc is the carrier frequency, f is the
frequency, and ti is the time delay of the ith multipath.
The various multipaths with independent fading channel amplitudes are
added in the frequency domain and transformed back into the time domain.
The star then outputs the complex data as two channels ( in-phase and
quad-phase) in 128 sample chunks. This helps in limiting the size of
buffers.
Note that other doppler spectrums and Rician distributions will be
supported later. The star can easily be changed.
Programmer:     Sasan Ardalan
Date:           Dec. 27, 1990
Modified:       Jeyhan Karaoguz (Time reversal and some other bugs)
Date:           June 28, 1991
*/