为子系统生成可重用的代码
高密度脂蛋白编码器™可以检测原子相同的子系统,或相同的除了他们的面具参数值,在任何级别的层次结构模型,并生成一个可重用的高密度脂蛋白模块
或实体
。可重用的HDL代码生成一个文件并多次实例化。
要求为原子子系统生成可重用的代码
的
DefaultParameterBehavior
金宝app®配置参数必须内联
。你可以设置这个参数在命令行中使用set_param
或hdlsetup
函数。指定此设置配置参数对话框,你必须有金宝app仿真软件编码器™。请注意
使用
hdlsetup
集InlineParams
财产在
。启用此参数设置是一样的DefaultParameterBehavior
来内联
。设置InlineParams
来从
变化DefaultParameterBehavior
价值可调
。不要使用功能,如信号记录或使用块像什么到工作空间或到文件。
原子子系统必须相同,或相同的除了他们的面具参数值。
MaskParameterAsGeneric
必须在
。有关更多信息,请参见从蒙面子系统生成参数化HDL代码。必须nontunable面具参数。代码生成器并不与面具分享原子子系统参数可调。
面具参数必须标量。
参数数据类型必须是面具
整数
或定点
的单词长度小于或等于32
。唯一的可调参数必须使用常数,获得,或比较恒定的块。
端口数据类型必须匹配。
如果你改变面具可调参数的值,可以改变输出端口数据类型。如果一个原子子系统有一个不同的端口数据类型,生成的代码的子系统也不同。
要求为虚拟子系统生成可重用的代码
的
DefaultParameterBehavior
金宝app仿真软件配置参数必须内联
。你可以设置这个参数在命令行中使用set_param
或hdlsetup
函数。指定此设置配置参数对话框,你必须有金宝app仿真软件编码器。请注意
使用
hdlsetup
集InlineParams
财产在
。启用此参数设置是一样的DefaultParameterBehavior
来内联
。设置InlineParams
来从
变化DefaultParameterBehavior
价值可调
。不要使用日志功能,如信号日志或块像什么到工作空间或到文件。
虚拟子系统必须相同,或相同的除了他们的面具参数值。
SubsystemReuse
必须设置为原子和虚拟的
。设置
SubsystemReuse
来原子和虚拟的
减少人工代数错误和提高识别相同的子系统,不管他们的拓扑内其余的设计。识别相似的子系统可以资源共享。设置这些值,你需要设置,在MATLAB命令窗口中,输入:
hdlset_param (“myHDLModel”,“SubsystemReuse”,原子和虚拟的)
另外,您可以从顶层设置这个选项HDL代码生成面板的配置参数对话框。下全局设置>编码风格,你可以改变代码重用设置所需的选项。
前面的命令集
SubsystemReuse
选择您的项目。设置这个选项只有当前代码生成会话,输入:makehdl (< DUT系统>,“SubsystemReuse”,原子和虚拟的)
MaskParameterAsGeneric
必须在
。有关更多信息,请参见从蒙面子系统生成参数化HDL代码。必须nontunable面具参数。代码生成器并不与面具分享原子子系统参数可调。
面具参数必须标量。
参数数据类型必须是面具
整数
或定点
的单词长度小于或等于32
。唯一的可调参数必须使用常数,获得,或比较恒定的块。
端口数据类型必须匹配。
如果你改变面具可调参数的值,可以改变输出端口数据类型。如果一个原子子系统有一个不同的端口数据类型,生成的代码的子系统也不同。
为原子子系统生成可重用的代码
这个例子展示了HDL代码生成的模型有相同的原子子系统。如果你的设计包含相同的原子子系统,编码器生成一个高密度脂蛋白模块或子系统和多次实例化它的实体。
开放模式
打开hdlcoder_reusable_code_identical_subsystem
模型来看到的一个例子DUT子系统包含三个相同的原子子系统。
load_system (“hdlcoder_reusable_code_identical_subsystem”);open_system (“hdlcoder_reusable_code_identical_subsystem / DUT”);
生成HDL代码
你可以通过使用生成的HDL代码模型makehdl
函数。生成HDL代码DUT
子系统,运行这个命令:
makehdl (“hdlcoder_reusable_code_identical_subsystem / DUT”)
# # #生成hdlcoder_reusable_code_identical_subsystem / DUT的高密度脂蛋白。使用的配置集模型# # # < a href = " matlab: configset。showParameterGroup (hdlcoder_reusable_code_identical_subsystem, {HDL代码生成的})" > hdlcoder_reusable_code_identical_subsystem < / > HDL代码生成参数。# # #“hdlcoder_reusable_code_identical_subsystem”高密度脂蛋白检查运行模型。# # #开始编译模型的“hdlcoder_reusable_code_identical_subsystem”……# # #工作模型“hdlcoder_reusable_code_identical_subsystem”……# # #工作……< a href = " matlab: configset.internal.open (‘hdlcoder_reusable_code_identical_subsystem’,‘GenerateModel’)”> GenerateModel < / > # # #开始模型生成的gm_hdlcoder_reusable_code_identical_subsystem ....# # #呈现DUT优化相关变化(IO,区域,流水线)…# # #模型生成完成。 ### Generating new validation model: gm_hdlcoder_reusable_code_identical_subsystem_vnl. ### Validation model generation complete. ### Begin VHDL Code Generation for 'hdlcoder_reusable_code_identical_subsystem'. ### Working on hdlcoder_reusable_code_identical_subsystem/DUT/vsum as hdl_prj/hdlsrc/hdlcoder_reusable_code_identical_subsystem/vsum.vhd. ### Working on hdlcoder_reusable_code_identical_subsystem/DUT as hdl_prj/hdlsrc/hdlcoder_reusable_code_identical_subsystem/DUT.vhd. ### Generating package file hdl_prj/hdlsrc/hdlcoder_reusable_code_identical_subsystem/DUT_pkg.vhd. ### Code Generation for 'hdlcoder_reusable_code_identical_subsystem' completed. ### Creating HDL Code Generation Check Report file:///tmp/Bdoc23a_2213998_3310088/tp57ccc1b9/hdlcoder-ex21822210/hdl_prj/hdlsrc/hdlcoder_reusable_code_identical_subsystem/DUT_report.html ### HDL check for 'hdlcoder_reusable_code_identical_subsystem' complete with 0 errors, 0 warnings, and 2 messages. ### HDL code generation complete.
高密度脂蛋白编码器生成单个硬件描述语言(VHDL)®文件,vsum.vhd
三个子系统。DUT子系统生成的代码,DUT.vhd
,包含三个实例化的vsum
组件。
体系结构rtl的DUT是
——组件声明组件vsum端口(三机一体:vector_of_std_logic_vector16(0到9);——int16[10]着干活:std_logic_vector(19报纸0)——sfix20);结束组件;
——组件配置语句为所有:vsum使用实体work.vsum (rtl);
——信号的信号vsum_out1:std_logic_vector(19报纸0);——ufix20信号vsum1_out1:std_logic_vector(19报纸0);——ufix20信号vsum2_out1:std_logic_vector(19报纸0);——ufix20
开始u_vsum: vsum端口地图(In1 = >三机一体,int16 [10]着干活= > vsum_out1——sfix20);
u_vsum1: vsum港口地图(In1 = > In2, int16 [10]着干活= > vsum1_out1——sfix20);
u_vsum2: vsum港口地图(In1 = > In3, int16 [10]着干活= > vsum2_out1——sfix20);
着干活< = vsum_out1;
Out2 < = vsum1_out1;
Out3 < = vsum2_out1;
结束rtl;
为原子子系统生成可重用的代码和可调面罩参数
使用这个示例中,您可以生成包含原子子系统设计的HDL代码是相同的除了他们的可调面罩参数值。你可以生成一个高密度脂蛋白模块或子系统的实体。在生成的代码中,多次被实例化模块或实体。
开放模式
的hdlcoder_reusable_code_parameterized_subsystem
模型显示了一个示例包含原子的DUT子系统子系统是相同的除了他们的可调面罩参数值。
load_system (“hdlcoder_reusable_code_parameterized_subsystem”);open_system (“hdlcoder_reusable_code_parameterized_subsystem / DUT”);
在hdlcoder_reusable_code_parameterized_subsystem / DUT
,增益模块子系统与增益值由可调面罩参数。增益值是:4
为gain_module
,5
为gain_module1
,7
为gain_module2
。
生成HDL代码
为相同的原子子系统生成可重用的代码,使MaskParameterAsGeneric
的模型。默认情况下,MaskParameterAsGeneric
是禁用的。
使原子可重用代码的生成子系统与可调参数集MaskParameterAsGeneric
选择“在”模型通过使用hdlset_param
函数。
hdlset_param (“hdlcoder_reusable_code_parameterized_subsystem”,“MaskParameterAsGeneric”,“上”);
另外,在配置参数对话框HDL代码生成>全局设置>编码风格选项卡中,使从蒙面子系统生成参数化HDL代码选择。
你也可以使MaskParameterAsGeneric
选择使用makehdl
DUT子系统的功能和生成HDL代码。
makehdl (“hdlcoder_reusable_code_parameterized_subsystem / DUT”,“MaskParameterAsGeneric”,“上”,…“开发”,“Verilog”)
# # #生成hdlcoder_reusable_code_parameterized_subsystem / DUT的高密度脂蛋白。使用的配置集模型# # # < a href = " matlab: configset。showParameterGroup (hdlcoder_reusable_code_parameterized_subsystem, {HDL代码生成的})" > hdlcoder_reusable_code_parameterized_subsystem < / > HDL代码生成参数。# # #“hdlcoder_reusable_code_parameterized_subsystem”高密度脂蛋白检查运行模型。# # #开始编译模型的“hdlcoder_reusable_code_parameterized_subsystem”……# # #工作模型“hdlcoder_reusable_code_parameterized_subsystem”……# # #工作……< a href = " matlab: configset.internal.open (‘hdlcoder_reusable_code_parameterized_subsystem’,‘GenerateModel’)”> GenerateModel < / > # # #开始模型生成的gm_hdlcoder_reusable_code_parameterized_subsystem ....# # # .... DUT复制到生成的模型# # #模型生成完成。 ### Begin Verilog Code Generation for 'hdlcoder_reusable_code_parameterized_subsystem'. ### Working on hdlcoder_reusable_code_parameterized_subsystem/DUT/gain_module as hdlsrc/hdlcoder_reusable_code_parameterized_subsystem/gain_module.v. ### Working on hdlcoder_reusable_code_parameterized_subsystem/DUT as hdlsrc/hdlcoder_reusable_code_parameterized_subsystem/DUT.v. ### Code Generation for 'hdlcoder_reusable_code_parameterized_subsystem' completed. ### Creating HDL Code Generation Check Report file:///tmp/Bdoc23a_2213998_3309690/tp9b00d648/hdlcoder-ex53380017/hdlsrc/hdlcoder_reusable_code_parameterized_subsystem/DUT_report.html ### HDL check for 'hdlcoder_reusable_code_parameterized_subsystem' complete with 0 errors, 0 warnings, and 0 messages. ### HDL code generation complete.
与MaskParameterAsGeneric
启用,高密度脂蛋白编码器生成一个单一的源文件,gain_module.v
,三个增益模块子系统。DUT子系统生成的代码,DUT.v
,包含三个实例化的gain_module
组件。
模块DUT(In3 In1, In2着干活,Out2, Out3);
输入(7:0)三机一体;/ / uint8输入(7:0)In2;/ / uint8输入(7:0)In3;/ / uint8输出(31:0)着干活;/ / uint32输出(31:0)Out2;/ / uint32输出(31:0)Out3;/ / uint32
线(31:0)gain_module_out1;/ / uint32线(31:0)gain_module1_out1;/ / uint32线(31:0)gain_module2_out1;/ / uint32
gain_module#(.myGain (4))u_gain_module (.In1 (in) / / uint8 .Out1 (gain_module_out1) / / uint32);
分配着干活=gain_module_out1;
gain_module#(.myGain (5))u_gain_module1 (.In1 (In2) / / uint8 .Out1 (gain_module1_out1) / / uint32);
分配Out2=gain_module1_out1;
gain_module#(.myGain (7))u_gain_module2 (.In1 (In3) / / uint8 .Out1 (gain_module2_out1) / / uint32);
分配Out3=gain_module2_out1;
endmodule/ /DUT
在gain_module.v
,myGain
Verilog®生成的参数可调面罩参数。
模块gain_module(In1,着干活);
输入(7:0)三机一体;/ / uint8输出(31:0)着干活;/ / uint32
参数(31:0)myGain=4;/ / ufix32
线(31:0)kconst;/ / ufix32线(39:0)Gain_mul_temp;/ / ufix40线(31:0)Gain_out1;/ / uint32
分配kconst=myGain;
分配Gain_mul_temp=kconst*三机一体;分配Gain_out1=Gain_mul_temp [31:0];
分配着干活=Gain_out1;
endmodule/ /gain_module
如果输入模型子系统包含掩码信息,如面具变量和初始化代码面具,面具这些子系统的信息都保存在生成模型。如果你不需要这个信息,你可以删除它。