Hi,
I am working on porting FFT functionality from CMSIS DSP library to another architecture.Unfortunate I faced with problem that arm_bitreversal_32 function is implemented in assembler.
Does any body tried to convert it to C code?
Hello,
I'm sorry that the C code was not eqivalent to the original code.
The below is the corrected version.
Best regards,
Yasuhilko Koumoto.
void arm_bitreversal_32 (uint32_t * pSrc, const uint16_t bitRevLen, const uint16_t * pBitRevTable) { uint32_t r7,r6,r5,r4,r3; if (bitRevLen <= 0) return; r3 = ((bitRevLen + 1) >> 2); while (r3 > 0) { r7 = pSrc[(pBitRevTable[3]>>2)]; r6 = pSrc[(pBitRevTable[2]>>2)]; r5 = pSrc[(pBitRevTable[1]>>2)]; r4 = pSrc[(pBitRevTable[0]>>2)]; pSrc[(pBitRevTable[3]>>2)] = r6; pSrc[(pBitRevTable[2]>>2)] = r7; pSrc[(pBitRevTable[1]>>2)] = r4; pSrc[(pBitRevTable[0]>>2)] = r5; r7 = pSrc[(pBitRevTable[3]>>2) + 1]; r6 = pSrc[(pBitRevTable[2]>>2) + 1]; r5 = pSrc[(pBitRevTable[1]>>2) + 1]; r4 = pSrc[(pBitRevTable[0]>>2) + 1]; pSrc[(pBitRevTable[3]>>2) + 1] = r6; pSrc[(pBitRevTable[2]>>2) + 1] = r7; pSrc[(pBitRevTable[1]>>2) + 1] = r4; pSrc[(pBitRevTable[0]>>2) + 1] = r5; pBitRevTable += 4; r3--; } }
I'm very sorry. I revised the code again.
This revision would be identical to the original.
Best regards.
Yasuhiko Koumoto.
void arm_bitreversal_32 (uint32_t * pSrc, const uint16_t bitRevLen, const uint16_t * pBitRevTable) { uint32_t r7,r6,r5,r4,r3; if (bitRevLen <= 0) return; r3 = ((bitRevLen+1) >> 2); while (r3 > 0) { r7 = *(uint32_t*)((uint8_t*) pSrc + pBitRevTable[3]); r6 = *(uint32_t*)((uint8_t*) pSrc + pBitRevTable[2]); r5 = *(uint32_t*)((uint8_t*) pSrc + pBitRevTable[1]); r4 = *(uint32_t*)((uint8_t*) pSrc + pBitRevTable[0]); *(uint32_t*)((uint8_t*) pSrc + pBitRevTable[3]) = r6; *(uint32_t*)((uint8_t*) pSrc + pBitRevTable[2]) = r7; *(uint32_t*)((uint8_t*) pSrc + pBitRevTable[1]) = r4; *(uint32_t*)((uint8_t*) pSrc + pBitRevTable[0]) = r5; r7 = *(uint32_t*)((uint8_t*) pSrc + pBitRevTable[3] + 4); r6 = *(uint32_t*)((uint8_t*) pSrc + pBitRevTable[2] + 4); r5 = *(uint32_t*)((uint8_t*) pSrc + pBitRevTable[1] + 4); r4 = *(uint32_t*)((uint8_t*) pSrc + pBitRevTable[0] + 4); *(uint32_t*)((uint8_t*) pSrc + pBitRevTable[3] + 4) = r6; *(uint32_t*)((uint8_t*) pSrc + pBitRevTable[2] + 4) = r7; *(uint32_t*)((uint8_t*) pSrc + pBitRevTable[1] + 4) = r4; *(uint32_t*)((uint8_t*) pSrc + pBitRevTable[0] + 4) = r5; pBitRevTable += 4; r3--; } }
Thank you for all your assistance.
BR,
Iurii