$clog2(转)

时间:2022-03-10 10:17:12

(转http://www.xilinx.com/support/answers/44586.html)

13.2 Verilog $clog2 function implemented improperly

 
SEARCH

Description

The $clog2 function returns the ceiling of the logarithm to the base e (natural logarithm)rather than the ceiling of

the logarithm to the base 2.

Here is a sample Verilog code that uses the $clog2 function,

module tb;
parameter A = $clog2(325);
endmodule

When 13.2 XST synthesizes the above piece of Verilog,it generatesa value 6 for A instead of an expected value of 9,

which is actually the ceiling of log2(325).

Solution

The XST parser of ISE 13.2design tools supports Verilog-2001, therefore,customers will not be able to get a proper outputfor $clog2 function.

The Math function $clog2 was incorporated starting from Verilog-2005 (IEEE 1364-2005). Before that, clog2 could be realized as a Constant Function

in Verilog 2001. Following is a samplefunction that can be used insteadfor the $clog2 function to get a proper output:

function integer clog2;
input integer value;
begin
value = value-1;
for (clog2=0; value>0; clog2=clog2+1)
value = value>>1;
end
endfunction

The above sample Verilog code with use of this function willnow become as follows:

module tb;
parameter A = clog2(325);

function integer clog2;
input integer value;
begin 
value = value-1;
for (clog2=0; value>0; clog2=clog2+1)
value = value>>1;
end 
endfunction
endmodule

This issue has been fixed as part of the 14.1 XST release. Also, It is in the road map to support System Verilog, which isa superset of Verilog-2005

using Xilinx tools and would include all advanced functionsmentioned in theLRM.

随机推荐

  1. psp记录个人项目花费时间

    预估时间 120min 设计分析时间 30min 具体设计时间 ≍40min 编码时间 ≍1h 测试时间 10min 整理结论时间 10min 总结与探讨时间 5min

  2. c#基础,面试前迅速巩固c#最基础知识点

    n年前为了面试,搜罗的C#基础知识,记在了文档里.今天写到博客园里,与人分享,因为不是专家,所以仅供参考. 1.面向对象 在面向对象概念提出之前,语言都是面向过程的,说到面向对象,应该与面向过程比较, ...

  3. 7 Reverse Integer(数字反转Easy)

    题目意思:int数字反转 考虑:越界问题 class Solution { public: int reverse(int x) { ; while(x){ ans=ans*+x%; x=x/; } ...

  4. leetcode第一刷_Pow(x, n)

    高速乘方的算法,写了好多变,出了各种错,真是服了我自己了. 思想是每次对n减半,将当前的temp平方.须要注意的是假设当前的n是个奇数,减半之后会丢失掉一次乘积,因此假设当前的n为奇数,应该先在结果里 ...

  5. 使用队列实现栈(2)(Java)

    class MyStack { private Queue q1; private Queue q2; public MyStack(int size) { this.q1 = new Queue(s ...

  6. Django 执行单独脚本及SyntaxError缩进报错解决

    有时候会碰到这样的场景,对于一些业务升级,我需要把数据库数据做些处理,同时又想以 Django 项目的环境变量执行脚本,这个时候使用 python 脚本是再适合不过的手段了. 注意:在pycharm里 ...

  7. App架构师实践指南三之基础组件

    App架构师实践指南三之基础组件 1.基础组件库随着时间的增长,代码量的逐渐积累,新旧项目之间有太多可以服用的代码.下面是整理的公共代码库. 2.关于加密密钥的保护以及网络传输安全是移动应用安全最关键 ...

  8. Shell编程-11-子Shell和Shell嵌套

    目录 什么是子Shell 子Shell产生的途径 Shell脚本调用模式 什么是子Shell     子Shell的概念其实是贯穿整个Shell的,如果想要更好的理解和写Shell脚本则必须要了解子S ...

  9. 大数据【二】HDFS部署及文件读写(包含eclipse hadoop配置)

    一 原理阐述 1' DFS 分布式文件系统(即DFS,Distributed File System),指文件系统管理的物理存储资源不一定直接连接在本地节点上,而是通过计算机网络与节点相连.该系统架构 ...

  10. Java中ArrayList的fori和foreach效率比较

    1. list的元素为Integer [代码实例1] public static void main(String[] args) { List<Integer> list = new A ...