Commit 06181733 authored by Karl Tomlinson's avatar Karl Tomlinson Committed by Ralph Giles

fixed-point: introduce MULT16_32_32 to handle unexpected types in MULT16_32_Q15

parent 00d2e621
Pipeline #2159 passed with stage
in 1 minute and 40 seconds
......@@ -177,6 +177,7 @@ typedef float spx_word32_t;
#define ADD32(a,b) ((a)+(b))
#define SUB32(a,b) ((a)-(b))
#define MULT16_16_16(a,b) ((a)*(b))
#define MULT16_32_32(a,b) ((a)*(b))
#define MULT16_16(a,b) ((spx_word32_t)(a)*(spx_word32_t)(b))
#define MAC16_16(c,a,b) ((c)+(spx_word32_t)(a)*(spx_word32_t)(b))
......
......@@ -250,6 +250,21 @@ static inline short MULT16_16_16(int a, int b)
return res;
}
/* result fits in 32 bits */
static inline int MULT16_32_32(int a, long long b)
{
long long res;
if (!VERIFY_SHORT(a) || !VERIFY_INT(b))
{
fprintf (stderr, "MULT16_32_32: inputs are not short+int: %d %d\n", a, (int)b);
}
res = a*b;
if (!VERIFY_INT(res))
fprintf (stderr, "MULT16_32_32: output is not int: %d\n", (int)res);
spx_mips++;
return res;
}
#define MULT16_16(a, b) _MULT16_16(a, b, __FILE__, __LINE__)
static inline int _MULT16_16(int a, int b, char *file, int line)
{
......
......@@ -69,16 +69,18 @@
/* result fits in 16 bits */
#define MULT16_16_16(a,b) ((((spx_word16_t)(a))*((spx_word16_t)(b))))
#define MULT16_16_16(a,b) (((spx_word16_t)(a))*((spx_word16_t)(b)))
/* result fits in 32 bits */
#define MULT16_32_32(a,b) (((spx_word16_t)(a))*((spx_word32_t)(b)))
/* (spx_word32_t)(spx_word16_t) gives TI compiler a hint that it's 16x16->32 multiply */
#define MULT16_16(a,b) (((spx_word32_t)(spx_word16_t)(a))*((spx_word32_t)(spx_word16_t)(b)))
#define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b))))
#define MULT16_32_P15(a,b) ADD32((a)*SHR((b),15), PSHR(MULT16_16((a),((b)&0x00007fff)),15))
#define MULT16_32_Q15(a,b) ADD32((a)*SHR((b),15), SHR(MULT16_16((a),((b)&0x00007fff)),15))
#define MAC16_32_Q15(c,a,b) ADD32(c,ADD32((a)*SHR((b),15), SHR(MULT16_16((a),((b)&0x00007fff)),15)))
#define MULT16_32_P15(a,b) ADD32(MULT16_32_32(a,SHR((b),15)), PSHR(MULT16_16((a),((b)&0x00007fff)),15))
#define MULT16_32_Q15(a,b) ADD32(MULT16_32_32(a,SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))
#define MAC16_32_Q15(c,a,b) ADD32(c,MULT16_32_Q15(a,b))
#define MAC16_16_Q11(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),11)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment