Handle vpiRealVal reads of signals, and real anyedge events.
This commit is contained in:
parent
2c7d2effd1
commit
316422d93b
24
vvp/event.cc
24
vvp/event.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: event.cc,v 1.22 2006/11/22 06:10:05 steve Exp $"
|
||||
#ident "$Id: event.cc,v 1.23 2006/12/09 19:06:53 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "event.h"
|
||||
|
|
@ -101,6 +101,8 @@ void vvp_fun_edge::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
|
|||
vvp_fun_anyedge::vvp_fun_anyedge(bool debug_flag)
|
||||
: debug_(debug_flag)
|
||||
{
|
||||
for (unsigned idx = 0 ; idx < 4 ; idx += 1)
|
||||
bitsr_[idx] = 0.0;
|
||||
}
|
||||
|
||||
vvp_fun_anyedge::~vvp_fun_anyedge()
|
||||
|
|
@ -132,6 +134,23 @@ void vvp_fun_anyedge::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
|
|||
}
|
||||
}
|
||||
|
||||
void vvp_fun_anyedge::recv_real(vvp_net_ptr_t port, double bit)
|
||||
{
|
||||
unsigned pdx = port.port();
|
||||
bool flag = false;
|
||||
|
||||
if (bitsr_[pdx] != bit) {
|
||||
flag = true;
|
||||
bitsr_[pdx] = bit;
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
run_waiting_threads_();
|
||||
vvp_net_t*net = port.ptr();
|
||||
vvp_send_vec4(net->out, vvp_vector4_t());
|
||||
}
|
||||
}
|
||||
|
||||
vvp_fun_event_or::vvp_fun_event_or()
|
||||
{
|
||||
}
|
||||
|
|
@ -254,6 +273,9 @@ void compile_named_event(char*label, char*name)
|
|||
|
||||
/*
|
||||
* $Log: event.cc,v $
|
||||
* Revision 1.23 2006/12/09 19:06:53 steve
|
||||
* Handle vpiRealVal reads of signals, and real anyedge events.
|
||||
*
|
||||
* Revision 1.22 2006/11/22 06:10:05 steve
|
||||
* Fix spurious event from net8 that is forced.
|
||||
*
|
||||
|
|
|
|||
12
vvp/event.h
12
vvp/event.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: event.h,v 1.12 2006/11/22 06:10:05 steve Exp $"
|
||||
#ident "$Id: event.h,v 1.13 2006/12/09 19:06:53 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vvp_net.h"
|
||||
|
|
@ -73,6 +73,10 @@ extern const vvp_fun_edge::edge_t vvp_edge_none;
|
|||
* vector changes. Unlike the vvp_fun_edge, which watches for the LSB
|
||||
* of its inputs to change in a particular direction, the anyedge
|
||||
* functor looks at the entire input vector for any change.
|
||||
*
|
||||
* The anyedge is also different in that it can receive real
|
||||
* values. in this case, any detectable change in the real value leads
|
||||
* to an even trigger.
|
||||
*/
|
||||
class vvp_fun_anyedge : public vvp_net_fun_t, public waitable_hooks_s {
|
||||
|
||||
|
|
@ -81,10 +85,13 @@ class vvp_fun_anyedge : public vvp_net_fun_t, public waitable_hooks_s {
|
|||
virtual ~vvp_fun_anyedge();
|
||||
|
||||
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
|
||||
void recv_real(vvp_net_ptr_t port, double bit);
|
||||
|
||||
private:
|
||||
bool debug_;
|
||||
vvp_vector4_t bits_[4];
|
||||
// In case I'm a real-valued event.
|
||||
double bitsr_[4];
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -122,6 +129,9 @@ class vvp_named_event : public vvp_net_fun_t, public waitable_hooks_s {
|
|||
|
||||
/*
|
||||
* $Log: event.h,v $
|
||||
* Revision 1.13 2006/12/09 19:06:53 steve
|
||||
* Handle vpiRealVal reads of signals, and real anyedge events.
|
||||
*
|
||||
* Revision 1.12 2006/11/22 06:10:05 steve
|
||||
* Fix spurious event from net8 that is forced.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: vpi_signal.cc,v 1.74 2006/02/21 05:31:54 steve Exp $"
|
||||
#ident "$Id: vpi_signal.cc,v 1.75 2006/12/09 19:06:53 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -476,6 +476,13 @@ static void signal_get_value(vpiHandle ref, s_vpi_value*vp)
|
|||
break;
|
||||
}
|
||||
|
||||
case vpiRealVal: {
|
||||
bool flag = rfp->signed_flag;
|
||||
vp->value.real = 0.0;
|
||||
vector4_to_value(vsig->vec4_value(), vp->value.real, flag);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
fprintf(stderr, "vvp internal error: get_value: "
|
||||
"value type %u not implemented."
|
||||
|
|
@ -717,6 +724,9 @@ vpiHandle vpip_make_net(const char*name, int msb, int lsb,
|
|||
|
||||
/*
|
||||
* $Log: vpi_signal.cc,v $
|
||||
* Revision 1.75 2006/12/09 19:06:53 steve
|
||||
* Handle vpiRealVal reads of signals, and real anyedge events.
|
||||
*
|
||||
* Revision 1.74 2006/02/21 05:31:54 steve
|
||||
* Put strings for reg objects.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ident "$Id: vvp_net.cc,v 1.55 2006/11/22 06:10:05 steve Exp $"
|
||||
#ident "$Id: vvp_net.cc,v 1.56 2006/12/09 19:06:53 steve Exp $"
|
||||
|
||||
# include "config.h"
|
||||
# include "vvp_net.h"
|
||||
|
|
@ -25,6 +25,7 @@
|
|||
# include <iostream>
|
||||
# include <typeinfo>
|
||||
# include <limits.h>
|
||||
# include <math.h>
|
||||
# include <assert.h>
|
||||
|
||||
/* *** BIT operations *** */
|
||||
|
|
@ -588,6 +589,52 @@ bool vector4_to_value(const vvp_vector4_t&vec, unsigned long&val)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool vector4_to_value(const vvp_vector4_t&vec, double&val, bool signed_flag)
|
||||
{
|
||||
|
||||
if (vec.size() == 0) {
|
||||
val = 0.0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (vec.value(vec.size()-1) != BIT4_1) {
|
||||
signed_flag = false;
|
||||
}
|
||||
|
||||
double res = 0.0;
|
||||
if (signed_flag) {
|
||||
vvp_bit4_t carry = BIT4_1;
|
||||
for (unsigned idx = 0 ; idx < vec.size() ; idx += 1) {
|
||||
vvp_bit4_t a = ~vec.value(idx);
|
||||
vvp_bit4_t x = add_with_carry(a, BIT4_0, carry);
|
||||
switch (x) {
|
||||
case BIT4_0:
|
||||
break;
|
||||
case BIT4_1:
|
||||
res += pow(2.0, idx);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
res *= -1.0;
|
||||
} else {
|
||||
for (unsigned idx = 0 ; idx < vec.size() ; idx += 1) {
|
||||
switch (vec.value(idx)) {
|
||||
case BIT4_0:
|
||||
break;
|
||||
case BIT4_1:
|
||||
res += pow(2.0, idx);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
val = res;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T> T coerce_to_width(const T&that, unsigned width)
|
||||
{
|
||||
if (that.size() == width)
|
||||
|
|
@ -2209,6 +2256,9 @@ vvp_bit4_t compare_gtge_signed(const vvp_vector4_t&a,
|
|||
|
||||
/*
|
||||
* $Log: vvp_net.cc,v $
|
||||
* Revision 1.56 2006/12/09 19:06:53 steve
|
||||
* Handle vpiRealVal reads of signals, and real anyedge events.
|
||||
*
|
||||
* Revision 1.55 2006/11/22 06:10:05 steve
|
||||
* Fix spurious event from net8 that is forced.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ident "$Id: vvp_net.h,v 1.52 2006/08/04 04:37:37 steve Exp $"
|
||||
#ident "$Id: vvp_net.h,v 1.53 2006/12/09 19:06:53 steve Exp $"
|
||||
|
||||
# include "config.h"
|
||||
# include <stddef.h>
|
||||
|
|
@ -254,6 +254,7 @@ template <class T> extern T coerce_to_width(const T&that, unsigned width);
|
|||
* return value becomes false to indicate an error.
|
||||
*/
|
||||
extern bool vector4_to_value(const vvp_vector4_t&a, unsigned long&val);
|
||||
extern bool vector4_to_value(const vvp_vector4_t&a, double&val, bool is_signed);
|
||||
|
||||
/* vvp_vector2_t
|
||||
*/
|
||||
|
|
@ -1026,6 +1027,9 @@ inline void vvp_send_vec4_pv(vvp_net_ptr_t ptr, const vvp_vector4_t&val,
|
|||
|
||||
/*
|
||||
* $Log: vvp_net.h,v $
|
||||
* Revision 1.53 2006/12/09 19:06:53 steve
|
||||
* Handle vpiRealVal reads of signals, and real anyedge events.
|
||||
*
|
||||
* Revision 1.52 2006/08/04 04:37:37 steve
|
||||
* Support release of a for/linked reg.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue