big reorg on PowerDecoder2, actually Decode2Execute1Type
[soc.git] / src / soc / fu / branch / br_input_record.py
1 from nmigen.hdl.rec import Record, Layout
2
3 from soc.decoder.power_enums import InternalOp, Function, CryIn
4
5
6 class CompBROpSubset(Record):
7 """CompBROpSubset
8
9 TODO: remove anything not needed by the Branch pipeline (determine this
10 after all branch operations have been written. see
11 https://bugs.libre-soc.org/show_bug.cgi?id=313#c3)
12
13 a copy of the relevant subset information from Decode2Execute1Type
14 needed for Branch operations. use with eq_from_execute1 (below) to
15 grab subsets.
16 """
17 def __init__(self, name=None):
18 layout = (('insn_type', InternalOp),
19 ('fn_unit', Function),
20 ('imm_data', Layout((("imm", 64), ("imm_ok", 1)))),
21 ('lk', 1),
22 ('is_32bit', 1),
23 ('insn', 32),
24 )
25
26 Record.__init__(self, Layout(layout), name=name)
27
28 # grrr. Record does not have kwargs
29 self.insn_type.reset_less = True
30 self.fn_unit.reset_less = True
31 self.lk.reset_less = True
32 self.is_32bit.reset_less = True
33 self.insn.reset_less = True
34
35 def eq_from_execute1(self, other):
36 """ use this to copy in from Decode2Execute1Type
37 """
38 res = []
39 for fname, sig in self.fields.items():
40 eqfrom = other.do.fields[fname]
41 res.append(sig.eq(eqfrom))
42 return res
43
44 def ports(self):
45 return [self.insn_type,
46 self.fn_unit,
47 self.lk,
48 self.is_32bit,
49 self.insn,
50 ]