예제 #1
0
def above(ea, includeSegment=False):
    '''Return all of the function names and their offset that calls the function at `ea`.'''
    tryhard = lambda ea: "{:s}{:+x}".format(func.name(func.top(
        ea)), ea - func.top(ea)) if func.within(ea) else "{:+x}".format(
            ea) if func.name(ea) is None else func.name(ea)
    return '\n'.join(':'.join(
        [segment.name(ea), tryhard(ea)] if includeSegment else [tryhard(ea)])
                     for ea in func.up(ea))
예제 #2
0
def above(ea, includeSegment=False):
    '''Display all the callers of the function at /ea/'''
    tryhard = lambda ea: "{:s}+{:x}".format(database.name(function.top(
        ea)), ea - function.top(ea)) if function.within(
            ea) else "+{:x}".format(ea) if database.name(
                ea) is None else database.name(ea)
    return '\n'.join(
        ':'.join((segment.name(ea),
                  tryhard(ea)) if includeSegment else (tryhard(ea), ))
        for ea in function.up(ea))
예제 #3
0
def sc_decoder(y_llr,information_pos,frozen_bit):
    N = y_llr.size
    #print(N)
    n = int(np.log2(N))
    llr_matrix=np.ones((n+1,N))
    llr_matrix[llr_matrix == 1] = float('nan')
    bit_matrix=llr_matrix.copy()
    llr_matrix[0]=y_llr
    position=[0,0,n,N]
    while function.all_num(bit_matrix[n]) == 0:
        up_llr=llr_matrix[position[0]][position[1]:position[1]+2**(position[2]-position[0])]
        up_bit=bit_matrix[position[0]][position[1]:position[1]+2**(position[2]-position[0])]
        left_llr=llr_matrix[position[0]+1][position[1]:position[1]+2**(position[2]-position[0]-1)]
        left_bit=bit_matrix[position[0]+1][position[1]:position[1]+2**(position[2]-position[0]-1)]
        right_llr=llr_matrix[position[0]+1][position[1]+2**(position[2]-position[0]-1):position[1]+2**(position[2]-position[0])]
        right_bit=bit_matrix[position[0]+1][position[1]+2**(position[2]-position[0]-1):position[1]+2**(position[2]-position[0])]
        #print(left_llr)

        if function.all_num(up_bit) == 1:
            position=function.up(position)
        else:
            if function.all_num(right_bit) == 1:
                up_bit=function.get_up_bit(left_bit,right_bit)
                bit_matrix[position[0]][position[1]:position[1] + 2 ** (position[2] - position[0])]=up_bit.copy()
            else:
                if function.all_num(right_llr) == 1:
                    if position[0] == position[2]-1:
                        right_bit_pos=position[1]+1
                        right_bit=function.get_right_bit(right_llr,information_pos,frozen_bit,right_bit_pos)
                        bit_matrix[position[0]+1][position[1]+2**(position[2]-position[0]-1):position[1]+2**(position[2]-position[0])]=right_bit
                    else:
                        position=function.rightdown(position)
                else:
                    if function.all_num(left_bit) == 1:
                        right_llr=function.get_right_llr(left_bit,up_llr)
                        llr_matrix[position[0]+1][position[1]+2**(position[2]-position[0]-1):position[1]+2**(position[2]-position[0])]=right_llr
                    else:
                        if function.all_num(left_llr) == 0:
                            left_llr = function.get_left_llr(up_llr)
                            llr_matrix[position[0] + 1][position[1]:position[1] + 2 ** (position[2] - position[0] - 1)] = left_llr
                        else:
                            if position[0] == position[2]-1:
                                left_bit_pos=position[1]
                                left_bit=function.get_left_bit(left_llr,information_pos,frozen_bit,left_bit_pos)
                                bit_matrix[position[0]+1][position[1]:position[1]+2**(position[2]-position[0]-1)]=left_bit
                            else:
                                position = function.leftdown(position)

    u_d=[bit_matrix[n],llr_matrix[n]]
    return u_d
예제 #4
0
def sc_stepping_decoder(llr_matrix,bit_matrix,information_pos,frozen_bit,split_pos):           #运行到判决split_pos的位置,注意是split_pos判决完成后返回的
    N = int(bit_matrix[0].size)
    n = int(np.log2(N))
    loc=function.get_up_loc(bit_matrix)
    position = [loc[0], loc[1], n, N]

    while bit_matrix[n][split_pos] != 0 and bit_matrix[n][split_pos] != 1:
        up_llr=llr_matrix[position[0]][position[1]:position[1]+2**(position[2]-position[0])]
        up_bit=bit_matrix[position[0]][position[1]:position[1]+2**(position[2]-position[0])]
        left_llr=llr_matrix[position[0]+1][position[1]:position[1]+2**(position[2]-position[0]-1)]
        left_bit=bit_matrix[position[0]+1][position[1]:position[1]+2**(position[2]-position[0]-1)]
        right_llr=llr_matrix[position[0]+1][position[1]+2**(position[2]-position[0]-1):position[1]+2**(position[2]-position[0])]
        right_bit=bit_matrix[position[0]+1][position[1]+2**(position[2]-position[0]-1):position[1]+2**(position[2]-position[0])]

        if function.all_num(up_bit) == 1:
            position = function.up(position)
        else:
            if function.all_num(right_bit) == 1:
                up_bit = function.get_up_bit(left_bit, right_bit)
                bit_matrix[position[0]][position[1]:position[1] + 2 ** (position[2] - position[0])] = up_bit.copy()
            else:
                if function.all_num(right_llr) == 1:
                    if position[0] == position[2] - 1:                  #右底
                        right_bit_pos = position[1] + 1
                        right_bit = function.get_right_bit(right_llr, information_pos, frozen_bit, right_bit_pos)
                        bit_matrix[position[0] + 1][position[1] + 2 ** (position[2] - position[0] - 1):position[1] + 2 ** (
                                    position[2] - position[0])] = right_bit
                    else:
                        position = function.rightdown(position)
                else:
                    if function.all_num(left_bit) == 1:
                        right_llr = function.get_right_llr(left_bit, up_llr)
                        llr_matrix[position[0] + 1][position[1] + 2 ** (position[2] - position[0] - 1):position[1] + 2 ** (
                                    position[2] - position[0])] = right_llr
                    else:
                        if function.all_num(left_llr) == 0:
                            left_llr = function.get_left_llr(up_llr)
                            llr_matrix[position[0] + 1][
                            position[1]:position[1] + 2 ** (position[2] - position[0] - 1)] = left_llr
                        else:
                            if position[0] == position[2] - 1:         #左底
                                left_bit_pos = position[1]
                                left_bit = function.get_left_bit(left_llr, information_pos, frozen_bit, left_bit_pos)
                                bit_matrix[position[0] + 1][
                                position[1]:position[1] + 2 ** (position[2] - position[0] - 1)] = left_bit
                            else:
                                position = function.leftdown(position)
    return [llr_matrix,bit_matrix]
예제 #5
0
def above(ea):
    '''Display all the callers of the function at /ea/'''
    tryhard = lambda x: '%s+%x'%(database.name(function.top(x)),x-function.top(x)) if function.within(x) else hex(x) if database.name(x) is None else database.name(x)
    return '\n'.join(map(tryhard,function.up(ea)))
예제 #6
0
def fsc_decoder(y_llr,information_pos,frozen_bit,decode_para):
    N = y_llr.size
    n = int(np.log2(N))
    node_list = function.node_identify(N,information_pos,decode_para[1])

    llr_matrix = np.ones((n + 1, N))
    llr_matrix[llr_matrix == 1] = float('nan')
    bit_matrix = llr_matrix.copy()
    llr_matrix[0] = y_llr
    position = [0, 0, n, N]
    while function.all_num(bit_matrix[n]) == 0:
        node_col = int(np.floor(position[1]/(2**(n-position[0]))))
        if node_list[position[0]][node_col] == 'nan':
            up_llr = llr_matrix[position[0]][position[1]:position[1] + 2 ** (position[2] - position[0])]
            up_bit = bit_matrix[position[0]][position[1]:position[1] + 2 ** (position[2] - position[0])]
            left_llr = llr_matrix[position[0] + 1][position[1]:position[1] + 2 ** (position[2] - position[0] - 1)]
            left_bit = bit_matrix[position[0] + 1][position[1]:position[1] + 2 ** (position[2] - position[0] - 1)]
            right_llr = llr_matrix[position[0] + 1][
                        position[1] + 2 ** (position[2] - position[0] - 1):position[1] + 2 ** (position[2] - position[0])]
            right_bit = bit_matrix[position[0] + 1][
                        position[1] + 2 ** (position[2] - position[0] - 1):position[1] + 2 ** (position[2] - position[0])]

            if function.all_num(up_bit) == 1:
                position = function.up(position)
            else:
                if function.all_num(right_bit) == 1:
                    up_bit = function.get_up_bit(left_bit, right_bit)
                    bit_matrix[position[0]][position[1]:position[1] + 2 ** (position[2] - position[0])] = up_bit.copy()
                else:
                    if function.all_num(right_llr) == 1:
                        if position[0] == position[2] - 1:
                            right_bit_pos = position[1] + 1
                            right_bit = function.get_right_bit(right_llr, information_pos, frozen_bit, right_bit_pos)
                            bit_matrix[position[0] + 1][
                            position[1] + 2 ** (position[2] - position[0] - 1):position[1] + 2 ** (
                                        position[2] - position[0])] = right_bit
                        else:
                            position = function.rightdown(position)
                    else:
                        if function.all_num(left_bit) == 1:
                            right_llr = function.get_right_llr(left_bit, up_llr)
                            llr_matrix[position[0] + 1][
                            position[1] + 2 ** (position[2] - position[0] - 1):position[1] + 2 ** (
                                        position[2] - position[0])] = right_llr
                        else:
                            if function.all_num(left_llr) == 0:
                                left_llr = function.get_left_llr(up_llr)
                                llr_matrix[position[0] + 1][
                                position[1]:position[1] + 2 ** (position[2] - position[0] - 1)] = left_llr
                            else:
                                if position[0] == position[2] - 1:
                                    left_bit_pos = position[1]
                                    left_bit = function.get_left_bit(left_llr, information_pos, frozen_bit, left_bit_pos)
                                    bit_matrix[position[0] + 1][
                                    position[1]:position[1] + 2 ** (position[2] - position[0] - 1)] = left_bit
                                else:
                                    position = function.leftdown(position)

        else:
            up_llr = llr_matrix[position[0]][position[1]:position[1] + 2 ** (position[2] - position[0])]
            node_result = function.node_process(up_llr,node_list[position[0]][node_col])
            bit_matrix[position[0]][position[1]:position[1] + 2 ** (position[2] - position[0])] = node_result[0]
            bit_matrix[n][position[1]:position[1] + 2 ** (position[2] - position[0])] = node_result[1]
            position = function.up(position)
    u_d = bit_matrix[n]
    return u_d
예제 #7
0
def above(ea, includeSegment=False):
    '''Return all of the function names and their offset that calls the function at `ea`.'''
    tryhard = lambda ea: "{:s}{:+x}".format(func.name(func.top(ea)), ea - func.top(ea)) if func.within(ea) else "{:+x}".format(ea) if func.name(ea) is None else func.name(ea)
    return '\n'.join(':'.join((segment.name(ea), tryhard(ea)) if includeSegment else (tryhard(ea),)) for ea in func.up(ea))
예제 #8
0
def above(ea):
    '''Display all the callers of the function at /ea/'''
    tryhard = lambda x: '%s+%x' % (database.name(function.top(
        x)), x - function.top(x)) if function.within(x) else hex(
            x) if database.name(x) is None else database.name(x)
    return '\n'.join(map(tryhard, function.up(ea)))