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] log base 2 in verilog

Status
Not open for further replies.

richa.verma

Newbie level 6
Newbie level 6
Joined
Jun 5, 2012
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,348
I have designed the function to calculate log base 2 and then calling it in module, but it is giving error "External Function 'logb2' may not be used in a constant expression"
The code is:

Code:
  function integer logb2;
    // inputs
    input integer n;
    begin
      n = n-1;
      for(logb2=0; n>0; logb2=logb2 + 1)
        n = n>>1;
    end
 endfunction

 module fifo(wfull, rempty, data_out, wck, rck, arst_n, wdata_en, rdata_en, data_in);
 
   // Parameters
   parameter P_DATA_WIDTH = 32;
   parameter P_ADDR_WIDTH = 32;
   parameter P_FIFO_DEPTH = 32;
   parameter gc_bit = logb2(P_FIFO_DEPTH);      [I][B] <<<< The error is for this line[/B][/I]
 ...
 ...
 ...
 endmodule

Help me out to solve this problem!
 
Last edited by a moderator:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top