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的更多相关文章

  1. select count(*)和select count(1)

    一般情况下,Select Count (*)和Select Count(1)两着返回结果是一样的 假如表沒有主键(Primary key), 那么count(1)比count(*)快, 如果有主键的話 ...

  2. select count(*)和select count(1)的区别

    一般情况下,Select Count (*)和Select Count(1)两着返回结果是一样的 假如表沒有主键(Primary key), 那么count(1)比count(*)快, 如果有主键的話 ...

  3. 仅Firefox中A元素包含Select时点击Select不能选择option

    这是在使用京东的一个日期组件时碰到的bug,重现bug的代码精简如下 <!DOCTYPE HTML> <html> <head> <title> 仅Fi ...

  4. string strSQL = "Select * From Employees;Select * from Customers";执行两次查询

    SqlCommand对象的字符串SQL命令可以做多个,以查询为例,用到SqlDataReader的一些方法,如ExecuteReader(),Read()(一条命令内的移动至下一记录),NextRes ...

  5. select count(*)和select count(1)的区别 (转)

    A 一般情况下,Select Count (*)和Select Count(1)两着返回结果是一样的 假如表沒有主键(Primary key), 那么count(1)比count(*)快, 如果有主键 ...

  6. 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 ...

  7. 【SQL】INSERT INTO SELECT语句与SELECT INTO FROM语句

    INSERT INTO SELECT语句与SELECT INTO FROM语句,都是将一个结果集插入到一个表中: #INSERT INTO SELECT语句 1.语法形式: Insert into T ...

  8. Go语言规格说明书 之 select语句(Select statements)

    go version go1.11 windows/amd64 本文为阅读Go语言中文官网的规则说明书(https://golang.google.cn/ref/spec)而做的笔记,介绍Go语言的 ...

  9. 测试--错误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 ...

  10. select 1 与 select null (转)

    1.Select 1 在这里我主要讨论的有以下几个select 语句: table表是一个数据表,假设表的行数为10行,以下同. 1:select  1 from table 2:select cou ...

随机推荐

  1. 建站手册-浏览器信息:Netscape 浏览器

    ylbtech-建站手册-浏览器信息:Netscape 浏览器 1.返回顶部 1. http://www.w3school.com.cn/browsers/browsers_netscape.asp ...

  2. 2019 ACM-ICPC 南京 现场赛 H. Prince and Princess

    题意 王子想要娶公主,但是需要完成一个挑战:在一些房间中找出公主在哪. 每个房间有一个人,他们彼此知道谁在哪个房间.可以问他们三种问题: 你是谁? 在某个房间是谁? 公主在哪个房间? 有三类人,一类一 ...

  3. 洛谷 P1198 [JSOI2008]最大数——单调栈/线段树

    先上一波题目 https://www.luogu.org/problem/P1198 题目要求维护后缀最大值 以及在数列的最后面添加一个数 这道题呢我们有两种做法 1.单调栈 因为只需要维护后缀最大值 ...

  4. 关系型数据的分布式处理系统:Cobar

    Cobar简介 Cobar是关系型数据的分布式处理系统,它可以在分布式的环境下像传统数据库一样为您提供海量数据服务. Github:https://github.com/alibaba/cobar 整 ...

  5. Spring入门之生命周期

    好几日没有读东西了,今天本来要读mybatis原理部分,但是看到作者讲,只是学会用不用学那么深,遂直接开干spring,工作中一直用springboot,框架都是领导搭好的,每天的任务就是增删改查,挺 ...

  6. Oracle中常见的Hint(一)

    Oracle中的Hint可以用来调整SQL的执行计划,提高SQL执行效率.下面分类介绍Oracle数据库中常见的Hint.这里描述的是Oracle11gR2中的常见Hint,Oracle数据库中各个版 ...

  7. vue $attrs 父组件和孙子组件的传值,传函数

    上一篇我们说到provide/inject的依赖注入的传值方法,今天我们来说一下另一个父组件给孙子组件的传值方式$attrs 我们接着上一个例子继续来写 parent父组件 我们给child子组件穿了 ...

  8. Vue之自建管理后台(一)准备工作

    完成最基础的Vue环境及新建一个vue项目. 一般来说,我们拿到一个项目需求或者得到一个需求的时候,第一件应该做的事情不是立马坐在电脑前面去写代码,如果你这么做的,好吧...我只能暂时认定你为一个刚上 ...

  9. WiFi基础知识

    自从只需少量的话费就可以将笔记本.平板电脑连接到互联网,WiFi已成为我们熟知的网络,并无处不在.Wi-Fi对于一些物联网应用十分有用,比如楼宇自动化.内部能源管理.WiFi的重要性对于我们的日常生活 ...

  10. Ti 949 配置 948 i2c

    如果不想用 远端 slave,只访问948   选 i2c pass through all =1  :i2c pass through =0/1 0x0c 0x17 0x9e 如果想用远端  sla ...