create and use ShiftRotPipeSpec
[soc.git] / src / soc / fu / shift_rot / pipe_data.py
1 from nmigen import Signal, Const
2 from nmutil.dynamicpipe import SimpleHandshakeRedir
3 from soc.fu.alu.alu_input_record import CompALUOpSubset
4 from ieee754.fpcommon.getop import FPPipeContext
5 from soc.fu.alu.pipe_data import ALUOutputData, IntegerData
6 from nmutil.dynamicpipe import SimpleHandshakeRedir
7
8
9 class ShiftRotInputData(IntegerData):
10 regspec = [('INT', 'ra', '0:63'),
11 ('INT', 'rs', '0:63'),
12 ('INT', 'rb', '0:63'),
13 ('XER', 'xer_so', '32'),
14 ('XER', 'xer_ca', '34,45')]
15 def __init__(self, pspec):
16 super().__init__(pspec)
17 self.ra = Signal(64, reset_less=True) # RA
18 self.rs = Signal(64, reset_less=True) # RS
19 self.rb = Signal(64, reset_less=True) # RB/immediate
20 self.xer_so = Signal(reset_less=True) # XER bit 32: SO
21 self.xer_ca = Signal(2, reset_less=True) # XER bit 34/45: CA/CA32
22
23 def __iter__(self):
24 yield from super().__iter__()
25 yield self.ra
26 yield self.rs
27 yield self.rb
28 yield self.xer_ca
29 yield self.xer_so
30
31 def eq(self, i):
32 lst = super().eq(i)
33 return lst + [self.rs.eq(i.rs), self.ra.eq(i.ra),
34 self.rb.eq(i.rb),
35 self.xer_ca.eq(i.xer_ca),
36 self.xer_so.eq(i.xer_so)]
37
38
39 # TODO: replace CompALUOpSubset with CompShiftRotOpSubset
40 class ShiftRotPipeSpec:
41 regspec = (ShiftRotInputData.regspec, ALUOutputData.regspec)
42 opsubsetkls = CompALUOpSubset
43 def __init__(self, id_wid, op_wid):
44 self.id_wid = id_wid
45 self.op_wid = op_wid
46 self.opkls = lambda _: self.opsubsetkls(name="op")
47 self.stage = None
48 self.pipekls = SimpleHandshakeRedir