again reduce combinatorial chains, similar to Trap pipeline,
[soc.git] / src / soc / fu / branch / pipeline.py
1 from nmutil.singlepipe import ControlBase
2 from nmutil.pipemodbase import PipeModBaseChain
3 from soc.fu.branch.main_stage import BranchMainStage
4 from nmutil.pipemodbase import PipeModBase
5 from soc.fu.branch.pipe_data import BranchInputData
6 from nmigen import Module
7
8 # gives a 1-clock delay to stop combinatorial link between in and out
9 class DummyBranchStage(PipeModBase):
10 def __init__(self, pspec): super().__init__(pspec, "dummy")
11 def ispec(self): return BranchInputData(self.pspec)
12 def ospec(self): return BranchInputData(self.pspec)
13
14 def elaborate(self, platform):
15 m = Module()
16 m.d.comb += self.o.eq(self.i) # pass-through output
17 return m
18
19 class BranchDummyStages(PipeModBaseChain):
20 def get_chain(self):
21 dummy = DummyBranchStage(self.pspec)
22 return [dummy]
23
24
25 class BranchStages(PipeModBaseChain):
26 def get_chain(self):
27 main = BranchMainStage(self.pspec)
28 return [main]
29
30
31 class BranchBasePipe(ControlBase):
32 def __init__(self, pspec):
33 ControlBase.__init__(self)
34 self.pspec = pspec
35 self.pipe1 = BranchDummyStages(pspec)
36 self.pipe2 = BranchStages(pspec)
37 self._eqs = self.connect([self.pipe1, self.pipe2])
38
39 def elaborate(self, platform):
40 m = ControlBase.elaborate(self, platform)
41 m.submodules.pipe1 = self.pipe1
42 m.submodules.pipe2 = self.pipe2
43 m.d.comb += self._eqs
44 return m