3d64de891870a2580a3cbd5a34484d2ade10b93d
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
.decoder
.power_decoder2
import Data
9 def __init__(self
, pspec
):
10 self
.ctx
= FPPipeContext(pspec
)
11 self
.muxid
= self
.ctx
.muxid
17 return [self
.ctx
.eq(i
.ctx
)]
20 return self
.ctx
.ports()
23 class ALUInputData(IntegerData
):
24 regspec
= [('INT', 'a', '0:63'),
26 ('XER', 'xer_so', '32'),
27 ('XER', 'xer_ca', '34,45')]
28 def __init__(self
, pspec
):
29 super().__init
__(pspec
)
30 self
.a
= Signal(64, reset_less
=True) # RA
31 self
.b
= Signal(64, reset_less
=True) # RB/immediate
32 self
.xer_so
= Signal(reset_less
=True) # XER bit 32: SO
33 self
.xer_ca
= Signal(2, reset_less
=True) # XER bit 34/45: CA/CA32
36 yield from super().__iter
__()
44 return lst
+ [self
.a
.eq(i
.a
), self
.b
.eq(i
.b
),
45 self
.xer_ca
.eq(i
.xer_ca
),
46 self
.xer_so
.eq(i
.xer_so
)]
48 # TODO: ALUIntermediateData which does not have
49 # cr0, ov, ov32 in it (because they are generated as outputs by
50 # the final output stage, not by the intermediate stage)
51 # https://bugs.libre-soc.org/show_bug.cgi?id=305#c19
53 class ALUOutputData(IntegerData
):
54 regspec
= [('INT', 'o', '0:63'),
56 ('XER', 'xer_ca', '34,45'),
57 ('XER', 'xer_ov', '33,44'),
58 ('XER', 'xer_so', '32')]
59 def __init__(self
, pspec
):
60 super().__init
__(pspec
)
61 self
.o
= Signal(64, reset_less
=True, name
="stage_o")
62 self
.cr0
= Data(4, name
="cr0")
63 self
.xer_ca
= Data(2, name
="xer_co") # bit0: ca, bit1: ca32
64 self
.xer_ov
= Data(2, name
="xer_ov") # bit0: ov, bit1: ov32
65 self
.xer_so
= Data(1, name
="xer_so")
68 yield from super().__iter
__()
77 return lst
+ [self
.o
.eq(i
.o
),
78 self
.xer_ca
.eq(i
.xer_ca
),
80 self
.xer_ov
.eq(i
.xer_ov
), self
.xer_so
.eq(i
.xer_so
)]
84 def __init__(self
, id_wid
=2, op_wid
=1):
87 self
.opkls
= lambda _
: CompALUOpSubset(name
="op")
91 class ALUPipeSpec(IntPipeSpec
):
92 def __init__(self
, id_wid
, op_wid
):
93 super().__init
__(id_wid
, op_wid
)
94 self
.pipekls
= SimpleHandshakeRedir