Fixup real value output from user defined functions

User defined functions need to check the output from the function,
which is an unfiltered signal.
This commit is contained in:
Stephen Williams 2009-09-12 12:25:18 -07:00
parent a1295db6bf
commit 03f2432f6e
4 changed files with 8 additions and 70 deletions

View File

@ -84,8 +84,7 @@ void ufunc_core::finish_thread(vthread_t thr)
{
thread_ = 0;
if (vvp_fun_signal_real*sig = dynamic_cast<vvp_fun_signal_real*>(result_->fun))
propagate_real(sig->real_value());
propagate_real(sig->real_unfiltered_value());
if (vvp_fun_signal_vec*sig = dynamic_cast<vvp_fun_signal_vec*>(result_->fun))
propagate_vec4(sig->vec4_unfiltered_value());

View File

@ -694,66 +694,6 @@ void vvp_fun_signal8::get_value(struct t_vpi_value*vp)
}
}
void vvp_fun_signal_real::get_value(struct t_vpi_value*vp)
{
char*rbuf = need_result_buf(64 + 1, RBUF_VAL);
switch (vp->format) {
case vpiObjTypeVal:
vp->format = vpiRealVal;
case vpiRealVal:
vp->value.real = real_value();
break;
case vpiIntVal:
vp->value.integer = (int)(real_value() + 0.5);
break;
case vpiDecStrVal:
sprintf(rbuf, "%0.0f", real_value());
vp->value.str = rbuf;
break;
case vpiHexStrVal:
sprintf(rbuf, "%lx", (long)real_value());
vp->value.str = rbuf;
break;
case vpiBinStrVal: {
unsigned long val = (unsigned long)real_value();
unsigned len = 0;
while (val > 0) {
len += 1;
val /= 2;
}
val = (unsigned long)real_value();
for (unsigned idx = 0 ; idx < len ; idx += 1) {
rbuf[len-idx-1] = (val & 1)? '1' : '0';
val /= 2;
}
rbuf[len] = 0;
if (len == 0) {
rbuf[0] = '0';
rbuf[1] = 0;
}
vp->value.str = rbuf;
break;
}
case vpiSuppressVal:
break;
default:
fprintf(stderr, "vpi_callback: value "
"format %d not supported (fun_signal_real)\n",
vp->format);
}
}
void vvp_wire_vec4::get_value(struct t_vpi_value*value)
{
get_signal_value(value);

View File

@ -486,9 +486,9 @@ vvp_fun_signal_real_sa::vvp_fun_signal_real_sa()
bits_ = 0.0;
}
double vvp_fun_signal_real_sa::real_value() const
double vvp_fun_signal_real_sa::real_unfiltered_value() const
{
assert(0);
return bits_;
}
void vvp_fun_signal_real_sa::recv_real(vvp_net_ptr_t ptr, double bit,
@ -548,7 +548,7 @@ void vvp_fun_signal_real_aa::free_instance(vvp_context_t context)
}
#endif
double vvp_fun_signal_real_aa::real_value() const
double vvp_fun_signal_real_aa::real_unfiltered_value() const
{
double*bits = static_cast<double*>
(vthread_get_rd_context_item(context_idx_));
@ -719,7 +719,7 @@ vvp_bit4_t vvp_wire_vec4::value(unsigned idx) const
vvp_scalar_t vvp_wire_vec4::scalar_value(unsigned idx) const
{
assert(0);
return vvp_scalar_t(value(idx),6,6);
}
vvp_vector4_t vvp_wire_vec4::vec4_value() const

View File

@ -222,9 +222,8 @@ class vvp_fun_signal_real : public vvp_fun_signal_base {
explicit vvp_fun_signal_real() {};
// Get information about the vector value.
virtual double real_value() const = 0;
virtual double real_unfiltered_value() const = 0;
void get_value(struct t_vpi_value*value);
unsigned size() const { return 1; }
};
@ -240,7 +239,7 @@ class vvp_fun_signal_real_sa : public vvp_fun_signal_real {
vvp_context_t);
// Get information about the vector value.
double real_value() const;
double real_unfiltered_value() const;
private:
double bits_;
@ -264,7 +263,7 @@ class vvp_fun_signal_real_aa : public vvp_fun_signal_real, public automatic_hook
vvp_context_t context);
// Get information about the vector value.
double real_value() const;
double real_unfiltered_value() const;
private:
unsigned context_idx_;