Trouble on using DSP library

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
cjf1699
Active Member
Posts: 48
Joined: Fri Mar 16, 2018 2:30 pm

Trouble on using DSP library

Post by cjf1699 »

Hi everyone,
I am having trouble understanding something about the function:

Image

I do understand what it is doing, while I don't know why it is called like this in the dsp_adaptive_lms function in the app_adaptive which is part of the AN00209 example:

Code: Select all

int32_t dsp_adaptive_lms
(
    int32_t  source_sample,
    int32_t  reference_sample,
    int32_t* error_sample,
    const int32_t* filter_coeffs,
    int32_t* state_data,
    const int32_t num_taps,
    const int32_t mu,
    const int32_t q_format
) {
    int32_t output_sample, mu_err;
    

    // Output signal y[n] is computed via standard FIR filter:
    // y[n] = b[0] * x[n] + b[1] * x[n-1] + b[2] * x[n-2] + ...+ b[N-1] * x[n-N+1]

    output_sample = dsp_filters_fir( source_sample, filter_coeffs, state_data, num_taps, q_format );

    // Error equals difference between reference and filter output:
    // e[n] = d[n] - y[n]
    *error_sample = reference_sample - output_sample;
    
    // FIR filter coefficients b[k] are updated on a sample-by-sample basis:
    // b[k] = b[k] + mu_err * x[n-k] --- where mu_err = e[n] * mu
    
    mu_err = dsp_math_multiply( *error_sample, mu, q_format );

   [b]dsp_vector_muls_addv( state_data, mu_err, (int32_t*) filter_coeffs, (int32_t*) filter_coeffs, num_taps, q_format );[/b]

    return output_sample;
}
Now that filter_coeffs is to be changed ,why is it declared as const? Besides, since filter_coeffs is already the type of int32_t*, why applying a force type casting to it?
When I try to write a simple demo like this :

Code: Select all

int32_t input[] = {1,2,3,4,5,6};
  int32_t fir_coeff[6] = {1,0,2,3,1,2};
  
  dsp_vector_muls_addv( input, 2,   (int32_t*)fir_coeff,  (int32_t*)fir_coeff, 6, 0 );
It gave an error:
../src/app_adaptive.xc:534:62: error: call makes alias in function `dsp_vector_muls_addv'
dsp_vector_muls_addv( state_data, 2, (int32_t*)fir_coeff, (int32_t*)fir_coeff, 6, 0 );
^~~~~~~~~~~~~~~~~~~
../src/app_adaptive.xc:534:41: note: aliased item is here
Thank you!


Post Reply