From: Luke Kenneth Casson Leighton Date: Wed, 15 Nov 2023 14:33:03 +0000 (+0000) Subject: add 2nd maxloc case X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8020a657dcd8b84f5535d183bcb9a45975cbc6f6;p=openpower-isa.git add 2nd maxloc case --- diff --git a/src/openpower/decoder/isa/maxloc.py b/src/openpower/decoder/isa/maxloc.py new file mode 100644 index 00000000..c5185c42 --- /dev/null +++ b/src/openpower/decoder/isa/maxloc.py @@ -0,0 +1,29 @@ +def m2(a): + m = 0; + nm = -1; + i = 0; + n = len(a) + + while (i m) : + print("%d idx %d > m %d" % (i, a[i], m)) + m = a[i] + nm = i + i += 1 + return nm; + +# /*Testbench*/ + +if __name__ == '__main__': + arr = [5,2,8,1,3,7,9,4] + print("search list", arr) + result = m2(arr) + print("Index of the maximum value in an array is: %d" % result) + + arr = [5,2,8,9,9,7,9,4] + print("search list", arr) + result = m2(arr) + print("Index of the maximum value in an array is: %d" % result) diff --git a/src/openpower/decoder/isa/maxloc/maxloc.py b/src/openpower/decoder/isa/maxloc/maxloc.py deleted file mode 100644 index bb260d25..00000000 --- a/src/openpower/decoder/isa/maxloc/maxloc.py +++ /dev/null @@ -1,25 +0,0 @@ -def m2(a): - m = 0; - nm = -1; - i = 0; - n = len(a) - - while (i m) : - print("%d idx %d > m %d" % (i, a[i], m)) - m = a[i] - nm = i - i += 1 - return nm; - -# /*Testbench*/ - -if __name__ == '__main__': - arr = [5,2,8,1,3,7,9,4] - print("search list", arr) - result = m2(arr) - - print("Index of the maximum value in an array is: %d" % result)