def writeConfigs(CurAttrs, CurChunkNum):
    (CurPlatform, CurDesign) = CurAttrs.get('PLATFORM_DESIGN').split('-')
    CurClkPeriod = CurAttrs.get('CP')
    CurAbcClkPeriod = CurAttrs.get('ABC_CP')
    CurFlatten = CurAttrs.get('FLATTEN')
    CurUncertainty = CurAttrs.get('UNCERTAINTY')
    CurIoDelay = CurAttrs.get('IO_DELAY')
    CurCoreUtil = CurAttrs.get('UTIL')
    CurAspectRatio = CurAttrs.get('AR')
    CurCoreDieMargin = CurAttrs.get('GAP')
    CurPinsDistance = CurAttrs.get('PINS_DISTANCE')
    CurGpPad = CurAttrs.get('GP_PAD')
    CurDpPad = CurAttrs.get('DP_PAD')
    CurPlaceDensity = CurAttrs.get('PD')
    CurPlaceDensityLbAddon = CurAttrs.get('PD_LB_ADD')
    CurCtsClusterSize = CurAttrs.get('CTS_CLUSTER_SIZE')
    CurCtsClusterDiameter = CurAttrs.get('CTS_CLUSTER_DIAMETER')
    CurLayerAdjust = CurAttrs.get('LAYER_ADJUST')
    CurLayerAdjustM1 = CurAttrs.get('M1')
    CurLayerAdjustM2 = CurAttrs.get('M2')
    CurLayerAdjustM3 = CurAttrs.get('M3')
    CurLayerAdjustM4 = CurAttrs.get('M4')
    CurLayerAdjustM5 = CurAttrs.get('M5')
    CurLayerAdjustM6 = CurAttrs.get('M6')
    CurLayerAdjustM7 = CurAttrs.get('M7')
    CurLayerAdjustM8 = CurAttrs.get('M8')
    CurLayerAdjustM9 = CurAttrs.get('M9')
    CurGrSeed = CurAttrs.get('GR_SEED')
    CurGrOverflow = CurAttrs.get('GR_OVERFLOW')
    CurDrSeed = CurAttrs.get('DR_SEED')
    if (not os.path.isdir(('./designs/%s/%s/chunks' % (CurPlatform, CurDesign)))):
        os.mkdir(('./designs/%s/%s/chunks' % (CurPlatform, CurDesign)))
    CurDesignDir = ('./designs/%s/%s' % (CurPlatform, CurDesign))
    CurChunkDir = ('./designs/%s/%s/chunks/chunk%s' % (CurPlatform, CurDesign, CurChunkNum))
    if (not os.path.isdir(CurChunkDir)):
        os.mkdir(CurChunkDir)
    if (MakeArg == 'clean'):
        fileList = glob.glob(('%s/*-DoE-*' % CurChunkDir))
        if (fileList is not None):
            for file in fileList:
                os.remove(file)
        return
    variantName = ''
    for (k, v) in CurAttrs.items():
        if ((v != 'empty') and (k != 'PLATFORM_DESIGN')):
            variantName = ((((variantName + '-') + str(k)) + '_') + str(v))
    variantName = variantName[1:]
    fileName = (('config-DoE-' + variantName) + '.mk')
    fo = open(('%s/%s' % (CurChunkDir, fileName)), 'w')
    fo.write('include $(realpath $(dir $(DESIGN_CONFIG))../../)/config.mk\n')
    fo.write('\n')
    fo.write(('FLOW_VARIANT = %s\n' % variantName))
    fo.write('\n')
    if ((CurClkPeriod != 'empty') or (CurUncertainty != 'empty') or (CurIoDelay != 'empty')):
        fOrigSdc = open(('%s/%s' % (CurDesignDir, OriginalSDC)), 'r')
        filedata = fOrigSdc.read()
        fOrigSdc.close()
        if (CurClkPeriod != 'empty'):
            filedata = re.sub('-period [0-9\\.]+', ('-period ' + str(CurClkPeriod)), filedata)
            filedata = re.sub('-waveform [{}\\s0-9\\.]+[\\s|\n]', '', filedata)
        if (CurUncertainty != 'empty'):
            filedata = re.sub('set uncertainty [0-9\\.]+', ('set uncertainty ' + str(CurUncertainty)), filedata)
        if (CurIoDelay != 'empty'):
            filedata = re.sub('set io_delay [0-9\\.]+', ('set io_delay ' + str(CurIoDelay)), filedata)
        fOutSdc = open(((('%s/constraint-DoE-' % CurChunkDir) + variantName) + '.sdc'), 'w')
        fOutSdc.write(filedata)
        fOutSdc.close()
        fo.write(('export SDC_FILE = $(dir $(DESIGN_CONFIG))/constraint-DoE-%s.sdc\n' % variantName))
    if (CurAbcClkPeriod != 'empty'):
        fo.write(('export ABC_CLOCK_PERIOD_IN_PS = %s\n' % CurAbcClkPeriod))
    if (CurFlatten != 'empty'):
        if (CurFlatten == 0):
            fo.write('export SYNTH_ARGS = \n')
    if (CurCoreUtil != 'empty'):
        fo.write(('export CORE_UTILIZATION = %s\n' % CurCoreUtil))
    if (CurPlaceDensity != 'empty'):
        fo.write(('export PLACE_DENSITY = %.2f\n' % CurPlaceDensity))
    if (CurPlaceDensityLbAddon != 'empty'):
        fo.write(('export PLACE_DENSITY_LB_ADDON = %.2f\n' % CurPlaceDensityLbAddon))
    if (CurAspectRatio != 'empty'):
        fo.write(('export CORE_ASPECT_RATIO = %s\n' % CurAspectRatio))
    if (CurCoreDieMargin != 'empty'):
        fo.write(('export CORE_MARGIN = %s\n' % CurCoreDieMargin))
    if (CurPinsDistance != 'empty'):
        fo.write(('export PLACE_PINS_ARGS = -min_distance %s\n' % CurPinsDistance))
    if (CurGpPad != 'empty'):
        fo.write(('export CELL_PAD_IN_SITES_GLOBAL_PLACEMENT = %s\n' % CurGpPad))
    if (CurDpPad != 'empty'):
        fo.write(('export CELL_PAD_IN_SITES_DETAIL_PLACEMENT = %s\n' % CurDpPad))
    if (CurCtsClusterSize != 'empty'):
        fo.write(('export CTS_CLUSTER_SIZE = %s\n' % CurCtsClusterSize))
    if (CurCtsClusterDiameter != 'empty'):
        fo.write(('export CTS_CLUSTER_DIAMETER = %s\n' % CurCtsClusterDiameter))
    if (CurDrSeed != 'empty'):
        fo.write('export OR_K = 1.0\n')
        fo.write(('export OR_SEED = %s\n' % CurDrSeed))
    if ((CurLayerAdjust != 'empty') or (CurLayerAdjustM1 != 'empty') or (CurLayerAdjustM2 != 'empty') or (CurLayerAdjustM3 != 'empty') or (CurLayerAdjustM4 != 'empty') or (CurLayerAdjustM5 != 'empty') or (CurLayerAdjustM6 != 'empty') or (CurLayerAdjustM7 != 'empty') or (CurLayerAdjustM8 != 'empty') or (CurLayerAdjustM9 != 'empty') or (CurGrSeed != 'empty')):
        fo.write(('export FASTROUTE_TCL = $(dir $(DESIGN_CONFIG))/fastroute-DoE-%s.tcl' % variantName))
        if (CurPlatform in PUBLIC):
            PLATFORM_DIR = ('./platforms/%s' % CurPlatform)
        else:
            PLATFORM_DIR = ('../../%s' % CurPlatform)
        fFrIn = open(('%s/fastroute.tcl' % PLATFORM_DIR), 'r')
        filedata = fFrIn.read()
        fFrIn.close()
        CurLayerAdjustSet = [CurLayerAdjust, CurLayerAdjustM1, CurLayerAdjustM2, CurLayerAdjustM3, CurLayerAdjustM4, CurLayerAdjustM5, CurLayerAdjustM6, CurLayerAdjustM7, CurLayerAdjustM8, CurLayerAdjustM9]
        filedata = adjustFastRoute(filedata, CurLayerAdjustSet, CurGrOverflow)
        FrName = (('fastroute-DoE-' + variantName) + '.tcl')
        fOutFr = open(('%s/%s' % (CurChunkDir, FrName)), 'w')
        fOutFr.write(filedata)
        if (CurGrSeed != 'empty'):
            fOutFr.write(('set_global_routing_random -seed %s' % CurGrSeed))
        fOutFr.close()
    fo.close()
    frun = open(('./%s.sh' % ShellName), 'a')
    RunName = ('DESIGN_CONFIG=%s/%s make\n' % (CurChunkDir, fileName))
    frun.write(RunName)
    frun.close()
    fcollect = open(('./%s_metrics_collect.sh' % ShellName), 'a')
    CollectName = ('python util/genMetrics.py -x -p %s -d %s -v %s -o metrics_%s/%s.json\n' % (CurPlatform, CurDesign, variantName, ShellName, variantName))
    fcollect.write(CollectName)
    fcollect.close()
def writeConfigs(CurAttrs, CurChunkNum):
    (CurPlatform, CurDesign) = CurAttrs.get('PLATFORM_DESIGN').split('-')
    CurClkPeriod = CurAttrs.get('CP')
    CurAbcClkPeriod = CurAttrs.get('ABC_CP')
    CurFlatten = CurAttrs.get('FLATTEN')
    CurUncertainty = CurAttrs.get('UNCERTAINTY')
    CurIoDelay = CurAttrs.get('IO_DELAY')
    CurCoreUtil = CurAttrs.get('UTIL')
    CurAspectRatio = CurAttrs.get('AR')
    CurCoreDieMargin = CurAttrs.get('GAP')
    CurPinsDistance = CurAttrs.get('PINS_DISTANCE')
    CurGpPad = CurAttrs.get('GP_PAD')
    CurDpPad = CurAttrs.get('DP_PAD')
    CurPlaceDensity = CurAttrs.get('PD')
    CurPlaceDensityLbAddon = CurAttrs.get('PD_LB_ADD')
    CurCtsClusterSize = CurAttrs.get('CTS_CLUSTER_SIZE')
    CurCtsClusterDiameter = CurAttrs.get('CTS_CLUSTER_DIAMETER')
    CurLayerAdjust = CurAttrs.get('LAYER_ADJUST')
    CurLayerAdjustM1 = CurAttrs.get('M1')
    CurLayerAdjustM2 = CurAttrs.get('M2')
    CurLayerAdjustM3 = CurAttrs.get('M3')
    CurLayerAdjustM4 = CurAttrs.get('M4')
    CurLayerAdjustM5 = CurAttrs.get('M5')
    CurLayerAdjustM6 = CurAttrs.get('M6')
    CurLayerAdjustM7 = CurAttrs.get('M7')
    CurLayerAdjustM8 = CurAttrs.get('M8')
    CurLayerAdjustM9 = CurAttrs.get('M9')
    CurGrSeed = CurAttrs.get('GR_SEED')
    CurGrOverflow = CurAttrs.get('GR_OVERFLOW')
    CurDrSeed = CurAttrs.get('DR_SEED')
    if (not os.path.isdir(('./designs/%s/%s/chunks' % (CurPlatform, CurDesign)))):
        os.mkdir(('./designs/%s/%s/chunks' % (CurPlatform, CurDesign)))
    CurDesignDir = ('./designs/%s/%s' % (CurPlatform, CurDesign))
    CurChunkDir = ('./designs/%s/%s/chunks/chunk%s' % (CurPlatform, CurDesign, CurChunkNum))
    if (not os.path.isdir(CurChunkDir)):
        os.mkdir(CurChunkDir)
    if (MakeArg == 'clean'):
        fileList = glob.glob(('%s/*-DoE-*' % CurChunkDir))
        if (fileList is not None):
            for file in fileList:
                os.remove(file)
        return
    variantName = 
    for (k, v) in CurAttrs.items():
        if ((v != 'empty') and (k != 'PLATFORM_DESIGN')):
            variantName = ((((variantName + '-') + str(k)) + '_') + str(v))
    variantName = variantName[1:]
    fileName = (('config-DoE-' + variantName) + '.mk')
    fo = open(('%s/%s' % (CurChunkDir, fileName)), 'w')
    fo.write('include $(realpath $(dir $(DESIGN_CONFIG))../../)/config.mk\n')
    fo.write('\n')
    fo.write(('FLOW_VARIANT = %s\n' % variantName))
    fo.write('\n')
    if ((CurClkPeriod != 'empty') or (CurUncertainty != 'empty') or (CurIoDelay != 'empty')):
        fOrigSdc = open(('%s/%s' % (CurDesignDir, OriginalSDC)), 'r')
        filedata = fOrigSdc.read()
        fOrigSdc.close()
        if (CurClkPeriod != 'empty'):
            filedata = re.sub('-period [0-9\\.]+', ('-period ' + str(CurClkPeriod)), filedata)
            filedata = re.sub('-waveform [{}\\s0-9\\.]+[\\s|\n]', , filedata)
        if (CurUncertainty != 'empty'):
            filedata = re.sub('set uncertainty [0-9\\.]+', ('set uncertainty ' + str(CurUncertainty)), filedata)
        if (CurIoDelay != 'empty'):
            filedata = re.sub('set io_delay [0-9\\.]+', ('set io_delay ' + str(CurIoDelay)), filedata)
        fOutSdc = open(((('%s/constraint-DoE-' % CurChunkDir) + variantName) + '.sdc'), 'w')
        fOutSdc.write(filedata)
        fOutSdc.close()
        fo.write(('export SDC_FILE = $(dir $(DESIGN_CONFIG))/constraint-DoE-%s.sdc\n' % variantName))
    if (CurAbcClkPeriod != 'empty'):
        fo.write(('export ABC_CLOCK_PERIOD_IN_PS = %s\n' % CurAbcClkPeriod))
    if (CurFlatten != 'empty'):
        if (CurFlatten == 0):
            fo.write('export SYNTH_ARGS = \n')
    if (CurCoreUtil != 'empty'):
        fo.write(('export CORE_UTILIZATION = %s\n' % CurCoreUtil))
    if (CurPlaceDensity != 'empty'):
        fo.write(('export PLACE_DENSITY = %.2f\n' % CurPlaceDensity))
    if (CurPlaceDensityLbAddon != 'empty'):
        fo.write(('export PLACE_DENSITY_LB_ADDON = %.2f\n' % CurPlaceDensityLbAddon))
    if (CurAspectRatio != 'empty'):
        fo.write(('export CORE_ASPECT_RATIO = %s\n' % CurAspectRatio))
    if (CurCoreDieMargin != 'empty'):
        fo.write(('export CORE_MARGIN = %s\n' % CurCoreDieMargin))
    if (CurPinsDistance != 'empty'):
        fo.write(('export PLACE_PINS_ARGS = -min_distance %s\n' % CurPinsDistance))
    if (CurGpPad != 'empty'):
        fo.write(('export CELL_PAD_IN_SITES_GLOBAL_PLACEMENT = %s\n' % CurGpPad))
    if (CurDpPad != 'empty'):
        fo.write(('export CELL_PAD_IN_SITES_DETAIL_PLACEMENT = %s\n' % CurDpPad))
    if (CurCtsClusterSize != 'empty'):
        fo.write(('export CTS_CLUSTER_SIZE = %s\n' % CurCtsClusterSize))
    if (CurCtsClusterDiameter != 'empty'):
        fo.write(('export CTS_CLUSTER_DIAMETER = %s\n' % CurCtsClusterDiameter))
    if (CurDrSeed != 'empty'):
        fo.write('export OR_K = 1.0\n')
        fo.write(('export OR_SEED = %s\n' % CurDrSeed))
    if ((CurLayerAdjust != 'empty') or (CurLayerAdjustM1 != 'empty') or (CurLayerAdjustM2 != 'empty') or (CurLayerAdjustM3 != 'empty') or (CurLayerAdjustM4 != 'empty') or (CurLayerAdjustM5 != 'empty') or (CurLayerAdjustM6 != 'empty') or (CurLayerAdjustM7 != 'empty') or (CurLayerAdjustM8 != 'empty') or (CurLayerAdjustM9 != 'empty') or (CurGrSeed != 'empty')):
        fo.write(('export FASTROUTE_TCL = $(dir $(DESIGN_CONFIG))/fastroute-DoE-%s.tcl' % variantName))
        if (CurPlatform in PUBLIC):
            PLATFORM_DIR = ('./platforms/%s' % CurPlatform)
        else:
            PLATFORM_DIR = ('../../%s' % CurPlatform)
        fFrIn = open(('%s/fastroute.tcl' % PLATFORM_DIR), 'r')
        filedata = fFrIn.read()
        fFrIn.close()
        CurLayerAdjustSet = [CurLayerAdjust, CurLayerAdjustM1, CurLayerAdjustM2, CurLayerAdjustM3, CurLayerAdjustM4, CurLayerAdjustM5, CurLayerAdjustM6, CurLayerAdjustM7, CurLayerAdjustM8, CurLayerAdjustM9]
        filedata = adjustFastRoute(filedata, CurLayerAdjustSet, CurGrOverflow)
        FrName = (('fastroute-DoE-' + variantName) + '.tcl')
        fOutFr = open(('%s/%s' % (CurChunkDir, FrName)), 'w')
        fOutFr.write(filedata)
        if (CurGrSeed != 'empty'):
            fOutFr.write(('set_global_routing_random -seed %s' % CurGrSeed))
        fOutFr.close()
    fo.close()
    frun = open(('./%s.sh' % ShellName), 'a')
    RunName = ('DESIGN_CONFIG=%s/%s make\n' % (CurChunkDir, fileName))
    frun.write(RunName)
    frun.close()
    fcollect = open(('./%s_metrics_collect.sh' % ShellName), 'a')
    CollectName = ('python util/genMetrics.py -x -p %s -d %s -v %s -o metrics_%s/%s.json\n' % (CurPlatform, CurDesign, variantName, ShellName, variantName))
    fcollect.write(CollectName)
    fcollect.close()