I have generated a sine wave using 257-point lookup table that covers only one quadrant (4th quadrant). The entries in the table are in Q(1.15) format. [0,....,-32768].
I used linear interpolation to find unknown values from the table. I came across an example in which linear interpolation is implemented and used the same logic.
x -> phase in Q1.15
entries in look up table = 2^(n) + 1 = 2^(8) + 1 = 257
n = 8;
if (x > 0)
{
sign_flag = 1;
x = ~(x);
}
if (x < -16384)
{
x = -32768 - x;
}
x = ~(x);
index = x >> (14-n);
delta = (x & ((1 << (14 - n)) - 1)) << (1 + n);
z = table[index];
y = ((table[index+1] - table[index]) * delta) >> 15;
y = z + y;
1) What is the logic behind index and delta?
2) If delta is calculated using 'x' (phase) in float, what will be the expression of delta without using shift operation?