v0_8: print an error message for an invalid bit selection.

This code may be used for more than just a bit select so the error message
is fairly generic. Though it should help in tracking down the real problem
(invalid Verilog code).
This commit is contained in:
Cary R 2007-10-25 18:59:57 -07:00 committed by Stephen Williams
parent 40e09cd719
commit 5530aea6a3
1 changed files with 6 additions and 1 deletions

View File

@ -27,6 +27,7 @@
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
@ -50,7 +51,11 @@ vvp_ipoint_t vvp_fvector_get(vvp_fvector_t v, unsigned i)
{
if (!v->size)
return ipoint_index(v->cont.iptr, i);
assert(i < v->size);
if (v->size >= i) {
fprintf(stderr, "ERROR: index value (%d) must be less than "
"element size (%d).\n", i, v->size);
assert(0);
}
return v->iptrs[i];
}