Fencepost error in memory writes. (Stephan Boettcher)

This commit is contained in:
steve
2001-09-29 20:55:42 +00:00
parent ff55af1e9e
commit 3854e12024
+3 -3
View File
@@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: memory.cc,v 1.9 2001/09/29 04:45:20 steve Exp $" #ident "$Id: memory.cc,v 1.10 2001/09/29 20:55:42 steve Exp $"
#endif #endif
#include "memory.h" #include "memory.h"
@@ -400,7 +400,7 @@ void vvp_memory_port_s::set(vvp_ipoint_t i, functor_t f, bool push)
void memory_set(vvp_memory_t mem, unsigned idx, unsigned char val) void memory_set(vvp_memory_t mem, unsigned idx, unsigned char val)
{ {
if (idx/4 > (mem->size * mem->fwidth)) if (idx/4 >= (mem->size * mem->fwidth))
return; return;
if (!set_bit(mem->bits, idx, val)) if (!set_bit(mem->bits, idx, val))
@@ -413,7 +413,7 @@ void memory_set(vvp_memory_t mem, unsigned idx, unsigned char val)
unsigned memory_get(vvp_memory_t mem, unsigned idx) unsigned memory_get(vvp_memory_t mem, unsigned idx)
{ {
if (idx/4 > (mem->size * mem->fwidth)) if (idx/4 >= (mem->size * mem->fwidth))
return 2; return 2;
return get_bit(mem->bits, idx); return get_bit(mem->bits, idx);