litex/migen/flow/plumbing.py

50 lines
1.5 KiB
Python
Raw Normal View History

2012-01-06 11:24:05 -05:00
from migen.fhdl.structure import *
from migen.flow.actor import *
from migen.corelogic.record import *
from migen.corelogic.misc import optree
class Buffer(Actor):
2012-01-09 09:14:42 -05:00
def __init__(self, layout):
self.d = Record(layout)
self.q = Record(layout)
2012-01-06 11:24:05 -05:00
Actor.__init__(self,
SchedulingModel(SchedulingModel.PIPELINE, 1),
self.d, self.q)
def get_process_fragment(self):
sigs_d = self.d.flatten()
sigs_q = self.q.flatten()
2012-01-06 18:33:28 -05:00
sync = [If(self.pipe_ce, Cat(*sigs_q).eq(Cat(*sigs_d)))]
2012-01-06 11:24:05 -05:00
return Fragment(sync=sync)
class Combinator(Actor):
2012-01-09 09:14:42 -05:00
def __init__(self, layout, *subrecords):
self.destination = Record(layout)
2012-01-06 18:33:28 -05:00
self.ins = [self.destination.subrecord(*subr) for subr in subrecords]
2012-01-06 11:24:05 -05:00
Actor.__init__(self,
SchedulingModel(SchedulingModel.COMBINATORIAL),
2012-01-06 18:33:28 -05:00
self.ins, self.destination)
2012-01-06 11:24:05 -05:00
def get_process_fragment(self):
return Fragment() # nothing to do
def get_control_fragment(self):
2012-01-06 18:33:28 -05:00
source = self.sources()[0]
sinks = self.sinks()
comb = [source.stb.eq(optree('&', [sink.stb for sink in sinks]))]
comb += [sink.ack.eq(source.ack & source.stb) for sink in sinks]
2012-01-06 11:24:05 -05:00
return Fragment(comb)
class Splitter(Actor):
2012-01-09 09:14:42 -05:00
def __init__(self, layout, *subrecords):
self.source = Record(layout)
2012-01-06 18:33:28 -05:00
self.outs = [self.source.subrecord(*subr) for subr in subrecords]
2012-01-06 11:24:05 -05:00
Actor.__init__(self,
SchedulingModel(SchedulingModel.COMBINATORIAL),
2012-01-06 18:33:28 -05:00
self.source, self.outs)
2012-01-06 11:24:05 -05:00
def get_process_fragment(self):
return Fragment() # nothing to do
# TODO def get_control_fragment(self):