sim_dq0_am.py

Pasted by zyp on Sat Dec 2 14:07:29 2023 UTC as Python
dut = InverseDQ0(1000)

async def test_angle(d, q, enc):
    await dut.input.send({'dq': (d, q), 'enc': enc})

    a, b, c = (await dut.output.recv())['current']

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