diff options
author | Pavel V. Shatov (Meister) <meisterpaul1@yandex.ru> | 2019-03-24 12:18:47 +0300 |
---|---|---|
committer | Pavel V. Shatov (Meister) <meisterpaul1@yandex.ru> | 2019-03-24 12:20:55 +0300 |
commit | 711ffbd6cda490d4d7da096160dd194bece4047e (patch) | |
tree | 087e88596e5f3527b9d31c6f24243c54000fcf15 /modexpng_fpga_model.py | |
parent | 701e3f1670042c9f9c7c76c529eac43802b20c24 (diff) |
Simplified index calculation and accumulator clearing logic.
Better debug printout of accumulators.
Diffstat (limited to 'modexpng_fpga_model.py')
-rw-r--r-- | modexpng_fpga_model.py | 29 |
1 files changed, 16 insertions, 13 deletions
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): |