(转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. .Net 常用开发工具

    ,net常用开发工具 LinqPad使用 LinqPad连接Oracle 使用 LINQPad 将linq转换为 lambda表达式 或者 SQL语句 LINQPad 4 初次使用心得 一.双击 二. ...

  2. c++ static成员

    static 成员通常不能在类的定义体重初始化 有一种例外,const static成员可以在定义体内初始化,并且可以用于构造函数 将函数声明为const表示该函数不能修改其所属的对象

  3. 【转】vc api 录音

    一.数字音频基础知识 Fourier级数: 任何周期的波形可以分解成多个正弦波,这些正弦波的频率都是整数倍.级数中其他正线波的频率是基础频率的整数倍.基础频率称为一级谐波. PCM: pulse co ...

  4. os.popen与os.system区别

    os.system 调用系统命令,完成后退出,返回结果是命令执行状态,一般是0 os.popen 可以实现一个“管道”,从这个命令获取的值可以在python 中继续被使用 #该方法不但执行命令还返回执 ...

  5. 树莓派Zero W添加音频输出

    编译:陈拓 chentuo@ms.xab.ac.cn 2018.06.07/2018.07.14 原文:Adding Basic Audio Ouput to Raspberry Pi Zero ht ...

  6. Python——序列

    #!/usr/bin/python #coding:utf8 ''' Python——序列 字符串的操作 ''' s = 'abcdefg' print s print s[2] print s[-1 ...

  7. java 解析命令行参数

    下载地址: https://jcenter.bintray.com/org/apache/commons/com.springsource.org.apache.commons.cli/1.2.0/ ...

  8. Maven命令行使用 mvn clean package

    先把命令行切换到Maven项目的根目录,比如:/d/xxxwork/java/maven-test,然后执行命令:  mvn clean package 执行结果如下: [INFO] Scanning ...

  9. 在Windows下远程连接CentOS6

    远程连接linux服务器的方式:以显示的类型来分类,可以分为字符界面和图形界面两种.字符界面软件有SecureCRT.PUTTY等:图形界面有Xmanager.Xdmcp和VNC软件等.

  10. 爬楼梯 · Climbing Stairs

    [抄题]: 假设你正在爬楼梯,需要n步你才能到达顶部.但每次你只能爬一步或者两步,你能有多少种不同的方法爬到楼顶部? [思维问题]: 不知道一步.两步怎么加.还是用iteration迭代.此题公式可被 ...