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
--------------------------------------------------------------
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! */
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
> 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
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).