def __write_Target(targetFile, regName, regPos, __GATE2INDEX, __NODELIST): fout = open(targetFile, 'w') gate = xlate_core.pre2post((regName, regPos)) filename = gate[0] + ".v" try: index = __GATE2INDEX[filename][gate[1]] except KeyError: print "target " + gate[1] + " not found" sys.exit(1) fout.write(__NODELIST[filename][__NODELIST[filename][index].fanin[0]].name + "\n") # for ele in target: # gate = xlate_core.pre2post(ele) # try: # index = __GATE2INDEX[filename][gate[1]] # except KeyError: # print "target " + gate[1] + " not found" # sys.exit(1) # fout.write(__NODELIST[filename][__NODELIST[filename][index].fanin[0]].name + "\n") fout.close() return
def __grab_Circuit(targetName, targetPos, netlistFile, ignoreList, postsynDir, __GATE2INDEX, __NODELIST, __NAME2INDEX, __DFF2NETLIST): global __POSTSYN_DIR __init_Grab() print __GATELIST __POSTSYN_DIR = postsynDir print "netlist directory: " + postsynDir netList = [] nodeFinal = [] newDFF = [] DFFList = [] targetList = [] targetGate = xlate_core.pre2post((targetName, targetPos)) try: filename = targetGate[0] + ".v" except TypeError: print "target gate cannot be found!" return [] t1 = time.time() __build_Graph(filename, __NAME2INDEX, __GATE2INDEX, __DFF2NETLIST, __NODELIST) t2 = time.time() nodelist = __NODELIST[filename] index = __GATE2INDEX[filename][targetGate[1]] targetList.append(nodelist[index].fanin[0]) __CIRCUITOUT[nodelist[nodelist[index].fanin[0]].name] = (filename, nodelist[index].gatename) DFFList.append([filename, targetGate[1], nodelist[index].name]) inNode = [] while (targetList != []): __node_Match_BK(targetList.pop(), nodeFinal, newDFF, ignoreList, filename, inNode, __NODELIST) while (inNode != []): inNodeFileList = {} __classify_Input(inNode, inNodeFileList) inNode = [] for file in inNodeFileList: if file not in __NODELIST: __build_Graph(file, __NAME2INDEX, __GATE2INDEX, __DFF2NETLIST, __NODELIST) nodeList = inNodeFileList[file] while (nodeList != []): node = nodeList.pop() try: node_index = __NAME2INDEX[file][node] except KeyError: print file + " not found!" print node continue __node_Match_BK(node_index, nodeFinal, newDFF, ignoreList, file, inNode, __NODELIST) t3 = time.time() print "time for backward traversal of the whole netlist is " + str(t3 - t2) targetDict = dict() for ele in newDFF: if ele not in DFFList: DFFList.append(ele) index = __GATE2INDEX[ele[0]][ele[1]] if ele[0] in targetDict: targetDict[ele[0]].append(index) else: targetDict[ele[0]] = [index] newDFF = [] nodeFinal = [] outNode = [] for file in targetDict: targetList = targetDict[file] if file not in __NODELIST: __build_Graph(file, __NAME2INDEX, __GATE2INDEX, __DFF2NETLIST, __NODELIST) while(targetList != []): __node_Match_FW(targetList.pop(), nodeFinal, newDFF, ignoreList, file, outNode, __NODELIST) while outNode != []: outNodeFileList = {} __classify_Output(outNode, outNodeFileList) outNode = [] for file in outNodeFileList: if file not in __NODELIST: __build_Graph(file, __NAME2INDEX, __GATE2INDEX, __DFF2NETLIST, __NODELIST) nodeList = outNodeFileList[file] while nodeList != []: node = nodeList.pop() try: node_index = __NAME2INDEX[file][node] except KeyError: print file + " not found!" print node continue __node_Match_FW(node_index, nodeFinal, newDFF, ignoreList, file, outNode, __NODELIST) t4 = time.time() print "time for forward traversal of the whole netlist is " + str(t4 - t3) targetDict = dict() for ele in newDFF: if ele not in DFFList: DFFList.append(ele) print "element " + str(ele[1]) # if ele[1] not in target: if not (ele[1] == targetGate[1]): index = __NAME2INDEX[ele[0]][ele[2]] index = __NODELIST[ele[0]][index].fanin[0] if ele[0] in targetDict: targetDict[ele[0]].append(index) else: targetDict[ele[0]] = [index] newDFF = [] nodeFinal = [] inNode = [] for file in targetDict: targetList = targetDict[file] if file not in __NODELIST and file not in __IGNORE_MODULE: __build_Graph(file, __NAME2INDEX, __GATE2INDEX, __DFF2NETLIST, __NODELIST) while(targetList != []): __node_Match_BK(targetList.pop(), nodeFinal, newDFF, ignoreList, file, inNode, __NODELIST) while inNode != []: inNodeFileList = {} __classify_Input(inNode, inNodeFileList) inNode = [] for file in inNodeFileList: if file not in __NODELIST and file not in __IGNORE_MODULE: __build_Graph(file, __NAME2INDEX, __GATE2INDEX, __DFF2NETLIST, __NODELIST) nodeList = inNodeFileList[file] while nodeList != []: node = nodeList.pop() try: node_index = __NAME2INDEX[file][node] except KeyError: print file + " not found!" print node continue __node_Match_BK(node_index, nodeFinal, newDFF, ignoreList, file, inNode, __NODELIST) t5 = time.time() print "time for backward traversal of the whole netlist is " + str(t5 - t4) for ele in newDFF: if ele not in DFFList: DFFList.append(ele) index = __NAME2INDEX[ele[0]][ele[2]] index = __NODELIST[ele[0]][index].fanin[0] name = __NODELIST[ele[0]][index].name if name not in __CIRCUITOUT: # __CIRCUITOUT[name] = ele[2] __CIRCUITOUT[name] = (ele[0], ele[1]) # if (index not in circuitOut): # circuitOut.append(__NODELIST[ele[0]][index].name) fout = open(netlistFile, 'w') fout.write("output ") for out in range(0, len(__CIRCUITOUT.keys())): fout.write(__CIRCUITOUT.keys()[out]) if (out == len(__CIRCUITOUT.keys())-1): fout.write(";\n") elif (out % 10 == 0): fout.write(",\n") else: fout.write(", ") fout.close() __build_Netlist(netlistFile, __DFF2NETLIST) t6 = time.time() print "time to build the netlist is " + str(t6 - t5) return DFFList