2013-03-30 12:28:41 -04:00
|
|
|
from collections import defaultdict
|
|
|
|
|
2013-05-22 11:11:09 -04:00
|
|
|
from migen.fhdl.std import *
|
2012-07-06 17:36:10 -04:00
|
|
|
from migen.flow.actor import *
|
|
|
|
|
2013-03-15 14:41:30 -04:00
|
|
|
class EndpointSimHook(Module):
|
2012-07-06 17:36:10 -04:00
|
|
|
def __init__(self, endpoint):
|
|
|
|
self.endpoint = endpoint
|
2014-10-17 05:08:37 -04:00
|
|
|
|
2012-07-06 17:36:10 -04:00
|
|
|
def on_ack(self):
|
|
|
|
pass
|
2014-10-17 05:08:37 -04:00
|
|
|
|
2012-07-06 17:36:10 -04:00
|
|
|
def on_nack(self):
|
|
|
|
pass
|
2014-10-17 05:08:37 -04:00
|
|
|
|
2012-07-06 17:36:10 -04:00
|
|
|
def on_inactive(self):
|
|
|
|
pass
|
2014-10-17 05:08:37 -04:00
|
|
|
|
2014-01-26 16:19:43 -05:00
|
|
|
def do_simulation(self, selfp):
|
|
|
|
if selfp.endpoint.stb:
|
|
|
|
if selfp.endpoint.ack:
|
2012-07-06 17:36:10 -04:00
|
|
|
self.on_ack()
|
|
|
|
else:
|
|
|
|
self.on_nack()
|
|
|
|
else:
|
|
|
|
self.on_inactive()
|
|
|
|
|
2013-03-30 12:28:41 -04:00
|
|
|
class DFGHook(Module):
|
2012-07-06 17:36:10 -04:00
|
|
|
def __init__(self, dfg, create):
|
|
|
|
assert(not dfg.is_abstract())
|
2013-03-30 12:28:41 -04:00
|
|
|
self.nodepair_to_ep = defaultdict(dict)
|
2013-04-10 13:12:42 -04:00
|
|
|
for hookn, (u, v, data) in enumerate(dfg.edges_iter(data=True)):
|
2013-03-30 12:28:41 -04:00
|
|
|
ep_to_hook = self.nodepair_to_ep[(u, v)]
|
2012-07-06 17:36:10 -04:00
|
|
|
ep = data["source"]
|
2013-03-30 12:28:41 -04:00
|
|
|
h = create(u, ep, v)
|
|
|
|
ep_to_hook[ep] = h
|
|
|
|
setattr(self.submodules, "hook"+str(hookn), h)
|
2014-10-17 05:08:37 -04:00
|
|
|
|
2012-08-03 12:48:35 -04:00
|
|
|
def hooks_iter(self):
|
2012-07-06 17:36:10 -04:00
|
|
|
for v1 in self.nodepair_to_ep.values():
|
|
|
|
for v2 in v1.values():
|
2012-08-03 12:48:35 -04:00
|
|
|
yield v2
|