Question, Need help

I

ian

Guest
Hi,

I am trying to use $system(setenv DISPLAY bird) to setup an env
variable in verilog. But it seems it complains that the command setenv
can not be found. So my question is: How can I define an env variable,
for example DISPLAY, in verilog. I am using linux server to do the job,
I think the setenv works the same.

Thanks in advance!

Ian
 
Ian,
Very likely (though it is my guess work) that "sh" is invoked as
part of $system and hence setenv is not found, try "export" or "echo
$SHELL" etc.

HTH
Ajeetha, CVC
www,noveldv.com
 
Ajeetha appears to be correct. The error I see is

/bin/sh: line 1: setenv: command not found

which is clearly coming from sh, and setenv is a csh command.

I am not sure it would do you any good anyway. I would guess that the
command is run in a subprocess, and would only set the environment
variable for that subprocess, not for its parent process. So it
wouldn't affect the environment variables for the simulator process.
And if you were trying to direct the GUI to display on your desktop,
that wouldn't work anyway since the GUI would have already opened the
display before executing any of the Verilog code.

There may or may not be some complex way to get what you want from
$system. But it seems to me like it would be a lot easier to do the
setenv before invoking the simulator.
 
ian wrote:

I am trying to use $system(setenv DISPLAY bird) to setup an env
variable in verilog. But it seems it complains that the command setenv
can not be found. So my question is: How can I define an env variable,
for example DISPLAY, in verilog. I am using linux server to do the job,
I think the setenv works the same.
As other people have pointed out this will be run inside a subshell and
hence later invocations won't see it.

You can do this for all the commands you call though
$system(env DISPLAY=foobar:0 command option option)

Also, if you do 'export DISPLAY=foobar:0' before you run your simulator then
that variable should be propgated through to all the $system() calls.

(I may be an FPGA noob but I know unix ;)

--
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
-- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C
 
Thanks, Ajeetha,

I think it must be the reason. I am now using $system(export
FLAG=my_name) to set an env variable FLAG, which I want
to use on the C side for PLI function. I use a getenv(FLAG) function to
detect if the env variable is set or not by the Verilog code.

I will let you know if it works.

Ian
 
Thanks Sharp

I am trying to use $system( export FLAG=myname) now.

I am actually trying to set the env variable FLAG at the verilog side
and then C side can detect it
in my PLI application by using getenv(FLAG). I was using DISPLAY as an
example.

Thanks again

Ian
 
I don't think it will work.

The PLI is running in the same process as the simulator. the export
command will only set the environment variable for the child subprocess
created by $system to execute the command. It will not affect the
parent process, where the PLI is running.
 

Welcome to EDABoard.com

Sponsor

Back
Top