https://mp.weixin.qq.com/s/rI-CJM6GyI6EUHPZ3uYiFg

 
如同Verilog中的众多运算符,Chisel也针对自身的数据类型,提供了很多运算符。
 
Chisel语言内嵌于Scala。在Scala中,基本上所有的运算符都被当做一般的字符,可以作为命名符号(identifier)的一部分。并且Scala支持省略函数调用时,括在参数两边的括号。所以Scala中定义运算符重载很简单,可以很大的提高代码的可读性。
 
 
1. 运算符
 
参考链接:
 
a. Bitwise operators
 
 
~ & | ^ 这些其实都是方法名,如:
 
b. Bitwise reductions
 
 
c. Equality comparison.
 
 
d. Shifts
 
 
e. Bitfield manipulation
 
 
f. Logical Operations
 
 
g. Arithmetic operations
 
 
h. Arithmetic comparisons
 
 
2. 位宽推断
 
两个相同类型但位宽不同的变量,也可以进行运算。运算参数以及运算结果的位宽会进行自动推断拓展。
 
参考链接:
 
 
Chisel provides bit width inference to reduce design effort. Users are encouraged to manually specify widths of ports and registers to prevent any surprises, but otherwise unspecified widths will be inferred by the Firrtl compiler.
For all circuit components declared with unspecified widths, the FIRRTL compiler will infer the minimum possible width that maintains the legality of all its incoming connections. Implicit here is that inference is done in a right to left fashion in the sense of an assignment statement in chisel, i.e. from the left hand side from the right hand side. If a component has no incoming connections, and the width is unspecified, then an error is thrown to indicate that the width could not be inferred.
For module input ports with unspecified widths, the inferred width is the minimum possible width that maintains the legality of all incoming connections to all instantiations of the module. The width of a ground-typed multiplexor expression is the maximum of its two corresponding input widths. For multiplexing aggregate-typed expressions, the resulting widths of each leaf subelement is the maximum of its corresponding two input leaf subelement widths. The width of a conditionally valid expression is the width of its input expression. For the full formal description see the Firrtl Spec.

Chisel3 - 运算符和位宽推断的更多相关文章

  1. system verilog中的类型转换(type casting)、位宽转换(size casting)和符号转换(sign casting)

    类型转换 verilog中,任何类型的任何数值都用来给任何类型赋值.verilog使用赋值语句自动将一种类型的数值转换为另一种类型. 例如,当一个wire类型赋值给一个reg类型的变量时,wire类型 ...

  2. swift:高级运算符(位运算符、溢出运算符、优先级和结合性、运算符重载函数)

    swift:高级运算符 http://www.cocoachina.com/ios/20140612/8794.html 除了基本操作符中所讲的运算符,Swift还有许多复杂的高级运算符,包括了C语和 ...

  3. FPGA位宽的转换和定义

    数字表达式的定义<位宽><进制><数字>,这是一种全面的描述方式 例如:如果我要定义一个变量counter = 5000 0000 ,10进制数:那么他的位宽应该是 ...

  4. MySQL----数据的显示位宽

    问题:在MySQL表中的列可以定义它显示的位宽.那么定义了位宽会不会影响数据的取值范围呢? 测试: 1.定义一个用于测试的表 create table t(x int,y int(2),z int(2 ...

  5. 外设位宽为8、16、32时,CPU与外设之间地址线的连接方法

    有不少人问到:flash连接CPU时,根据不同的数据宽度,比如16位的NOR FLASH (A0-A19),处理器的地址线要(A1-A20)左移偏1位.为什么要偏1位? (全文有点晦涩,建议收藏本文对 ...

  6. Verilog中变量位宽注意

    Verilog中,变量定义方式可以为:reg[位宽-1:0] 数据名:reg[位宽:1] 数据名.其他变量也类似. 以reg变量cnt为例,当cnt位宽为4时,可定义为reg[3:0] cnt,或者定 ...

  7. FPGA设计千兆以太网MAC(3)——数据缓存及位宽转换模块设计与验证

    本文设计思想采用明德扬至简设计法.上一篇博文中定制了自定义MAC IP的结构,在用户侧需要位宽转换及数据缓存.本文以TX方向为例,设计并验证发送缓存模块.这里定义该模块可缓存4个最大长度数据包,用户根 ...

  8. 【设计经验】3、ISE中烧录QSPI Flash以及配置mcs文件的加载速度与传输位宽

    一.软件与硬件平台 软件平台: 操作系统:Windows 7 64-bit 开发套件:ISE14.7 硬件平台: FPGA型号:XC6SLX45-CSG324 QSPI Flash型号:W25Q128 ...

  9. Verilog定义计算位宽的函数clogb2

    在很多情况下要计算输入输出的位宽,比如你写一个8*8的ram,那么地址需要三位去表示,那么这个函数的方便就体现出来了,你需要使用函数定义就好了,如果对于多文件可以包含定义的文件: 如果你的DEPTH是 ...

随机推荐

  1. Kafka 的一些知识点整理【1】

    First: Kafka 是什么? Kafka 是一个发布订阅系统 最初是是LinkedIn 开发 最后交给Apache 开源组织 github地址:https://github.com/apache ...

  2. Scrapy模块使用出错,出现builtins.ImportError: DLL load failed: 找不到指定的程序

    问题描述:初次学习scrapy,使用scrapy官方文档创建爬虫项目出错, 出现builtins.ImportError: DLL load failed: 找不到指定的程序, ImportError ...

  3. shell 条件结构之 if 语句使用总结

    文章目录 #条件判断的格式 [ exp ] [[ exp ]] test exp 注意: exp 与 "["."]"括号之间必须要有空格,否则会报语法错误: [ ...

  4. ubuntu文件系统修改( for arm)

    系统:ubuntu14.04 镜像:ubuntu-rootfs.img for aarch64 创建一个文件夹 ubuntu-mount mkdir ubuntu-mount 将ubuntu-root ...

  5. QtCreator MSVC 搭建 Debugger

    QtCreatorForWindows搭建Debugger QtCreator for windows选择mingw或者msvc: qt-opensource-windows-x86-msvc2015 ...

  6. [poj2778 DNA Sequence]AC自动机,矩阵快速幂

    题意:给一些字符串的集合S和整数n,求满足 长度为n 只含charset = {'A'.'T‘.'G'.'C'}包含的字符 不包含S中任一字符串 的字符串的种类数. 思路:首先对S建立ac自动机,考虑 ...

  7. [zoj3813]Alternating Sum 公式化简,线段树

    题意:给一个长度不超过100000的原串S(只包含数字0-9),令T为将S重复若干次首尾连接后得到的新串,有两种操作:(1)修改原串S某个位置的值(2)给定L,R,询问T中L<=i<=j& ...

  8. 微信小程序云开发|Error: ResourceNotFound.FunctionName, FunctionName 指定的资源不存在。 (41cd9de8-ff9b-4b1e-a65e-81ae9

    今天在上传云函数部署的时候老发现上传login 失败   ... 经过查阅资料有两种方法可行: 云函数上传后不要轻易删除!!! 1.重启客户端 2.最好的解决方法在云平台开发创建一个新的云函数覆盖就o ...

  9. java ->网络通信协议(UDP协议、TCP协议)

    网络通信协议 通过计算机网络可以使多台计算机实现连接,位于同一个网络中的计算机在进行连接和通信时需要遵守一定的规则,这就好比在道路中行驶的汽车一定要遵守交通规则一样.在计算机网络中,这些连接和通信的规 ...

  10. python--集合和文件基本操作

    集合 # 集合天生就能去重,集合也是无序的  集合也是{ }  但是空集合定义特殊s=set()  #空集合s2 = set('1234445566778')print(s2) s3 = {'1',' ...