From 711ffbd6cda490d4d7da096160dd194bece4047e Mon Sep 17 00:00:00 2001 From: "Pavel V. Shatov (Meister)" Date: Sun, 24 Mar 2019 12:18:47 +0300 Subject: Simplified index calculation and accumulator clearing logic. Better debug printout of accumulators. --- modexpng_fpga_model.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'modexpng_fpga_model.py') diff --git a/modexpng_fpga_model.py b/modexpng_fpga_model.py index d3b7841..844cc86 100644 --- a/modexpng_fpga_model.py +++ b/modexpng_fpga_model.py @@ -353,13 +353,22 @@ class ModExpNG_WordMultiplier(): for col in range(num_cols): - self._clear_all_macs() - self._preset_indices(col) + for t in range(ab_num_words): - if dump and DUMP_MACS_CLEARING: - print("t= 0, col=%2d > clear > all" % (col)) + if t == 0: self._preset_indices(col) + else: self._rotate_indices(ab_num_words) + + if t == 0: + self._clear_all_macs() + if dump and DUMP_MACS_CLEARING: + print("t= 0, col=%2d > clear > all" % (col)) + else: + t1 = t - 1 + if (t1 // 8) == col: + self._clear_one_mac(t1 % NUM_MULTS) + if dump and DUMP_MACS_CLEARING: + print("t=%2d, col=%2d > clear > x=%d:" % (t, col, t1 % NUM_MULTS)) - for t in range(ab_num_words): if dump and DUMP_INDICES: print("t=%2d, col=%2d > indices:" % (t, col), end='') @@ -377,18 +386,14 @@ class ModExpNG_WordMultiplier(): if t == (col * NUM_MULTS + x): parts[t] = self._macs[x] - self._clear_one_mac(x) - if dump and DUMP_MACS_CLEARING: - print("t=%2d, col=%2d > clear > x=%d:" % (t, col, x)) if dump and DUMP_MACS_ACCUMULATION: + print("t=%2d, col=%2d > "% (t, col), end='') for i in range(NUM_MULTS): if i > 0: print(" | ", end='') - print("[%d]: 0x%012x" % (i, self._macs[i]), end='') + print("mac[%d]: 0x%012x" % (i, self._macs[i]), end='') print("") - - # save the uppers part of product at end of column, # for the last column don't save the very last part if t == (ab_num_words - 1): @@ -396,8 +401,6 @@ class ModExpNG_WordMultiplier(): if not (col == (num_cols - 1) and x == (NUM_MULTS - 1)): parts[ab_num_words + col * NUM_MULTS + x] = self._macs[x] - self._rotate_indices(ab_num_words) - return parts def multiply_triangle(self, a_wide, b_narrow, ab_num_words): -- cgit v1.2.3