PLAT-130888: Added support for .out files

Change-Id: Ia2fe1966e0264f42ee1159d732d5606438b7bb91
Этот коммит содержится в:
Giovanni LB
2023-04-14 17:59:15 -03:00
коммит произвёл Giovanni Baraldi
родитель c64b5e0090
Коммит fd2376fe90
Исполняемый файл
+40
Просмотреть файл
@@ -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]