litex/migen/test/support.py

25 lines
589 B
Python
Raw Normal View History

2013-11-29 03:47:32 -05:00
from migen.fhdl.std import *
2014-01-26 16:19:43 -05:00
from migen.sim.generic import run_simulation
2013-11-29 03:47:32 -05:00
from migen.fhdl import verilog
2015-04-13 14:45:35 -04:00
2013-11-29 03:47:32 -05:00
class SimBench(Module):
callback = None
def do_simulation(self, selfp):
if self.callback is not None:
return self.callback(self, selfp)
2013-11-29 03:47:32 -05:00
2015-04-13 14:45:35 -04:00
class SimCase:
TestBench = SimBench
2013-11-29 03:47:32 -05:00
def setUp(self, *args, **kwargs):
self.tb = self.TestBench(*args, **kwargs)
2013-11-29 03:47:32 -05:00
def test_to_verilog(self):
verilog.convert(self.tb)
2013-11-29 03:47:32 -05:00
def run_with(self, cb, ncycles=None):
self.tb.callback = cb
run_simulation(self.tb, ncycles=ncycles)