diff --git a/vvp/vpi_callback.cc b/vvp/vpi_callback.cc index 931d92d39..db8cf64b1 100644 --- a/vvp/vpi_callback.cc +++ b/vvp/vpi_callback.cc @@ -127,6 +127,12 @@ static struct __vpiCallback* make_value_change(p_cb_data data) obj->cb_time.type = vpiSuppressTime; } obj->cb_data.time = &obj->cb_time; + if (data->value) { + obj->cb_value = *(data->value); + } else { + obj->cb_value.format = vpiSuppressVal; + } + obj->cb_data.value = &obj->cb_value; assert(data->obj); assert(data->obj->vpi_type); @@ -457,8 +463,25 @@ void callback_execute(struct __vpiCallback*cur) vpi_mode_flag = VPI_MODE_RWSYNC; assert(cur->cb_data.cb_rtn); - cur->cb_data.time->type = vpiSimTime; - vpip_time_to_timestruct(cur->cb_data.time, schedule_simtime()); + switch (cur->cb_data.time->type) { + case vpiSimTime: + vpip_time_to_timestruct(cur->cb_data.time, schedule_simtime()); + break; + case vpiScaledRealTime: { + cur->cb_data.time->real = + vpip_time_to_scaled_real(schedule_simtime(), + (struct __vpiScope *) vpi_handle(vpiScope, + cur->cb_data.obj)); + break; + } + case vpiSuppressTime: + break; + default: + fprintf(stderr, "Unsupported time format %d.\n", + cur->cb_data.time->type); + assert(0); + break; + } (cur->cb_data.cb_rtn)(&cur->cb_data); vpi_mode_flag = save_mode; @@ -546,10 +569,32 @@ void vvp_fun_signal::get_value(struct t_vpi_value*vp) { switch (vp->format) { case vpiScalarVal: + // This works because vvp_bit4_t has the same encoding + // as a scalar value! See vpip_vec4_get_value() for a + // more robust method. vp->value.scalar = value(0); break; + + case vpiBinStrVal: + case vpiOctStrVal: + case vpiDecStrVal: + case vpiHexStrVal: + case vpiIntVal: + case vpiVectorVal: + case vpiStringVal: + case vpiRealVal: { + unsigned wid = size(); + vvp_vector4_t vec4(wid); + for (unsigned idx = 0; idx < wid; idx += 1) { + vec4.set_bit(idx, value(idx)); + } + vpip_vec4_get_value(vec4, wid, false, vp); + break; + } + case vpiSuppressVal: break; + default: fprintf(stderr, "vpi_callback: value " "format %d not supported (fun_signal)\n", @@ -622,6 +667,9 @@ void vvp_fun_signal_real::get_value(struct t_vpi_value*vp) break; } + case vpiSuppressVal: + break; + default: fprintf(stderr, "vpi_callback: value " "format %d not supported (fun_signal_real)\n", diff --git a/vvp/vpi_priv.cc b/vvp/vpi_priv.cc index 0c004d2a9..8e0a63fe0 100644 --- a/vvp/vpi_priv.cc +++ b/vvp/vpi_priv.cc @@ -456,6 +456,9 @@ void vpip_vec4_get_value(const vvp_vector4_t&word_val, unsigned width, vp->format); assert(0 && "format not implemented"); + case vpiSuppressVal: + break; + case vpiBinStrVal: rbuf = need_result_buf(width+1, RBUF_VAL); for (unsigned idx = 0 ; idx < width ; idx += 1) { @@ -504,6 +507,7 @@ void vpip_vec4_get_value(const vvp_vector4_t&word_val, unsigned width, break; case BIT4_X: vp->value.scalar = vpiX; + break; case BIT4_Z: vp->value.scalar = vpiZ; break; diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index 25a5282b8..49d38ed5d 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -137,6 +137,7 @@ struct __vpiCallback { // user supplied callback data struct t_cb_data cb_data; struct t_vpi_time cb_time; + struct t_vpi_value cb_value; // scheduled event struct sync_cb* cb_sync;