From e207e166deb962642ed8c6192c05bed279e427eb Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 2 Dec 2021 15:04:30 +0000 Subject: [PATCH] use namedtuple for regspec_decode --- src/openpower/decoder/power_regspec_map.py | 81 ++++++++++++---------- 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/src/openpower/decoder/power_regspec_map.py b/src/openpower/decoder/power_regspec_map.py index ecea6c9c..749bdb2e 100644 --- a/src/openpower/decoder/power_regspec_map.py +++ b/src/openpower/decoder/power_regspec_map.py @@ -38,7 +38,9 @@ from nmigen import Const from openpower.consts import XERRegsEnum, FastRegsEnum, StateRegsEnum from openpower.decoder.power_enums import CryIn from openpower.util import log +from collections import namedtuple +RegDecodeInfo = namedtuple("RedDecodeInfo", ['okflag', 'regport']) def regspec_decode_read(m, e, regfile, name): """regspec_decode_read @@ -49,24 +51,24 @@ def regspec_decode_read(m, e, regfile, name): if regfile == 'INT': # Int register numbering is *unary* encoded if name == 'ra': # RA - return e.read_reg1.ok, e.read_reg1.data + return RegDecodeInfo(e.read_reg1.ok, e.read_reg1.data) if name == 'rb': # RB - return e.read_reg2.ok, e.read_reg2.data + return RegDecodeInfo(e.read_reg2.ok, e.read_reg2.data) if name == 'rc': # RS - return e.read_reg3.ok, e.read_reg3.data + return RegDecodeInfo(e.read_reg3.ok, e.read_reg3.data) # CR regfile if regfile == 'CR': # CRRegs register numbering is *unary* encoded if name == 'full_cr': # full CR (from FXM field) - return e.do.read_cr_whole.ok, e.do.read_cr_whole.data + return RegDecodeInfo(e.do.read_cr_whole.ok, e.do.read_cr_whole.data) if name == 'cr_a': # CR A - return e.read_cr1.ok, 1<<(7-e.read_cr1.data) + return RegDecodeInfo(e.read_cr1.ok, 1<<(7-e.read_cr1.data)) if name == 'cr_b': # CR B - return e.read_cr2.ok, 1<<(7-e.read_cr2.data) + return RegDecodeInfo(e.read_cr2.ok, 1<<(7-e.read_cr2.data)) if name == 'cr_c': # CR C - return e.read_cr3.ok, 1<<(7-e.read_cr3.data) + return RegDecodeInfo(e.read_cr3.ok, 1<<(7-e.read_cr3.data)) # XER regfile @@ -78,14 +80,15 @@ def regspec_decode_read(m, e, regfile, name): if name == 'xer_so': # SO needs to be read for overflow *and* for creation # of CR0 and also for MFSPR - return ((e.do.oe.oe[0] & e.do.oe.ok) | (e.xer_in & SO == SO)| - (e.do.rc.rc & e.do.rc.ok)), SO + return RegDecodeInfo(((e.do.oe.oe[0] & e.do.oe.ok) | + (e.xer_in & SO == SO)| + (e.do.rc.rc & e.do.rc.ok)), SO) if name == 'xer_ov': - return ((e.do.oe.oe[0] & e.do.oe.ok) | - (e.xer_in & CA == CA)), OV + return RegDecodeInfo(((e.do.oe.oe[0] & e.do.oe.ok) | + (e.xer_in & CA == CA)), OV) if name == 'xer_ca': - return ((e.do.input_carry == CryIn.CA.value) | - (e.xer_in & OV == OV)), CA + return RegDecodeInfo(((e.do.input_carry == CryIn.CA.value) | + (e.xer_in & OV == OV)), CA) # STATE regfile @@ -95,29 +98,32 @@ def regspec_decode_read(m, e, regfile, name): MSR = 1<