From 6f0d98cf186ddae536e1e5c9952f334f0242984f Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Thu, 29 May 2008 14:00:03 -0700 Subject: [PATCH] Constrain multiply word to prevent overflow. The multiply runs does not need to do all the combinations of digit products, because the higher ones cannot add into the result. Fix the iteration to limit the scan. --- vvp/vthread.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vvp/vthread.cc b/vvp/vthread.cc index 5f82644ba..b170cb01f 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -3032,7 +3032,7 @@ bool of_MUL(vthread_t thr, vvp_code_t cp) res[idx] = 0; for (unsigned mul_a = 0 ; mul_a < words ; mul_a += 1) { - for (unsigned mul_b = 0 ; mul_b < words ; mul_b += 1) { + for (unsigned mul_b = 0 ; mul_b < (words-mul_a) ; mul_b += 1) { unsigned long sum; unsigned long tmp = multiply_with_carry(ap[mul_a], bp[mul_b], sum); unsigned base = mul_a + mul_b;