How can I interpret "sfix32 en24" data in binary? (from WLAN transmitter HDL example)

Dear all,
I am using the example:
The mcs is set to be 0 for BPSK, so I am expecting the output I/Q data should form two clusters.
The output I/Q data from this TX HDL simulation are both 32 bits, where it is written as "sfix32 en24" in the HDL code.
However, if I simply change the 32-bit raw binary I/Q data into uint32, then I can see four clusters at:
(0,0)
(0,2^32)
(2^32,0)
(2^32,2^32)
Or, if I change the 32-bit raw binary I/Q data into signed int32, no cluster can be seen.
I think that I misunderstood the format of the raw data.
How should I correctly interpret the 32-bit data with "sfix32 en24"? Does one of the specific bit correspond to sign?
Thank you in advance.

 Risposta accettata

Hi Yun-Tsung,
sfix32: This typically stands for "signed fixed-point 32-bit".
  • Signed: Indicates that the number can be both positive and negative, with the most significant bit (MSB) representing the signed bit.
  • Fixed-point: A method of representing real numbers that has a fixed number of digits after the decimal point.
  • 32-bit: The total size of the data type is 32 bits. This includes both the integer and fractional parts.
en24: This refers to the "encoding" with 24 bits.
  • It means that 24 bits are used for the fractional part, leaving 8 bits for the integer part which includes signed bit also.
In summary, "sfix32 en24" describes a signed, fixed-point number with a total size of 32 bits, where 24 bits are used for the fractional part and 8 bits are used for integer part.
For more information, you can look at Fixed-Point Data in MATLAB and Simulink
If you are using a data type conversion block in Simulink to convert the sfix32 en24 data type to another data type, the data might get clipped based on the number of integer bits used in the conversion and you might see clusters. You can also adjust the "input and output to have equal" parameter in the data type conversion block, with options for "Real World Value (RWV)" and "Stored Integer (SI)", to ensure you have the correct bit configuration for your needs.
Hope that helps!
Best regards,
Dharma

3 Commenti

Thank you for the reply. Therefore, the MSB bit (the 32nd bit in case of sfix32) means sign of the value.
The reason for me to have this question is due to the data generated by the WLAN HDL example.
(In the code, it states sfix32 en24.)
The data looks like this (in hex):
006836bf
fed331c2
ffe11c73
01447a3c
00d1014c
01447a3c
ffe1665a
fed331c2
006880a6
00057c25
ff4d985a
ffe36bab
ffffb619
ffe36bab
ff4d4e73
00057c25
006836bf
......
Therefore, it is obviously that, it is either "a very large value", or "close to 0".
However, what we are expecting from the data is actually either "-1" or "1".
If I followed your suggestion to use MSB as sign to define the value, then they will become either "a very large negative value", or "close to 0". Still, I cannot obtain two clusters with positive and negative values.
Could you please perhaps give some hints with taking a look on these data? Thank you again.
format long g
data = {
'006836bf'
'fed331c2'
'ffe11c73'
'01447a3c'
};
ddec = hex2dec(data);
int32min = double(typecast(0x80000000s32, 'uint32'));
mask = ddec >= int32min;
ddec(mask) = ddec(mask) - 2^32;
number = ddec / 2^24
number = 4×1
0.407085359096527 -1.17502200603485 -0.120659649372101 1.26749014854431
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Thank you. I did a try with your suggestions on the data.
I think the method is no problem but the data don't looks like expectation. It becomes 1 cluster centered at (0,0).
I think this is a problem of the WLAN HDL module, not about the format, so I will ask another question for WLAN reference.
Thank you again.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Communications Toolbox in Centro assistenza e File Exchange

Prodotti

Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by