How two combine two integers into a fixdt
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to make a custom simulink block that does type conversion for a custom fixdt
The block has 2 inputs (dataA and dataB, both int32) and 1 output (myType, fixdt(1,32,24))
We treat dataA and dataB as two 32-bit binary values and parse out their data differently depending on the type specified. In the case I'm interested in, their values are represented as follows:
__type__ _______fractional_______
dataA = '00000000|000000000000000000000000'
___________integer______________
dataB = '00000000000000000000000000000000'
where type is 8-bit, fractional is 24-bit, and integer is 32-bit.
I want to take the fractional and integer components and combine them into my fixdt type. Is there a way that I can typecast this in simulink?
I can get the fractional components out of dataA using a bitslice, but I can't figure out how to combine the fractional and integer into a fixdt.
0 Kommentare
Antworten (1)
Karan Singh
am 5 Feb. 2025 um 10:54
How about using a 'Shift Arithmetic' block to shift the integer part 24 bits to the left, aligning it with the fractional part? Then, you can add it using the 'Add' block to combine the numbers. You can read more about it here.
Karan
0 Kommentare
Siehe auch
Kategorien
Mehr zu Fixed Point finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!