Add change callback to vpiMemory objects.
This commit is contained in:
parent
7527c466ed
commit
27e633410c
|
|
@ -18,9 +18,10 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: memory.cc,v 1.22.2.1 2006/02/19 00:11:36 steve Exp $"
|
||||
#ident "$Id: memory.cc,v 1.22.2.2 2006/02/19 16:57:31 steve Exp $"
|
||||
#endif
|
||||
|
||||
#include "vpi_priv.h"
|
||||
#include "memory.h"
|
||||
#include "symbols.h"
|
||||
#include "schedule.h"
|
||||
|
|
@ -31,7 +32,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#if 0
|
||||
typedef struct vvp_memory_port_s *vvp_memory_port_t;
|
||||
|
||||
struct vvp_memory_s
|
||||
|
|
@ -50,7 +51,11 @@ struct vvp_memory_s
|
|||
|
||||
vvp_memory_bits_t bits; // Array of bits
|
||||
vvp_memory_port_t addr_root; // Port list root;
|
||||
|
||||
// callbacks
|
||||
struct __vpiCallback*cb; // callback list for this vpiMemory
|
||||
};
|
||||
#endif
|
||||
|
||||
unsigned memory_data_width(vvp_memory_t mem)
|
||||
{
|
||||
|
|
@ -153,7 +158,7 @@ vvp_memory_t memory_create(char *label)
|
|||
symbol_value_t v;
|
||||
v.ptr = mem;
|
||||
sym_set_value(memory_table, label, v);
|
||||
|
||||
mem->cb = NULL; // clear the callbacks
|
||||
return mem;
|
||||
}
|
||||
|
||||
|
|
@ -432,6 +437,17 @@ void memory_set(vvp_memory_t mem, unsigned idx, unsigned char val)
|
|||
unsigned bidx = idx%(4*mem->fwidth);
|
||||
|
||||
update_data_ports(mem, get_word_ix(mem, widx), bidx, val);
|
||||
|
||||
// execute vpiMemory callbacks
|
||||
for (struct __vpiCallback*cur = mem->cb ; cur ; cur = cur->next) {
|
||||
cur->cb_data.time->type = vpiSimTime;
|
||||
cur->cb_data.index = widx; // assign the memory word index
|
||||
vpip_time_to_timestruct(cur->cb_data.time, schedule_simtime());
|
||||
assert(cur->cb_data.cb_rtn != 0);
|
||||
vpi_mode_flag = VPI_MODE_RWSYNC;
|
||||
(cur->cb_data.cb_rtn)(&cur->cb_data);
|
||||
vpi_mode_flag = VPI_MODE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
// %load/mem
|
||||
|
|
@ -494,6 +510,9 @@ void schedule_memory(vvp_memory_t mem, unsigned idx,
|
|||
|
||||
/*
|
||||
* $Log: memory.cc,v $
|
||||
* Revision 1.22.2.2 2006/02/19 16:57:31 steve
|
||||
* Add change callback to vpiMemory objects.
|
||||
*
|
||||
* Revision 1.22.2.1 2006/02/19 00:11:36 steve
|
||||
* Handle synthesis of FF vectors with l-value decoder.
|
||||
*
|
||||
|
|
|
|||
30
vvp/memory.h
30
vvp/memory.h
|
|
@ -20,7 +20,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: memory.h,v 1.7 2004/10/04 01:10:59 steve Exp $"
|
||||
#ident "$Id: memory.h,v 1.7.2.1 2006/02/19 16:57:31 steve Exp $"
|
||||
#endif
|
||||
|
||||
#include "pointers.h"
|
||||
|
|
@ -35,6 +35,31 @@ typedef struct vvp_memory_s *vvp_memory_t;
|
|||
typedef unsigned char *vvp_memory_bits_t;
|
||||
typedef struct vvp_memory_index_s *vvp_memory_index_t;
|
||||
|
||||
// moved from memory.cc for callback function visibility
|
||||
typedef struct vvp_memory_port_s *vvp_memory_port_t;
|
||||
|
||||
// moved here from memory.cc for callback function visibility
|
||||
struct vvp_memory_s
|
||||
{
|
||||
char *name; // VPI scope.name
|
||||
|
||||
// Address port properties:
|
||||
unsigned size; // total number of data words
|
||||
unsigned a_idxs; // number of address indices
|
||||
vvp_memory_index_t a_idx; // vector of address indices
|
||||
|
||||
// Data port properties:
|
||||
unsigned width; // number of data bits
|
||||
unsigned fwidth; // number of bytes (4bits) per data word
|
||||
int msb, lsb; // Most/Least Significant data bit (VPI)
|
||||
|
||||
vvp_memory_bits_t bits; // Array of bits
|
||||
vvp_memory_port_t addr_root; // Port list root;
|
||||
|
||||
// callbacks
|
||||
struct __vpiCallback*cb; // callback list for this vpiMemory
|
||||
};
|
||||
|
||||
void memory_new(vvp_memory_t mem, char *name, int lsb, int msb,
|
||||
unsigned idxs, long *idx);
|
||||
vvp_ipoint_t memory_port_new(vvp_memory_t mem,
|
||||
|
|
@ -65,6 +90,9 @@ vvp_memory_t memory_create(char *label);
|
|||
|
||||
/*
|
||||
* $Log: memory.h,v $
|
||||
* Revision 1.7.2.1 2006/02/19 16:57:31 steve
|
||||
* Add change callback to vpiMemory objects.
|
||||
*
|
||||
* Revision 1.7 2004/10/04 01:10:59 steve
|
||||
* Clean up spurious trailing white space.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: vpi_callback.cc,v 1.34 2004/10/04 01:10:59 steve Exp $"
|
||||
#ident "$Id: vpi_callback.cc,v 1.34.2.1 2006/02/19 16:57:31 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -219,6 +219,10 @@ static struct __vpiCallback* make_value_change(p_cb_data data)
|
|||
sig->callback->cb_handle = obj;
|
||||
break;
|
||||
|
||||
case vpiMemory: /* callback for change in any location of this vpiMemory */
|
||||
vpip_memory_value_change(obj,data->obj);
|
||||
break;
|
||||
|
||||
case vpiRealVar:
|
||||
vpip_real_value_change(obj, data->obj);
|
||||
break;
|
||||
|
|
@ -564,6 +568,9 @@ void callback_functor_s::set(vvp_ipoint_t, bool, unsigned val, unsigned)
|
|||
|
||||
/*
|
||||
* $Log: vpi_callback.cc,v $
|
||||
* Revision 1.34.2.1 2006/02/19 16:57:31 steve
|
||||
* Add change callback to vpiMemory objects.
|
||||
*
|
||||
* Revision 1.34 2004/10/04 01:10:59 steve
|
||||
* Clean up spurious trailing white space.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
* Picture Elements, Inc., 777 Panoramic Way, Berkeley, CA 94704.
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: vpi_memory.cc,v 1.23 2004/05/19 03:30:46 steve Exp $"
|
||||
#ident "$Id: vpi_memory.cc,v 1.23.2.1 2006/02/19 16:57:31 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
|
|
@ -583,8 +583,19 @@ vpiHandle vpip_make_memory(vvp_memory_t mem)
|
|||
return &(obj->base);
|
||||
}
|
||||
|
||||
void vpip_memory_value_change(struct __vpiCallback*cbh,
|
||||
vpiHandle ref)
|
||||
{
|
||||
struct __vpiMemory*obj = (struct __vpiMemory*)ref;
|
||||
cbh->next = obj->mem->cb;
|
||||
obj->mem->cb = cbh;
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: vpi_memory.cc,v $
|
||||
* Revision 1.23.2.1 2006/02/19 16:57:31 steve
|
||||
* Add change callback to vpiMemory objects.
|
||||
*
|
||||
* Revision 1.23 2004/05/19 03:30:46 steve
|
||||
* Support delayed/non-blocking assignment to reals and others.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: vpi_priv.h,v 1.59 2004/10/04 01:10:59 steve Exp $"
|
||||
#ident "$Id: vpi_priv.h,v 1.59.2.1 2006/02/19 16:57:31 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_user.h"
|
||||
|
|
@ -209,6 +209,12 @@ extern vpiHandle vpip_make_named_event(const char*name, vvp_ipoint_t f);
|
|||
extern void vpip_run_named_event_callbacks(vpiHandle ref);
|
||||
extern void vpip_real_value_change(struct __vpiCallback*cbh,
|
||||
vpiHandle ref);
|
||||
/*
|
||||
* Callback for vpiMemory type
|
||||
*/
|
||||
void vpip_memory_value_change(struct __vpiCallback*cbh,
|
||||
vpiHandle ref);
|
||||
|
||||
|
||||
/*
|
||||
* Memory is an array of bits that is accessible in N-bit chunks, with
|
||||
|
|
@ -418,6 +424,9 @@ extern char *need_result_buf(unsigned cnt, vpi_rbuf_t type);
|
|||
|
||||
/*
|
||||
* $Log: vpi_priv.h,v $
|
||||
* Revision 1.59.2.1 2006/02/19 16:57:31 steve
|
||||
* Add change callback to vpiMemory objects.
|
||||
*
|
||||
* Revision 1.59 2004/10/04 01:10:59 steve
|
||||
* Clean up spurious trailing white space.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue