Add callbacks to vpiMemory objects.

This patch adds the ability to set a global array callback.
These type of callbacks will be called when any element of
the array changes.
This commit is contained in:
Cary R 2008-09-04 20:19:07 -07:00 committed by Stephen Williams
parent 66949122cf
commit 90fbac6e33
3 changed files with 22 additions and 2 deletions

View File

@ -977,12 +977,18 @@ void array_word_change(vvp_array_t array, unsigned long addr)
struct __vpiCallback*cur = next;
next = cur->next;
// Skip callbacks for callbacks not for me.
if (cur->extra_data != (long)addr) {
// Skip callbacks that are not for me. -1 is for every element.
if (cur->extra_data != (long)addr && cur->extra_data != -1) {
prev = cur;
continue;
}
// For whole array callbacks we need to set the index.
if (cur->extra_data == -1) {
cur->cb_data.index = (PLI_INT32) ((int)addr +
array->first_addr.value);
}
if (cur->cb_data.cb_rtn != 0) {
if (cur->cb_data.value)
vpip_vec4_get_value(array->vals->get_word(addr),
@ -1058,6 +1064,15 @@ void vpip_array_word_change(struct __vpiCallback*cb, vpiHandle obj)
parent->vpi_callbacks = cb;
}
void vpip_array_change(struct __vpiCallback*cb, vpiHandle obj)
{
struct __vpiArray*arr = ARRAY_HANDLE(obj);
cb->extra_data = -1; // This is a callback for every element.
cb->next = arr->vpi_callbacks;
arr->vpi_callbacks = cb;
}
void compile_array_port(char*label, char*array, char*addr)
{
array_port_resolv_list_t*resolv_mem

View File

@ -48,6 +48,7 @@ extern vvp_vector4_t array_get_word(vvp_array_t array, unsigned address);
/* VPI hooks */
extern void vpip_array_word_change(struct __vpiCallback*cb, vpiHandle word);
extern void vpip_array_change(struct __vpiCallback*cb, vpiHandle word);
/* Compile hooks */
extern void compile_variablew(char*label, vvp_array_t array,

View File

@ -170,6 +170,10 @@ static struct __vpiCallback* make_value_change(p_cb_data data)
vpip_array_word_change(obj, data->obj);
break;
case vpiMemory:
vpip_array_change(obj, data->obj);
break;
case vpiPartSelect:
vpip_part_select_value_change(obj, data->obj);
break;