(转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. ABAP-Generate subroutine

    1.定义 data:zprog like abapsource occurs with header line, prog() type c, msg() type c. 2.动态语句 zprog-l ...

  2. UI5-文档-4.38-Accessibility

    作为本教程的最后一步,我们将改进应用程序的可访问性. 为此,我们将添加ARIA属性.屏幕阅读器使用ARIA属性识别应用程序结构并正确解释UI元素.通过这种方式,我们可以让我们的应用程序对那些使用电脑有 ...

  3. PowerEdge服务器生命周期控制器:Lifecycle Controller

    戴尔从第11代服务器开始推出生命周期控制器(简称LC,即Lifecycle Controller).生命周期控制器(LC)通过在主板上部署的控制芯片和闪存,与BMC以及iDRAC卡配合,在服务器的整个 ...

  4. 趣味编程:FizzBuzz(Kotlin版)

    fun toFizzBuzzIf(n: Int) = if (n % 3 == 0 && n % 5 == 0) "FizzBuzz" else if (n % 3 ...

  5. 【337】Text Mining Using Twitter Streaming API and Python

    Reference: An Introduction to Text Mining using Twitter Streaming API and Python Reference: How to R ...

  6. Redis cli 操作

    备份 root@575e8088b5fb:/data# redis-cli LASTSAVE(integer) 1500273743root@575e8088b5fb:/data# redis-cli ...

  7. Python3使用csv模块csv.writer().writerow()保存csv文件,产生空行的问题

    问题:csv.writer().writerow()保存的csv文件,打开时每行后都多一行空行 解决方法:在open()内增加一个参数newline='' 即可   问题现象:   1.代码 with ...

  8. 利用css和javascript实现简单的计算器

    <!doctype html> <html> <head> <!--声明当前页面的编码集--> <meta http-equiv="Co ...

  9. 【校招面试 之 C/C++】第13题 C++ 指针和引用的区别

    1.指针和引用的定义和性质区别: (1)指针:指针是一个变量,只不过这个变量存储的是一个地址,指向内存的一个存储单元:而引用跟原来的变量实质上是同一个东西,只不过是原变量的一个别名而已.如: int ...

  10. error: In function ‘void* opencv_showimg(void*)’:

    今天这个问题折磨了我一下午,终于知道是为什么了,心酸历程.....赶紧来记录一下 错误: /home/wj/workspace/Loitor_VI_Sensor_SDK_V1./SDK/src/cam ...