当前位置: 首页 > news >正文

vivado $clog2函数

对于.v文件在vivado中是不支持,但是可以修改为.sv或更改文件属性使用sytemverilog来支持。

 /*** Math function: $clog2 as specified in Verilog-2005** clog2 =          0        for value == 0*         ceil(log2(value)) for value >= 1** This implementation is a synthesizable variant of the $clog2 function as* specified in the Verilog-2005 standard (IEEE 1364-2005).** To quote the standard:*   The system function $clog2 shall return the ceiling of the log*   base 2 of the argument (the log rounded up to an integer*   value). The argument can be an integer or an arbitrary sized*   vector value. The argument shall be treated as an unsigned*   value, and an argument value of 0 shall produce a result of 0.*/function automatic integer clog2;input integer value;beginvalue = value - 1;for (clog2 = 0; value > 0; clog2 = clog2 + 1) beginvalue = value >> 1;endendendfunction/*** Math function: enhanced clog2 function**                        0        for value == 0* clog2_width =          1        for value == 1*               ceil(log2(value)) for value > 1*** This function is a variant of the clog2() function, which returns 1 if the* input value is 1. In all other cases it behaves exactly like clog2().* This is useful to define registers which are wide enough to contain* "value" values.** Example 1:*   parameter ITEMS = 1;*   localparam ITEMS_WIDTH = clog2_width(ITEMS); // 1*   reg [ITEMS_WIDTH-1:0] item_register; // items_register is now [0:0]** Example 2:*   parameter ITEMS = 64;*   localparam ITEMS_WIDTH = clog2_width(ITEMS); // 6*   reg [ITEMS_WIDTH-1:0] item_register; // items_register is now [5:0]** Note: I if you want to store the number "value" inside a* register, you need a register with size clog2(value + 1), since* you also need to store the number 0.** Example 3:*   reg [clog2_width(64) - 1 : 0]     store_64_items;  // width is [5:0]*   reg [clog2_width(64 + 1) - 1 : 0] store_number_64; // width is [6:0]*/function automatic integer clog2_width;input integer value;beginif (value == 1) beginclog2_width = 1;end else beginclog2_width = clog2(value);endendendfunction

有一种说法时clog在仿真中以2为对数,而在综合时以e为对数。(暂时认为是一种错误的看法,如果这样那对vivado来说将是非常严重的错误)

参考:

xilinx的$clog2函数_hhh_fpga的博客-CSDN博客

相关文章:

  • RHEL8_Linux访问NFS存储及自动挂载
  • 苹果 macOS 14.1.2 正式发布 更新了哪些内容?
  • harmony开发之Text组件的使用
  • 【wvp】测试记录
  • 华媒舍:引擎霸屏推广,10个技巧帮助你登上霸者!
  • 【risc-v】易灵思efinix FPGA riscv嵌入式软件源码分享
  • TCP通信
  • Linux lshw命令(lshw指令)(List Hardware,获取底层硬件信息)(查询硬件信息)
  • echarts更改工具栏图标为本地图片
  • 前端知识笔记(三十四)———HBuilder的下载与使用(详细步骤)
  • 游戏架构之继承对象模型和组件对象模型
  • IDEA删除最近打开的文件记录
  • VSCode 配置JavaScript环境
  • Jinja2使用Layui报 “d is not defined“
  • git分支修改名称并推送到远程
  • “大数据应用场景”之隔壁老王(连载四)
  • 【402天】跃迁之路——程序员高效学习方法论探索系列(实验阶段159-2018.03.14)...
  • C# 免费离线人脸识别 2.0 Demo
  • Docker入门(二) - Dockerfile
  • js数组之filter
  • js中forEach回调同异步问题
  • laravel5.5 视图共享数据
  • niucms就是以城市为分割单位,在上面 小区/乡村/同城论坛+58+团购
  • NSTimer学习笔记
  • Puppeteer:浏览器控制器
  • scrapy学习之路4(itemloder的使用)
  • 动手做个聊天室,前端工程师百无聊赖的人生
  • 每天10道Java面试题,跟我走,offer有!
  • 名企6年Java程序员的工作总结,写给在迷茫中的你!
  • 批量截取pdf文件
  • 漂亮刷新控件-iOS
  • 前端技术周刊 2019-02-11 Serverless
  • 入职第二天:使用koa搭建node server是种怎样的体验
  • 深入浅出webpack学习(1)--核心概念
  • 写给高年级小学生看的《Bash 指南》
  • 学习笔记TF060:图像语音结合,看图说话
  • 在Docker Swarm上部署Apache Storm:第1部分
  • 最简单的无缝轮播
  • 【干货分享】dos命令大全
  • python最赚钱的4个方向,你最心动的是哪个?
  • ###C语言程序设计-----C语言学习(3)#
  • #、%和$符号在OGNL表达式中经常出现
  • #多叉树深度遍历_结合深度学习的视频编码方法--帧内预测
  • (1)(1.9) MSP (version 4.2)
  • (3)(3.2) MAVLink2数据包签名(安全)
  • (PyTorch)TCN和RNN/LSTM/GRU结合实现时间序列预测
  • (第61天)多租户架构(CDB/PDB)
  • (二)Eureka服务搭建,服务注册,服务发现
  • (附源码)spring boot车辆管理系统 毕业设计 031034
  • (三)终结任务
  • (转)Android学习笔记 --- android任务栈和启动模式
  • (转载)Linux网络编程入门
  • ***详解账号泄露:全球约1亿用户已泄露
  • .equal()和==的区别 怎样判断字符串为空问题: Illegal invoke-super to void nio.file.AccessDeniedException
  • .NET Core、DNX、DNU、DNVM、MVC6学习资料