litex/migen/test/support.py

23 lines
530 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
class SimBench(Module):
callback = None
2014-01-26 16:19:43 -05:00
def do_simulation(self, selfp):
2013-11-29 03:47:32 -05:00
if self.callback is not None:
2014-01-26 16:19:43 -05:00
return self.callback(self, selfp)
2013-11-29 03:47:32 -05:00
class SimCase:
2013-11-29 03:47:32 -05:00
TestBench = SimBench
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)
2014-03-24 11:32:26 -04:00
def run_with(self, cb, ncycles=None):
2013-11-29 03:47:32 -05:00
self.tb.callback = cb
2014-01-26 16:19:43 -05:00
run_simulation(self.tb, ncycles=ncycles)