Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions Source/BasicMathFunctions/arm_mult_q31.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ ARM_DSP_ATTRIBUTE void arm_mult_q31(
uint32_t blockSize)
{
uint32_t blkCnt; /* Loop counter */
q31_t out; /* Temporary output variable */

#if defined (ARM_MATH_LOOPUNROLL)

Expand All @@ -119,21 +118,13 @@ ARM_DSP_ATTRIBUTE void arm_mult_q31(
/* C = A * B */

/* Multiply inputs and store result in destination buffer. */
out = ((q63_t) *pSrcA++ * *pSrcB++) >> 32;
out = __SSAT(out, 31);
*pDst++ = out << 1U;
*pDst++ = (q31_t) clip_q63_to_q31(((q63_t) *pSrcA++ * *pSrcB++) >> 31);

out = ((q63_t) *pSrcA++ * *pSrcB++) >> 32;
out = __SSAT(out, 31);
*pDst++ = out << 1U;
*pDst++ = (q31_t) clip_q63_to_q31(((q63_t) *pSrcA++ * *pSrcB++) >> 31);

out = ((q63_t) *pSrcA++ * *pSrcB++) >> 32;
out = __SSAT(out, 31);
*pDst++ = out << 1U;
*pDst++ = (q31_t) clip_q63_to_q31(((q63_t) *pSrcA++ * *pSrcB++) >> 31);

out = ((q63_t) *pSrcA++ * *pSrcB++) >> 32;
out = __SSAT(out, 31);
*pDst++ = out << 1U;
*pDst++ = (q31_t) clip_q63_to_q31(((q63_t) *pSrcA++ * *pSrcB++) >> 31);

/* Decrement loop counter */
blkCnt--;
Expand All @@ -154,9 +145,7 @@ ARM_DSP_ATTRIBUTE void arm_mult_q31(
/* C = A * B */

/* Multiply inputs and store result in destination buffer. */
out = ((q63_t) *pSrcA++ * *pSrcB++) >> 32;
out = __SSAT(out, 31);
*pDst++ = out << 1U;
*pDst++ = (q31_t) clip_q63_to_q31(((q63_t) *pSrcA++ * *pSrcB++) >> 31);

/* Decrement loop counter */
blkCnt--;
Expand Down
4 changes: 4 additions & 0 deletions Testing/Include/Tests/BasicTestsQ31.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,9 @@ class BasicTestsQ31:public Client::Suite
/* Offset or scale value */
q31_t scalar;

/* Set for the saturation tests, where the reference pattern is the
exact Q31 limit and no tolerance is allowed. */
bool exactRef;

q31_t min,max;
};
16 changes: 14 additions & 2 deletions Testing/Source/Tests/BasicTestsQ31.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,17 @@ uint32_t *outp=outputLogical.ptr();

ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);

ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q31);

if (this->exactRef)
{
/* Saturation test: the reference pattern is the Q31 limit itself,
so ABS_ERROR_Q31 must not be allowed to absorb the difference. */
ASSERT_EQ(output,ref);
}
else
{
ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q31);
}

}

void BasicTestsQ31::test_negate_q31()
Expand Down Expand Up @@ -239,6 +248,8 @@ uint32_t *outp=outputLogical.ptr();

this->scalar = ONEHALF;

this->exactRef = false;


switch(id)
{
Expand Down Expand Up @@ -444,6 +455,7 @@ uint32_t *outp=outputLogical.ptr();
output.create(ref.nbSamples(),BasicTestsQ31::OUT_SAMPLES_ID,mgr);
input1.reload(BasicTestsQ31::MAXNEG2_Q31_ID,mgr);
input2.reload(BasicTestsQ31::MAXNEG2_Q31_ID,mgr);
this->exactRef = true;
break;

case BasicTestsQ31::TEST_NEGATE_Q31_30:
Expand Down
Loading