help needed on a complex macro

This is a discussion on help needed on a complex macro within the verilog forums in Programming Languages category; Hi, Can somebody explain what is m3 meant to be doing in this code? And before that, is it a valid verilog code? `define m1(a1,a2) a1 = a1 - a2; `define m2(a2,a3) (a2 * a3) `define m3(t) `" calling : `\`"m1(t)`\`"AND `\`m2(t)` \`"`" module mod; reg v1, v2, v3; always begin `m1(v1,v2); v3 = `m2(v1,v2); $display(`m3(v1)); end endmodule...

Go Back   Application Development Forum > Programming Languages > verilog

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-05-2008, 03:43 AM
very_very_log
Guest
 
Default help needed on a complex macro

Hi,

Can somebody explain what is m3 meant to be doing in this code?
And before that, is it a valid verilog code?

`define m1(a1,a2) a1 = a1 - a2;
`define m2(a2,a3) (a2 * a3)

`define m3(t) `" calling : `\`"m1(t)`\`"AND `\`m2(t)`
\`"`"


module mod;

reg v1, v2, v3;
always begin
`m1(v1,v2);
v3 = `m2(v1,v2);
$display(`m3(v1));
end

endmodule


Reply With Quote
  #2  
Old 09-05-2008, 02:43 PM
Kevin Neilson
Guest
 
Default Re: help needed on a complex macro

very_very_log wrote:
> Hi,
>
> Can somebody explain what is m3 meant to be doing in this code?
> And before that, is it a valid verilog code?
>
> `define m1(a1,a2) a1 = a1 - a2;
> `define m2(a2,a3) (a2 * a3)
>
> `define m3(t) `" calling : `\`"m1(t)`\`"AND `\`m2(t)`
> \`"`"
>
>
> module mod;
>
> reg v1, v2, v3;
> always begin
> `m1(v1,v2);
> v3 = `m2(v1,v2);
> $display(`m3(v1));
> end
>
> endmodule
>
>

This type of macro was introduced in Verilog 2001 (or 2005?). You
really should avoid all precompiler macros if possible. The replacement
works like this:

`m1(v1,v2);

becomes:
v1 = v1 - v2;

I don't really see the point of this here.
-Kevin
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 11:28 PM.


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.