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 ...
随机推荐
- PyInstaller 库
将.py 源代码转换成无需源代码的可执行文件 首先,PyInstaller是第三方库,需要下载额外安装(安装第三方库需要使用pip工具) 步骤: 1.用管理员运行cmd命令行 "pip in ...
- Tomcat - 怎么控制某个类或者包下的日志打印级别
问题与分析 Tomcat是使用自己的日志实现tomcat-juli.jar来打印日志信息的,日志会被打印到catalina.out里,除去你在项目里自己使用的日志框架外,由System.out,Sys ...
- Windows类标识符及其妙用
Windows类标识符 百度百科这样解释: Windows的类标识符class identifier也称为CLASSID或CLSID,是与某一个类对象相联系的唯一标记(UUID).一个准备创建多个对象 ...
- Django (七) token&静态文件&媒体文件
token&静态文件&媒体文件 1. token 1. 会话技术 2. 服务端会话技术 3. 它实际上就是手动实现的session 4. 实现token 4.1 在models.py中 ...
- Codeforces 1132D(二分模拟)
要点 二分显然,关键在于怎么判断 题解方法:开k个队列代表每个时间有哪些电脑会挂掉,这部分O(n)预处理一下,之后扫一遍时间,每个时间点贪心选取最靠前的会挂的电脑未雨绸缪给它充电,然后看看充电以后要不 ...
- POJ-3275:Ranking the Cows(Floyd、bitset)
Ranking the Cows Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 3301 Accepted: 1511 ...
- Crusher Django 学习笔记2 基本url配置
http://crusher-milling.blogspot.com/2013/09/crusher-django-tutorial2-conf-basic-url.html 顺便学习一下FQ Cr ...
- ubuntu下sublime屏蔽alt键显示顶部菜单栏
在sulime下喜欢把方向键映的上下左右映射为alt+i/k/j/l ,按单词移动alt+h/; 但是在ubuntu下按alt会弹出sublime的顶部菜单栏,如果想屏蔽sublime按alt屏蔽菜单 ...
- How many '1's are there题解
Description: Description: 第一行输入数字n(n<=50),表示有n组测试用例,第2到第n+1行每行输入数m(m为整数),统计并输出m用二进制表示时,1的个数. 例如:m ...
- Spring 配置定时器(注解+xml)方式—整理
一.注解方式 1. 在Spring的配置文件ApplicationContext.xml,首先添加命名空间 xmlns:task="http://www.springframework.or ...