conditional statement

case statement

1. conditional statement

    if(expression)

        statement_or_null[else statement_or_null]

    | if_else_if_statement

If the expression evaluates to true(that is ,has a nonzero know value),the first statement shall be executed.

If it evaluates to flase(that is ,has a zero value or the value is x or z) , the first statement shall not execute.

If there is an else statement and expression is false , the else statement shall be executed.

  if-else-if construct(mutiway decision statement)

      The expression shall be evaluated in order.If any expression is true,the statement associated with it shall be executed,and this shall terminate the whole chain.

  Each statement is either a single statement or a block of statement.

2.case statement(multiway decision statement)

   The case expression given in parentheses shall be evaluated exactly once and before any of the case item expression.

   The case item expressions shall be evaluated and compared in the exactly order in which they are given.

   If there is a default case item, it is ignored during this linear search.

   During the linear search , if one of the case item shall be executed, and the linear search shall terminate.

   If all comparisions fail and the default item is given,then the default item statement shall be executed .

  If the default statement is not given and all of the comparision fail, then none of the case item statements shall be executed.

    linear search ??

  The case statement differs from the multiway if-else-if construct in two important ways:

   a) The condition expression in the if-else-if construct are more general than comparing one expression with several others,as in the case statement.

  b)  The case statement provides a definitive result when there are x and z values in an expression.

         In a case expression comparison,the comparison only succeeds when each bit mathes exactly with respect to the valule 0 、 1、x and z.

         As a consequence, care is needed in  specifying the expression in the case statement.

         The bit length of all the expression shall be equal so that exact bitwise matching can be performed.

         The length of all the case item expressions as well as the case expression in the parentheses,shall be made equal to the length of the longest case expression and case item expression.

         If any of these expression is unsigned , then all of them shall be treated as unsigned.

         If all of these expressions are signed, then they shall be treated as signed.

3.casex / casez --dont care

   case x --- treats x /z as do-not-care condition

   case z ---treats z as do-not-care condition

   allows the use of mark(?) in place of z it these case statements(可以用来实现具有优先级的分支选择类似if-else-if)

   eg:

        reg [7:0] ir;

        casez(ir)

           8'b1???????:instruction(ir);

           8'b01??????:instruction(ir);

           8'b001?????:instruction(ir);

           8'b0001????:instruction(ir);

           8'b00001???:instruction(ir);

      endcase

      constant expression in case statement(也可以实现priority,觉得相比于 mark(?)实现priority,这个更好 )

       reg [2:0] encode;

       case(1)

          encode[2]: $display("Select line 2");

          encode[1]:$display("Select line 1");

          encode[0]:$display("Select line 0");

          default $display("Error:one of the bits expected ON");

         endcase

verilog behavioral modeling--branch statement的更多相关文章

  1. verilog behavioral modeling --loop statement

    1.forever 2.repeat 3.while 4.for The for statement accomplishes the same results as the following ps ...

  2. verilog behavioral modeling ---Block statements

    block statements : 1. sequential block  : begin-end block 2.parallel block       :  fork - join bloc ...

  3. verilog behavioral modeling --procedural assignments

    1.procedural assignments are used for updating reg ,integer , time ,real,realtime and memory data ty ...

  4. verilog behavioral modeling--overview

    1.verilog behavioral models contain procedural statements that control the simulation and manipulate ...

  5. verilog behaviral modeling -- procedural timing contronls

    1.delay control : an expression specifies the time duration between initially encountering the state ...

  6. verilog behavioral modeling--procedural continous assignment(不用)

    assign / deassgin force /release the procedural continuous assignments(using keywords assign and for ...

  7. verilog behavioral modeling--blocking and nonblocking

                                                                                                 BLOCKIN ...

  8. verilog behavioral modeling--sequential and parallel statements

    1.Sequential statement groups the begin-end keywords: .group several statements togethor .cause the ...

  9. verilog FAQ(zz)

    1. What is the race condition in verilog? Ans :The situation when two expressions are allowed to exe ...

随机推荐

  1. AngularJS - 入门小Demo

    AngularJS四大特效 MVC模式.模块化设计.自动化双向数据绑定.依赖注入 如果了解了后端开发知识,想必对这些词汇不会陌生,AngularJS融合了后端开发的一些思想,虽然身为前端框架,但与jQ ...

  2. django_uWSGI+nginx环境

    1 uWSGI 作用 Django 默认使用的是 Python 自带的 simple HTTPServer 提供web服务的,在安全性和效率上都是不行的,只能用作django开发测试. WSGI是一个 ...

  3. 根据select中选定option触发不同事件

    做公司项目,要实现一个小需求,根据下拉框选定的数据,绑定不同的事件.我的思路是获取select下面的option值,然后给它们定义不同的点击事件,但是在使用中option不能添加类,同时没有click ...

  4. python之错题巩固

    .#把班级学⽣数学考试成绩录⼊到⼀个列表中: 并求平均值. 要求: 录⼊的时候 # 要带着⼈名录⼊, 例如: 张三_44 li = [] : str_input = input('请输入你的姓名和分数 ...

  5. python入门之数据类型之列表、元组、字典

    list 格式: test_list = ["a",123,[1,"b"]] 索引: >>>print(test_list[0]) " ...

  6. CocoaPods 提交自己的库

    今想把自己写的一个view提交到CocoaPods时候,突然发现pull request被拒了,原来从去年开始就改用trunk了... 网上那些folk 在提交的pull request的教程都不可用 ...

  7. JavaScript单元测试框架:Jasmine

    摘抄:http://blog.csdn.net/GuoJiangweigege/article/details/52130589 互联网的快速发展,给web开发人员带来了前所未有的挑战.对于前端开发, ...

  8. if __FILE__ == $0 end

    if __FILE__ == $0 end __FILE__是一个“具有魔力”的变量,它代表了当前文件名.$0是用于启动程序的文件名.那么代码“if __FILE__ == $0”便意味着检查此文件是 ...

  9. 如何尽量避免引用jQuery

    Introduction 正如jQuery所宣称的一样,Write Less, Do More.很多时候我们喜欢用它来解决问题.但增加一个库必然意味着更大的网络负担,意味着更高的页面初始载入时间.并且 ...

  10. hihocoder1822 战舰日常任务

    思路: 使用堆即可. 实现: #include <iostream> #include <map> #include <vector> #include <c ...