Support addresses in readmemh.
This commit is contained in:
parent
0cebef872a
commit
64d7b1cee5
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT) && !defined(macintosh)
|
#if !defined(WINNT) && !defined(macintosh)
|
||||||
#ident "$Id: sys_readmem.c,v 1.7 2001/11/09 03:39:21 steve Exp $"
|
#ident "$Id: sys_readmem.c,v 1.8 2001/12/01 02:40:10 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -35,11 +35,13 @@ static int sys_readmem_calltf(char*name)
|
||||||
int wwid;
|
int wwid;
|
||||||
char*path;
|
char*path;
|
||||||
FILE*file;
|
FILE*file;
|
||||||
|
unsigned addr;
|
||||||
s_vpi_value value;
|
s_vpi_value value;
|
||||||
vpiHandle words;
|
vpiHandle words;
|
||||||
vpiHandle sys = vpi_handle(vpiSysTfCall, 0);
|
vpiHandle sys = vpi_handle(vpiSysTfCall, 0);
|
||||||
vpiHandle argv = vpi_iterate(vpiArgument, sys);
|
vpiHandle argv = vpi_iterate(vpiArgument, sys);
|
||||||
vpiHandle item = vpi_scan(argv);
|
vpiHandle item = vpi_scan(argv);
|
||||||
|
vpiHandle mitem;
|
||||||
|
|
||||||
if (item == 0) {
|
if (item == 0) {
|
||||||
vpi_printf("%s: file name parameter missing.\n", name);
|
vpi_printf("%s: file name parameter missing.\n", name);
|
||||||
|
|
@ -63,14 +65,14 @@ static int sys_readmem_calltf(char*name)
|
||||||
path = strdup(value.value.str);
|
path = strdup(value.value.str);
|
||||||
|
|
||||||
/* Get and check the second paramter. It must be a memory. */
|
/* Get and check the second paramter. It must be a memory. */
|
||||||
item = vpi_scan(argv);
|
mitem = vpi_scan(argv);
|
||||||
if (item == 0) {
|
if (mitem == 0) {
|
||||||
vpi_printf("%s: Missing memory parameter\n", name);
|
vpi_printf("%s: Missing memory parameter\n", name);
|
||||||
free(path);
|
free(path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vpi_get(vpiType, item) != vpiMemory) {
|
if (vpi_get(vpiType, mitem) != vpiMemory) {
|
||||||
vpi_printf("%s: Second parameter must be a memory.\n", name);
|
vpi_printf("%s: Second parameter must be a memory.\n", name);
|
||||||
free(path);
|
free(path);
|
||||||
vpi_free_object(argv);
|
vpi_free_object(argv);
|
||||||
|
|
@ -88,7 +90,7 @@ static int sys_readmem_calltf(char*name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
words = vpi_iterate(vpiMemoryWord, item);
|
words = vpi_iterate(vpiMemoryWord, mitem);
|
||||||
assert(words);
|
assert(words);
|
||||||
|
|
||||||
item = vpi_scan(words);
|
item = vpi_scan(words);
|
||||||
|
|
@ -101,14 +103,32 @@ static int sys_readmem_calltf(char*name)
|
||||||
else
|
else
|
||||||
sys_readmem_start_file(file, 0, wwid, value.value.vector);
|
sys_readmem_start_file(file, 0, wwid, value.value.vector);
|
||||||
|
|
||||||
while (item && ((code = readmemlex()) != 0)) {
|
addr = 0;
|
||||||
|
|
||||||
|
while ((code = readmemlex()) != 0) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case MEM_ADDRESS:
|
case MEM_ADDRESS:
|
||||||
vpi_printf("XXXX addresses not supported\n");
|
if (addr > value.value.vector->aval) {
|
||||||
|
vpi_free_object(words);
|
||||||
|
words = vpi_iterate(vpiMemoryWord, mitem);
|
||||||
|
item = vpi_scan(words);
|
||||||
|
addr = 0;
|
||||||
|
}
|
||||||
|
while (item && addr < value.value.vector->aval) {
|
||||||
|
item = vpi_scan(words);
|
||||||
|
addr += 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MEM_WORD:
|
case MEM_WORD:
|
||||||
vpi_put_value(item, &value, 0, vpiNoDelay);
|
if (item) {
|
||||||
item = vpi_scan(words);
|
vpi_put_value(item, &value, 0, vpiNoDelay);
|
||||||
|
item = vpi_scan(words);
|
||||||
|
addr += 1;
|
||||||
|
} else {
|
||||||
|
vpi_printf("%s(%s): too much data (addr=0x%x)\n",
|
||||||
|
name, path, addr);
|
||||||
|
goto bailout;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
vpi_printf("Huh?! (%d)\n", code);
|
vpi_printf("Huh?! (%d)\n", code);
|
||||||
|
|
@ -116,7 +136,9 @@ static int sys_readmem_calltf(char*name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bailout:
|
||||||
if (item) vpi_free_object(words);
|
if (item) vpi_free_object(words);
|
||||||
|
free(path);
|
||||||
free(value.value.vector);
|
free(value.value.vector);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -231,6 +253,9 @@ void sys_readmem_register()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: sys_readmem.c,v $
|
* $Log: sys_readmem.c,v $
|
||||||
|
* Revision 1.8 2001/12/01 02:40:10 steve
|
||||||
|
* Support addresses in readmemh.
|
||||||
|
*
|
||||||
* Revision 1.7 2001/11/09 03:39:21 steve
|
* Revision 1.7 2001/11/09 03:39:21 steve
|
||||||
* Support $writememh
|
* Support $writememh
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,11 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT) && !defined(macintosh)
|
#if !defined(WINNT) && !defined(macintosh)
|
||||||
#ident "$Id: sys_readmem_lex.lex,v 1.4 2001/07/25 03:10:50 steve Exp $"
|
#ident "$Id: sys_readmem_lex.lex,v 1.5 2001/12/01 02:40:10 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
# include "sys_readmem_lex.h"
|
# include "sys_readmem_lex.h"
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
|
static void make_addr();
|
||||||
static void make_hex_value();
|
static void make_hex_value();
|
||||||
static void make_bin_value();
|
static void make_bin_value();
|
||||||
%}
|
%}
|
||||||
|
|
@ -36,7 +37,7 @@ static void make_bin_value();
|
||||||
<*>"//".* { ; }
|
<*>"//".* { ; }
|
||||||
<*>[ \t\f\n\r] { ; }
|
<*>[ \t\f\n\r] { ; }
|
||||||
|
|
||||||
<*>@[0-9a-fA-F]+ { return MEM_ADDRESS; }
|
<*>@[0-9a-fA-F]+ { make_addr(); return MEM_ADDRESS; }
|
||||||
<HEX>[0-9a-fA-FxXzZ_]+ { make_hex_value(); return MEM_WORD; }
|
<HEX>[0-9a-fA-FxXzZ_]+ { make_hex_value(); return MEM_WORD; }
|
||||||
<BIN>[01_]+ { make_bin_value(); return MEM_WORD; }
|
<BIN>[01_]+ { make_bin_value(); return MEM_WORD; }
|
||||||
|
|
||||||
|
|
@ -44,6 +45,11 @@ static void make_bin_value();
|
||||||
static unsigned word_width = 0;
|
static unsigned word_width = 0;
|
||||||
static struct t_vpi_vecval*vecval = 0;
|
static struct t_vpi_vecval*vecval = 0;
|
||||||
|
|
||||||
|
static void make_addr()
|
||||||
|
{
|
||||||
|
sscanf(yytext+1, "%x", &vecval->aval);
|
||||||
|
}
|
||||||
|
|
||||||
static void make_hex_value()
|
static void make_hex_value()
|
||||||
{
|
{
|
||||||
char*beg = yytext;
|
char*beg = yytext;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue