Force part base out of bounds if index is invalid.

This commit is contained in:
steve 2005-05-09 00:36:58 +00:00
parent 7dd0d255a6
commit ed78c5b677
2 changed files with 16 additions and 3 deletions

View File

@ -16,11 +16,12 @@
* 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: part.cc,v 1.4 2005/05/08 23:40:14 steve Exp $"
#ident "$Id: part.cc,v 1.5 2005/05/09 00:36:58 steve Exp $"
# include "compile.h"
# include "vvp_net.h"
# include <stdlib.h>
# include <limits.h>
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
@ -84,6 +85,7 @@ void vvp_fun_part_var::recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit)
source_ = bit;
break;
case 1:
tmp = ULONG_MAX;
vector4_to_value(bit, tmp);
if (tmp == base_) return;
base_ = tmp;
@ -103,7 +105,10 @@ void vvp_fun_part_var::recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit)
res.set_bit(idx, source_.value(adr));
}
if (! ref_.eeq(res)) {
ref_ = res;
vvp_send_vec4(port.ptr()->out, res);
}
}
@ -153,6 +158,9 @@ void compile_part_select_var(char*label, char*source, char*var,
/*
* $Log: part.cc,v $
* Revision 1.5 2005/05/09 00:36:58 steve
* Force part base out of bounds if index is invalid.
*
* Revision 1.4 2005/05/08 23:40:14 steve
* Add support for variable part select.
*

View File

@ -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.26 2005/05/08 23:40:14 steve Exp $"
#ident "$Id: vvp_net.h,v 1.27 2005/05/09 00:36:58 steve Exp $"
# include "config.h"
# include <assert.h>
@ -548,6 +548,8 @@ class vvp_fun_part_var : public vvp_net_fun_t {
unsigned base_;
unsigned wid_;
vvp_vector4_t source_;
// Save the last output, for detecting change.
vvp_vector4_t ref_;
};
/* vvp_fun_signal
@ -719,6 +721,9 @@ class vvp_wide_fun_t : public vvp_net_fun_t {
/*
* $Log: vvp_net.h,v $
* Revision 1.27 2005/05/09 00:36:58 steve
* Force part base out of bounds if index is invalid.
*
* Revision 1.26 2005/05/08 23:40:14 steve
* Add support for variable part select.
*