From bc7a5a97252af3dce4141f8459e726ca2cd542b9 Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 22 Mar 2010 18:49:11 -0700 Subject: [PATCH] vpi_get_value should return an appropriate value during compiletf. The vpi_get_value() function should not crash when called during the compiletf phase. This patch fixes this by returning 'bx for any vectors in thread space. It also fixes some other minor things that my test code uncovered. Most of the other objects work as expected. --- vvp/vpi_vthr_vector.cc | 7 +++++-- vvp/vthread.cc | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/vvp/vpi_vthr_vector.cc b/vvp/vpi_vthr_vector.cc index edef159dc..d1e87fbe9 100644 --- a/vvp/vpi_vthr_vector.cc +++ b/vvp/vpi_vthr_vector.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2009 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com) * Copyright (c) 2001 Stephan Boettcher * * This source code is free software; you can redistribute it @@ -109,7 +109,8 @@ static int vthr_vec_get(int code, vpiHandle ref) static char* vthr_vec_get_str(int code, vpiHandle ref) { assert((ref->vpi_type->type_code==vpiNet) - || (ref->vpi_type->type_code==vpiReg)); + || (ref->vpi_type->type_code==vpiReg) + || (ref->vpi_type->type_code==vpiConstant)); struct __vpiVThrVec*rfp = (struct __vpiVThrVec*)ref; @@ -319,6 +320,8 @@ static void vthr_vec_get_value(vpiHandle ref, s_vpi_value*vp) } break; + case vpiObjTypeVal: + vp->format = vpiVectorVal; case vpiVectorVal: vp->value.vector = (s_vpi_vecval*) need_result_buf((wid+31)/32*sizeof(s_vpi_vecval), RBUF_VAL); diff --git a/vvp/vthread.cc b/vvp/vthread.cc index a93eb4dbf..c9ce00092 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2009 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -167,7 +167,8 @@ static inline void thr_clr_bit_(struct vthread_s*thr, unsigned addr) vvp_bit4_t vthread_get_bit(struct vthread_s*thr, unsigned addr) { - return thr_get_bit(thr, addr); + if (vpi_mode_flag == VPI_MODE_COMPILETF) return BIT4_X; + else return thr_get_bit(thr, addr); } void vthread_put_bit(struct vthread_s*thr, unsigned addr, vvp_bit4_t bit)