def edf_to_dcp_tcl(target, source, env): edfTclFile = open(edfTcl,'w') for netlist in gen_netlists + given_netlists: edfTclFile.write('read_edif ' + model.rel_if_not_abspath(netlist, edfCompileDirectory) + '\n') refName = module.wrapperName() # If this is an platform/user-defined area group, the wrapper name may be different. if((not self.firstPassLIGraph is None) and (module.name in self.firstPassLIGraph.modules)): if (not self.firstPassLIGraph.modules[module.name].getAttribute('BLACK_BOX_AREA_GROUP') is None): area_constraints.loadAreaConstraints() refName = area_constraints.constraints[module.name].attributes['MODULE_NAME'] if(module.getAttribute('TOP_MODULE') is None): edfTclFile.write("link_design -mode out_of_context -top " + refName + " -part " + self.part + "\n") edfTclFile.write("set_property HD.PARTITION 1 [current_design]\n") else: edfTclFile.write("link_design -top " + refName + " -part " + self.part + "\n") if(not module.platformModule): edfTclFile.write("opt_design -quiet\n") edfTclFile.write('write_checkpoint -force ' + module.name + ".synth.dcp" + '\n') edfTclFile.close()
def edf_to_dcp_tcl(target, source, env): edfTclFile = open(edfTcl, 'w') for netlist in gen_netlists + given_netlists: edfTclFile.write('read_edif ' + model.rel_if_not_abspath( netlist, edfCompileDirectory) + '\n') refName = module.wrapperName() # If this is an platform/user-defined area group, the wrapper name may be different. if ((not self.firstPassLIGraph is None) and (module.name in self.firstPassLIGraph.modules)): if (not self.firstPassLIGraph.modules[module.name]. getAttribute('BLACK_BOX_AREA_GROUP') is None): area_constraints.loadAreaConstraints() refName = area_constraints.constraints[ module.name].attributes['MODULE_NAME'] if (module.getAttribute('TOP_MODULE') is None): edfTclFile.write("link_design -mode out_of_context -top " + refName + " -part " + self.part + "\n") edfTclFile.write( "set_property HD.PARTITION 1 [current_design]\n") else: edfTclFile.write("link_design -top " + refName + " -part " + self.part + "\n") if (not module.platformModule): edfTclFile.write("opt_design -quiet\n") edfTclFile.write('write_checkpoint -force ' + module.name + ".synth.dcp" + '\n') edfTclFile.close()
def generateVivadoTcl(moduleList, module, globalVerilogs, globalVHDs, vivadoCompileDirectory): # spit out a new top-level prj prjPath = vivadoCompileDirectory.File(module.wrapperName() + '.synthesis.tcl') newTclFile = open(str(prjPath), 'w') # Emit verilog source and stub references verilogs = globalVerilogs + [model.get_temp_path(moduleList,module) + module.wrapperName() + '.v'] verilogs += moduleList.getDependencies(module, 'VERILOG_STUB') givenNetlists = [ moduleList.env['DEFS']['ROOT_DIR_HW'] + '/' + netlist for netlist in moduleList.getAllDependenciesWithPaths('GIVEN_NGCS') + moduleList.getAllDependenciesWithPaths('GIVEN_EDFS') ] # Replace any known black boxes blackBoxDeps = [] blackBoxes = module.getAttribute('BLACK_BOX') for vlog in sorted(verilogs): if(not blackBoxes is None): if(vlog in blackBoxes): vlog = blackBoxes[vlog] blackBoxDeps.append(vlog) relpath = model.rel_if_not_abspath(vlog, str(vivadoCompileDirectory)) newTclFile.write("read_verilog -quiet " + relpath + "\n") # grab the system verilogs. for sysv in map(model.modify_path_hw, moduleList.getAllDependenciesWithPaths('GIVEN_SYSTEM_VERILOGS')): relpath = model.rel_if_not_abspath(sysv, str(vivadoCompileDirectory)) newTclFile.write("read_verilog -sv -quiet " + relpath + "\n") for vhd in sorted(globalVHDs): if(isinstance(vhd, model.Source.Source)): # Got a source object, potentially more work to do. relpath = model.rel_if_not_abspath(vhd.file, str(vivadoCompileDirectory)) lib = 'work' if('lib' in vhd.attributes): newTclFile.write("read_vhdl -lib " + vhd.attributes['lib'] + " " + relpath + "\n") else: # Just got a string relpath = model.rel_if_not_abspath(vhd, str(vivadoCompileDirectory)) newTclFile.write("read_vhdl -lib work " + relpath + "\n") for netlist in givenNetlists: relpath = model.rel_if_not_abspath(netlist, str(vivadoCompileDirectory)) newTclFile.write('read_edif ' + relpath + '\n') annotationFiles, annotationDeps = generateSynthesisTcl(moduleList, module, vivadoCompileDirectory) part = moduleList.getAWBParam('physical_platform_config', 'FPGA_PART_XILINX') # the out of context option instructs the tool not to place iobuf # and friends on the external ports. # First, elaborate the rtl design. inc_dirs = model.rel_if_not_abspath(moduleList.env['DEFS']['ROOT_DIR_HW_INC'], str(vivadoCompileDirectory)) # For the top module, we don't use out of context.b if(module.getAttribute('TOP_MODULE') is None): newTclFile.write("synth_design -rtl -mode out_of_context -top " + module.wrapperName() + " -part " + part + " -include_dirs " + inc_dirs + "\n") else: newTclFile.write("synth_design -rtl -top " + module.wrapperName() + " -part " + part + " -include_dirs " + inc_dirs + "\n") for file in annotationFiles: newTclFile.write("add_files " + file + "\n") if(module.getAttribute('TOP_MODULE') is None): newTclFile.write("set_property USED_IN {synthesis implementation out_of_context} [get_files " + file + "]\n") else: newTclFile.write("set_property USED_IN {synthesis implementation} [get_files " + file + "]\n") if(module.getAttribute('TOP_MODULE') is None): clockConversion = "" useClockConversion = moduleList.getAWBParamSafe('synthesis_tool', 'VIVADO_ENABLE_CLOCK_CONVERSION') print " VIVADO CLOCK CONVERSION: " + str(useClockConversion) if(useClockConversion > 0): clockConversion = " -gated_clock_conversion auto " newTclFile.write("synth_design " + clockConversion + " -mode out_of_context -top " + module.wrapperName() + " -part " + part + " -include_dirs " + inc_dirs + "\n") newTclFile.write("set_property HD.PARTITION 1 [current_design]\n") else: newTclFile.write("synth_design -top " + module.wrapperName() + " -part " + part + " -include_dirs " + inc_dirs + "\n") newTclFile.write("all_clocks\n") newTclFile.write("report_clocks\n") newTclFile.write("report_utilization -file " + module.wrapperName() + ".synth.preopt.util\n") # We should do opt_design here because it will be faster in # parallel. However, opt_design seems to cause downstream # problems and needs more testing. newTclFile.write("opt_design -quiet\n") newTclFile.write("report_utilization -file " + module.wrapperName() + ".synth.opt.util\n") newTclFile.write("write_checkpoint -force " + module.wrapperName() + ".synth.dcp\n") newTclFile.write("close_project -quiet\n") newTclFile.close() return [prjPath] + blackBoxDeps + annotationDeps
def generateSynthesisTcl(moduleList, module, compileDirectory): # Eventually we will want to add some of these to the synthesis tcl # From UG905 pg. 11, involving clock definition. # We need to declare a top-level clock. Unfortunately, the platform module will require special handling. clockFiles = [] # Physical devices require special handling, since they have # complicated clocking mechanisms which must be exposed at # synthesis. MODEL_CLOCK_FREQ = moduleList.getAWBParam('clocks_device', 'MODEL_CLOCK_FREQ') synthAnnotationsTclPath = compileDirectory.File(module.wrapperName() + '.annotations.tcl') synthAnnotationsTclFile = open(str(synthAnnotationsTclPath), 'w') annotationFiles = [os.path.relpath(str(synthAnnotationsTclPath), str(compileDirectory))] clockDeps = [synthAnnotationsTclPath] relpathCurry = functools.partial(os.path.relpath, start = str(compileDirectory)) synthAnnotationsTclFile.write('set SYNTH_OBJECT ' + module.name + '\n') synthAnnotationsTclFile.write('set IS_TOP_BUILD 0\n') synthAnnotationsTclFile.write('set IS_AREA_GROUP_BUILD 0\n') tclDefs = [] if(len(moduleList.getAllDependenciesWithPaths('GIVEN_VIVADO_TCL_DEFINITIONS')) > 0): tclDefs = map(model.modify_path_hw, moduleList.getAllDependenciesWithPaths('GIVEN_VIVADO_TCL_DEFINITIONS')) clockDeps += tclDefs tclDefs = map(relpathCurry, tclDefs) tclSynth = [] #if (module.platformModule or 'AREA_GROUP' not in module.attributes): if(len(moduleList.getAllDependenciesWithPaths('GIVEN_VIVADO_TCL_SYNTHESISS')) > 0): tclSynth = map(model.modify_path_hw, moduleList.getAllDependenciesWithPaths('GIVEN_VIVADO_TCL_SYNTHESISS')) clockDeps += tclSynth tclSynth = map(relpathCurry, tclSynth) tclParams= [] if(len(moduleList.getAllDependencies('PARAM_TCL')) > 0): tclParams = moduleList.getAllDependencies('PARAM_TCL') # Add in other synthesis algorithms tclHeaders = [] if(len(moduleList.getAllDependenciesWithPaths('GIVEN_VIVADO_TCL_HEADERS')) > 0): tclHeaders = map(model.modify_path_hw, moduleList.getAllDependenciesWithPaths('GIVEN_VIVADO_TCL_HEADERS')) tclFuncs = [] if(len(moduleList.getAllDependenciesWithPaths('GIVEN_VIVADO_TCL_FUNCTIONS')) > 0): tclFuncs = map(model.modify_path_hw, moduleList.getAllDependenciesWithPaths('GIVEN_VIVADO_TCL_FUNCTIONS')) for tclParam in tclParams: #newTclFile.write('source ' + model.rel_if_not_abspath(tcl_param, str(vivadoCompileDirectory)) + '\n') synthAnnotationsTclFile.write('source ' + model.rel_if_not_abspath(tclParam, str(compileDirectory)) + '\n') for tclHeader in tclHeaders: #newTclFile.write('source ' + model.rel_if_not_abspath(tcl_header, str(vivadoCompileDirectory)) + '\n') synthAnnotationsTclFile.write('source ' + model.rel_if_not_abspath(tclHeader, str(compileDirectory)) + '\n') synthAnnotationsTclFile.write('annotateModelClock\n') # apply tcl synthesis functions/patches for tclFunc in tclFuncs: relpath = model.rel_if_not_abspath(tclFunc, str(compileDirectory)) synthAnnotationsTclFile.write('source ' + relpath + '\n') for file in tclDefs: synthAnnotationsTclFile.write("source " + file + "\n") for file in tclSynth: synthAnnotationsTclFile.write("source " + file + "\n") # we need some synthesis algorithms... synthAnnotationsTclFile.close() return annotationFiles, tclFuncs + tclHeaders + tclParams + clockDeps
def generateVivadoTcl(moduleList, module, globalVerilogs, globalVHDs, vivadoCompileDirectory): # spit out a new top-level prj prjPath = vivadoCompileDirectory.File(module.wrapperName() + '.synthesis.tcl') newTclFile = open(str(prjPath), 'w') # Emit verilog source and stub references verilogs = globalVerilogs + [model.get_temp_path(moduleList,module) + module.wrapperName() + '.v'] verilogs += moduleList.getDependencies(module, 'VERILOG_STUB') givenNetlists = [ moduleList.env['DEFS']['ROOT_DIR_HW'] + '/' + netlist for netlist in moduleList.getAllDependenciesWithPaths('GIVEN_NGCS') + moduleList.getAllDependenciesWithPaths('GIVEN_EDFS') ] # Replace any known black boxes blackBoxDeps = [] blackBoxes = module.getAttribute('BLACK_BOX') for vlog in sorted(verilogs): if(not blackBoxes is None): if(vlog in blackBoxes): vlog = blackBoxes[vlog] blackBoxDeps.append(vlog) relpath = model.rel_if_not_abspath(vlog, str(vivadoCompileDirectory)) newTclFile.write("read_verilog -quiet " + relpath + "\n") # grab the system verilogs. for sysv in map(model.modify_path_hw, moduleList.getAllDependenciesWithPaths('GIVEN_SYSTEM_VERILOGS')): relpath = model.rel_if_not_abspath(sysv, str(vivadoCompileDirectory)) newTclFile.write("read_verilog -sv -quiet " + relpath + "\n") for vhd in sorted(globalVHDs): if(isinstance(vhd, model.Source.Source)): # Got a source object, potentially more work to do. relpath = model.rel_if_not_abspath(vhd.file, str(vivadoCompileDirectory)) lib = 'work' if('lib' in vhd.attributes): newTclFile.write("read_vhdl -lib " + vhd.attributes['lib'] + " " + relpath + "\n") else: # Just got a string relpath = model.rel_if_not_abspath(vhd, str(vivadoCompileDirectory)) newTclFile.write("read_vhdl -lib work " + relpath + "\n") for netlist in givenNetlists: relpath = model.rel_if_not_abspath(netlist, str(vivadoCompileDirectory)) newTclFile.write('read_edif ' + relpath + '\n') annotationFiles, annotationDeps = generateSynthesisTcl(moduleList, module, vivadoCompileDirectory) part = moduleList.getAWBParam('physical_platform_config', 'FPGA_PART_XILINX') # the out of context option instructs the tool not to place iobuf # and friends on the external ports. # First, elaborate the rtl design. # Obtain the include directories of any other verilog headers. inc_dirs = moduleList.getAllDependencies('VERILOG_INC_DIRS') # The user might have provided verilog header files. Make the visible here. for verilog_h in map(model.modify_path_hw, moduleList.getAllDependenciesWithPaths('GIVEN_VERILOG_HS')): relpath = os.path.dirname(model.rel_if_not_abspath(verilog_h, str(vivadoCompileDirectory))) if relpath not in inc_dirs: inc_dirs.append(relpath) # add in the present header files inc_dirs.append(model.rel_if_not_abspath(moduleList.env['DEFS']['ROOT_DIR_HW_INC'], str(vivadoCompileDirectory))) # For the top module, we don't use out of context.b if(module.getAttribute('TOP_MODULE') is None): newTclFile.write("synth_design -rtl -mode out_of_context -top " + module.wrapperName() + " -part " + part + " -include_dirs [list " + " ".join(inc_dirs) + "]\n") else: newTclFile.write("synth_design -rtl -top " + module.wrapperName() + " -part " + part + " -include_dirs [list " + " ".join(inc_dirs) + "]\n") for file in annotationFiles: newTclFile.write("add_files " + file + "\n") if(module.getAttribute('TOP_MODULE') is None): newTclFile.write("set_property USED_IN {synthesis implementation out_of_context} [get_files " + file + "]\n") else: newTclFile.write("set_property USED_IN {synthesis implementation} [get_files " + file + "]\n") if(module.getAttribute('TOP_MODULE') is None): clockConversion = "" useClockConversion = moduleList.getAWBParamSafe('synthesis_tool', 'VIVADO_ENABLE_CLOCK_CONVERSION') print " VIVADO CLOCK CONVERSION: " + str(useClockConversion) if(useClockConversion > 0): clockConversion = " -gated_clock_conversion auto " newTclFile.write("synth_design " + clockConversion + " -mode out_of_context -top " + module.wrapperName() + " -part " + part + " -include_dirs [list " + " ".join(inc_dirs) + "]\n") newTclFile.write("set_property HD.PARTITION 1 [current_design]\n") else: newTclFile.write("synth_design -top " + module.wrapperName() + " -part " + part + " -include_dirs [list " + " ".join(inc_dirs) + "]\n") newTclFile.write("all_clocks\n") newTclFile.write("report_clocks\n") newTclFile.write("report_utilization -file " + module.wrapperName() + ".synth.preopt.util\n") # We should do opt_design here because it will be faster in # parallel. However, opt_design seems to cause downstream # problems and needs more testing. newTclFile.write("opt_design -quiet\n") newTclFile.write("report_utilization -file " + module.wrapperName() + ".synth.opt.util\n") newTclFile.write("write_checkpoint -force " + module.wrapperName() + ".synth.dcp\n") newTclFile.write("close_project -quiet\n") newTclFile.close() return [prjPath] + blackBoxDeps + annotationDeps
def place_dcp_tcl(target, source, env): # TODO: Eventually, we'll need to examine the contstraints to decide if we need to rebuild. area_constraints.loadAreaConstraints() edfTclFile = open(edfTcl,'w') constraintsTclFile = open(constraintsTcl,'w') edfTclFile.write('read_checkpoint ' + model.rel_if_not_abspath(checkpoint[0], placeCompileDirectory) + '\n') # throw out area group constraints. (and maybe loc constraints too?) # Some modules may not have placement information. Ignore them for now. needToLink = True refName = module.wrapperName() # If this is an platform/user-defined area group, the wrapper name may be different. if (not self.firstPassLIGraph.modules[module.name].getAttribute('BLACK_BOX_AREA_GROUP') is None): refName = area_constraints.constraints[module.name].attributes['MODULE_NAME'] if((self.firstPassLIGraph.modules[module.name].getAttribute('BLACK_BOX_AREA_GROUP') is None) or moduleList.getAWBParamSafe('area_group_tool', 'AREA_GROUPS_PAR_DEVICE_AG')): if(not area_constraints.emitModuleConstraintsVivado(constraintsTclFile, module.name, useSourcePath=False) is None): # for platform modules, we need to insert the tcl environment. constraintsTclFile.write('set IS_TOP_BUILD 0\n') constraintsTclFile.write('set AG_OBJECT ' + module.name + '\n') constraintsTclFile.write('set IS_AREA_GROUP_BUILD 1\n') constraintsTclFile.write('source ' + model.rel_if_not_abspath(self.paramTclFile, placeCompileDirectory) + '\n') for tcl_header in self.tcl_headers: constraintsTclFile.write('source ' + model.rel_if_not_abspath(tcl_header, placeCompileDirectory) + '\n') for tcl_def in self.tcl_defs: constraintsTclFile.write('source ' + model.rel_if_not_abspath(tcl_def, placeCompileDirectory) + '\n') for tcl_func in self.tcl_funcs: constraintsTclFile.write('source ' + model.rel_if_not_abspath(tcl_func, placeCompileDirectory) + '\n') constraintsTclFile.write("annotateModelClock\n") constraintsTclFile.write("annotateCLK_SRC\n") for tcl_alg in self.tcl_algs: constraintsTclFile.write('source ' + model.rel_if_not_abspath(tcl_alg, placeCompileDirectory) + '\n') edfTclFile.write('add_file ' + model.rel_if_not_abspath(constraintsTcl, placeCompileDirectory) + '\n') if(not 'NO_PLACE' in area_constraints.constraints[module.name].attributes): if(not 'NO_ROUTE' in area_constraints.constraints[module.name].attributes and self.routeAG): edfTclFile.write("set_property USED_IN {synthesis implementation opt_design place_design phys_opt_design route_design out_of_context} [get_files " + model.rel_if_not_abspath(constraintsTcl, placeCompileDirectory) + "]\n") else: edfTclFile.write("set_property USED_IN {synthesis implementation opt_design place_design phys_opt_design out_of_context} [get_files " + model.rel_if_not_abspath(constraintsTcl, placeCompileDirectory) + "]\n") # linking lets us pull in placement constraints. edfTclFile.write("link_design -mode out_of_context -top " + refName + " -part " + self.part + "\n") needToLink = False # if ended here... if(not 'NO_PLACE' in area_constraints.constraints[module.name].attributes): edfTclFile.write("place_design -no_drc \n") edfTclFile.write("report_timing_summary -file " + module.name + ".place.twr\n") edfTclFile.write("phys_opt_design \n") if(not 'NO_ROUTE' in area_constraints.constraints[module.name].attributes and self.routeAG): edfTclFile.write("route_design\n") edfTclFile.write("report_timing_summary -file " + module.name + ".route.twr\n") edfTclFile.write("report_route_status\n") # still need to link design. if(needToLink): edfTclFile.write("link_design -mode out_of_context -top " + refName + " -part " + self.part + "\n") edfTclFile.write('write_checkpoint -force ' + module.name + ".place.dcp" + '\n') edfTclFile.close() constraintsTclFile.close()
def __init__(self, moduleList): altera_apm_name = moduleList.compileDirectory + "/" + moduleList.apmName qsf_src_dir = moduleList.env["DEFS"]["ROOT_DIR_HW_MODEL"] # If the compilation directory doesn't exist, create it. if not os.path.exists(moduleList.compileDirectory): os.mkdir(moduleList.compileDirectory) rel_qsf_src_dir = model.rel_if_not_abspath(qsf_src_dir, moduleList.compileDirectory) # pick up awb parameters. paramTclFile = moduleList.topModule.moduleDependency["PARAM_TCL"][0] ## QA build expects to build sys_cfg_pkg.svh in the build directory if os.path.exists(qsf_src_dir + "/sys_cfg_pkg.svh") and not os.path.exists( moduleList.compileDirectory + "/sys_cfg_pkg.svh" ): os.symlink(rel_qsf_src_dir + "/sys_cfg_pkg.svh", moduleList.compileDirectory + "/sys_cfg_pkg.svh") altera_qsf = altera_apm_name + ".tcl" altera_qpf = altera_apm_name + ".qpf" prjFile = open(altera_qsf, "w") prjFile.write("package require ::quartus::project\n") prjFile.write("package require ::quartus::flow\n") prjFile.write("package require ::quartus::incremental_compilation\n") # Check for the existence of a project here, so that we can # make use of incremental compilation. prjFile.write("set created_project [project_exists " + moduleList.apmName + "]\n") prjFile.write("if $created_project {\n") prjFile.write(" project_open " + moduleList.apmName + " \n") prjFile.write("} else {\n") prjFile.write(" project_new " + moduleList.apmName + "\n") prjFile.write("}\n\n") ## ## Define which version of CCI is in use for SystemVerilog packages ## imported from outside LEAP. ## if moduleList.getAWBParamSafe("qa_platform_libs", "CCI_S_IFC"): prjFile.write('set_global_assignment -name VERILOG_MACRO "MPF_PLATFORM_OME=1"\n') if moduleList.getAWBParamSafe("qa_platform_libs", "CCI_P_IFC"): prjFile.write('set_global_assignment -name VERILOG_MACRO "MPF_PLATFORM_BDX=1"\n') prjFile.write('set_global_assignment -name VERILOG_MACRO "BSV_POSITIVE_RESET=1"\n') prjFile.write("source " + rel_qsf_src_dir + "/ome2_ivt.qsf\n") prjFile.write("source " + rel_qsf_src_dir + "/qsf_env_settings.qsf\n") prjFile.write("source " + rel_qsf_src_dir + "/qsf_qph_PAR_files.qsf\n") # Include file path inc_dirs = ["hw/include"] for inc in inc_dirs: inc = model.rel_if_not_abspath(inc, moduleList.compileDirectory) prjFile.write("set_global_assignment -name SEARCH_PATH " + inc + "\n") # Include SDC (Tcl) files. These must be included in a specific order to honor dependencies among them. sdcs = ( map(model.modify_path_hw, moduleList.getAllDependenciesWithPaths("GIVEN_TCL_HEADERS")) + map(model.modify_path_hw, moduleList.getAllDependenciesWithPaths("GIVEN_SDCS")) + map(model.modify_path_hw, moduleList.getAllDependenciesWithPaths("GIVEN_SDC_ALGEBRAS")) ) for tcl_header in [paramTclFile] + sdcs: prjFile.write( "set_global_assignment -name SDC_FILE " + model.rel_if_not_abspath(tcl_header, moduleList.compileDirectory) + "\n" ) # List SystemVerilog packages first for pkg in moduleList.getAllDependenciesWithPaths("GIVEN_VERILOG_PKGS"): v = model.rel_if_not_abspath(pkg, moduleList.compileDirectory) prjFile.write("set_global_assignment -name SYSTEMVERILOG_FILE " + v + "\n") # Add in all the verilog here. [globalVerilogs, globalVHDs] = synthesis_library.globalRTLs(moduleList, moduleList.moduleList) # gather verilog for LI Modules. for module in [mod for mod in moduleList.synthBoundaries()] + [moduleList.topModule]: globalVerilogs += [model.get_temp_path(moduleList, module) + module.wrapperName() + ".v"] for v in globalVerilogs: t = "VERILOG" if (v[-2:] == "sv") or (v[-2:] == "vh"): t = "SYSTEMVERILOG" v = model.rel_if_not_abspath(v, moduleList.compileDirectory) prjFile.write("set_global_assignment -name " + t + "_FILE " + v + "\n") for v in globalVHDs: v = model.rel_if_not_abspath(v, moduleList.compileDirectory) prjFile.write("set_global_assignment -name VHDL_FILE " + v + "\n") # add the verilogs of the files generated by quartus system builder for v in model.Utils.clean_split(moduleList.env["DEFS"]["GIVEN_ALTERAVS"], sep=" "): v = model.rel_if_not_abspath(v, moduleList.compileDirectory) prjFile.write("set_global_assignment -name VERILOG_FILE " + v + "\n") fullCompilePath = os.path.abspath(moduleList.compileDirectory) # elaborate the design. prjFile.write( 'execute_module -tool map -args "--verilog_macro=\\"QUARTUS_COMPILATION=1\\" --lib_path ' + fullCompilePath + '--incremental_compilation=full_incremental_compilation --analysis_and_elaboration " \n' ) prjFile.write('puts "Elaboration Complete"\n') # create a partition for leap and the QA driver if they don't exist already. prjFile.write("if $created_project { \n") prjFile.write(' puts "Reusing existing LEAP partitions"\n') prjFile.write("} else { \n") prjFile.write( " create_partition -contents cci_std_afu:cci_std_afu|mk_model_Wrapper:model_wrapper|mk_platform_platform_Wrapper:m_sys_sys_vp_m_mod|mkQADeviceSynth:llpi_phys_plat_qa_device -partition qa_cci_part \n" ) prjFile.write("} \n") ## Hack to meet timing -- turning off LEAP partition partition_mode = moduleList.getAWBParamSafe("qa_device", "CCI_LOOPBACK_HACK") if partition_mode < 2: prjFile.write('set_partition -partition qa_cci_part -netlist_type "Post-Fit"\n') else: prjFile.write('set_partition -partition qa_cci_part -netlist_type "Empty"\n') # if (partition_mode < 1): # prjFile.write('set_partition -partition leap_part -netlist_type "Post-Fit"\n') # else: # prjFile.write('set_partition -partition leap_part -netlist_type "Empty"\n') prjFile.write( 'execute_module -tool map -args "--verilog_macro=\\"QUARTUS_COMPILATION=1\\" --incremental_compilation=full_incremental_compilation --lib_path ' + fullCompilePath + ' " \n' ) prjFile.write('execute_module -tool cdb -args "--merge" \n') prjFile.write("execute_module -tool fit \n") prjFile.write("execute_module -tool sta \n") prjFile.write('execute_module -tool sta -args "--do_report_timing"\n') prjFile.write("execute_module -tool asm \n") prjFile.write("project_close \n") prjFile.close() altera_sof = moduleList.env.Command( altera_apm_name + ".sof", globalVerilogs + globalVHDs + [altera_apm_name + ".tcl"] + [paramTclFile] + sdcs, ["cd " + moduleList.compileDirectory + "; quartus_sh -t " + moduleList.apmName + ".tcl"], ) moduleList.topModule.moduleDependency["BIT"] = [altera_sof] # generate the download program newDownloadFile = open("config/" + moduleList.apmName + ".download.temp", "w") newDownloadFile.write("#!/bin/sh\n") newDownloadFile.write("nios2-configure-sof " + altera_apm_name + ".sof\n") newDownloadFile.close() altera_download = moduleList.env.Command( "config/" + moduleList.apmName + ".download", "config/" + moduleList.apmName + ".download.temp", ["cp $SOURCE $TARGET", "chmod 755 $TARGET"], ) altera_loader = moduleList.env.Command( moduleList.apmName + "_hw.errinfo", moduleList.swExe + moduleList.topModule.moduleDependency["BIT"] + altera_download, [ "@ln -fs " + moduleList.swExeOrTarget + " " + moduleList.apmName, SCons.Script.Delete(moduleList.apmName + "_hw.exe"), SCons.Script.Delete(moduleList.apmName + "_hw.vexe"), '@echo "++++++++++++ Post-Place & Route ++++++++"', synthesis_library.leap_physical_summary( altera_apm_name + ".sta.rpt", moduleList.apmName + "_hw.errinfo", "Timing Analyzer was successful", "Timing requirements not met", ), ], ) moduleList.topModule.moduleDependency["LOADER"] = [altera_loader] moduleList.topDependency = moduleList.topDependency + [altera_loader]
def __init__(self, moduleList): altera_apm_name = moduleList.compileDirectory + '/' + moduleList.apmName # pick up awb parameters. paramTclFile = moduleList.topModule.moduleDependency['PARAM_TCL'][0] # If the compilation directory doesn't exist, create it. if(not os.path.exists(moduleList.compileDirectory)): os.mkdir(moduleList.compileDirectory) newPrjFile = open(altera_apm_name + '.tcl', 'w') newPrjFile.write('package require ::quartus::project\n') newPrjFile.write('package require ::quartus::flow\n') # do we want to check for the existence of a project here? newPrjFile.write('project_new ' + moduleList.apmName +' -overwrite\n') # Add in all the verilog here. [globalVerilogs, globalVHDs] = synthesis_library.globalRTLs(moduleList, moduleList.moduleList) # gather verilog for LI Modules. for module in [ mod for mod in moduleList.synthBoundaries()] + [moduleList.topModule]: globalVerilogs += [model.get_temp_path(moduleList,module) + module.wrapperName() + '.v'] # Write files to the quartus project file. Due to a bug in the STA tool, we need to execute # Quartus from the compileDirectory. This means we have to rebase all of the files. for v in globalVerilogs: newPrjFile.write('set_global_assignment -name VERILOG_FILE ' + model.rel_if_not_abspath(v, moduleList.compileDirectory) + '\n'); for v in globalVHDs: newPrjFile.write('set_global_assignment -name VHDL_FILE ' + model.rel_if_not_abspath(v, moduleList.compileDirectory) + '\n'); for sysVerilogFile in map(model.modify_path_hw, moduleList.getAllDependenciesWithPaths('GIVEN_SYSTEM_VERILOGS')): newPrjFile.write('set_global_assignment -name SYSTEMVERILOG_FILE ' + model.rel_if_not_abspath(sysVerilogFile, moduleList.compileDirectory)+ '\n') # Altera flows appear to accept some kinds of memory intialization files. # incorporate them here. for memFile in map(model.modify_path_hw,moduleList.getAllDependenciesWithPaths('GIVEN_MIFS') + moduleList.getAllDependenciesWithPaths('GIVEN_MIFS')): newPrjFile.write('set_global_assignment -name SOURCE_FILE ' + model.rel_if_not_abspath(memFile, moduleList.compileDirectory)+ '\n') print " Compile directory : " + moduleList.compileDirectory # add the verilogs of the files generated by quartus system builder for v in model.Utils.clean_split(moduleList.env['DEFS']['GIVEN_ALTERAVS'], sep = ' ') : newPrjFile.write('set_global_assignment -name VERILOG_FILE ' + model.rel_if_not_abspath(v, moduleList.compileDirectory) + '\n'); # Include SDC (Tcl) files. These must be included in a specific order to honor dependencies among them. sdcs = map(model.modify_path_hw, moduleList.getAllDependenciesWithPaths('GIVEN_TCL_HEADERS')) + map(model.modify_path_hw, moduleList.getAllDependenciesWithPaths('GIVEN_SDCS')) + map(model.modify_path_hw, moduleList.getAllDependenciesWithPaths('GIVEN_SDC_ALGEBRAS')) for tcl_header in [paramTclFile] + sdcs: newPrjFile.write('set_global_assignment -name SDC_FILE ' + model.rel_if_not_abspath(tcl_header, moduleList.compileDirectory)+ '\n') newPrjFile.write('set_global_assignment -name TOP_LEVEL_ENTITY ' + moduleList.topModule.wrapperName() + '\n') for qsf in map(model.modify_path_hw,moduleList.getAllDependenciesWithPaths('GIVEN_QSFS')): newPrjFile.write('source ' + model.rel_if_not_abspath(qsf, moduleList.compileDirectory)+ '\n') fullCompilePath = os.path.abspath(moduleList.compileDirectory) newPrjFile.write('execute_module -tool map -args "--verilog_macro=\\"QUARTUS_COMPILATION=1\\" --lib_path ' + fullCompilePath + ' " \n') newPrjFile.write('execute_module -tool fit \n') newPrjFile.write('execute_module -tool sta \n') newPrjFile.write('execute_module -tool sta -args "--do_report_timing"\n') newPrjFile.write('execute_module -tool asm \n') newPrjFile.write('project_close \n') newPrjFile.close() altera_sof = moduleList.env.Command(altera_apm_name + '.sof', globalVerilogs + globalVHDs + [altera_apm_name + '.tcl'] + [paramTclFile] + sdcs, ['cd ' + moduleList.compileDirectory + '; quartus_sh -t ' + moduleList.apmName + '.tcl' ]) moduleList.topModule.moduleDependency['BIT'] = [altera_sof] # generate the download program newDownloadFile = open('config/' + moduleList.apmName + '.download.temp', 'w') newDownloadFile.write('#!/bin/sh\n') fpgaPosition = moduleList.getAWBParam('physical_platform_config', 'FPGA_POSITION') newDownloadFile.write('nios2-configure-sof --device ' + str(fpgaPosition) + ' ' + altera_apm_name + '.sof\n') newDownloadFile.close() altera_download = moduleList.env.Command( 'config/' + moduleList.apmName + '.download', 'config/' + moduleList.apmName + '.download.temp', ['cp $SOURCE $TARGET', 'chmod 755 $TARGET']) altera_loader = moduleList.env.Command( moduleList.apmName + '_hw.errinfo', moduleList.swExe + moduleList.topModule.moduleDependency['BIT'] + altera_download, ['@ln -fs ' + moduleList.swExeOrTarget + ' ' + moduleList.apmName, SCons.Script.Delete(moduleList.apmName + '_hw.exe'), SCons.Script.Delete(moduleList.apmName + '_hw.vexe'), '@echo "++++++++++++ Post-Place & Route ++++++++"', synthesis_library.leap_physical_summary(altera_apm_name + '.sta.rpt', moduleList.apmName + '_hw.errinfo', 'Timing Analyzer was successful', 'Timing requirements not met')]) moduleList.topModule.moduleDependency['LOADER'] = [altera_loader] moduleList.topDependency = moduleList.topDependency + [altera_loader]
def place_dcp_tcl(target, source, env): # TODO: Eventually, we'll need to examine the contstraints to decide if we need to rebuild. area_constraints.loadAreaConstraints() edfTclFile = open(edfTcl, 'w') constraintsTclFile = open(constraintsTcl, 'w') edfTclFile.write('read_checkpoint ' + model.rel_if_not_abspath( checkpoint[0], placeCompileDirectory) + '\n') # throw out area group constraints. (and maybe loc constraints too?) # Some modules may not have placement information. Ignore them for now. needToLink = True refName = module.wrapperName() # If this is an platform/user-defined area group, the wrapper name may be different. if (not self.firstPassLIGraph.modules[module.name]. getAttribute('BLACK_BOX_AREA_GROUP') is None): refName = area_constraints.constraints[ module.name].attributes['MODULE_NAME'] if ((self.firstPassLIGraph.modules[module.name].getAttribute( 'BLACK_BOX_AREA_GROUP') is None) or moduleList.getAWBParamSafe( 'area_group_tool', 'AREA_GROUPS_PAR_DEVICE_AG')): if (not area_constraints.emitModuleConstraintsVivado( constraintsTclFile, module.name, useSourcePath=False) is None): # for platform modules, we need to insert the tcl environment. constraintsTclFile.write('set IS_TOP_BUILD 0\n') constraintsTclFile.write('set AG_OBJECT ' + module.name + '\n') constraintsTclFile.write('set IS_AREA_GROUP_BUILD 1\n') constraintsTclFile.write( 'source ' + model.rel_if_not_abspath( self.paramTclFile, placeCompileDirectory) + '\n') for tcl_header in self.tcl_headers: constraintsTclFile.write( 'source ' + model.rel_if_not_abspath( tcl_header, placeCompileDirectory) + '\n') for tcl_def in self.tcl_defs: constraintsTclFile.write( 'source ' + model.rel_if_not_abspath( tcl_def, placeCompileDirectory) + '\n') for tcl_func in self.tcl_funcs: constraintsTclFile.write( 'source ' + model.rel_if_not_abspath( tcl_func, placeCompileDirectory) + '\n') constraintsTclFile.write("annotateModelClock\n") constraintsTclFile.write("annotateCLK_SRC\n") for tcl_alg in self.tcl_algs: constraintsTclFile.write( 'source ' + model.rel_if_not_abspath( tcl_alg, placeCompileDirectory) + '\n') edfTclFile.write( 'add_file ' + model.rel_if_not_abspath( constraintsTcl, placeCompileDirectory) + '\n') if (not 'NO_PLACE' in area_constraints.constraints[ module.name].attributes): if (not 'NO_ROUTE' in area_constraints.constraints[ module.name].attributes and self.routeAG): edfTclFile.write( "set_property USED_IN {synthesis implementation opt_design place_design phys_opt_design route_design out_of_context} [get_files " + model.rel_if_not_abspath( constraintsTcl, placeCompileDirectory) + "]\n") else: edfTclFile.write( "set_property USED_IN {synthesis implementation opt_design place_design phys_opt_design out_of_context} [get_files " + model.rel_if_not_abspath( constraintsTcl, placeCompileDirectory) + "]\n") # linking lets us pull in placement constraints. edfTclFile.write( "link_design -mode out_of_context -top " + refName + " -part " + self.part + "\n") needToLink = False # if ended here... if (not 'NO_PLACE' in area_constraints.constraints[ module.name].attributes): edfTclFile.write("place_design -no_drc \n") edfTclFile.write("report_timing_summary -file " + module.name + ".place.twr\n") edfTclFile.write("phys_opt_design \n") if (not 'NO_ROUTE' in area_constraints.constraints[ module.name].attributes and self.routeAG): edfTclFile.write("route_design\n") edfTclFile.write( "report_timing_summary -file " + module.name + ".route.twr\n") edfTclFile.write("report_route_status\n") # still need to link design. if (needToLink): edfTclFile.write( "link_design -mode out_of_context -top " + refName + " -part " + self.part + "\n") edfTclFile.write('write_checkpoint -force ' + module.name + ".place.dcp" + '\n') edfTclFile.close() constraintsTclFile.close()