verilog behavioral modeling--branch statement
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的更多相关文章
- verilog behavioral modeling --loop statement
1.forever 2.repeat 3.while 4.for The for statement accomplishes the same results as the following ps ...
- verilog behavioral modeling ---Block statements
block statements : 1. sequential block : begin-end block 2.parallel block : fork - join bloc ...
- verilog behavioral modeling --procedural assignments
1.procedural assignments are used for updating reg ,integer , time ,real,realtime and memory data ty ...
- verilog behavioral modeling--overview
1.verilog behavioral models contain procedural statements that control the simulation and manipulate ...
- verilog behaviral modeling -- procedural timing contronls
1.delay control : an expression specifies the time duration between initially encountering the state ...
- verilog behavioral modeling--procedural continous assignment(不用)
assign / deassgin force /release the procedural continuous assignments(using keywords assign and for ...
- verilog behavioral modeling--blocking and nonblocking
BLOCKIN ...
- verilog behavioral modeling--sequential and parallel statements
1.Sequential statement groups the begin-end keywords: .group several statements togethor .cause the ...
- verilog FAQ(zz)
1. What is the race condition in verilog? Ans :The situation when two expressions are allowed to exe ...
随机推荐
- Jquery | 基础 | .hover()
https://api.jquery.com/hover/#hover-handlerIn-handlerOut http://jquery.cuishifeng.cn/hover.html
- 使用JMeter上传文件
使用JMeter录制文件上载 创建JMeter测试计划的最简单方法是使用HTTP(s)测试脚本记录器记录相应的请求.JMeter充当代理服务器,捕获Web浏览器与被测应用程序(AUT)之间的所有流量, ...
- Metasploits之Adobe阅读器漏洞
实验环境:Kali 2.0+Windows XP+Adobe Reader 9.3.0 类别:缓冲区溢出 描述:这个漏洞针对Adobe阅读器9.3.4之前的版本,一个名为SING表对象中一个名为uni ...
- [在读] javascript权威指南第六版
耽搁了有大半年没看,记得当时看到5分之2了吧.权威指南是不管读几遍都能觉得有新收获的书^^
- Unix高级编程之文件权限
1.访问权限表 st_mode 意义 S_IRUSR 用户-读 S_IWUSR 用户-写 S_IXUSR 用户-执行 S_IRGRP 组-读 S_IWGRP 组-写 S_IXGRP 组-执行 S_IR ...
- MDX之百分比
MDX的几种百分比的计算方法 实际应用中,特别是一些分析报表,经常需要计算数据百分比.份额.平均值.累计占比等,在数据仓库飞速发展的今天,我们需要了解一些经常编写的MDX语句的写法,以满足工作中的需要 ...
- Spark Mllib里如何删除每一条数据中所有的双引号“”(图文详解)
不多说,直接上干货! 具体,见 Hadoop+Spark大数据巨量分析与机器学习整合开发实战的第13章 使用决策树二元分类算法来预测分类StumbleUpon数据集
- 实战:mysql写存储过程并定时调用
有表:cap_meter_detail 字段:recordtime 情景:recordtime每半个小时记录一次,故一天会产生很很多数据,我们要做的是,每天00:00:00对cap_meter_det ...
- 我的NopCommerce之旅(3): 系统代码结构分析
一.概述 基于MVC 二.详细描述 \Libraries\Nop.Core 核心类,包括缓存.事件.帮助类.业务对象(订单.客户实体) \Libraries\Nop.Data 数据访问层,采用Enti ...
- jquery中each的3种遍历方法
1.选择器+遍历 $('div').each(function (i){ i就是索引值 this 表示获取遍历每一个dom对象 }); 2.选择器+遍历 $('div').each(function ...