Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

$readmemh

1,672 views
Skip to first unread message

Alan Gibbons

unread,
Mar 27, 1995, 11:53:27 AM3/27/95
to
Is there anyway for me to get $readmemh to look for the file to be loaded in a
directory other than the current working directory. +incdir and the library
switches dont apply in this case and I dont really want to hard code the path
in the call to $readmemh (even with a 'define). I am really looking for a
search path type capability.

The documentation doesn't give me much help here. I need a solution that works
in both Verilog XL and VCS.

Any help appreciated.

Thx,
Alan

--------------------------------------------------------------
Alan Gibbons E-mail: gib...@chdasic.sps.mot.com
Motorola CSP Phone: 602 814 4449 Fax: 602 814 4963
--------------------------------------------------------------

MARK INDOVINA Xxxxx Ppppp

unread,
Apr 5, 1995, 3:00:00 AM4/5/95
to
In article <3l6qi7$c...@newsgate.sps.mot.com>,

Alan Gibbons <gib...@chdasic.sps.mot.com> wrote:
>Is there anyway for me to get $readmemh to look for the file to be loaded in a
>directory other than the current working directory. +incdir and the library
>switches dont apply in this case and I dont really want to hard code the path
>in the call to $readmemh (even with a 'define). I am really looking for a
>search path type capability.
>
>The documentation doesn't give me much help here. I need a solution that works
>in both Verilog XL and VCS.
>

Alan,
Just put in the use the full, or relative path to the file. You can't
use shell variables or ~, but ., or .. will work.

Regards,
Mark

--
/* Mark A. Indovina, Principal Staff Engineer mark_i...@pts.mot.com */
/* MOTOROLA Strategic Semiconductor Operation, IC Technology Laboratory */
/* Mail Stop 63, 1500 Gateway Boulevard, Boynton Beach, FL 33436-8292 USA */
/* phone: 1-407-739-2379, fax: 1-407-739-3904 ...just speaking for me! */

Alan Gibbons

unread,
Apr 6, 1995, 3:00:00 AM4/6/95
to

In article <D6L3o...@pts.mot.com>, ep5...@pts.mot.com (MARK INDOVINA Xxxxx Ppppp) writes:
>Alan Gibbons <gib...@chdasic.sps.mot.com> wrote:
>>Is there anyway for me to get $readmemh to look for the file to be loaded in a
>>directory other than the current working directory. +incdir and the library
>>switches dont apply in this case and I dont really want to hard code the path
>>in the call to $readmemh (even with a 'define). I am really looking for a
>>search path type capability.
>Alan,
>Just put in the use the full, or relative path to the file. You can't
>use shell variables or ~, but ., or .. will work.
>
>Regards,
>Mark
>

Mark,

What I am trying to do is avoid having any hard coded pathnames in the call to
$readmemh. The best I can do now is to reference the file location with a `define
and then define the value of the variable at run time with a +define switch to VCS.

Thanks,
Alan


-----------------------------------------------------------
Alan Gibbons Motorola CSP gib...@chdasic.sps.mot.com


Michael T.Y. McNamara

unread,
Apr 7, 1995, 3:00:00 AM4/7/95
to gib...@chdasic.sps.mot.com

>>>>> ">" == Alan Gibbons <gib...@chdasic.sps.mot.com> writes:
> What I am trying to do is avoid having any hard coded pathnames in
> the call to $readmemh. The best I can do now is to reference the
> file location with a `define and then define the value of the
> variable at run time with a +define switch to VCS.

> Thanks, Alan

Since a +define command line switch is not acceptable, it would seem
likely that any other command line option is out as well...

Ok, presumably you want something like:
$readmemh("~alan/register1",...);

Or, perhaps you are looking for:
$readmemh("$SRC/register1",...);

where $SRC is an environment variable?

At present, for any open, we essentially call fopen. It
sounds like you are asking that we glob as does the csh any filenames
that start with a tilde key (~), and expand any $variables

Is this what you want?

You could do this in your own pli code, as follows:

module foo;
reg [80*8:0] name;

initial begin
name = "~mac/.emacs";
$display("Name is %s",name);
$glob(name); // Expands ~ to home directory
$display("After glob, name is %s",name);
end
endmodule

where your pli file is:

#include "acc_user.h"
#include <stdio.h>
#include <pwd.h>
#include <string.h>

/* Return the globbed version of argument */
glob(){
char * ep;
s_acc_value val;
s_setval_delay dly;

HANDLE handleArg = acc_handle_tfarg(1);

int cbits = acc_fetch_size(handleArg);
val.value.str = (char*)malloc(cbits<<3);
val.format = accStringVal;
dly.model = accNoDelay;

acc_fetch_value(handleArg,"%%",&val);
if (acc_error_flag) {
io_printf("Error in $glob...");
return;
}
ep = val.value.str;
while(ep && isspace(*ep)) {
ep++;
}
switch (*ep) {
case '~': {
struct passwd *pwent = NULL;
/* Grab the name */
char *sp;
if( sp = strchr(ep,'/')) {
*sp = 0;
pwent = getpwnam(ep+1);
if (pwent) {
sprintf(val.value.str, "%s/%s", pwent->pw_dir, ep+1);
} else {
io_printf("$glob: %s User unknown. Not expanded.\n",ep+1);
return;
}
} else {
/* Just a directory... Curious */
pwent = getpwnam(ep+1);
if (pwent) {
sprintf(val.value.str, "%s", pwent->pw_dir);
} else {
io_printf("$glob: %s User unknown. Not expanded.\n",ep+1);
return;
}
}
}
case '$':
/* Left as exercise... (HINT: use getenv(2)) */
break;
default:
/* No magic characters; don't need to modify register contents */
return;
}
/* Now write it back */
acc_set_value(handleArg,&val,&dly);
if (acc_error_flag) {
io_printf("Error in $glob...");
}
}


--
,------. Michael McNamara Send mail to in...@chronologic.com for INFO
|CHRONO|LOGIC SIMULATION to sup...@chronologic.com for SUPPORT
`------' A VIEWlogic Company For information, call 1-800-VERILOG

Don Reid

unread,
Apr 10, 1995, 3:00:00 AM4/10/95
to
: >Is there anyway for me to get $readmemh to look for the file to be loaded in a

: >directory other than the current working directory. +incdir and the library
: >switches dont apply in this case and I dont really want to hard code the path
: >in the call to $readmemh (even with a 'define). I am really looking for a
: >search path type capability.

The "Unix" workaround for this is to put a symbolic link to the real file
in the directory the tool will use. You can use a shell script to implement
any complex search function you want (before running the simulator).

0 new messages