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. wrtnode板

    Arduino技术交流:www.openjumper.com QQ群 ArduinoCN I  : 180646674,ArduinoCN II : 203870250 商品详情 产品介绍 : WRT ...

  2. java 11 已移除 javax.xml.bind

    @SneakyThrows public static <T> String convertToXml(T obj) { require(obj); JAXBContext jaxbCon ...

  3. (54) C# 调用 kernel32.dll

    https://www.cnblogs.com/cwy173/archive/2010/10/02/1841321.html Kernel32 API AddAtom 向本地原子表添加一个字符串 Al ...

  4. layui.form小例子

    layui.form小例子 需要引入layui的包 <!doctype html> <html> <head> <meta charset="utf ...

  5. 修改Mysql procedure,function and view definer

    1 一次性修改遇到错误 update mysql.proc set definer='root@%'; update mysql.proc set definer='root@%'; ERROR 10 ...

  6. interleave two text files with specified lines

    a_file=$1 a_step=$2 b_file=$3 b_step=$4 a_start=1 let a_end=$a_start+$a_step b_start=1 let b_end=$b_ ...

  7. Intellij IDEA 安装Scala插件 + 创建Scala项目

    一.IDEA  2018 Ultimate edition (旗舰破解版下载地址) 百度网盘地址:https://pan.baidu.com/s/1d9ArRH6adhDUGiJvRqnZMw 二.I ...

  8. 运维 05 Shell基本命令

    Shell基本命令   前言 前面咱们已经成功安装了Linux系统--centos7,那么现在跟着超哥奔向Linux的大门. Linux命令行的组成结构 [root@oldboy_python ~]# ...

  9. upc组队赛6 Odd Gnome【枚举】

    Odd Gnome 题目描述 According to the legend of Wizardry and Witchcraft, gnomes live in burrows undergroun ...

  10. 高博SLAM14讲 ch5 点云拼接例程实现与bug处理

    一.环境配置,基本库的安装 1.Eigen库 apt-get 安装 2.sophus库 apt-get 安装 3.pcl 点云库 (1)官方预编译版本 sudo apt-get install lib ...