Skip to content

Instantly share code, notes, and snippets.

@riteshkevin
Last active December 22, 2015 13:19
Embed
What would you like to do?
import re
import glob
import os
import sys
import fnmatch
def ConvertToLLT_19nm_Seal(addr_orig):
my_str1 = addr_orig
my_str1_length = len(my_str1)
if my_str1_length < 8:
my_str1= my_str1.zfill(8)
print "my_str1 is:", my_str1
LLT = hex(int(my_str1[1:4], 16)*2)
die_number = hex(int(my_str1[0], 16)/2)
my_str3 = int(my_str1[4:8], 16)
word_line = str(my_str3/96)
output_file.write("Die number : " + die_number + "\n")
output_file.write("Word Line : " + word_line + "\n")
return LLT
main_source_list = os.listdir("/Python24/Tutorial/Error_log")
source_list = fnmatch.filter(main_source_list, '*.txt')
#print source_list[4]
if not os.path.exists("/Python24/Tutorial/Output"):
os.makedirs("/Python24/Tutorial/Output")
output_file = open("/Python24/Tutorial/Output/out.txt", "w")
fo = open(source_list[0], "r+")
for line in fo:
if re.match("(.*)(RSECC)(.*)", line):
str_temp1 = line
pattern = "(0x"
for word in str_temp1.split():
if word.startswith(pattern):
addr_orig = word.replace("(0x", "0x");
output_file.write("input: " + addr_orig + "\n")
converted = ConvertToLLT_19nm_Seal(addr_orig.rstrip(",").lstrip("0x"));
output_file.write("Block address: " + converted + "\n" + "\n") #converted needs to be a string
fo.close()
output_file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment