Example #1
0
def __combine_bitvector(postsyn_dict):
    output_dict = dict()
    for (postsyn_name, value) in postsyn_dict.iteritems():
        presyn_name = xlate_core.post2pre(postsyn_name)
        reg_name, bit_pos = presyn_name
        if reg_name not in output_dict:
            output_dict[reg_name] = long(value) << bit_pos
        else:
            output_dict[reg_name] = output_dict[reg_name] ^ \
                ((-value ^ output_dict[reg_name]) & (1 << bit_pos))
    return { k: format(v, 'b') for k, v in output_dict.items() }
Example #2
0
def __get_DFF_Logic(infile, outfile, dfflist):

    print infile

    expr = '{'
    fin = open(infile, 'r')
    try:
        for line in fin:
            expr = expr + line
    except IOError:
        print "Error in file " + infile
        sys.exit(1)
    finally:
        fin.close()

    expr = expr + '}'

    dfflogicDict = eval(expr)
    dffLogic = []

    for dff in dfflist:

        modulename = dff[0][:-2]

        dffname = (modulename, dff[1])

        dffname = xlate_core.post2pre(dffname)

        try:
            logic = dfflogicDict[dffname[0]]
        except KeyError:
# Need to modified when all the synthesized netlists are avaliable
            print dff[1] + " does not exist!"
            logic = "0"
#            sys.exit(1)

#        dffLogic.append((int(float(logic)) >> (dffname[1])) & 1)
#        print logic
        dffLogic.append(logic[max(len(logic) - dffname[1] - 1, 0)])

    fout = open(outfile, 'w')
    for i in range(0, len(dffLogic)):
#        print dfflist[i]
        fout.write(dfflist[i][2] + " " + str(dffLogic[i]) + "\n")
    fout.close() 

    return
Example #3
0
def __convert_Output(outfile, infile):

    fout = open(outfile, 'w')
    fout.close()
    fout = open(outfile, 'a')
    fin = open(infile, 'r')

    nodelogic = dict()

    fout.write("[\n")
    for line in fin:
        if line.find("0") == -1 and line.find("1") == -1:
            nodelogic_temp = {k: format(v, 'b') for k, v in nodelogic.items()}
            fout.write("%r,\n" % nodelogic_temp)
            nodelogic = {}
        else:
            ele = line.split()
            dffpair = __CIRCUITOUT[ele[0]]
            dffpairt = list(dffpair)
            dffpairt[0] = dffpairt[0][:-2]
            dffpair = tuple(dffpairt)
            dffname = xlate_core.post2pre(dffpair)
            reg_name, bit_pos = dffname
            print bit_pos
            if reg_name not in nodelogic:
                nodelogic[reg_name] = long(1) << bit_pos
            else:
                nodelogic[reg_name] = nodelogic[reg_name] ^ \
                            ((-1 ^ nodelogic[reg_name]) & (1 << bit_pos))
#            if (dffpair[1].endswith("[" + str(dffname[1]) + "]")):
#                name = dffname[0] + "[" + str(dffname[1]) + "]" 
#            else:
#                name = dffname[0]
#            nodelogic[name] = ele[1]
    fout.write("]\n")
    fin.close()
    fout.close()
    return