Simulate and Generate HDL Code for the Float Typecast Block
This example shows how you can use the Float Typecast block to extract the sign, exponent, and mantissa bits from a floating-point input, and then convert the bits back to a floating-point output after performing any computations.
Open the hdlcoder_float_typecast_example model.
open_system('hdlcoder_float_typecast_example')

The model multiplies the floating-point input by two to produce the floating-point output. To multiply the input, the algorithm increments the exponent by one. Open the HDL_DUT subsystem.
open_system('hdlcoder_float_typecast_example/HDL_DUT')

The model is already configured for HDL compatibility by using the hdlsetup function. Simulate the model.
sim('hdlcoder_float_typecast_example') open_system('hdlcoder_float_typecast_example')

Before you generate HDL code, enable the Native Floating Point mode.
nfpconfig = hdlcoder.createFloatingPointTargetConfig('NATIVEFLOATINGPOINT'); hdlset_param('hdlcoder_float_typecast_example', ... 'FloatingPointTargetConfiguration', nfpconfig);
Generate HDL code for the HDL_DUT subsystem.
makehdl('hdlcoder_float_typecast_example/HDL_DUT')