Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] What is the $clog2 built-in function do in systemverilog???

Status
Not open for further replies.

alam.tauqueer

Full Member level 2
Joined
Jun 19, 2007
Messages
127
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,298
Activity points
2,005
Hi All,

Can anyone tell me what is the meaning of $clog2 in SV??

Please tell me the usage also and where I can get the information on it??

I have a expression like

localparam param1 = 2'h2;
localparam param2 = 4'h8;
logic [$clog2(param1*int'(param2))-1:0] out1;


regards,
tauqueer
 

Re: What is the $clog2 built-in function do in systemverilog

According to 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.

So $clog2(N) is the number of address bits needed for a memory of size N.

Note that, as pointed out in http://www.eda.org/svdb/view.php?id=2247, it is not "the number of bits needed to express the value" N. Consider the case when N is a power of 2. To calculate that you'd use $clog2(N+1).
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top