@pytest.mark.parametrize("mod,clks,memory", [(Top(), 1.0 / 12e6, MemoryArgs(init=PRIMES))], indirect=["memory"], ids=asm_label(PRIMES, "primes")) def test_primes(sim, mod, memory_process, ucode_panic): m = mod restart_timeout = Signal(1) async def timeout_process(ctx): while True: for i in range(1000): *_, restart_ack = await ctx.tick().sample(restart_timeout) if restart_ack: break else: raise AssertionError("CPU (but not microcode) probably stuck " "in infinite loop") async def io_tb(ctx): primes = [3, 5, 7, 11, 13, 17, 2] # 19, 23, 29, 31, 37, 41, 43, 47, 53, # 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, # 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, # 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, # 251, 2] for p in primes: *_, dat_w = await ctx.tick().sample(m.bus.dat_w).until( (m.bus.adr == 0x2000000 >> 2) & m.bus.cyc & \ m.bus.stb) ctx.set(m.bus.ack, 1) assert dat_w == p ctx.set(restart_timeout, 1) await ctx.tick() ctx.set(m.bus.ack, 0) ctx.set(restart_timeout, 0) sim.run(testbenches=[io_tb], processes=[ucode_panic, memory_process, timeout_process])