Forum Discussion
Altera_Forum
Honored Contributor
14 years agosigned to unsigned
i, i want to convert a 10 bit signed into a 8 bit unsigned. i tried with the altbus, but when implemented if i input -32 i get FF instead of 0. Is there an other block? which settings i have to m...
Altera_Forum
Honored Contributor
14 years agoOk, I checked my simulation again and could reproduce your results after enabling the saturation in the Altbus block. And you are right the simulation produces '0' as output but already a VHDL simulation showed 255 (decimal) or 0xFF (hex). What is a result I would expect.
To explain this here what happens: input to AltBus: -32 (10 bit signed decimal) = 11 1110 0000 (binary) = 0x3E0 (hexadecimal) convert to unsigned 992 (10 bit unsigned decimal) = 11 1110 0000 (binary) = 0x3E0 (hexadecimal) saturate, then 992 > 255: 255 (8 bit unsigned decimal) = 1111 1111 (binary) = 0xFF (hexadecimal)