コード例 #1
0
def patch_mem(fasm=None,
              init=None,
              mdd=None,
              outfile=None,
              selectedMemToPatch=None,
              verbose=False,
              partial=False):
    assert fasm is not None
    assert init is not None
    assert mdd is not None
    assert selectedMemToPatch is not None

    mdd_data = mddutil.readAndFilterMDDData(mdd, selectedMemToPatch, verbose)

    # Get all the FASM tuples
    fasm_tups = read_fasm(fasm)

    # Get everything BUT the INIT ones selected for patching
    cleared_tups = fasmutil.clear_init(fasm_tups, mdd_data)

    # Create the new tuples from initfile contents
    memfasm = initutil.initfile_to_memfasm(infile=init,
                                           fasm_tups=fasm_tups,
                                           memfasm_name='temp_mem.fasm',
                                           mdd=mdd_data)

    if partial == True:
        # Find any and all non-INIT tuples located at the patched BRAM
        frame_tups = []
        for data in mdd_data:
            for tup in cleared_tups:
                if tup[0] != None and tup.set_feature.feature.find(
                        data.tile) != -1:
                    frame_tups.append(tup)
        # Merge the newly found non_INIT tuples located at the BRAM with the
        # new memory tuples to create a partial FASM file
        merged = merge_tuples(cleared_tups=frame_tups, mem_tups=memfasm)
        write_fasm(outfile, merged)
        print("In partial")
    else:
        # Merge all non-INIT tuples (cleared_tups) in with the new memory tuples
        # to create a new complete FASM file
        merged = merge_tuples(cleared_tups=cleared_tups, mem_tups=memfasm)
        write_fasm(outfile, merged)
        print("We ain't in Kansas no more")

    print("Patching done...")
コード例 #2
0
def createBitMappings(
    memName,
    mddName,
    verbose,
    printMappings
):

    # 1. Load the MDD file.
    mdd_data = parse_mdd.readAndFilterMDDData(mddName, memName)
    words, bits = misc.getMDDMemorySize(mdd_data)
    #print("Words = {}, bits = {}".format(words, bits))

    # 2. Load the segment data from the prjxray database.
    #    This uses the environment variables set by prjxray
    #    Passing it into createBitMappings() each time will save a lot of time since it can be reused for all
    #       the BRAMs in a design.
    #segs = loadSegs()

    # 3. Define the data structure to hold the mappings that are returned.
    #    Format is: [word, bit, tileName, bits (width of each init.mem word), fasmY, fasmINITP, fasmLine, fasmBit, frameAddr, frameBitOffset]
    mappings = []

    # 4. Create the bitmappings for each BRAM Primitive
    for cell in mdd_data:
        mappings = createBitMapping(
            #segs,  # The segs info
            words,  # Depth of memory
            bits,  # Width of memory
            cell,  # The BRAM primitive to process
            mappings,  # The returned mappings data structure
            verbose,
            printMappings
        )

    # Inner function for use in sort below
    def mapSort(m):
        # Need a key that is ascending for the order we want
        return m.word * m.bits + m.bit

    # 5. Sort the mappings to enable fast lookups
    mappings.sort(key=mapSort)

    return mappings