第七讲综合建模与仿真.ppt

  1. 1、本文档共67页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
循环激励 从循环产生激励特性: 在每一次循环,修改同一组激励变量 时序关系规则 代码紧凑 module loop_tb; reg clk; reg [7:0] stimulus; wire [7:0] results; integer i; DUT u1 (results, stimulus); always begin // clock generation clk = 1; #5 clk = ~clk; end initial begin for (i = 0; i 256; i = i + 1) @( negedge clk) stimulus = i; #20 $finish; end endmodule 数组激励 数组产生激励特性: 在每次反复中,修改同一组激励变量 激励数组可以直接从文件中读取 module array_ tb; reg [7: 0] data_ bus, stim_ array[15:0]; // 数组 integer i; DUT u1 (results, stimulus); initial begin // 从数组读入数据 #20 stimulus = stim_array[0]; #30 stimulus = stim_array[15]; // 线激励 #20 stimulus = stim_array[1]; for (i = 14; i 1; i = i - 1) // 循环激励 #50 stimulus = stim_array[i] ; #30 $finish; end endmodule 空调有限状态机测试平台 module testbench; wire heat, cool; reg t_high, t_low, clk, reset; my_state U1(.t_high(t_high), .t_low(t_low), .heat(heat), .cool(cool), .clk(clk), .reset(reset)); initial begin t_high=0; t_low=0; clk=0; reset=0; #3 reset=1; end always #5 clk=~clk; initial fork #12 t_high=1; //too heat 1 #32 t_high=0; #42 t_low=1; // too cool 1 #72 t_low=0; #92 t_high=1; // too heat 2 #102 t_low=1; #102 t_high=0; #122 t_high=0; #122 t_low=0; #142 t_low=1; //too cool 2 #152 t_high=1; #152 t_low=0; #172 t_high=0; #172 t_low=0; #182 t_high=1; // error 1 #202 t_low=1; #222 t_high=0; #222 t_low=0; #242 t_low=1; // error 2 #252 t_high=1; #272 t_high=0; #272 t_low=0; join endmodule 空调有限状态机仿真结果 仿真测试平台对六种工作状态进行了功能测试,实现测试目标。 当温度太高和太低同时出现时,设计不合理,需改进设计。 * 状态机设计例 例:用于空调控制的有限状态机。它有两个输入,分别与传感器相连,用于检测室内温度。如果温度在设定的范围内,如18 ~ 23度,则两个温度输入t_high和t_low为低(0)。如果室内温度超过最高设定温度(23度),则输入t_high变为高(1);如果室内温度低于最低设定温度(18度),则输入t_low变为高(1)。空调控制器输出为加热信号heat和制冷信号cool,当二者其一为高时,空调进行加热和制冷。 空调控制有限状态机 状态 状态转移条件 状态转移优先级 t_high t_low 控制器 heat cool 空调有限状态机的verilog描述1

文档评论(0)

kabudou + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档