主要内容

对 Float Typecast 模块进行仿真并为其生成 HDL 代码

此示例说明如何使用 Float Typecast 模块从浮点输入中提取符号位、指数位和尾数位,然后在执行任何计算后将这些位转换回浮点输出。

打开 hdlcoder_float_typecast_example 模型。

open_system('hdlcoder_float_typecast_example')

该模型将浮点输入乘以二以产生浮点输出。为了对输入执行乘法,该算法将指数增加一。打开 HDL_DUT 子系统。

open_system('hdlcoder_float_typecast_example/HDL_DUT')

该模型已通过使用 hdlsetup 函数配置为与 HDL 兼容。对模型进行仿真。

sim('hdlcoder_float_typecast_example')
open_system('hdlcoder_float_typecast_example')

在生成 HDL 代码之前,启用 Native Floating Point 模式。

nfpconfig = hdlcoder.createFloatingPointTargetConfig('NATIVEFLOATINGPOINT');
hdlset_param('hdlcoder_float_typecast_example', ...
                            'FloatingPointTargetConfiguration', nfpconfig);

HDL_DUT 子系统生成 HDL 代码。

makehdl('hdlcoder_float_typecast_example/HDL_DUT')