Add the VPI implementation of $readmemh.
This commit is contained in:
parent
6e3c258edb
commit
5fa7e1c31b
|
|
@ -1,3 +1,4 @@
|
|||
Makefile
|
||||
sys_readmem_lex.c
|
||||
system.vpi
|
||||
dep
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
# 59 Temple Place - Suite 330
|
||||
# Boston, MA 02111-1307, USA
|
||||
#
|
||||
#ident "$Id: Makefile.in,v 1.7 1999/11/07 20:33:30 steve Exp $"
|
||||
#ident "$Id: Makefile.in,v 1.8 1999/12/15 04:01:14 steve Exp $"
|
||||
#
|
||||
#
|
||||
SHELL = /bin/sh
|
||||
|
|
@ -52,11 +52,15 @@ all: system.vpi
|
|||
$(CC) -Wall $(CPPFLAGS) -I$(srcdir) -MD -c $< -o $*.o
|
||||
mv $*.d dep
|
||||
|
||||
O = sys_table.o sys_display.o sys_finish.o sys_vcd.o
|
||||
O = sys_table.o sys_display.o sys_finish.o sys_readmem.o sys_readmem_lex.o \
|
||||
sys_vcd.o
|
||||
|
||||
system.vpi: $O
|
||||
$(CC) -shared -o $@ $O
|
||||
|
||||
sys_readmem_lex.c: sys_readmem_lex.lex
|
||||
flex -t -Preadmem sys_readmem_lex.lex > sys_readmem_lex.c
|
||||
|
||||
clean:
|
||||
rm -f *.o dep/*.d
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* Copyright (c) 1999 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
* General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: sys_readmem.c,v 1.1 1999/12/15 04:01:14 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <vpi_user.h>
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h>
|
||||
# include <assert.h>
|
||||
# include "sys_readmem_lex.h"
|
||||
|
||||
static int sys_readmem_calltf(char*name)
|
||||
{
|
||||
int code;
|
||||
int wwid;
|
||||
char*path;
|
||||
FILE*file;
|
||||
s_vpi_value value;
|
||||
vpiHandle words;
|
||||
vpiHandle sys = vpi_handle(vpiSysTfCall, 0);
|
||||
vpiHandle argv = vpi_iterate(vpiArgument, sys);
|
||||
vpiHandle item = vpi_scan(argv);
|
||||
|
||||
if (item == 0) {
|
||||
vpi_printf("%s: file name parameter missing.\n", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (vpi_get(vpiType, item) != vpiConstant) {
|
||||
vpi_printf("ERROR: %s parameter must be a constant\n", name);
|
||||
vpi_free_object(argv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (vpi_get(vpiConstType, item) != vpiStringConst) {
|
||||
vpi_printf("ERROR: %s parameter must be a constant\n", name);
|
||||
vpi_free_object(argv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
value.format = vpiStringVal;
|
||||
vpi_get_value(item, &value);
|
||||
path = strdup(value.value.str);
|
||||
|
||||
/* Get and check the second paramter. It must be a memory. */
|
||||
item = vpi_scan(argv);
|
||||
if (item == 0) {
|
||||
vpi_printf("%s: Missing memory parameter\n", name);
|
||||
free(path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (vpi_get(vpiType, item) != vpiMemory) {
|
||||
vpi_printf("%s: Second parameter must be a memory.\n", name);
|
||||
free(path);
|
||||
vpi_free_object(argv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* XXXX remaining parameters not supported. */
|
||||
vpi_free_object(argv);
|
||||
|
||||
/* Open the data file. */
|
||||
file = fopen(path, "r");
|
||||
if (file == 0) {
|
||||
vpi_printf("%s: Unable to open %s for reading.\n", name, path);
|
||||
free(path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
words = vpi_iterate(vpiMemoryWord, item);
|
||||
assert(words);
|
||||
|
||||
item = vpi_scan(words);
|
||||
wwid = vpi_get(vpiSize, item);
|
||||
|
||||
value.format = vpiVectorVal;
|
||||
value.value.vector = calloc((wwid+31)/32, sizeof (s_vpi_vecval));
|
||||
sys_readmem_start_file(file, 0, wwid, value.value.vector);
|
||||
|
||||
while (item && ((code = readmemlex()) != 0)) {
|
||||
switch (code) {
|
||||
case MEM_ADDRESS:
|
||||
vpi_printf("XXXX addresses not supported\n");
|
||||
break;
|
||||
case MEM_WORD:
|
||||
vpi_put_value(item, &value, 0, vpiNoDelay);
|
||||
item = vpi_scan(words);
|
||||
break;
|
||||
default:
|
||||
vpi_printf("Huh?! (%d)\n", code);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vpi_printf("%s: task not implemented, yet.\n", name);
|
||||
|
||||
if (item) vpi_free_object(words);
|
||||
free(value.value.vector);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sys_readmem_register()
|
||||
{
|
||||
s_vpi_systf_data tf_data;
|
||||
|
||||
tf_data.type = vpiSysTask;
|
||||
tf_data.tfname = "$readmemh";
|
||||
tf_data.calltf = sys_readmem_calltf;
|
||||
tf_data.compiletf = 0;
|
||||
tf_data.sizetf = 0;
|
||||
tf_data.user_data = "$readmemh";
|
||||
vpi_register_systf(&tf_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: sys_readmem.c,v $
|
||||
* Revision 1.1 1999/12/15 04:01:14 steve
|
||||
* Add the VPI implementation of $readmemh.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef __sys_readmem_lex_H
|
||||
#define __sys_readmem_lex_H
|
||||
/*
|
||||
* Copyright (c) 1999 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
* General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: sys_readmem_lex.h,v 1.1 1999/12/15 04:01:14 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <stdio.h>
|
||||
# include <vpi_user.h>
|
||||
|
||||
# define MEM_ADDRESS 257
|
||||
# define MEM_WORD 258
|
||||
|
||||
extern void sys_readmem_start_file(FILE*in, int bin_flag,
|
||||
unsigned width, struct t_vpi_vecval*val);
|
||||
extern int readmemlex();
|
||||
|
||||
/*
|
||||
* $Log: sys_readmem_lex.h,v $
|
||||
* Revision 1.1 1999/12/15 04:01:14 steve
|
||||
* Add the VPI implementation of $readmemh.
|
||||
*
|
||||
*/
|
||||
#endif
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
|
||||
%{
|
||||
# include "sys_readmem_lex.h"
|
||||
# include <string.h>
|
||||
static void make_hex_value();
|
||||
static void make_bin_value();
|
||||
%}
|
||||
|
||||
%x BIN
|
||||
%x HEX
|
||||
|
||||
%option noyywrap
|
||||
%%
|
||||
|
||||
<*>"//".* { ; }
|
||||
<*>[ \t\f\n\r] { ; }
|
||||
|
||||
<*>@[0-9a-fA-F]+ { return MEM_ADDRESS; }
|
||||
<HEX>[0-9a-fA-FxXzZ_]+ { make_hex_value(); return MEM_WORD; }
|
||||
<BIN>[01_]+ { make_bin_value(); return MEM_WORD; }
|
||||
|
||||
%%
|
||||
static unsigned word_width = 0;
|
||||
static struct t_vpi_vecval*vecval = 0;
|
||||
|
||||
static void make_hex_value()
|
||||
{
|
||||
char*beg = yytext;
|
||||
char*end = beg + strlen(beg);
|
||||
struct t_vpi_vecval*cur;
|
||||
int idx;
|
||||
int width = 0, word_max = word_width;
|
||||
|
||||
for (idx = 0, cur = vecval ; idx < word_max ; idx += 32, cur += 1) {
|
||||
cur->aval = 0;
|
||||
cur->bval = 0;
|
||||
}
|
||||
|
||||
cur = vecval;
|
||||
while ((width < word_max) && (end > beg)) {
|
||||
int aval, bval;
|
||||
|
||||
end -= 1;
|
||||
if (*end == '_') continue;
|
||||
switch (*end) {
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
aval = *end - '0';
|
||||
bval = 0;
|
||||
break;
|
||||
case 'a':
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'd':
|
||||
case 'e':
|
||||
case 'f':
|
||||
aval = *end - 'a' + 10;
|
||||
bval = 0;
|
||||
break;
|
||||
case 'A':
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'D':
|
||||
case 'E':
|
||||
case 'F':
|
||||
aval = *end - 'A' + 10;
|
||||
bval = 0;
|
||||
break;
|
||||
case 'x':
|
||||
case 'X':
|
||||
aval = 15;
|
||||
bval = 15;
|
||||
break;
|
||||
case 'z':
|
||||
case 'Z':
|
||||
aval = 0;
|
||||
bval = 15;
|
||||
break;
|
||||
}
|
||||
|
||||
cur->aval |= aval << width;
|
||||
cur->bval |= bval << width;
|
||||
width += 4;
|
||||
if (width == 32) {
|
||||
cur += 1;
|
||||
width = 0;
|
||||
word_max -= 32;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void make_bin_value()
|
||||
{
|
||||
char*beg = yytext;
|
||||
char*end = beg + strlen(beg);
|
||||
struct t_vpi_vecval*cur;
|
||||
int idx;
|
||||
int width = 0, word_max = word_width;
|
||||
|
||||
for (idx = 0, cur = vecval ; idx < word_max ; idx += 32, cur += 1) {
|
||||
cur->aval = 0;
|
||||
cur->bval = 0;
|
||||
}
|
||||
|
||||
cur = vecval;
|
||||
while ((width < word_max) && (end > beg)) {
|
||||
int aval, bval;
|
||||
|
||||
end -= 1;
|
||||
if (*end == '_') continue;
|
||||
switch (*end) {
|
||||
case '0':
|
||||
case '1':
|
||||
aval = *end - '0';
|
||||
bval = 0;
|
||||
break;
|
||||
case 'x':
|
||||
case 'X':
|
||||
aval = 1;
|
||||
bval = 1;
|
||||
break;
|
||||
case 'z':
|
||||
case 'Z':
|
||||
aval = 0;
|
||||
bval = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
cur->aval |= aval << width;
|
||||
cur->bval |= bval << width;
|
||||
width += 1;
|
||||
if (width == 32) {
|
||||
cur += 1;
|
||||
width = 0;
|
||||
word_max -= 32;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sys_readmem_start_file(FILE*in, int bin_flag,
|
||||
unsigned width, struct t_vpi_vecval *vv)
|
||||
{
|
||||
yyin = in;
|
||||
YY_FLUSH_BUFFER;
|
||||
BEGIN(bin_flag? BIN : HEX);
|
||||
word_width = width;
|
||||
vecval = vv;
|
||||
}
|
||||
|
|
@ -17,16 +17,18 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: sys_table.c,v 1.2 1999/11/07 20:33:30 steve Exp $"
|
||||
#ident "$Id: sys_table.c,v 1.3 1999/12/15 04:01:14 steve Exp $"
|
||||
#endif
|
||||
|
||||
extern void sys_finish_register();
|
||||
extern void sys_display_register();
|
||||
extern void sys_readmem_register();
|
||||
extern void sys_vcd_register();
|
||||
|
||||
void (*vlog_startup_routines[])() = {
|
||||
sys_finish_register,
|
||||
sys_display_register,
|
||||
sys_readmem_register,
|
||||
sys_vcd_register,
|
||||
0
|
||||
};
|
||||
|
|
@ -34,6 +36,9 @@ void (*vlog_startup_routines[])() = {
|
|||
|
||||
/*
|
||||
* $Log: sys_table.c,v $
|
||||
* Revision 1.3 1999/12/15 04:01:14 steve
|
||||
* Add the VPI implementation of $readmemh.
|
||||
*
|
||||
* Revision 1.2 1999/11/07 20:33:30 steve
|
||||
* Add VCD output and related system tasks.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_user.h,v 1.9 1999/11/28 00:56:08 steve Exp $"
|
||||
#ident "$Id: vpi_user.h,v 1.10 1999/12/15 04:01:14 steve Exp $"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -59,6 +59,10 @@ typedef struct t_vpi_time {
|
|||
#define vpiSimTime 2
|
||||
#define vpiSuppressTime 3
|
||||
|
||||
typedef struct t_vpi_vecval {
|
||||
int aval, bval; /* ab encoding: 00=0, 10=1, 11=X, 01=Z */
|
||||
} s_vpi_vecval, *p_vpi_vecval;
|
||||
|
||||
/*
|
||||
* This structure holds values that are passed back and forth between
|
||||
* the simulator and the application.
|
||||
|
|
@ -124,6 +128,15 @@ typedef struct t_vpi_value {
|
|||
# define vpiHexConst 5
|
||||
# define vpiStringConst 6
|
||||
|
||||
/* DELAY MODES */
|
||||
#define vpiNoDelay 1
|
||||
#define vpiInertialDelay 2
|
||||
#define vpiTransportDelay 3
|
||||
#define vpiPureTransportDelay 4
|
||||
|
||||
#define vpiForceFlag 5
|
||||
#define vpiReleaseFlag 6
|
||||
|
||||
|
||||
/* VPI FUNCTIONS */
|
||||
extern void vpi_register_systf(const struct t_vpi_systf_data*ss);
|
||||
|
|
@ -198,6 +211,8 @@ extern vpiHandle vpi_scan(vpiHandle iter);
|
|||
extern int vpi_get(int property, vpiHandle ref);
|
||||
extern char* vpi_get_str(int property, vpiHandle ref);
|
||||
extern void vpi_get_value(vpiHandle expr, p_vpi_value value);
|
||||
extern vpiHandle vpi_put_value(vpiHandle obj, p_vpi_value value,
|
||||
p_vpi_time when, int flags);
|
||||
|
||||
extern int vpi_free_object(vpiHandle ref);
|
||||
|
||||
|
|
@ -211,6 +226,9 @@ extern void (*vlog_startup_routines[])();
|
|||
|
||||
/*
|
||||
* $Log: vpi_user.h,v $
|
||||
* Revision 1.10 1999/12/15 04:01:14 steve
|
||||
* Add the VPI implementation of $readmemh.
|
||||
*
|
||||
* Revision 1.9 1999/11/28 00:56:08 steve
|
||||
* Build up the lists in the scope of a module,
|
||||
* and get $dumpvars to scan the scope for items.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_callback.c,v 1.4 1999/11/07 20:33:30 steve Exp $"
|
||||
#ident "$Id: vpi_callback.c,v 1.5 1999/12/15 04:01:14 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
|
|
@ -30,6 +30,7 @@ static struct __vpirt vpip_callback_rt = {
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
|
|
@ -169,6 +170,9 @@ int vpi_remove_cb(vpiHandle ref)
|
|||
|
||||
/*
|
||||
* $Log: vpi_callback.c,v $
|
||||
* Revision 1.5 1999/12/15 04:01:14 steve
|
||||
* Add the VPI implementation of $readmemh.
|
||||
*
|
||||
* Revision 1.4 1999/11/07 20:33:30 steve
|
||||
* Add VCD output and related system tasks.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_const.c,v 1.4 1999/11/06 22:16:50 steve Exp $"
|
||||
#ident "$Id: vpi_const.c,v 1.5 1999/12/15 04:01:14 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
|
|
@ -286,6 +286,7 @@ static const struct __vpirt vpip_string_rt = {
|
|||
0,
|
||||
string_value,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
|
|
@ -295,6 +296,7 @@ static const struct __vpirt vpip_number_rt = {
|
|||
0,
|
||||
number_value,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
|
|
@ -317,6 +319,9 @@ vpiHandle vpip_make_number_const(struct __vpiNumberConst*ref,
|
|||
|
||||
/*
|
||||
* $Log: vpi_const.c,v $
|
||||
* Revision 1.5 1999/12/15 04:01:14 steve
|
||||
* Add the VPI implementation of $readmemh.
|
||||
*
|
||||
* Revision 1.4 1999/11/06 22:16:50 steve
|
||||
* Get the $strobe task working.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_iter.c,v 1.1 1999/10/28 00:47:25 steve Exp $"
|
||||
#ident "$Id: vpi_iter.c,v 1.2 1999/12/15 04:01:14 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -34,6 +34,7 @@ static const struct __vpirt vpip_iterator_rt = {
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
|
|
@ -67,6 +68,9 @@ vpiHandle vpi_scan(vpiHandle ref)
|
|||
|
||||
/*
|
||||
* $Log: vpi_iter.c,v $
|
||||
* Revision 1.2 1999/12/15 04:01:14 steve
|
||||
* Add the VPI implementation of $readmemh.
|
||||
*
|
||||
* Revision 1.1 1999/10/28 00:47:25 steve
|
||||
* Rewrite vvm VPI support to make objects more
|
||||
* persistent, rewrite the simulation scheduler
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
* Picture Elements, Inc., 777 Panoramic Way, Berkeley, CA 94704.
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_memory.c,v 1.1 1999/11/10 02:52:24 steve Exp $"
|
||||
#ident "$Id: vpi_memory.c,v 1.2 1999/12/15 04:01:14 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
|
|
@ -51,7 +51,6 @@ static int memory_get(int code, vpiHandle ref)
|
|||
static char* memory_get_str(int code, vpiHandle ref)
|
||||
{
|
||||
struct __vpiMemory*rfp = (struct __vpiMemory*)ref;
|
||||
|
||||
assert(ref->vpi_type->type_code==vpiMemory);
|
||||
|
||||
switch (code) {
|
||||
|
|
@ -63,27 +62,86 @@ static char* memory_get_str(int code, vpiHandle ref)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static vpiHandle memory_iterate(int code, vpiHandle ref)
|
||||
{
|
||||
unsigned idx;
|
||||
struct __vpiMemory*rfp = (struct __vpiMemory*)ref;
|
||||
assert(ref->vpi_type->type_code==vpiMemory);
|
||||
|
||||
switch (code) {
|
||||
case vpiMemoryWord:
|
||||
if (rfp->args == 0) {
|
||||
rfp->args = calloc(rfp->size, sizeof(vpiHandle));
|
||||
for (idx = 0 ; idx < rfp->size ; idx += 1)
|
||||
rfp->args[idx] = &rfp->words[idx].base;
|
||||
}
|
||||
return vpip_make_iterator(rfp->size, rfp->args);
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int memory_word_get(int code, vpiHandle ref)
|
||||
{
|
||||
struct __vpiMemoryWord*rfp = (struct __vpiMemoryWord*)ref;
|
||||
assert(ref->vpi_type->type_code==vpiMemoryWord);
|
||||
|
||||
switch (code) {
|
||||
case vpiSize:
|
||||
return rfp->mem->width;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static const struct __vpirt vpip_memory_rt = {
|
||||
vpiMemory,
|
||||
memory_get,
|
||||
memory_get_str,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
memory_iterate
|
||||
};
|
||||
|
||||
static const struct __vpirt vpip_memory_word_rt = {
|
||||
vpiMemoryWord,
|
||||
memory_word_get,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
vpiHandle vpip_make_memory(struct __vpiMemory*ref, const char*name,
|
||||
unsigned wid, unsigned siz)
|
||||
{
|
||||
unsigned idx;
|
||||
|
||||
ref->base.vpi_type = &vpip_memory_rt;
|
||||
ref->name = name;
|
||||
ref->bits = calloc(wid*siz, sizeof(enum vpip_bit_t));
|
||||
ref->words = calloc(siz, sizeof(struct __vpiMemoryWord));
|
||||
ref->args = 0;
|
||||
ref->width = wid;
|
||||
ref->size = siz;
|
||||
|
||||
for (idx = 0 ; idx < siz ; idx += 1) {
|
||||
ref->words[idx].base.vpi_type = &vpip_memory_word_rt;
|
||||
ref->words[idx].mem = ref;
|
||||
ref->words[idx].index = idx;
|
||||
}
|
||||
|
||||
return &(ref->base);
|
||||
}
|
||||
/*
|
||||
* $Log: vpi_memory.c,v $
|
||||
* Revision 1.2 1999/12/15 04:01:14 steve
|
||||
* Add the VPI implementation of $readmemh.
|
||||
*
|
||||
* Revision 1.1 1999/11/10 02:52:24 steve
|
||||
* Create the vpiMemory handle type.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_null.c,v 1.1 1999/10/28 00:47:25 steve Exp $"
|
||||
#ident "$Id: vpi_null.c,v 1.2 1999/12/15 04:01:14 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
|
|
@ -28,6 +28,7 @@ static const struct __vpirt vpip_null_rt = {
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
|
|
@ -37,6 +38,9 @@ struct __vpiNull vpip_null = {
|
|||
|
||||
/*
|
||||
* $Log: vpi_null.c,v $
|
||||
* Revision 1.2 1999/12/15 04:01:14 steve
|
||||
* Add the VPI implementation of $readmemh.
|
||||
*
|
||||
* Revision 1.1 1999/10/28 00:47:25 steve
|
||||
* Rewrite vvm VPI support to make objects more
|
||||
* persistent, rewrite the simulation scheduler
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_priv.c,v 1.1 1999/10/28 00:47:25 steve Exp $"
|
||||
#ident "$Id: vpi_priv.c,v 1.2 1999/12/15 04:01:14 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
|
|
@ -105,6 +105,15 @@ void vpi_get_value(vpiHandle expr, s_vpi_value*vp)
|
|||
vp->format = vpiSuppressVal;
|
||||
}
|
||||
|
||||
vpiHandle vpi_put_value(vpiHandle obj, s_vpi_value*vp,
|
||||
s_vpi_time*tp, int flags)
|
||||
{
|
||||
if (obj->vpi_type->vpi_put_value_)
|
||||
return (obj->vpi_type->vpi_put_value_)(obj, vp, tp, flags);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
vpiHandle vpi_handle(int type, vpiHandle ref)
|
||||
{
|
||||
if (type == vpiSysTfCall) {
|
||||
|
|
@ -150,6 +159,9 @@ void vpi_register_systf(const struct t_vpi_systf_data*systf)
|
|||
|
||||
/*
|
||||
* $Log: vpi_priv.c,v $
|
||||
* Revision 1.2 1999/12/15 04:01:14 steve
|
||||
* Add the VPI implementation of $readmemh.
|
||||
*
|
||||
* Revision 1.1 1999/10/28 00:47:25 steve
|
||||
* Rewrite vvm VPI support to make objects more
|
||||
* persistent, rewrite the simulation scheduler
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_priv.h,v 1.8 1999/11/28 00:56:08 steve Exp $"
|
||||
#ident "$Id: vpi_priv.h,v 1.9 1999/12/15 04:01:14 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -61,6 +61,7 @@ struct __vpirt {
|
|||
int (*vpi_get_)(int, vpiHandle);
|
||||
char* (*vpi_get_str_)(int, vpiHandle);
|
||||
void (*vpi_get_value_)(vpiHandle, p_vpi_value);
|
||||
vpiHandle (*vpi_put_value_)(vpiHandle, p_vpi_value, p_vpi_time, int);
|
||||
|
||||
/* These methods follow references. */
|
||||
vpiHandle (*handle_)(int, vpiHandle);
|
||||
|
|
@ -85,7 +86,6 @@ struct __vpiCallback {
|
|||
*/
|
||||
struct __vpiIterator {
|
||||
struct __vpiHandle base;
|
||||
|
||||
vpiHandle *args;
|
||||
unsigned nargs;
|
||||
unsigned next;
|
||||
|
|
@ -93,17 +93,27 @@ struct __vpiIterator {
|
|||
|
||||
/*
|
||||
* Memory is an array of bits that is accessible in N-bit chunks, with
|
||||
* N being the width of a word.
|
||||
* N being the width of a word. The memory word handle just points
|
||||
* back to the memory and uses an index to identify its position in
|
||||
* the memory.
|
||||
*/
|
||||
struct __vpiMemory {
|
||||
struct __vpiHandle base;
|
||||
/* The signal has a name (this points to static memory.) */
|
||||
const char*name;
|
||||
enum vpip_bit_t*bits;
|
||||
struct __vpiMemoryWord*words;
|
||||
vpiHandle*args;
|
||||
unsigned width;
|
||||
unsigned size;
|
||||
};
|
||||
|
||||
struct __vpiMemoryWord {
|
||||
struct __vpiHandle base;
|
||||
struct __vpiMemory*mem;
|
||||
int index;
|
||||
};
|
||||
|
||||
/*
|
||||
* This type is occasionally useful. Really! And while we're at it,
|
||||
* create a single instance of the null object. (This is all we need.)
|
||||
|
|
@ -274,6 +284,9 @@ extern int vpip_finished();
|
|||
|
||||
/*
|
||||
* $Log: vpi_priv.h,v $
|
||||
* Revision 1.9 1999/12/15 04:01:14 steve
|
||||
* Add the VPI implementation of $readmemh.
|
||||
*
|
||||
* Revision 1.8 1999/11/28 00:56:08 steve
|
||||
* Build up the lists in the scope of a module,
|
||||
* and get $dumpvars to scan the scope for items.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_scope.c,v 1.2 1999/11/28 00:56:08 steve Exp $"
|
||||
#ident "$Id: vpi_scope.c,v 1.3 1999/12/15 04:01:14 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
|
|
@ -42,6 +42,7 @@ static const struct __vpirt vpip_module_rt = {
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
module_iter
|
||||
};
|
||||
|
||||
|
|
@ -75,6 +76,9 @@ void vpip_attach_to_scope(struct __vpiScope*ref, vpiHandle obj)
|
|||
|
||||
/*
|
||||
* $Log: vpi_scope.c,v $
|
||||
* Revision 1.3 1999/12/15 04:01:14 steve
|
||||
* Add the VPI implementation of $readmemh.
|
||||
*
|
||||
* Revision 1.2 1999/11/28 00:56:08 steve
|
||||
* Build up the lists in the scope of a module,
|
||||
* and get $dumpvars to scan the scope for items.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_signal.c,v 1.5 1999/11/07 20:33:30 steve Exp $"
|
||||
#ident "$Id: vpi_signal.c,v 1.6 1999/12/15 04:01:14 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
|
|
@ -71,6 +71,7 @@ static const struct __vpirt vpip_net_rt = {
|
|||
signal_get_str,
|
||||
signal_get_value,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
|
|
@ -88,6 +89,7 @@ static const struct __vpirt vpip_reg_rt = {
|
|||
signal_get_str,
|
||||
signal_get_value,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
|
|
@ -101,6 +103,9 @@ vpiHandle vpip_make_reg(struct __vpiSignal*ref, const char*name)
|
|||
|
||||
/*
|
||||
* $Log: vpi_signal.c,v $
|
||||
* Revision 1.6 1999/12/15 04:01:14 steve
|
||||
* Add the VPI implementation of $readmemh.
|
||||
*
|
||||
* Revision 1.5 1999/11/07 20:33:30 steve
|
||||
* Add VCD output and related system tasks.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_systask.c,v 1.1 1999/10/28 00:47:25 steve Exp $"
|
||||
#ident "$Id: vpi_systask.c,v 1.2 1999/12/15 04:01:14 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
|
|
@ -41,11 +41,15 @@ const struct __vpirt vpip_systask_rt = {
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
systask_iter
|
||||
};
|
||||
|
||||
/*
|
||||
* $Log: vpi_systask.c,v $
|
||||
* Revision 1.2 1999/12/15 04:01:14 steve
|
||||
* Add the VPI implementation of $readmemh.
|
||||
*
|
||||
* Revision 1.1 1999/10/28 00:47:25 steve
|
||||
* Rewrite vvm VPI support to make objects more
|
||||
* persistent, rewrite the simulation scheduler
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_time.c,v 1.1 1999/10/28 00:47:25 steve Exp $"
|
||||
#ident "$Id: vpi_time.c,v 1.2 1999/12/15 04:01:14 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
|
|
@ -62,6 +62,7 @@ static const struct __vpirt vpip_time_var_rt = {
|
|||
0,
|
||||
timevar_get_value,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
|
|
@ -74,6 +75,9 @@ vpiHandle vpip_make_time_var(struct __vpiTimeVar*ref, const char*val)
|
|||
|
||||
/*
|
||||
* $Log: vpi_time.c,v $
|
||||
* Revision 1.2 1999/12/15 04:01:14 steve
|
||||
* Add the VPI implementation of $readmemh.
|
||||
*
|
||||
* Revision 1.1 1999/10/28 00:47:25 steve
|
||||
* Rewrite vvm VPI support to make objects more
|
||||
* persistent, rewrite the simulation scheduler
|
||||
|
|
|
|||
Loading…
Reference in New Issue