litex/migen/test/support.py

25 lines
523 B
Python
Raw Normal View History

2013-11-29 03:47:32 -05:00
import unittest
from migen.fhdl.std import *
from migen.sim.generic import Simulator
from migen.fhdl import verilog
class SimBench(Module):
callback = None
def do_simulation(self, s):
if self.callback is not None:
return self.callback(self, s)
class SimCase(unittest.TestCase):
TestBench = SimBench
def setUp(self):
self.tb = self.TestBench()
def test_to_verilog(self):
verilog.convert(self.tb)
def run_with(self, cb, cycles=-1):
self.tb.callback = cb
with Simulator(self.tb) as s:
s.run(cycles)