diff options
author | Brett Weiland <brett_weiland@gmail.com> | 2024-04-11 21:55:09 -0500 |
---|---|---|
committer | Brett Weiland <brett_weiland@gmail.com> | 2024-04-11 21:55:09 -0500 |
commit | 3f1369e4f9e48ff0dd19fe6f500364845d437b0c (patch) | |
tree | 04b6ca6d6d51ed014b6c374b68fe70d4e2ba9e94 /booth_multiplier.py | |
parent | cd17799a11de9a80aa1e1d98129e106083bf14b8 (diff) |
started reprot
Diffstat (limited to 'booth_multiplier.py')
-rwxr-xr-x | booth_multiplier.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/booth_multiplier.py b/booth_multiplier.py index afd6710..dc32263 100755 --- a/booth_multiplier.py +++ b/booth_multiplier.py @@ -91,8 +91,12 @@ def booth_mod(multiplier, multiplicand, length): return (result, operations) if __name__ == "__main__": - headers = ['multiplicand', 'multiplier', 'result (bin)', 'result (hex)'] - table = [] + result_headers = ['multiplicand', 'multiplier', 'result (bin)', 'result (hex)'] + result_table = [] + + opcount_headers = ['multiplicand', 'multiplier', 'length', 'booth', 'modified booth'] + opcount_table = [] + lengths = [] # for matplotlib plot ops_booth = [] ops_mod_booth = [] @@ -106,7 +110,7 @@ if __name__ == "__main__": multiplicand = int(operation.split(" ")[0], 2) multiplier = int(operation.split(" ")[1], 2) - + # get result and operation count of both algorithims result_booth = booth(multiplier, multiplicand, length) result_mod_booth = booth_mod(multiplier, multiplicand, length) @@ -115,11 +119,19 @@ if __name__ == "__main__": ops_mod_booth.append(result_mod_booth[1]) lengths.append(length) - table.append([bin(multiplicand), bin(multiplier), bin(result_booth[0]), hex(result_booth[0])]) + #gather data for report results table + result_table.append([bin(multiplicand), bin(multiplier), bin(result_booth[0]), hex(result_booth[0])]) + + #gather data for test function to check if simulator is working debug_results.append([multiplicand, multiplier, result_booth[0], result_mod_booth[0], length]) + #gather data for operation count table + opcount_table.append([bin(multiplicand), bin(multiplier), length, result_booth[1], result_mod_booth[1]]) + debug(debug_results) - print(tabulate(table, headers)) + print(tabulate(result_table, result_headers)) + print(tabulate(opcount_table, opcount_headers)) + # generate graph plt.plot(lengths, ops_booth, '^--m', label='booths algorithim') |