Names of vpi objects allocated as vpip_strings.
This commit is contained in:
parent
a05d8c2823
commit
fd8ceac170
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: compile.cc,v 1.133 2002/07/05 04:40:59 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.134 2002/07/05 17:14:15 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "arith.h"
|
||||
|
|
@ -1391,6 +1391,7 @@ void compile_variable(char*label, char*name, int msb, int lsb,
|
|||
vpip_attach_to_current_scope(obj);
|
||||
|
||||
free(label);
|
||||
free(name);
|
||||
}
|
||||
|
||||
void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag,
|
||||
|
|
@ -1414,11 +1415,15 @@ void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag,
|
|||
vpip_attach_to_current_scope(obj);
|
||||
|
||||
free(label);
|
||||
free(name);
|
||||
free(argv);
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.134 2002/07/05 17:14:15 steve
|
||||
* Names of vpi objects allocated as vpip_strings.
|
||||
*
|
||||
* Revision 1.133 2002/07/05 04:40:59 steve
|
||||
* Symbol table uses more efficient key string allocator,
|
||||
* and remove all the symbol tables after compile is done.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: event.cc,v 1.7 2002/05/19 05:18:16 steve Exp $"
|
||||
#ident "$Id: event.cc,v 1.8 2002/07/05 17:14:15 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "event.h"
|
||||
|
|
@ -179,10 +179,14 @@ void compile_named_event(char*label, char*name)
|
|||
vpip_attach_to_current_scope(obj->handle);
|
||||
|
||||
free(label);
|
||||
free(name);
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: event.cc,v $
|
||||
* Revision 1.8 2002/07/05 17:14:15 steve
|
||||
* Names of vpi objects allocated as vpip_strings.
|
||||
*
|
||||
* Revision 1.7 2002/05/19 05:18:16 steve
|
||||
* Add callbacks for vpiNamedEvent objects.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: main.cc,v 1.26 2002/07/05 03:47:06 steve Exp $"
|
||||
#ident "$Id: main.cc,v 1.27 2002/07/05 17:14:15 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "config.h"
|
||||
|
|
@ -242,6 +242,8 @@ int main(int argc, char*argv[])
|
|||
fprintf(stderr, " ... %8lu opcodes (%lu bytes)\n",
|
||||
count_opcodes, size_opcodes);
|
||||
fprintf(stderr, " ... %8lu nets\n", count_vpi_nets);
|
||||
fprintf(stderr, " ... %8lu memories\n", count_vpi_memories);
|
||||
fprintf(stderr, " ... %8lu scopes\n", count_vpi_scopes);
|
||||
}
|
||||
|
||||
if (verbose_flag) {
|
||||
|
|
@ -273,6 +275,9 @@ int main(int argc, char*argv[])
|
|||
|
||||
/*
|
||||
* $Log: main.cc,v $
|
||||
* Revision 1.27 2002/07/05 17:14:15 steve
|
||||
* Names of vpi objects allocated as vpip_strings.
|
||||
*
|
||||
* Revision 1.26 2002/07/05 03:47:06 steve
|
||||
* Track opcode memory space.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: statistics.cc,v 1.2 2002/07/05 03:46:43 steve Exp $"
|
||||
#ident "$Id: statistics.cc,v 1.3 2002/07/05 17:14:15 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "statistics.h"
|
||||
|
|
@ -31,12 +31,18 @@ unsigned long count_functors = 0;
|
|||
|
||||
unsigned long count_vpi_nets = 0;
|
||||
|
||||
unsigned long count_vpi_memories = 0;
|
||||
|
||||
unsigned long count_vpi_scopes = 0;
|
||||
|
||||
size_t size_opcodes = 0;
|
||||
|
||||
|
||||
/*
|
||||
* $Log: statistics.cc,v $
|
||||
* Revision 1.3 2002/07/05 17:14:15 steve
|
||||
* Names of vpi objects allocated as vpip_strings.
|
||||
*
|
||||
* Revision 1.2 2002/07/05 03:46:43 steve
|
||||
* Track opcode memory space.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: statistics.h,v 1.2 2002/07/05 03:46:43 steve Exp $"
|
||||
#ident "$Id: statistics.h,v 1.3 2002/07/05 17:14:15 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <stddef.h>
|
||||
|
|
@ -27,11 +27,16 @@
|
|||
extern unsigned long count_opcodes;
|
||||
extern unsigned long count_functors;
|
||||
extern unsigned long count_vpi_nets;
|
||||
extern unsigned long count_vpi_scopes;
|
||||
extern unsigned long count_vpi_memories;
|
||||
|
||||
extern size_t size_opcodes;
|
||||
|
||||
/*
|
||||
* $Log: statistics.h,v $
|
||||
* Revision 1.3 2002/07/05 17:14:15 steve
|
||||
* Names of vpi objects allocated as vpip_strings.
|
||||
*
|
||||
* Revision 1.2 2002/07/05 03:46:43 steve
|
||||
* Track opcode memory space.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_event.cc,v 1.2 2002/05/19 05:18:16 steve Exp $"
|
||||
#ident "$Id: vpi_event.cc,v 1.3 2002/07/05 17:14:15 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
|
|
@ -39,7 +39,7 @@ static char* named_event_str(int code, vpiHandle ref)
|
|||
switch (code) {
|
||||
|
||||
case vpiName:
|
||||
return obj->name;
|
||||
return const_cast<char*>(obj->name);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -85,13 +85,13 @@ static const struct __vpirt vpip_named_event_rt = {
|
|||
named_event_free_object
|
||||
};
|
||||
|
||||
vpiHandle vpip_make_named_event(char*name)
|
||||
vpiHandle vpip_make_named_event(const char*name)
|
||||
{
|
||||
struct __vpiNamedEvent*obj = (struct __vpiNamedEvent*)
|
||||
malloc(sizeof(struct __vpiNamedEvent));
|
||||
|
||||
obj->base.vpi_type = &vpip_named_event_rt;
|
||||
obj->name = name;
|
||||
obj->name = vpip_string(name);
|
||||
obj->scope = vpip_peek_current_scope();
|
||||
obj->callbacks = 0;
|
||||
|
||||
|
|
@ -114,6 +114,9 @@ void vpip_run_named_event_callbacks(vpiHandle ref)
|
|||
|
||||
/*
|
||||
* $Log: vpi_event.cc,v $
|
||||
* Revision 1.3 2002/07/05 17:14:15 steve
|
||||
* Names of vpi objects allocated as vpip_strings.
|
||||
*
|
||||
* Revision 1.2 2002/05/19 05:18:16 steve
|
||||
* Add callbacks for vpiNamedEvent objects.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -27,11 +27,12 @@
|
|||
* Picture Elements, Inc., 777 Panoramic Way, Berkeley, CA 94704.
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: vpi_memory.cc,v 1.15 2002/07/04 16:37:07 steve Exp $"
|
||||
#ident "$Id: vpi_memory.cc,v 1.16 2002/07/05 17:14:15 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
# include "memory.h"
|
||||
# include "statistics.h"
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <assert.h>
|
||||
|
|
@ -563,6 +564,7 @@ vpiHandle vpip_make_memory(vvp_memory_t mem)
|
|||
{
|
||||
struct __vpiMemory*obj = (struct __vpiMemory*)
|
||||
malloc(sizeof(struct __vpiMemory));
|
||||
count_vpi_memories += 1;
|
||||
|
||||
obj->base.vpi_type = &vpip_memory_rt;
|
||||
obj->scope = vpip_peek_current_scope();
|
||||
|
|
@ -579,6 +581,9 @@ vpiHandle vpip_make_memory(vvp_memory_t mem)
|
|||
|
||||
/*
|
||||
* $Log: vpi_memory.cc,v $
|
||||
* Revision 1.16 2002/07/05 17:14:15 steve
|
||||
* Names of vpi objects allocated as vpip_strings.
|
||||
*
|
||||
* Revision 1.15 2002/07/04 16:37:07 steve
|
||||
* Fix s_vpi_vecval array byte size.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,13 +17,14 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_priv.cc,v 1.17 2002/06/21 04:58:55 steve Exp $"
|
||||
#ident "$Id: vpi_priv.cc,v 1.18 2002/07/05 17:14:15 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
# include "schedule.h"
|
||||
# include <stdio.h>
|
||||
# include <stdarg.h>
|
||||
# include <string.h>
|
||||
# include <assert.h>
|
||||
#ifdef HAVE_MALLOC_H
|
||||
# include <malloc.h>
|
||||
|
|
@ -32,6 +33,39 @@
|
|||
|
||||
vpi_mode_t vpi_mode_flag = VPI_MODE_NONE;
|
||||
|
||||
/*
|
||||
* The vpip_string function creates a constant string from the pass
|
||||
* input. This constant string is permanently allocate from an
|
||||
* efficient string buffer store.
|
||||
*/
|
||||
struct vpip_string_chunk {
|
||||
struct vpip_string_chunk*next;
|
||||
char data[64*1024 - sizeof (struct vpip_string_chunk*)];
|
||||
};
|
||||
|
||||
const char *vpip_string(const char*str)
|
||||
{
|
||||
static vpip_string_chunk first_chunk = {0, {0}};
|
||||
static vpip_string_chunk*chunk_list = &first_chunk;
|
||||
static unsigned chunk_fill = 0;
|
||||
|
||||
unsigned len = strlen(str);
|
||||
assert( (len+1) <= sizeof chunk_list->data );
|
||||
|
||||
if ( (len+1) > (sizeof chunk_list->data - chunk_fill) ) {
|
||||
vpip_string_chunk*tmp = new vpip_string_chunk;
|
||||
tmp->next = chunk_list;
|
||||
chunk_list = tmp;
|
||||
chunk_fill = 0;
|
||||
}
|
||||
|
||||
char*res = chunk_list->data + chunk_fill;
|
||||
chunk_fill += len + 1;
|
||||
|
||||
strcpy(res, str);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* When a task is called, this value is set so that vpi_handle can
|
||||
* fathom the vpi_handle(vpiSysTfCall,0) function.
|
||||
|
|
@ -212,6 +246,9 @@ extern "C" void vpi_sim_vcontrol(int operation, va_list ap)
|
|||
|
||||
/*
|
||||
* $Log: vpi_priv.cc,v $
|
||||
* Revision 1.18 2002/07/05 17:14:15 steve
|
||||
* Names of vpi objects allocated as vpip_strings.
|
||||
*
|
||||
* Revision 1.17 2002/06/21 04:58:55 steve
|
||||
* Add support for special integer vectors.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.37 2002/06/21 04:58:55 steve Exp $"
|
||||
#ident "$Id: vpi_priv.h,v 1.38 2002/07/05 17:14:15 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_user.h"
|
||||
|
|
@ -135,7 +135,7 @@ struct __vpiScope {
|
|||
struct __vpiHandle base;
|
||||
struct __vpiScope *scope;
|
||||
/* The scope has a name. */
|
||||
char*name;
|
||||
const char*name;
|
||||
/* Keep an array of internal scope items. */
|
||||
struct __vpiHandle**intern;
|
||||
unsigned nintern;
|
||||
|
|
@ -156,7 +156,7 @@ struct __vpiSignal {
|
|||
struct __vpiHandle base;
|
||||
struct __vpiScope* scope;
|
||||
/* The name of this reg/net object */
|
||||
char*name;
|
||||
const char*name;
|
||||
/* The indices that define the width and access offset. */
|
||||
int msb, lsb;
|
||||
/* Flags */
|
||||
|
|
@ -167,11 +167,12 @@ struct __vpiSignal {
|
|||
/* This is the callback event functor */
|
||||
struct callback_functor_s *callback;
|
||||
};
|
||||
extern vpiHandle vpip_make_int(char*name, int msb, int lsb, vvp_fvector_t vec);
|
||||
extern vpiHandle vpip_make_reg(char*name, int msb, int lsb, bool signed_flag,
|
||||
vvp_fvector_t vec);
|
||||
extern vpiHandle vpip_make_net(char*name, int msb, int lsb, bool signed_flag,
|
||||
extern vpiHandle vpip_make_int(const char*name, int msb, int lsb,
|
||||
vvp_fvector_t vec);
|
||||
extern vpiHandle vpip_make_reg(const char*name, int msb, int lsb,
|
||||
bool signed_flag, vvp_fvector_t vec);
|
||||
extern vpiHandle vpip_make_net(const char*name, int msb, int lsb,
|
||||
bool signed_flag, vvp_fvector_t vec);
|
||||
|
||||
/*
|
||||
* These methods support the vpi creation of events. The name string
|
||||
|
|
@ -181,14 +182,14 @@ extern vpiHandle vpip_make_net(char*name, int msb, int lsb, bool signed_flag,
|
|||
struct __vpiNamedEvent {
|
||||
struct __vpiHandle base;
|
||||
/* base name of the event object */
|
||||
char*name;
|
||||
const char*name;
|
||||
/* Parent scope of this object. */
|
||||
struct __vpiScope*scope;
|
||||
/* List of callbacks interested in this event. */
|
||||
struct __vpiCallback*callbacks;
|
||||
};
|
||||
|
||||
extern vpiHandle vpip_make_named_event(char*name);
|
||||
extern vpiHandle vpip_make_named_event(const char*name);
|
||||
extern void vpip_run_named_event_callbacks(vpiHandle ref);
|
||||
|
||||
/*
|
||||
|
|
@ -324,6 +325,7 @@ extern void vpip_set_time_precision(int pres);
|
|||
extern void vpip_time_to_timestruct(struct t_vpi_time*ts, vvp_time64_t ti);
|
||||
extern vvp_time64_t vpip_timestruct_to_time(const struct t_vpi_time*ts);
|
||||
|
||||
extern const char* vpip_string(const char*str);
|
||||
|
||||
/*
|
||||
** Functions defined in vpi_scope.cc, to keep track of functor scope.
|
||||
|
|
@ -360,6 +362,9 @@ extern void vpip_oct_str_to_bits(unsigned char*bits, unsigned nbits,
|
|||
|
||||
/*
|
||||
* $Log: vpi_priv.h,v $
|
||||
* Revision 1.38 2002/07/05 17:14:15 steve
|
||||
* Names of vpi objects allocated as vpip_strings.
|
||||
*
|
||||
* Revision 1.37 2002/06/21 04:58:55 steve
|
||||
* Add support for special integer vectors.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,13 +17,14 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_scope.cc,v 1.15 2002/05/18 02:34:11 steve Exp $"
|
||||
#ident "$Id: vpi_scope.cc,v 1.16 2002/07/05 17:14:15 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "compile.h"
|
||||
# include "vpi_priv.h"
|
||||
# include "symbols.h"
|
||||
# include "functor.h"
|
||||
# include "statistics.h"
|
||||
#ifdef HAVE_MALLOC_H
|
||||
# include <malloc.h>
|
||||
#endif
|
||||
|
|
@ -55,10 +56,10 @@ static char* scope_get_str(int code, vpiHandle obj)
|
|||
|
||||
switch (code) {
|
||||
case vpiFullName:
|
||||
return ref->name;
|
||||
return const_cast<char*>(ref->name);
|
||||
|
||||
case vpiName:
|
||||
nn = n = ref->name;
|
||||
nn = n = const_cast<char*>(ref->name);
|
||||
while (*n)
|
||||
if (*n=='\\' && *++n)
|
||||
++n;
|
||||
|
|
@ -310,6 +311,7 @@ static void attach_to_scope_(struct __vpiScope*scope, vpiHandle obj)
|
|||
void compile_scope_decl(char*label, char*type, char*name, char*parent)
|
||||
{
|
||||
struct __vpiScope*scope = new struct __vpiScope;
|
||||
count_vpi_scopes += 1;
|
||||
|
||||
switch(type[2]) {
|
||||
case 'd': /* type == moDule */
|
||||
|
|
@ -334,7 +336,7 @@ void compile_scope_decl(char*label, char*type, char*name, char*parent)
|
|||
|
||||
assert(scope->base.vpi_type);
|
||||
|
||||
scope->name = name;
|
||||
scope->name = vpip_string(name);
|
||||
scope->intern = 0;
|
||||
scope->nintern = 0;
|
||||
scope->threads = 0;
|
||||
|
|
@ -342,7 +344,10 @@ void compile_scope_decl(char*label, char*type, char*name, char*parent)
|
|||
current_scope = scope;
|
||||
|
||||
compile_vpi_symbol(label, &scope->base);
|
||||
|
||||
free(label);
|
||||
free(type);
|
||||
free(name);
|
||||
|
||||
if (parent) {
|
||||
static vpiHandle obj;
|
||||
|
|
@ -384,6 +389,9 @@ void vpip_attach_to_current_scope(vpiHandle obj)
|
|||
|
||||
/*
|
||||
* $Log: vpi_scope.cc,v $
|
||||
* Revision 1.16 2002/07/05 17:14:15 steve
|
||||
* Names of vpi objects allocated as vpip_strings.
|
||||
*
|
||||
* Revision 1.15 2002/05/18 02:34:11 steve
|
||||
* Add vpi support for named events.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_signal.cc,v 1.40 2002/07/05 02:50:58 steve Exp $"
|
||||
#ident "$Id: vpi_signal.cc,v 1.41 2002/07/05 17:14:15 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -628,7 +628,7 @@ static const struct __vpirt vpip_net_rt = {
|
|||
* to minimize the code modifications. Icarus implements integers
|
||||
* as 'reg signed [31:0]'.
|
||||
*/
|
||||
vpiHandle vpip_make_int(char*name, int msb, int lsb, vvp_fvector_t vec)
|
||||
vpiHandle vpip_make_int(const char*name, int msb, int lsb, vvp_fvector_t vec)
|
||||
{
|
||||
vpiHandle obj = vpip_make_net(name, msb,lsb, true, vec);
|
||||
struct __vpiSignal*rfp = (struct __vpiSignal*)obj;
|
||||
|
|
@ -640,8 +640,8 @@ vpiHandle vpip_make_int(char*name, int msb, int lsb, vvp_fvector_t vec)
|
|||
/*
|
||||
* Construct a vpiReg object. It's like a net, except for the type.
|
||||
*/
|
||||
vpiHandle vpip_make_reg(char*name, int msb, int lsb, bool signed_flag,
|
||||
vvp_fvector_t vec)
|
||||
vpiHandle vpip_make_reg(const char*name, int msb, int lsb,
|
||||
bool signed_flag, vvp_fvector_t vec)
|
||||
{
|
||||
vpiHandle obj = vpip_make_net(name, msb,lsb, signed_flag, vec);
|
||||
obj->vpi_type = &vpip_reg_rt;
|
||||
|
|
@ -652,13 +652,13 @@ vpiHandle vpip_make_reg(char*name, int msb, int lsb, bool signed_flag,
|
|||
* Construct a vpiNet object. Give the object specified dimensions,
|
||||
* and point to the specified functor for the lsb.
|
||||
*/
|
||||
vpiHandle vpip_make_net(char*name, int msb, int lsb, bool signed_flag,
|
||||
vvp_fvector_t vec)
|
||||
vpiHandle vpip_make_net(const char*name, int msb, int lsb,
|
||||
bool signed_flag, vvp_fvector_t vec)
|
||||
{
|
||||
struct __vpiSignal*obj = (struct __vpiSignal*)
|
||||
malloc(sizeof(struct __vpiSignal));
|
||||
obj->base.vpi_type = &vpip_net_rt;
|
||||
obj->name = name;
|
||||
obj->name = vpip_string(name);
|
||||
obj->msb = msb;
|
||||
obj->lsb = lsb;
|
||||
obj->signed_flag = signed_flag? 1 : 0;
|
||||
|
|
@ -676,6 +676,9 @@ vpiHandle vpip_make_net(char*name, int msb, int lsb, bool signed_flag,
|
|||
|
||||
/*
|
||||
* $Log: vpi_signal.cc,v $
|
||||
* Revision 1.41 2002/07/05 17:14:15 steve
|
||||
* Names of vpi objects allocated as vpip_strings.
|
||||
*
|
||||
* Revision 1.40 2002/07/05 02:50:58 steve
|
||||
* Remove the vpi object symbol table after compile.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue