Untitled

Pasted by zyp on Thu Nov 30 23:20:16 2023 UTC as Python
dut = InverseDQ0(1000)

async def test_angle(d, q, enc):
    await dut.dq.d.set(d)
    await dut.dq.q.set(q)

    await dut.enc.set(enc)

    await dut.valid.set(1)

    await Tick()
    await dut.valid.set(0)

    for i in range(15):
        await Tick()
    
    a = await dut.output.current[0].get()
    b = await dut.output.current[1].get()
    c = await dut.output.current[2].get()

    print(f'{d=}, {q=}, {enc=}, {a=}, {b=}, {c=}')

async def testbench():
    for i in range(10):
        await Tick()

    await test_angle(1000, 0, 0)

    await test_angle(0, 1000, 0)

    await test_angle(1000, 1000, 0)

    await test_angle(0, 1000, 333)

    for i in range(10):
        await Tick()

sim = Simulator(dut)
sim.add_clock(1 / 75e6)
sim.add_sync_process(testbench)
with sim.write_vcd('dq0_am.vcd'):
    sim.run()