how to use define in a string?

Guest
Hi,

I want to run the following system task

$system("chmod 777 `FSDB_FILE");

this is not working because the defined value `FSDB_FILE.

I was trying the following:
$system("chmod 777 " `FSDB_FILE);

but I'm getting the error: "Incorrect number of arguments (8), (1)
required."

Does anyone have a solution?


Thanks,
Pazia
 
On Jun 25, 9:10 am, pazi...@gmail.com wrote:
I was trying the following:
$system("chmod 777 " `FSDB_FILE);

but I'm getting the error: "Incorrect number of arguments (8), (1)
required."

Does anyone have a solution?
Assuming `FSDB_FILE is a quoted string (i.e., contains quotes), you
can concatenate them together:
$system({"chmod 777 ", ``FSDB_FILE});

There are other solutions too. This is good if you're going to use it
more than once.
string cmd; // reg [80*8 : 1] cmd; <= if you don't use SV
$sformat(cmd, "chmod 777 %0s", `FSDB_FILE);
$display("Running: %0s", cmd);
$system(cmd);

-cb
 
Is there anyway to concatentate a `define with an instance suffix? Like

myModule {`DEFINENAME,"_instance_suffix"} (.port1(), .port2() );

obviously that doesn't work, but thought it would illustrate my point.


Chris Briggs wrote:
On Jun 25, 9:10 am, pazi...@gmail.com wrote:

I was trying the following:
$system("chmod 777 " `FSDB_FILE);

but I'm getting the error: "Incorrect number of arguments (8), (1)
required."

Does anyone have a solution?


Assuming `FSDB_FILE is a quoted string (i.e., contains quotes), you
can concatenate them together:
$system({"chmod 777 ", ``FSDB_FILE});

There are other solutions too. This is good if you're going to use it
more than once.
string cmd; // reg [80*8 : 1] cmd; <= if you don't use SV
$sformat(cmd, "chmod 777 %0s", `FSDB_FILE);
$display("Running: %0s", cmd);
$system(cmd);

-cb
 
On Jun 25, 5:43 pm, Yottameter <yottame...@yahoo.com> wrote:
Is there anyway to concatentate a `define with an instance suffix? Like

myModule {`DEFINENAME,"_instance_suffix"} (.port1(), .port2() );

obviously that doesn't work, but thought it would illustrate my point.
Do you have SystemVerilog? The LRM says you can do this:
`define foo(f) f``_suffix

So I expect this would work:
myModule `foo(`DEFINENAME) (.port1(), .port2() );

Haven't tried it myself.

If you don't have SV, I expect the auto_templates in emacs Verilog-
mode could be used for this. How's your knowledge of lisp? See the
docs and FAQ at http://www.veripool.org/wiki/verilog-mode.

Alternatively, you could use a preprocessor like m4.

-cb
 

Welcome to EDABoard.com

Sponsor

Back
Top