Make modular mult work
This commit is contained in:
@@ -57,10 +57,6 @@ def friendly_modular_mult(value_a: int, value_b: int) -> int:
|
||||
|
||||
mods = [friendly_modulo(prod, 26*i) for i, prod in enumerate(prods)]
|
||||
|
||||
if sum(mods) >= 2*PRIME:
|
||||
print("Saw greater than 2x prime!!!")
|
||||
|
||||
|
||||
mod_sum = friendly_modulo(sum(mods), 0)
|
||||
|
||||
return mod_sum
|
||||
|
||||
@@ -8,6 +8,8 @@ from cocotb.queue import Queue
|
||||
|
||||
from cocotbext.axi import AxiStreamBus, AxiStreamSource
|
||||
|
||||
from modulo_theory import friendly_modular_mult
|
||||
|
||||
import random
|
||||
|
||||
PRIME = 2**130-5
|
||||
@@ -48,7 +50,7 @@ class TB:
|
||||
|
||||
async def write_input(self, data: int, h: int):
|
||||
await self.input_queue.put((data, h))
|
||||
await self.expected_queue.put((data * h) % PRIME)
|
||||
await self.expected_queue.put(friendly_modular_mult(h, data))
|
||||
|
||||
async def run_input(self):
|
||||
while True:
|
||||
@@ -76,7 +78,7 @@ async def test_sanity(dut):
|
||||
|
||||
await tb.cycle_reset()
|
||||
|
||||
count = 1
|
||||
count = 16
|
||||
|
||||
for _ in range(count):
|
||||
await tb.write_input(random.randint(1,2**128-1), random.randint(0, 2**130-6))
|
||||
|
||||
Reference in New Issue
Block a user