FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > Verilog

Verilog comp.lang.verilog newsgroup / usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-06-2003, 07:07 AM
toby
Guest
 
Posts: n/a
Default Verilog-2001 `define expressions?

I was trying to use a macro 'expression' --

`define MAXIMUM2( x, y ) ( ((x)>(y))?(x)y) ) // return greater value

parameter A_W = 10; // Abus width (#bits)
parameter B_W = 12; // Bbus width (#bits)
parameter C_W = `MAXIMUM2( A_W, B_W ); // Cbus: intersect(A_W, B_W)

This works in NC-Verilog 4.0, Modelsim 5.6, Design Compiler 2003.06, and
Ambit/PKS 5.0. Xilinx ISE 6.1i's "XST" doesn't like it. Overall, so
far so good!

Then I tried to get more clever ...

`define MAXIMUM3(x,y,z ) ( (`MAXIMUM2(x,y)>z) ? (`MAXIMUM2(x,y))z) )

This barfs on most of the above...

Do any Verilog tools support nested MACROs?

('common, C-programmers have been doing this sort of #define stuff for
ages!)

Also don't worry...I'm not using the MACROs to evaluate combinational
exprsesions. I use the MACROs in parameter definitions. (I have some
data-bus width conversions in a few datapath modules. Each 'node' needs
to be sized to the larger of the 2 endpoints.)

Reply With Quote
  #2 (permalink)  
Old 12-08-2003, 08:37 AM
Pooja Maheshwari
Guest
 
Posts: n/a
Default Re: Verilog-2001 `define expressions?

toby wrote:

> I was trying to use a macro 'expression' --
>
> `define MAXIMUM2( x, y ) ( ((x)>(y))?(x)y) ) // return greater value
>
> parameter A_W = 10; // Abus width (#bits)
> parameter B_W = 12; // Bbus width (#bits)
> parameter C_W = `MAXIMUM2( A_W, B_W ); // Cbus: intersect(A_W, B_W)
>
> This works in NC-Verilog 4.0, Modelsim 5.6, Design Compiler 2003.06, and
> Ambit/PKS 5.0. Xilinx ISE 6.1i's "XST" doesn't like it. Overall, so
> far so good!
>
> Then I tried to get more clever ...
>
> `define MAXIMUM3(x,y,z ) ( (`MAXIMUM2(x,y)>z) ? (`MAXIMUM2(x,y))z) )
>
> This barfs on most of the above...
>
> Do any Verilog tools support nested MACROs?


Its working very well in Modelsim5.7a.

- Pooja

> ('common, C-programmers have been doing this sort of #define stuff for
> ages!)
>
> Also don't worry...I'm not using the MACROs to evaluate combinational
> exprsesions. I use the MACROs in parameter definitions. (I have some
> data-bus width conversions in a few datapath modules. Each 'node' needs
> to be sized to the larger of the 2 endpoints.)




Reply With Quote
  #3 (permalink)  
Old 12-08-2003, 06:41 PM
Steven Sharp
Guest
 
Posts: n/a
Default Re: Verilog-2001 `define expressions?

toby <[email protected]> wrote in message news:<[email protected]. com>...
>
> `define MAXIMUM3(x,y,z ) ( (`MAXIMUM2(x,y)>z) ? (`MAXIMUM2(x,y))z) )


Note that this could be written more compactly as

`define MAXIMUM3(x,y,z) `MAXIMUM2(`MAXIMUM2(x,y),z)

but this may be even less likely to work, since it involves a macro
appearing in a macro argument, not just the expansion text.

> This barfs on most of the above...


I will check the most recent NC-Verilog and file a bug report if
necessary.

Incidentally, macros with arguments were added in Verilog-1995, not
Verilog-2001. However, a lot of tools probably didn't support them
until they started implementing the Verilog-2001 extensions. The
standard does not specify whether macros can be nested (i.e. whether
the text expansion of a macro is subject to further substitution),
but it seems like a reasonable thing to expect.
Reply With Quote
  #4 (permalink)  
Old 12-11-2003, 06:14 PM
Hona
Guest
 
Posts: n/a
Default Re: Verilog-2001 `define expressions?



toby wrote:
> I was trying to use a macro 'expression' --
>
> `define MAXIMUM2( x, y ) ( ((x)>(y))?(x)y) ) // return greater value
>
> parameter A_W = 10; // Abus width (#bits)
> parameter B_W = 12; // Bbus width (#bits)
> parameter C_W = `MAXIMUM2( A_W, B_W ); // Cbus: intersect(A_W, B_W)
>
> This works in NC-Verilog 4.0, Modelsim 5.6, Design Compiler 2003.06, and
> Ambit/PKS 5.0. Xilinx ISE 6.1i's "XST" doesn't like it. Overall, so
> far so good!
>
> Then I tried to get more clever ...
>
> `define MAXIMUM3(x,y,z ) ( (`MAXIMUM2(x,y)>z) ? (`MAXIMUM2(x,y))z) )
>
> This barfs on most of the above...


I just tested that `define statement in DC_shell 2003.06-SP1 -- it
compiles just fine. I also tried

`define MAXIMUM3(x,y,z) `MAXIMUM2(`MAXIMUM2(x,y),z))

again...DC_shell 2003.06-SP1 compiles that just fine.

Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Verilog-2001 parameter declarations VhdlCohen Verilog 0 08-22-2003 12:46 AM
Re: Verilog-2001 parameter declarations VhdlCohen Verilog 0 07-29-2003 06:36 PM


All times are GMT +1. The time now is 11:52 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved