--- /dev/null
+/*
+* 32bit vector negate implementation.
+*
+* function prototype
+* void fr32_vector_neg(
+* const fract32 a[],
+* fract32 b[],
+* int count);
+*
+* parameters
+* FP+16 R2 count
+* FP+12 R1 const fr32 b[]
+* FP+ 8 R0 const fr32 a[]
+*
+* return
+* none
+*
+* side effect
+* out[] : obtain output data
+*
+
+* register layout
+* P1 : count : loop counter's initial value
+* I0 : a
+* I1 : b
+* R0 : a[i]
+* R1 : -a[i]
+*/
+
+ .text
+ .align 4
+ .global _fr32_vector_neg;
+ .type _fr32_vector_neg, STT_FUNC;
+
+_fr32_vector_neg:
+ link 0;
+ [--sp] = (r7:4, p5:3); // save all preserved register
+
+ /* Set up registers */
+ i0 = r0; // load a
+ i1 = r1; // load b
+ p1 = R2; // load count
+
+ /* outer loop */
+ loop count lc0 = p1; // Todo : can be 3 parallel instruction. But seems to be simulator bug in 2013RC1RC
+ loop_begin count;
+ r0 = [i0++];
+ r1 = - r0(s);
+ [i1++] = r1;
+ loop_end count;
+ /* end of outer loop */
+
+
+ (r7:4, p5:3) = [sp++]; // restore all preserved register
+ unlink;
+ rts;
+ .size _fr32_vector_neg, .-_fr32_vector_neg
* \brief vector subtraction A-B => C
* \param a input vector A
* \param b input vector B
- * \param c input vector C
+ * \param c output vector C
* \count length of vector
* \details
* Subtract the 32bit fixed point B from A, then, store the result to vector C.
* \brief vector addition A+B => C
* \param a input scalar A
* \param b input vector B
- * \param c input vector C
+ * \param c output vector C
* \count length of vector
* \details
* Add the 32bit fixed point scalar A to vector B, then, store the result to vector C.
* \brief vector Sbutraction A-B => C
* \param a input scalar A
* \param b input vector B
- * \param c input vector C
+ * \param c output vector C
* \count length of vector
* \details
* Subtract the 32bit fixed point vector B from scalar A , then, store the result to vector C.
* \brief vector multiplying A*B => C
* \param a input vector A
* \param b input vector B
- * \param c input vector C
+ * \param c output vector C
* \count length of vector
* \details
* Multiply the 32bit fixed point A by B, then, store the result to vector C.
/**
* \brief vector multiplying A*B => C
- * \param a input vector A
- * \param b input scalar B
- * \param c input vector C
+ * \param a input scalar A
+ * \param b input vector B
+ * \param c output vector C
* \count length of vector
* \details
* Multiply the 32bit fixed point vector B by scalar A, then, store the result to vector C.
* \param ai input vector im(A)
* \param br input vector re(B)
* \param bi input vector im(B)
- * \param cr input vector re(C)
- * \param ci input vector im(C)
+ * \param cr output vector re(C)
+ * \param ci output vector im(C)
* \count length of vector
* \details
* Mulitiply the complex fxied point vector A by B. Then, store the result to vector C
int count
);
+ /**
+ * \brief vector negate -A => B
+ * \param a input vector A
+ * \param b output vector B
+ * \count length of vector
+ * \details
+ * Negate the input vector A, then, store the result to vector B.
+ */
+void fr32_vector_neg(
+ const fract32 a[],
+ fract32 b[],
+ int count);
+
+ /**
+ * \brief vector fill A => B
+ * \param a input scalar A
+ * \param b output vectr B
+ * \count length of vector
+ * \details
+ * Fill output vector B by input scalar A
+ */
+void fr32_vector_fill(
+ const fract32 a,
+ fract32 b[],
+ int count);
+
+
#endif /* FX32_VECTOR_H_ */
#undef TAPS_07
#undef NUMSAMPLE_07
+
+/*
+ * Basic test to see scalar + vector addition.
+ */
+#define NUMSAMPLE_08 5
+
+fract32 buf_a_08[NUMSAMPLE_08]=
+ {
+ 0x00000001, //
+ 0xFFFFFFFF, //
+ 0x80000001,
+ 0x80000000,
+ 0x20000000
+ };
+
+
+fract32 desired_08[NUMSAMPLE_08] =
+ {
+ 0xFFFFFFFF, // -1
+ 0x00000001, // 1
+ 0x7FFFFFFF,
+ 0x7FFFFFFF, // saturated
+ 0x00000000, // 0 for count test
+ };
+
+void test_08_fr32_vector_neg()
+{
+ fract32 output[NUMSAMPLE_08];
+ int i;
+
+
+ // clear output buffer
+ clearBuffer( output, NUMSAMPLE_08);
+ // test subtraction. Sample is less than NUMSAMPLE_08 to test the count parameter
+ fr32_vector_neg( buf_a_08, output, NUMSAMPLE_08-1);
+
+ for ( i=0; i<NUMSAMPLE_08; i++)
+ {
+ if ( output[i] != desired_08[i] )
+ {
+ printf( "test_08 NG :output[%2d] = 0x%08X but should be 0x%08X\n", i, output[i], desired_08[i] );
+ return;
+ }
+ }
+ printf ("test_08 OK\n");
+}
+
+#undef TAPS_08
+#undef NUMSAMPLE_08
+