move common functionality between PipeSpecs to soc.fu.pipe_data
[soc.git] / src / soc / fu / cr / pipe_data.py
1 from nmigen import Signal, Const
2 from ieee754.fpcommon.getop import FPPipeContext
3 from soc.fu.pipe_data import IntegerData, CommonPipeSpec
4 from soc.fu.alu.alu_input_record import CompALUOpSubset # TODO: replace
5
6
7 class CRInputData(IntegerData):
8 regspec = [('INT', 'a', '0:63'),
9 ('CR', 'cr', '32')]
10 def __init__(self, pspec):
11 super().__init__(pspec)
12 self.a = Signal(64, reset_less=True) # RA
13 self.cr = Signal(32, reset_less=True) # CR in
14
15 def __iter__(self):
16 yield from super().__iter__()
17 yield self.a
18 yield self.cr
19
20 def eq(self, i):
21 lst = super().eq(i)
22 return lst + [self.a.eq(i.a),
23 self.cr.eq(i.cr)]
24
25 class CROutputData(IntegerData):
26 regspec = [('INT', 'o', '0:63'),
27 ('CR', 'cr', '32')]
28 def __init__(self, pspec):
29 super().__init__(pspec)
30 self.o = Signal(64, reset_less=True) # RA
31 self.cr = Signal(32, reset_less=True, name="cr_out") # CR in
32
33 def __iter__(self):
34 yield from super().__iter__()
35 yield self.o
36 yield self.cr
37
38 def eq(self, i):
39 lst = super().eq(i)
40 return lst + [self.o.eq(i.o),
41 self.cr.eq(i.cr)]
42
43 # TODO: replace CompALUOpSubset with CompCROpSubset
44 class CRPipeSpec(CommonPipeSpec):
45 regspec = (CRInputData.regspec, CROutputData.regspec)
46 opsubsetkls = CompALUOpSubset