From a42f84b31c3ac3733ac10201eb0a12680704dc49 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 6 Sep 2020 21:42:51 +0100 Subject: [PATCH] add row subset selector for PowerDecode. allows functions to be used to create subset decoders --- src/soc/decoder/power_decoder.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/soc/decoder/power_decoder.py b/src/soc/decoder/power_decoder.py index 26d9e378..752e706c 100644 --- a/src/soc/decoder/power_decoder.py +++ b/src/soc/decoder/power_decoder.py @@ -317,6 +317,10 @@ class PowerDecoder(Elaboratable): mname = get_pname("dec_sub%d" % key, self.pname) setattr(m.submodules, mname, subdecoder) comb += subdecoder.opcode_in.eq(self.opcode_in) + # XXX hmmm... + #if self.row_subsetfn: + # if not self.row_subsetfn(key, row): + # continue # add in the dynamic Case statement here with m.Case(key): comb += self.op.eq(subdecoder.op) @@ -331,6 +335,9 @@ class PowerDecoder(Elaboratable): opcode = int(opcode, 0) if not row['unit']: continue + if self.row_subsetfn: + if not self.row_subsetfn(opcode, row): + continue # add in the dynamic Case statement here with m.Case(opcode): comb += self.op._eq(row) @@ -467,12 +474,31 @@ def create_pdecode(name=None, col_subset=None, row_subset=None): if __name__ == '__main__': - pdecode = create_pdecode() + + # row subset + + def rowsubsetfn(opcode, row): + print ("row_subset", opcode, row) + return row['unit'] == 'ALU' + + pdecode = create_pdecode(name="rowsub", + col_subset={'function_unit', 'in1_sel'}, + row_subset=rowsubsetfn) vl = rtlil.convert(pdecode, ports=pdecode.ports()) - with open("decoder.il", "w") as f: + with open("row_subset_decoder.il", "w") as f: f.write(vl) + # col subset + pdecode = create_pdecode(name="fusubset", col_subset={'function_unit'}) vl = rtlil.convert(pdecode, ports=pdecode.ports()) with open("col_subset_decoder.il", "w") as f: f.write(vl) + + # full decoder + + pdecode = create_pdecode() + vl = rtlil.convert(pdecode, ports=pdecode.ports()) + with open("decoder.il", "w") as f: + f.write(vl) + -- 2.30.2