compiler/main.py
def genpus(num_pes, pes_per_pu, ns_size, ns_int_size):
    '''
    Instantiates both PU's and PE's, based on the config file.
    '''
    pu_list = []
    pe_list = []
    num_pus = num_pes // pes_per_pu

    for i in range(num_pus):
        pu_list.append(Pu(i))
    for i in range(num_pes):
        pe = Pe(id=i, ns_size=ns_size, ns_int_size=ns_int_size)
        pu_id = i // pes_per_pu
        pu = pu_list[pu_id]
        pe.pu = pu
        pe_list.append(pe)
        if i % pes_per_pu == 0:
            pu.head_pe = pe

    pu_list[0].next_pu = pu_list[-1]
    for i, pu in enumerate(pu_list[1:]): # kind of hacky
        pu.next_pu = pu_list[i]

    pe_count = 0 # index of PE in PU
    pu_count = 0
    for i, pe in enumerate(pe_list):
        if i % pes_per_pu == 0:
            pe.next = pe_list[pes_per_pu * pu_count + pes_per_pu - 1]
            pe.prev = pe_list[i + 1]
            pe_count += 1
            continue
        if pe_count == pes_per_pu - 1:
            pe.next = pe_list[i - 1]
            pe_count = 0
            pu_count += 1
            continue
        if i != num_pes - 1:
            pe.prev = pe_list[i + 1]
            pe.next = pe_list[i - 1]
            pe_count += 1

    return (pu_list, pe_list)

    Instantiates both PU's and PE's, based on the config file.
    
Instantiates both PU's and PE's, based on the config file.
Instantiates both PU ' s and PE ' s based on the config file .
def genpus(num_pes, pes_per_pu, ns_size, ns_int_size):
    pu_list = []
    pe_list = []
    num_pus = num_pes // pes_per_pu
    for i in range(num_pus):
        pu_list.append(Pu(i))
    for i in range(num_pes):
        pe = Pe(id=i, ns_size=ns_size, ns_int_size=ns_int_size)
        pu_id = i // pes_per_pu
        pu = pu_list[pu_id]
        pe.pu = pu
        pe_list.append(pe)
        if i % pes_per_pu == 0:
            pu.head_pe = pe
    pu_list[0].next_pu = pu_list[-1]
    for i, pu in enumerate(pu_list[1:]): 
        pu.next_pu = pu_list[i]
    pe_count = 0 
    pu_count = 0
    for i, pe in enumerate(pe_list):
        if i % pes_per_pu == 0:
            pe.next = pe_list[pes_per_pu * pu_count + pes_per_pu - 1]
            pe.prev = pe_list[i + 1]
            pe_count += 1
            continue
        if pe_count == pes_per_pu - 1:
            pe.next = pe_list[i - 1]
            pe_count = 0
            pu_count += 1
            continue
        if i != num_pes - 1:
            pe.prev = pe_list[i + 1]
            pe.next = pe_list[i - 1]
            pe_count += 1
    return (pu_list, pe_list)
def genpus ( num_pes , pes_per_pu , ns_size , ns_int_size ) : pu_list = [ ] pe_list = [ ] num_pus = num_pes // pes_per_pu for i in range ( num_pus ) : pu_list . append ( Pu ( i ) ) for i in range ( num_pes ) : pe = Pe ( id = i , ns_size = ns_size , ns_int_size = ns_int_size ) pu_id = i // pes_per_pu pu = pu_list [ pu_id ] pe . pu = pu pe_list . append ( pe ) if i % pes_per_pu == 0 : pu . head_pe = pe pu_list [ 0 ] . next_pu = pu_list [ - 1 ] for i , pu in enumerate ( pu_list [ 1 : ] ) : pu . next_pu = pu_list [ i ] pe_count = 0 pu_count = 0 for i , pe in enumerate ( pe_list ) : if i % pes_per_pu == 0 : pe . next = pe_list [ pes_per_pu * pu_count + pes_per_pu - 1 ] pe . prev = pe_list [ i + 1 ] pe_count += 1 continue if pe_count == pes_per_pu - 1 : pe . next = pe_list [ i - 1 ] pe_count = 0 pu_count += 1 continue if i != num_pes - 1 : pe . prev = pe_list [ i + 1 ] pe . next = pe_list [ i - 1 ] pe_count += 1 return ( pu_list , pe_list )
Instantiates both PU's and PE's, based on the config file.
Instantiates both PU ' s and PE ' s based on the config file .
'''
    Instantiates both PU's and PE's, based on the config file.
    ''' # kind of hacky # index of PE in PU
num_pes
pes_per_pu
ns_size
ns_int_size