Post Go back to editing

Custom sigma studio module not working on SH1 in dual core mode

Category: Software


I have written a custom sigma studio module, a level detector which I can grow to the desired number of channels. And of which i can read out the levels of the channels programmatically. This module works fine when running in single core mode on the ADSP-SC594 on SHARC 0. But when i run it in dual core mode and execute the module on SHARC1, the output buffers do not seem to be mapped correctly. I get the following mapping CH0 -> CH0, CH1 -> CH2, CH2 -> CH4, CH3 -> CH6, ....

So it seems that the ouptut channel mapping skips a channel for each channel. Why is this the case?

Below is the code of the module. And a screenshot of the sigmastudio file with the 12 channel level detector.

/*============= D E F I N E S =============*/

#define MAX(a,b)	(a<b?(b):(a))

typedef struct{
	float32_t state01;
	float32_t state02;

/*============= C O D E =============*/

#pragma inline
static float32_t max(float32_t a, float32_t b){
	return (a>b)?a:b;

#pragma inline
static float32_t abs(float32_t a){
	return (a>0)?a:-a;

#pragma section("seg_pmco")
void BPROCESS_LevelDetector (SSBlockAlgo* pBlkAlgoInfo)
	uint32_t        nChannel, nSample;
	uint32_t        nBlockSize, nChannels;


	nChannels       = pBlkAlgoInfo->nGrowth;

	State* pState = (State*)pBlkAlgoInfo->pState;
	float32_t* pParam = (float32_t*)(pBlkAlgoInfo->pParam);

	for (nChannel = 0; nChannel < nChannels; nChannel++)
		int32_t nSamplingRate = pBlkAlgoInfo->pInputs[nChannel].pBlockProperties->nSamplingRate;

		float32_t fAlphaRelease = exp(-1.0 / (nSamplingRate * pParam[0]));	/* param in seconds */
		float32_t fAlphaAttack = exp(-1.0 / (nSamplingRate * pParam[1]));	/* param in seconds */

		nBlockSize = pBlkAlgoInfo->pInputs[nChannel].pBlockProperties->nBlockSize;

		for(nSample = 0; nSample< nBlockSize; nSample++){
			float32_t* pInput = pBlkAlgoInfo->pInputs[nChannel].pSamples;
			float32_t* pOutput = pBlkAlgoInfo->pOutputs[nChannel].pSamples;

			pOutput[nSample] = pInput[nSample];

			pState[nChannel].state02 = max(pInput[nSample], fAlphaRelease * pState[nChannel].state02 + (1 - fAlphaRelease) * pInput[nSample]);
			pState[nChannel].state01 = fAlphaAttack * pState[nChannel].state01 + (1 - fAlphaAttack) * pState[nChannel].state02;

			float32_t* pVal = &pParam[2];
			float32_t fLevel = abs(pState[nChannel].state01);

			/* according to compiler docs, log10 returns 0 in case of domain error, so no need to check for 0*/
			float32_t fdB = 20*log10(fLevel);

			if(fLevel == 0 || fdB<-96.0)
				pVal[nChannel] = -96.0;
			else if(fdB>32.0)
				pVal[nChannel] = 32.0;
				pVal[nChannel] = fdB;


    STOP_CYCLE_COUNT(nCycleEnd, nCycleStart);
    anCycleDump[nDumpIndex++] = nCycleEnd;
    if (nDumpIndex == MIPS_DUMP_SIZE)
        nDumpIndex = 0;
    memcpy((uint32_t *) (pBlkAlgoInfo->pOutputs[0].pSamples), anCycleDump, MIPS_DUMP_SIZE);


void INIT_LevelDetector (SSBlockAlgo* pBlkAlgoInfo)
	int i;
	int *pSymbol = pBlkAlgoInfo->pExtSymbols;


[edited by: Robrechtb at 11:06 AM (GMT -5) on 9 Dec 2022]