当前位置: 首页 > news >正文

电商网站模板四川凡术品牌策划有限公司

电商网站模板,四川凡术品牌策划有限公司,莞城区网站建设公司,昆明做网站建设有哪些相关阅读 Verilog基础https://blog.csdn.net/weixin_45791458/category_12263729.html?spm1001.2014.3001.5482 作为一个硬件描述语言,Verilog HDL常常需要使用语句描述并行执行的电路,但其实在仿真器的底层,这些并行执行的语句是有先后顺序…

相关阅读

Verilog基础icon-default.png?t=N7T8https://blog.csdn.net/weixin_45791458/category_12263729.html?spm=1001.2014.3001.5482


        作为一个硬件描述语言,Verilog HDL常常需要使用语句描述并行执行的电路,但其实在仿真器的底层,这些并行执行的语句是有先后顺序的,然而Verilog标准并没有将这些事件调度的顺序定死,而是给予了仿真器厂商一定的自由去实现自己的产品,这就导致了设计者如果不遵循一定的编程习惯,会导致意想不到的仿真结果,下面是一些相关的规则。

1、不要在两个及以上的always或initial结构中对同一个变量赋值

        当两个以上的过程结构同时执行时,它们之间的执行顺序是不一定的,Verilog标准只规定了在一个顺序块(begin end)中的所有语句是按照其先后顺序执行的,但并没有规定同一个时间执行的多个结构的执行顺序,下面举例详细说明。

//例1
`timescale 1ns/1ps
module test();initial $display("The initial_0 execute");initial $display("The initial_1 execute");initial $display("The initial_2 execute");
endmodule

        在上例中,三个initial结构在0ns时同时执行,仿真器执行他们的顺序是不定的,但测试表明,许多仿真器都选择顺序执行这三个initial结构,如下所示。

对于Mentor Modelsim SE,输出结果为
The initial_0 execute
The initial_1 execute
The initial_2 execute对于Aldec Riviera Pro,输出结果为
The initial_0 execute
The initial_1 execute
The initial_2 execute对于Cadence Xcelium,输出结果为
The initial_0 execute
The initial_1 execute
The initial_2 execute对于Mentor Questa,输出结果为
The initial_0 execute
The initial_1 execute
The initial_2 execute对于Synopsys VCS,输出结果为
The initial_0 execute
The initial_1 execute
The initial_2 execute对于Icarus Verilog,输出结果为
The initial_0 execute
The initial_1 execute
The initial_2 execute

         虽然看起来仿真器的行为都是一致的,但其实这只是一个巧合,下面的例子就体现出了各种仿真器对同一段代码之间的不同行为。

//例2
`timescale 1ns/1ps
module test();reg a;initial #5 a = 1;initial @(a) $display("The initial_0 execute");initial @(a) $display("The initial_1 execute");initial @(a) $display("The initial_2 execute");
endmodule

        这段代码的三个initial结构都对事件a敏感,所以在5ns时,三个initial结构同时被触发,而他们的执行顺序是不定的,如下所示。

对于Mentor Modelsim SE,输出结果为
The initial_2 execute
The initial_1 execute
The initial_0 execute对于Aldec Riviera Pro,输出结果为
The initial_0 execute
The initial_1 execute
The initial_2 execute对于Cadence Xcelium,输出结果为
The initial_0 execute
The initial_1 execute
The initial_2 execute对于Mentor Questa,输出结果为
The initial_2 execute
The initial_1 execute
The initial_0 execute对于Synopsys VCS,输出结果为
The initial_0 execute
The initial_1 execute
The initial_2 execut对于Icarus Verilog,输出结果为
The initial_2 execute
The initial_1 execute
The initial_0 execute

        下面的代码中仍然体现了同一时间的多个结构的执行顺序是不定的,即使触发这些结构的事件在同一时间是有前后关系的。

//例3
`timescale 1ns/1ps
module test();reg a, b, c;initial begin#5;a = 1;b = 1;c = 1;endalways @(a) $display("The initial_0 execute");always @(b) $display("The initial_1 execute");always @(c) $display("The initial_2 execute");
endmodule

        在5ns时,a、b、c先后被赋值为1,Verilog标准保证了begin end块中的赋值顺序从上到下。但由这些赋值语句触发的其他always结构呢?是否也会按照a、b、c的顺序执行呢?

对于Mentor Modelsim SE,输出结果为
The initial_2 execute
The initial_1 execute
The initial_0 execute对于Aldec Riviera Pro,输出结果为
The initial_0 execute
The initial_1 execute
The initial_2 execute对于Cadence Xcelium,输出结果为
The initial_0 execute
The initial_1 execute
The initial_2 execute对于Mentor Questa,输出结果为
The initial_2 execute
The initial_1 execute
The initial_0 execute对于Synopsys VCS,输出结果为
The initial_0 execute
The initial_1 execute
The initial_2 execut对于Icarus Verilog,输出结果为
The initial_0 execute
The initial_1 execute
The initial_2 execute

        依然可以注意到不同仿真器之间的差异,为什么不都是按照a赋值,always @(a)执行,b赋值,always @(b)执行,c赋值,always @(c)执行的顺序执行呢?还是那句话,Verilog标准只规定了一个顺序块(begin end)中的所有语句是按照其先后顺序执行的,并没有保证其他行为。当a赋值后,always @(a)被调度了,但他不一定会在b赋值之前执行,有可能在执行完b赋值、c赋值之后再来执行always @(a),此时always @(b)和always @(c)也应该在队列中,他们执行的先后顺序是标准没有保证的(但需要注意的是,最基本的调度者和被调度者的先后关系是无法改变的,即always @(a)一定在a赋值后,b、c亦然)。下面是一个经典的两个结构交错执行的例子。

//例4
`timescale 1ns/1ps
module test();reg a;wire b;initial begin#1;a = 1;#1;a = 0;$display("b is %b", b);endassign b = a;endmodule

         当时间来到1ns,a被赋值为1,同时触发assign结构,对b连续赋值为1。1ns后,a被更改为0,紧接着打印b的值,结果是1还是0呢?

对于Mentor Modelsim SE,输出结果为
b is 1对于Aldec Riviera Pro,输出结果为
b is 1对于Cadence Xcelium,输出结果为
b is 1对于Mentor Questa,输出结果为
b is 1对于Synopsys VCS,输出结果为
b is 0对于Icarus Verilog,输出结果为
b is 0

        上面的结果显示,仿真器可能在执行了a=0的赋值后立刻执行被调度的assign连续赋值,再返回initial结构执行显示语句,也可能继续执行下面的显示语句,再去执行被调度的assign连续赋值。

        这就给了我们一个启示,在改变了一个全组合逻辑的电路的输入后,紧接着显示输出,可能无法得到更新后的输出。一个更好的做法是给$display语句一定的延时,这样就能确保在执行$display前,连续赋值已经执行完毕,因为不同时间的语句执行是不会产生竞争的。

//例5
`timescale 1ns/1ps
module test();reg a;wire b;initial begin#1;a = 1;#1;a = 0;#0.01 $display("b is %b", b);endassign b = a;endmodule

http://www.yayakq.cn/news/165279/

相关文章:

  • 投资公司网站源码wordpress大全
  • 网站空间租赁合同高级经济师
  • html5手机网站实例还有什么类似建设通的网站
  • 培训网站建设学校免费网站引导页
  • 制作网站404页面个人网页设计论文的开题报告
  • 网站建设小程序公众号推广开发参考消息电子版在线阅读
  • 网站开发 原理人力资源公司简介模板
  • 建站用哪个模板好企业网站建设费用会计科目
  • 公司网站备案号青岛房产网官网网址
  • 学生管理系统网站wordpress 顶部菜单
  • wordpress 腾讯验证码低价自适应网站建设优化建站
  • 创建网站的软件wordpress d7
  • 申请号的网站重庆渝中区企业网站建设联系电话
  • 有哪些好的做兼职网站美食网站建设的栏目和模板
  • 济南市做网站公司qq空间刷赞推广网站
  • 网站意义html手机网站模板
  • pc网站建设新八建设集团网站
  • 做视频网站赚钱微信 html5 网站
  • 重庆网站建设狐灵科技wordpress写文章报错
  • 石家庄哪里做网站比较好企业宣传片报价明细
  • 购物网站设计流程图如何备份wordpress站点
  • 建设一个域名抢注的网站三门峡市建设局官方网站
  • 上传网站中ftp地址写什么wordpress外贸网站增加个博客栏
  • google seo网站 被k详情页设计思路遵循哪五个营销环节
  • 企业网站建设的目的论文wordpress单机版
  • 湘阴网站建设公关公司官网
  • 威海泰浩建设集团有限公司网站网页设计实验总结100字
  • 代刷网站搭建教程网上最好购物网站
  • 厦门图书馆网站建设四川建设考试网
  • 购买游戏软件做网站沈阳建设工程信息网查询