From fd2376fe90f36aa6582bdb325cc173e37189e73e Mon Sep 17 00:00:00 2001 From: Giovanni LB Date: Fri, 14 Apr 2023 17:59:15 -0300 Subject: [PATCH] PLAT-130888: Added support for .out files Change-Id: Ia2fe1966e0264f42ee1159d732d5606438b7bb91 --- bin/att_to_out.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 bin/att_to_out.py diff --git a/bin/att_to_out.py b/bin/att_to_out.py new file mode 100755 index 0000000000..6be60a5014 --- /dev/null +++ b/bin/att_to_out.py @@ -0,0 +1,40 @@ +################################################################################ +# Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +################################################################################ + +import numpy as np +import sys +BYTE_MAP = [str(k) for k in range(10)] + ['a', 'b', 'c', 'd', 'e', 'f'] + +def map8(c): + return BYTE_MAP[(c//16)%16]+BYTE_MAP[c%16] + +def map16(c): + return map8(c>>8)+map8(c) + +in_filename = sys.argv[1] +out_filename = in_filename.split('.att')[0]+'.out' + +in_bytes = np.fromfile(in_filename, dtype=np.uint16) +out_bytes = [map16(c)+'\n' for c in in_bytes] + +with open(out_filename, 'w') as f: + [f.write(b) for b in out_bytes]