Make modular mult work

This commit is contained in:
Byron Lathi
2025-10-28 21:59:28 -07:00
parent ad257f4220
commit d6a062baa0
3 changed files with 16 additions and 14 deletions

View File

@@ -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))