(转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. Axel与Wget下载工具

    Axel工具是linux下的http/ftp中强大下载工具,支持多线程和断点续传下载.且可以从多个地址或者从一个地址的多个连接来下载同一个文件. 常用的选项: [root@wjoyxt ~]# axe ...

  2. Spring MVC 接受的请求参数

    目录 1. 概述 2. 详解 2.1 处理查询参数 2.2 处理路径参数接受输入 2.3 处理表单 3. 补充内容 3.1 Ajax/JSON 输入 3.2 multipart参数 3.3 接收 he ...

  3. SQL Server - 最佳实践 - 参数嗅探问题 转。

    文章来自:https://yq.aliyun.com/articles/61767 先说我的问题,最近某个存储过程,暂定名字:sp_a 总是执行超时,sp_a带有一个参数,暂定名为 para1 var ...

  4. Java工具类_模拟HTTP POST请求

    import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.InputStream; i ...

  5. Codeforces Round #534 (Div. 2)

    B. Game with string 题意: 给出一个字符串s只包括小写字母.当轮到一个玩家的时候,他可以选择两个连续且相等的字母并且删除它.当一个玩家没得删的时候他就输了. 题解: 乍一看有点懵, ...

  6. vs2013和vs2010的配置

    win10下vs2013和vs2010的相关配置 ------made by siwuxie095 主要是推荐一些vs2013和vs2010的好用的插件和配色方案,下面主要是以vs2013示例 1.首 ...

  7. 未能加载文件或程序集“AjaxControlToolkit”或它的某一个依赖项

    对于这个问题,网上的解答都大同小异,最多的就是Bin文件夹下没有dll文件,引用路径问题.但我碰到的问题偏偏不是这个,而是没有一个人给出方法的问题.其实问题很简单,也很低级:IIS上发布网站的时候把整 ...

  8. centos自定义安装pip3

    题记 在之前的文章centos云服务器安装Python3记录 记录了怎么自定义安装 Python3 ,在后边测试pip3的时候发现了个问题: pip --version terminal 打印: pi ...

  9. 不同的子序列 · Distinct Subsequences

    [抄题]: 给出字符串S和字符串T,计算S的不同的子序列中T出现的个数. 子序列字符串是原始字符串通过删除一些(或零个)产生的一个新的字符串,并且对剩下的字符的相对位置没有影响.(比如,“ACE”是“ ...

  10. c语言定义函数指针和typedef简写

    二种方法来定义函数指针 #include<stdio.h> #include<stdlib.h> #include<Windows.h> int add(int a ...