ADSP-SC58x/2158x IIR Accelerator: Example Code

Attached zip file contains the example code for using the IIR accelerator module.

  1. IIR_Accelerator_Two_Channels_Core1: This code shows how to use IIR accelerator to filter two input buffers (channels):
    • Channel 1: BIQUADS = 6, WINDOW SIZE = 1024
    • Channel 2: BIQUADS = 4, WINDOW SIZE = 512
  2. IIR_Accelerator_Two_Channels_Core0: This code can be run on ARM to enable the SHARC core.
  3. iir.m: This MATLAB script can be used to generate data for input, coefficients, expected output buffers.
IIRExampleCode.zip
  • I think there is a bug in this code example.

    In the file main.c where the TCB's are filled with the data, a value is added as :

    IIRA_TCB2[0]=((uint32_t)(IIRA_TCB1+12)>>2)|0xA000000; //CP

    This is a pointer to the last value of the next TCB block.  Since the TCB block contains 12 elements of type uint32_t, wich are 4 byte words I think the offset should be 12 words, not 12 bytes.  The code should be :

    IIRA_TCB2[0]=((uint32_t)(IIRA_TCB1+(12*4))>>2)|0xA000000 // CP.

    Also for the call to the IIRA_Init function, the second parameter should become (((uint32_t)(IIRA_TCB1+(12*4))>>2)|0xA000000).

    This behaviour will change if the IIR call is implemented in a continous circular buffer, where the TCB's are chained.

    Am i right ?

    Br,

    Thierry

  • 0
    •  Analog Employees 
    on Dec 14, 2015 7:19 PM over 5 years ago

    Hi Thierry,

    I do understand your confusion. But since this code works as expected, looks like the compiler indeed adds and offset of 48(=12*4) bytes as IIR_TCB is defined as unsigned int 32 bit array.

    This is shown in the screenshot below how the compiler uses the address 0x2d5010 (0x2D4FE0+0x30) for FIR_TCB1+12 in one for the FIR code I have.

    Thanks,

    Mitesh

  • Hi Mitesh,

    Indeed this makes it more clear to me.

    The reason why I have seen this problem is because I adapted your code.

    I've made it possible to use the IIR code not only for a single shot of data, but in a continous way in a circular buffer.

    I've also changed the code to support more than one stereo pair (2 channels).

    To be flexible, i've chaned the TCB definition in a 2D array, first dimension for the channel, the second one is the 12 elements of the TCB.  Now I fill the TCB data in a for-loop to connect the correct memory location to the correct TCB.

    Since the compiler has to make index based calculations to fill the next TCB pointer, it doesn't know anymore if it is a int8 pointer rather than a int32 pointer, so in the first implementation the destination address was wrong (the compiler added only 12 to the address).

    Enclosed the assembly code :

    So I think it is very confusing how the compiler deals with pointers

    If it can optimize to fill in the address directly into the register, it seems like it takes the uint32 pointer into accounts, but if the destination address has to be calculated in any way, it seems like it doesn't takes the int32 into account anymore.

    Br,

    Thierry

  • Hi Mitesh,

    Your example code is written to calculate the IIR just once.

    I've tried to implement the IIR accelerator in a continous way, using circular buffer.  I'm using blocks (IIR-windows) of 512 samples and I'm using four channels.

    The CTRL register is programmed to stop processing TCB's if the window of all channels are processed.

    In the hardware manual there is several times stated that the accelerator will 'wait for core intervention', but there is never explained what the core should do to start the next window processing :-(

    What does the accelerator expects that the core should do exactly ?

    At this moment I use the enable bit to disable and re-enable the accelerator to start the next window.  In that case the coefficients are also reloaded in the accelerator (takes memory bandwitdh).  The code works, but I would like to understand how to start the accelerator without re-loading the coeff's.

    Thanks,

    Br,

    Thierry

  • 0
    •  Analog Employees 
    on Jan 19, 2016 6:31 PM over 5 years ago

    Hi Thierry,

    Apologies for my late reply. Your question is valid. I am attaching a code which was written for ADSP-21469. It uses the IIR accelerator in real time mode. Note the following lines of code in the file "process_audio.c" which re-enables the accelerator without reloading the coefficients.

    I think the similar approach should work for ADSP-SC58x as well. Let me know if you face any specific issues.

    Thanks,

    Mitesh