I am trying to convert a number from one fixed point representation to another. I am using the 2's complement representation (Qmf representation) This is to verify the hardware implementation. The hardware implementation works as follows:
The input data is in Qmf format. The input data is 8bits wide and has a fractional length of 6 bits. I want to convert it to 4bit number with 4 fractional bits (No integer bits) and I have a few doubts regarding the same.
I noticed that when I am trying to convert numbers like 1.984375 from Q26 {range [-2,1.984375] } format to Q04 {range [-0.5,0.4375]} format, the hardware implementation runs as follows: I read bits 5-2 since bits 6&7 are used for the integer part and store it in a 4-bit register. So this value gets interpreted as -0.5 when converted to Q04 format. Is -0.5 correct? The amount of error incurred seems to be huge. Am I doing something wrong ? If the above mentioned approach is correct. Is there any standard procedure to convert from one fixed-point representation to another in software that mimics the hardware approach that I described above. I am thinking of converting the number from Q26 representation to floating point and the converting it back to fixed point. Is there a cleaner way of doing this in software?