-""" key strategic example showing how to do multi-input fan-in into a
+""" key strategic example showing how to do multi-input fan-in into a
multi-stage pipeline, then multi-output fanout.
the multiplex ID from the fan-in is passed in to the pipeline, preserved,
from nmigen.compat.sim import run_simulation
from nmigen.cli import verilog, rtlil
-from multipipe import CombMultiOutPipeline
-from multipipe import CombMultiInPipeline, InputPriorityArbiter
-from singlepipe import UnbufferedPipeline
-
-
-class PriorityCombPipeline(CombMultiInPipeline):
- def __init__(self, stage, p_len):
- p_mux = InputPriorityArbiter(self, p_len)
- CombMultiInPipeline.__init__(self, stage, p_len=p_len, p_mux=p_mux)
-
- def ports(self):
- return self.p_mux.ports()
- #return UnbufferedPipeline.ports(self) + self.p_mux.ports()
-
-
-class MuxCombPipeline(CombMultiOutPipeline):
- def __init__(self, stage, n_len):
- # HACK: stage is also the n-way multiplexer
- CombMultiOutPipeline.__init__(self, stage, n_len=n_len, n_mux=stage)
-
- # HACK: n-mux is also the stage... so set the muxid equal to input mid
- stage.m_id = self.p.i_data.mid
-
- def ports(self):
- return self.p_mux.ports()
+from multipipe import CombMultiOutPipeline, CombMuxOutPipe
+from multipipe import PriorityCombMuxInPipe
+from singlepipe import SimpleHandshake
class PassData: # (Value):
return PassData()
def ospec(self):
return self.ispec() # same as ospec
-
+
def process(self, i):
return i # pass-through
-class PassThroughPipe(UnbufferedPipeline):
+class PassThroughPipe(SimpleHandshake):
def __init__(self):
- UnbufferedPipeline.__init__(self, PassThroughStage())
+ SimpleHandshake.__init__(self, PassThroughStage())
class InputTest:
print ("recv ended", mid)
-class TestPriorityMuxPipe(PriorityCombPipeline):
+class TestPriorityMuxPipe(PriorityCombMuxInPipe):
def __init__(self, num_rows):
self.num_rows = num_rows
stage = PassThroughStage()
- PriorityCombPipeline.__init__(self, stage, p_len=self.num_rows)
-
- def ports(self):
- res = []
- for i in range(len(self.p)):
- res += [self.p[i].i_valid, self.p[i].o_ready] + \
- self.p[i].i_data.ports()
- res += [self.n.i_ready, self.n.o_valid] + \
- self.n.o_data.ports()
- return res
-
+ PriorityCombMuxInPipe.__init__(self, stage, p_len=self.num_rows)
class OutputTest:
yield rs.i_valid.eq(0)
-class TestMuxOutPipe(MuxCombPipeline):
+class TestMuxOutPipe(CombMuxOutPipe):
def __init__(self, num_rows):
self.num_rows = num_rows
stage = PassThroughStage()
- MuxCombPipeline.__init__(self, stage, n_len=self.num_rows)
-
- def ports(self):
- res = [self.p.i_valid, self.p.o_ready] + \
- self.p.i_data.ports()
- for i in range(len(self.n)):
- res += [self.n[i].i_ready, self.n[i].o_valid] + \
- self.n[i].o_data.ports()
- return res
+ CombMuxOutPipe.__init__(self, stage, n_len=self.num_rows)
class TestInOutPipe: