I need to model floating point math in system verilog code which basically requires me to manipulate floating numbers in system verilog: real/shortreal. I need the ability to determine the mantissa, exponent & sign of a floating point number.
A c solution to this problem is to typcast it into an int pointer and then use shift operators: How to get the sign, mantissa and exponent of a floating point number
If system verilog supported part/bit select operators on short real, this is how the function would look:
function automatic shortreal conv2shortreal (bit sign, bit[7:0] exp, bit[22:0] mantissa);
conv2shortreal[31] = sign;
conv2shortreal[30:23] = exp;
conv2shortreal[22:0] = mantissa;
endfunction
the output should be a shortreal/real