complex defines..

This is a discussion on complex defines.. within the verilog forums in Programming Languages category; Hi all, I have a define like #define N_THREADS 4 I want to have another define depending on N_THREADS which should be log (N_THREADS) to the base 2. In the above example it becomes 2.Is there any such way... Thanks, Vittal...

Go Back   Application Development Forum > Programming Languages > verilog

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-06-2008, 08:00 AM
designer
Guest
 
Default complex defines..

Hi all,
I have a define like
#define N_THREADS 4
I want to have another define depending on N_THREADS which should be
log (N_THREADS) to the base 2.
In the above example it becomes 2.Is there any such way...
Thanks,
Vittal
Reply With Quote
  #2  
Old 09-08-2008, 02:01 PM
Kevin Neilson
Guest
 
Default Re: complex defines..

designer wrote:
> Hi all,
> I have a define like
> #define N_THREADS 4
> I want to have another define depending on N_THREADS which should be
> log (N_THREADS) to the base 2.
> In the above example it becomes 2.Is there any such way...
> Thanks,
> Vittal

You can sort of do this with defines, but it's messy and much better to
do it with parameters and constant functions, which most tools support
now. As in:

parameter N_THREADS=4;
parameter log2_N_THREADS=clog2(N_THREADS);

....

function clog2(...

-Kevin
Reply With Quote
  #3  
Old 09-13-2008, 12:19 AM
arko
Guest
 
Default Re: complex defines..


"Kevin Neilson" <kevin_neilson@removethiscomcast.net> wrote in message
news:ga3p9j$puv2@cnn.xsj.xilinx.com...
> designer wrote:
>> Hi all,
>> I have a define like
>> #define N_THREADS 4
>> I want to have another define depending on N_THREADS which should be
>> log (N_THREADS) to the base 2.
>> In the above example it becomes 2.Is there any such way...
>> Thanks,
>> Vittal

> You can sort of do this with defines, but it's messy and much better to do
> it with parameters and constant functions, which most tools support now.
> As in:
>
> parameter N_THREADS=4;
> parameter log2_N_THREADS=clog2(N_THREADS);
>
> ...
>
> function clog2(...


Systemverilog-2008 will add a standard system-task $clog2(), which returns
log2() of its argument.
Unfortunately, no tools today support it yet. And you can bet industrywide
support is
years away...

function integer clog2;
input integer argument;
...
endfunction


Reply With Quote
  #4  
Old 09-16-2008, 03:52 PM
sharp@cadence.com
Guest
 
Default Re: complex defines..

On Sep 13, 12:19*am, "arko" <a...@winnet.com> wrote:
>
> Systemverilog-2008 will add a standard system-task $clog2(), which returns
> log2() of its argument.


This was actually added in Verilog-2005, along with the ability to use
this system function and certain others in constant expressions.

> Unfortunately, no tools today support it yet. *And you can bet industrywide
> support is
> years away...


I wouldn't be surprised. SystemVerilog has added an immense number of
features to be implemented, and the 2009 draft standard adds more.
This Verilog feature probably isn't very high priority for most
implementors.

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 04:07 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.