这篇博文是上篇博文:【Verilog HDL 训练】第 12 天(数据通路)的指导规则。

对有符号数以及无符号数运算的一些指导规则。

注:英文为原文,中文为个人认为重要的总结。


1. Signed Arithmetic

• Rule: Use type 'signed' (VHDL, Verilog 2001) for signed/2's complement arithmetic (do not emulate signed arithmetic using unsigned operands/operations). Also, do not use the 'integer' type except for constant values.

对于有符号的补码算术使用类型‘signed’,同时除了常量值,其他都不要使用integer。

•  Example: Signed multiplication (Verilog)

2. Sign-/zero-extension

•  Rule: Do not manually sign-/zero-extend operands if possible. By using the appropriate unsigned/signed types correct extension is done in the following way:
VHDL: Use standard functions ('resize' in 'ieee.numeric_std', 'conv_*' in 'ieee.std_logic_arith').
Verilog: Extension is automatically done.

不要人为的进行符号或者零扩展操作;

Verilog中扩展自动完成。

3. Mixed unsigned/signed expression (Verilog)

•  Rule: Do not mix unsigned and signed types in one expression.

不要再一个表达式中混合使用有符号以及无符号类型。

4. Signed part-select / concatenation (Verilog)

•  Note: Part-select results are unsigned, regardless of the operands. Therefore, part-selects of signed vectors (for example, "a[6:0]" of "input signed [7:0] a") become unsigned, even if part-select specifies the entire vector (for example, "a[7:0]" of "input signed [7:0] a").

无论什么操作,部分选择后是无符号的。因此对于有符号的向量,部分选择后也是无符号的。

•  Note: Concatenation results are unsigned, regardless of the operands.

连接也是如此。

5. Expression widths (Verilog)

•  Note: The width of an expression in Verilog is determined as followed:
o Context-determined expression: In an assignment, the left-hand side provides the context that determines the width of the right-hand side expression (that is, the expression has the width of the vector it is assigned to).

也就是说,表达式有它所赋值的向量的宽度。

o Self-determined expression: Expressions without context (for example, expressions in parenthesis) determine their width from the operand widths. For arithmetic operations, the width of a self-determined expression is the width of the widest operand.

自定义表达式:没有上下文的表达式(例如括号中的表达式)从操作数宽度确定它们的宽度。对于算术运算,自定义表达式的宽度是最宽操作数的宽度。

o Special cases: Some expressions are not self-determined even though they appear to be. The expression then takes the width of the higher-level context (for example, left-hand side of an assignment).
Example: Concatenation expression (Verilog).

•  Rule: Avoid using self-determined expressions. Use intermediate signals and additional assignments to make widths of arithmetic expressions unambiguous (context-determined expressions).



Guidelines for QoR

更多规则参考:Coding Guidelines for Datapath Synthesis

算术运算的RTL代码规则总结相关推荐

  1. Verilog RTL代码设计规范简单整理总结

    目录 1宗旨 2 IP的RTL设计文件的建立 3 TOP集成的设计文件的建立 4 文件头 5 宏定义 6 端口定义 6.1 IP设计中的端口定义 6.2 TOP集成中的端口定义 7 TOP模块的集成 ...

  2. 用PlanAhead进行RTL代码开发与分析

    用PlanAhead进行RTL代码开发与分析 这里介绍如何用PlanAhead进行RTL代码开发与分析.需要说明一点,本章所用的所有实例都可以在PlanAhead的安装目录E:\Xilinx\11.1 ...

  3. SonarQube中配置c语言/c++语言代码规则插件

    文章目录 一.下载+安装+重新启动 1. 下载文件 2.安装 3. 重新启动SonarQube 4. SonarQube管控台验证 二.SonarQube管控台配置 2.1. 创建配置模板 2.2. ...

  4. 5大代码规则,守护程序猿世界的爱与和平!

    全文共2878字,预计学习时长9分钟 图源:Unsplash 编码规则是程序编码所要遵循的规则,要注意代码的正确性.稳定性.可读性. 而对于这些条条框框,一些不拘小节的程序猿们往往并不在意,这导致常常 ...

  5. Gitlab Custom_hooks集代码规则注释校验脚本(pre-receive)

    #!/bin/bash##脚本提供功能:Commit提交的Message和代码规范是否符合统一规范 ##分三个部分: # 1.变量定义部分 # 2.校验部分:注释校验&代码分析 # 3.初始化 ...

  6. 单元测试系列之九:Sonar 常用代码规则整理(一)

    更多原创测试技术文章同步更新到微信公众号 :三国测,敬请扫码关注个人的微信号,感谢! 摘要:公司部署了一套sonar,经过一段时间运行,发现有一些问题出现频率很高,因此有必要将这些问题进行整理总结和分 ...

  7. FPGA(五)RTL代码之一(跨时钟域设计)

    文章目录 前言 一.异步FIFO 二.异步复位同步释放 三.两级触发器同步 四.握手CDC设计 五.异步双口RAM 总结 前言 这不马上要面试了嘛,有些慌!HDLbits的题目已经刷完了,但又知道自己 ...

  8. FPGA(九)RTL代码之五(基本电路设计2)

    系列文章目录 FPGA(四)数字IC面试的四个基本问题 FPGA(五)RTL代码之一(跨时钟域设计) FPGA(六)RTL代码之二(复杂电路设计1) FPGA(七)RTL代码之三(复杂电路设计2) F ...

  9. matlab生成代码veri,一种自动生成状态机RTL代码的方法

    1 引言 电子设计自动化(Electronic Design Automatic,EDA),在集成电路设计中扮演了重要的角色,无论前端还是后端设计都需要熟练掌握和使用各种EDA工具,现今EDA软件主要 ...

最新文章

  1. 打破欧美垄断,国防科大斩获“航天界奥林匹克”大赛首冠
  2. node.js path
  3. flutter 局部状态和全局状态区别_Flutter状态管理
  4. BZOJ1036 (其实这只是一份板子)
  5. 生生世世 —— schedule 的轮回(七)
  6. C# DateTime.Compare判断两个DateTime 日期是否相等
  7. 作者: ​李国杰,中国工程院院士。现任中国科学院计算技术所首席科学家,国家信息化专家咨询委员会信息技术与新兴产业专委会副主任。...
  8. u盘启动pxe安装linux,U盘启动安装centos5.5+centos6.3+PXE网络安装CentOS
  9. stm32核心板可以点亮灯吗_利用STM32F103C8T6最小系统板点亮流水灯
  10. 答网友问:如何按月进行统计公司采购进货、销售出库信息?
  11. SpringBoot整合RabbitMQ之Topic Exchange通配符交换机(学习总结)
  12. 常用激活函数(激励函数)理解与总结
  13. 数据可视化--基于excel表格数据生成柱状图
  14. jQuery下载及基本使用
  15. 驱动开发:Win10内核枚举SSDT表基址
  16. 2019互联网BATJ等大厂中秋礼盒大PK
  17. 使用HTML Purifier防止xss攻击
  18. 使用Flutter开发Github客户端及学习历程的小结
  19. 魅族容器云平台基于Kubernetes自动化运维实践
  20. 计算机教师格言座右铭,教师教育格言座右铭

热门文章

  1. NOP 指令作用[转]
  2. Google要推输入法 是战略布局还是战术需要?
  3. 时间字段 oracle 经验 设计,数据库设计与优化
  4. oracle ohs是什么,怎么更改OHS端口为80
  5. assign深拷贝_经典前端面试题: Object.assign 是浅拷贝还是深拷贝?实现深拷贝的方法有哪些?...
  6. 三星s8自带测试硬件软件,三星S8手机国行固件开启测试:或支持桌面级操作体验...
  7. 一加7充电_夜话丨一加7超级快充明天见
  8. 将获取到的JSONObject和JSONArray转换为实体对象
  9. 2021年人工神经网络第四次作业要求:第七题
  10. 基于USR-WiFi模块的 ESP32,ESP8266 Thonny调试器