4.2.1 Vector bit-select and part-select addressing
Frm:IEEE Std 1364™-2001, IEEE Standard Verilog® Hardware Description Language
Bit-selects extract a particular bit from a vector net, vector reg, integer variable, or time variable. The bit can be addressed using an expression. If the bit-select is out of the address bounds or the bit-select is x or z, then the value returned by the reference shall be x. The bit-select or part-select of a variable declared as real or realtime shall be considered illegal.
Several contiguous bits in a vector net, vector reg, integer variable, or time variable can be addressed and are known as part-selects. There are two types of part-selects, a constant part-select and an indexed part-select.
A constant part-select of a vector reg or net is given with the following syntax:
vect[msb_expr:lsb_expr]
Both expressions shall be constant expressions. The first expression has to address a more significant bit than the second expression. If the part-select is out of the address bounds or the part-select is x or z, then the value returned by the reference shall be x.
An indexed part select of a vector net, vector reg, integer variable, or time variable is given with the following syntax:
reg [:] big_vect;
reg [:] little_vect; big_vect[lsb_base_expr +: width_expr]
little_vect[msb_base_expr +: width_expr] big_vect[msb_base_expr -: width_expr]
little_vect[lsb_base_expr -: width_expr]
The width_expr shall be a constant expression. It also shall not be affected by run-time parameter assignments. The lsb_base_expr and msb_base_expr can vary at run-time. The first two examples select bits starting at the base and ascending the bit range. The number of bits selected is equal to the width expression. The second two examples select bits starting at the base and descending the bit range. Part-selects that address a range of bits that are completely out of the address bounds of the net, reg, integer, or time, or when the part-select is x or z, shall yield the value x when read, and shall have no effect on the data stored when written.
Part-selects that are partially out of range shall when read return x for the bits that are out of range, and when written shall only affect the bits that are in range.
Examples:
module top;
`timescale 10ns/1ns reg [:] big_vect = 'h12345678;
reg [:] little_vect = 'h87654321;
reg [:] dword; integer sel;
initial
begin
# $display("1. big_vect = 0x%h, big_vect[0 +:8] is %h, and big_vect[7 -:8] is %h ", big_vect, big_vect[ +:], big_vect[ -:] ); if ( big_vect[ +:] == big_vect[ : ])begin $display(" big_vect[0 +:8] == big_vect[7 : 0]"); end
if (little_vect[ +:] == little_vect[ : ])begin $display("little_vect[0 +:8] == little_vect[0 : 7]"); end
if ( big_vect[ -:] == big_vect[ : ])begin $display(" big_vect[15 -:8] == big_vect[15 : 8]"); end
if (little_vect[ -:] == little_vect[ :])begin $display("little_vect[15 -:8] == little_vect[8 :15]"); end
if (sel > && sel < ) dword[*sel +:] = big_vect[:]; // Replace the byte selected. // 注意: big_vect[0:7] 引用错误,同理little_vect[15:8] 也是引用错误。
// if ( big_vect[0 +:8] == big_vect[0 : 7])begin end end endmodule
output:
# . big_vect = 0x12345678, big_vect[ +:] is , and big_vect[ -:] is
# big_vect[ +:] == big_vect[ : ]
# little_vect[ +:] == little_vect[ : ]
# big_vect[ -:] == big_vect[ : ]
# little_vect[ -:] == little_vect[ :]
4.2.1 Vector bit-select and part-select addressing的更多相关文章
- select count(*)和select count(1)
一般情况下,Select Count (*)和Select Count(1)两着返回结果是一样的 假如表沒有主键(Primary key), 那么count(1)比count(*)快, 如果有主键的話 ...
- select count(*)和select count(1)的区别
一般情况下,Select Count (*)和Select Count(1)两着返回结果是一样的 假如表沒有主键(Primary key), 那么count(1)比count(*)快, 如果有主键的話 ...
- 仅Firefox中A元素包含Select时点击Select不能选择option
这是在使用京东的一个日期组件时碰到的bug,重现bug的代码精简如下 <!DOCTYPE HTML> <html> <head> <title> 仅Fi ...
- string strSQL = "Select * From Employees;Select * from Customers";执行两次查询
SqlCommand对象的字符串SQL命令可以做多个,以查询为例,用到SqlDataReader的一些方法,如ExecuteReader(),Read()(一条命令内的移动至下一记录),NextRes ...
- select count(*)和select count(1)的区别 (转)
A 一般情况下,Select Count (*)和Select Count(1)两着返回结果是一样的 假如表沒有主键(Primary key), 那么count(1)比count(*)快, 如果有主键 ...
- 8.2.1.1 Speed of SELECT Statements 加速SELECT 语句
8.2.1 Optimizing SELECT Statements 8.2.2 Optimizing Data Change Statements 8.2.3 Optimizing Database ...
- 【SQL】INSERT INTO SELECT语句与SELECT INTO FROM语句
INSERT INTO SELECT语句与SELECT INTO FROM语句,都是将一个结果集插入到一个表中: #INSERT INTO SELECT语句 1.语法形式: Insert into T ...
- Go语言规格说明书 之 select语句(Select statements)
go version go1.11 windows/amd64 本文为阅读Go语言中文官网的规则说明书(https://golang.google.cn/ref/spec)而做的笔记,介绍Go语言的 ...
- 测试--错误java.lang.Exception: No tests found matching [{ExactMatcher:fDisplayName=select], {ExactMatcher:fDisplayName=select(com.rjj.demo.DemoApplicationTests)]...
异常这个错误java.lang.Exception: No tests found matching [{ExactMatcher:fDisplayName=select], {ExactMatche ...
- select 1 与 select null (转)
1.Select 1 在这里我主要讨论的有以下几个select 语句: table表是一个数据表,假设表的行数为10行,以下同. 1:select 1 from table 2:select cou ...
随机推荐
- java中子类继承父类程序执行顺序
java中子类继承父类程序执行顺序 FatherTest.java public class FatherTest { private String name; public FatherTest() ...
- Java核心基础知识(一):概念、语法、使用、源码
1. Java中OOP的特点? OOP(Object Oriented Programming):面向对象编程.具有封装.继承.多态三大特征. 封装:解决数据安全性问题: 继承:解决代码的重用性问题: ...
- 5.如何使用jmeter参数话
参数化:简单的来理解一下,我们录制了一个脚本,这个脚本中有登录操作,需要输入用户名和密码,假如系统不允许相同的用户名和密码同时登录,或者更好的模拟多个用户来登录系统.这个时候就需要对用户名和密码进行参 ...
- Linux 登录、注销与关机
Linux 登录.注销与关机 这里主要学习的是命令行环境下的相关操作. 一.登录 Linux 默认的情况下会提供六个终端来让用户登录,切换的方式为使用:[Ctrl + Alt + F1 ~ F6]的组 ...
- ANdroid手机屏幕反横向等参数设定
经过我一番百度和看Android文档,我才发现,Android对旋转屏,特别是只有横屏或者竖屏虽重力旋转的支持是到Android4.3.1才有完美支持的 unspecified - 默认值,由系统选择 ...
- js取整 - 优雅版(装逼必备)
var a = 2.98; var z1 = ~~a; var z2 = a | 0; var z3 = a>>0; console.log(z1, z2, z3); // 2, ...
- windows线程函数必须为全局函数或者静态函数(转)
调用CreateThread(...)创建线程时要指定所创建线程的入口函数,此入口函数只能是全局函数或者类的静态成员函数. 全局函数很容易理解,但如果是类的成员函数则必须是静态成员函数,为何, 因为类 ...
- hbuilder 配置app为沉浸式状态栏
- 1.隐藏继承的成员new / 虚方法(override)/ abstract / 多态 ----- 重写
总结: 1. 在继承上, new/override没区别 2. 在多态上,new不支持多态,override支持 在C#中改变类中相同名称的方法的实现过程中有三种方式:重载.重写和覆盖. 重载:指具有 ...
- 57. Collections(list的工具类)、Arrays(数组的工具类)
List集合的工具类(Collections): 注意:Collection是单列集合的根接口 Collections是操作集合对象的工具类 1.对list集合排序: sort(List) 根据自然 ...