def write( self , aScriptVariables , aComponentPaths , aCommandList , aLibs, aMaps ):
   with SmartOpen( self.CommandLineArgs.output ) as write:
     write( "<FileList>" )
   
     for src in aCommandList["src"]:
       status = SvnStatus( src.FilePath , self.Pathmaker.root )
       string = [ '{0}="{1}"'.format(key,val).ljust(24) for key,val in sorted(status.iteritems()) ]
       write( "  <File {0} />".format( " ".join( string ) ) )
 
     write( "</FileList>" )
示例#2
0
    def write(self, aScriptVariables, aComponentPaths, aCommandList, aLibs):

        if not "device_name" in aScriptVariables:
            raise RuntimeError("Variable 'device_name' not defined.")

        with SmartOpen(self.CommandLineArgs.output) as write:

            write("# Autogenerated project build script")
            write(time.strftime("# %c"))
            write()
            write("project new top")

            write("project set family {0}".format(
                aScriptVariables["device_family"]))
            write("project set device {0}".format(
                aScriptVariables["device_name"]))
            write("project set package {0}".format(
                aScriptVariables["device_package"]))
            write("project set speed {0}".format(
                aScriptVariables["device_speed"]))

            for setup in aCommandList["setup"]:
                write("source {0}".format(setup.FilePath))

            for lib in aLibs:
                write("lib_vhdl new {0}".format(lib))

            for src in reversed(aCommandList["src"]):
                if os.path.splitext(src.FilePath)[1] == ".xco":
                    if not len(aCommandList["cgpfile"]):
                        raise SystemExit("No CGP file found in design")
                    write("exec mkdir -p ipcore_dir")
                    write("exec cp {0} {1}".format(
                        aCommandList["cgpfile"][0].FilePath, "ipcore_dir"))
                    write("exec cp {0} {1}".format(src.FilePath, "ipcore_dir"))
                    write("cd ipcore_dir")
                    write(
                        "exec coregen -r -b {0} -p coregen.cgp >& coregen.out".
                        format(os.path.basename(src.FilePath)))
                    write("cd ..")
                    lFile = os.path.join("ipcore_dir",
                                         os.path.basename(src.FilePath))
                else:
                    lFile = src.FilePath

                if src.Include:
                    if src.Lib is None:
                        write("xfile add {0}".format(lFile))
                    else:
                        write("xfile add {0} -lib_vhdl {1} -include_global".
                              format(lFile, src.Lib))

            write("project set top rtl top")
            write("project close")
 def write(self, aScriptVariables, aComponentPaths, aCommandList, aLibs,
           aMaps):
     with SmartOpen(self.CommandLineArgs.output) as write:
         write("# Autogenerated project build script")
         write(time.strftime("# %c"))
         write()
         for addrtab in aCommandList["addrtab"]:
             if addrtab.TopLevel:
                 n = os.path.basename(addrtab.FilePath)
                 write("gen_ipbus_addr_decode {0}".format(n))
                 b = "ipbus_decode_{0}.vhd".format(os.path.splitext(n)[0])
                 write("cp {0} {1}".format(
                     b,
                     self.Pathmaker.getpath(addrtab.ComponentPath, "src",
                                            b)))
示例#4
0
    def write(self, aScriptVariables, aComponentPaths, aCommandList, aLibs,
              aMaps):
        with SmartOpen(self.CommandLineArgs.output) as write:
            write("# Autogenerated project build script")
            write(time.strftime("# %c"))
            write('''
declare -a UPDATED_DECODERS

function generate_decoder {
    SRC=$1
    DECODER=$2
    TARGET="$3/$2"

    echo "#################################"
    echo "# Processing ${SRC}"
    echo "#################################"
    gen_ipbus_addr_decode ${SRC}
    res=$?
    if [ ${res} -eq 0 ]; then
      echo "Successfully created decoder for ${SRC}"
    else
      echo "Failed to generate decoder. Skipping." >&2
      return 999
    fi
    echo

    echo 'Comparing generated decoder and target'
    echo '----------------------------'
    diff -u -I '^-- START automatically' ${DECODER} ${TARGET}
    res=$?
    echo '----------------------------'

    if [ ${res} -eq 0 ]; then
      echo "No differences detected, ${TARGET} is up-to-date."
    else
      echo "Generated and target file differ. Updating ${TARGET}"
      cp ${DECODER} ${TARGET}
      UPDATED_DECODERS+=(${TARGET})
    fi

    echo
}

function generate_summary {
  echo
  echo "###################################"
  echo "# IPBus decoder generator summary"
  echo "###################################"
  echo
  if [ ${#UPDATED_DECODERS[@]} -eq 0 ]; then
    echo "  No decoders have been updated"
  else
    echo "  The following decoders have been updated"
    echo
    for DECODER in ${UPDATED_DECODERS[@]}
    do
      echo "  * ${DECODER}"
    done
  fi
  echo
}
        ''')
            write()
            for addrtab in aCommandList['addrtab']:
                if addrtab.TopLevel:
                    n = os.path.basename(addrtab.FilePath)
                    b = 'ipbus_decode_{0}.vhd'.format(os.path.splitext(n)[0])
                    write('generate_decoder {0} {1} {2}'.format(
                        n, b,
                        self.Pathmaker.getpath(addrtab.ComponentPath, 'src')))
            write()
            write('generate_summary')
    def write(self, aScriptVariables, aComponentPaths, aCommandList, aLibs,
              aMaps):

        if not "device_name" in aScriptVariables:
            raise RuntimeError("Variable 'device_name' not defined.")

        with SmartOpen(self.CommandLineArgs.output) as write:

            write("# Autogenerated project build script")
            write(time.strftime("# %c"))
            write()

            lWorkingDir = os.path.abspath(
                os.path.join(
                    os.path.split(self.CommandLineArgs.output)[0], "top"))
            write("set outputDir {0}".format(lWorkingDir))
            write("file mkdir $outputDir")

            write(
                "create_project top $outputDir -part {device_name}{device_package}{device_speed} -force"
                .format(**aScriptVariables))

            write(
                'if {[string equal [get_filesets -quiet constrs_1] ""]} {create_fileset -constrset constrs_1}'
            )
            write(
                'if {[string equal [get_filesets -quiet sources_1] ""]} {create_fileset -srcset sources_1}'
            )
            write(
                'if {[string equal [get_filesets -quiet ise_1] ""]} {create_fileset -srcset ise_1}'
            )

            for setup in aCommandList["setup"]:
                write("source {0}".format(setup.FilePath))

            lXciBasenames = []
            lXciTargetFiles = []

            for src in reversed(aCommandList["src"]):
                lPath, lBasename = os.path.split(src.FilePath)
                lName, lExt = os.path.splitext(lBasename)
                lTargetFile = os.path.join("$outputDir/top.srcs/sources_1/ip",
                                           lName, lBasename)

                if lExt == ".xci":
                    write("import_files -norecurse -fileset sources_1 {0}".
                          format(src.FilePath))
                    lXciBasenames.append(lName)
                    lXciTargetFiles.append(lTargetFile)
                else:
                    if src.Include:
                        cmd = "add_files -norecurse -fileset {1} {0}".format(
                            src.FilePath, self.FileSets[lExt])
                        if src.Vhdl2008:
                            cmd += "\nset_property FILE_TYPE {{VHDL 2008}} [get_files {0}]".format(
                                src.FilePath)
                        if lExt == ".tcl":
                            write("set_property USED_IN implementation [" +
                                  cmd + "]")
                        else:
                            write(cmd)
                    if src.Lib:
                        write("set_property library {1} [get_files [ {0} ]]".
                              format(lFile, src.Lib))

            write("set_property top top [current_fileset]")

            #for i in ["constrs_1" , "sources_1" , "ise_1" ]:
            #write( "reorder_files -fileset {0} -auto [get_files -of_objects [get_filesets {0}]]".format(i) )

            #      write( "set_property source_mgmt_mode All [get_projects top]" )
            #      write( "update_compile_order -fileset constrs_1" )
            #      write( "update_compile_order -fileset sources_1" )
            #      write( "update_compile_order -fileset sim_1" )

            write(
                'set_property "steps.synth_design.args.flatten_hierarchy" "none" [get_runs synth_1]'
            )

            for i in lXciBasenames:
                write("upgrade_ip [get_ips {0}]".format(i))
            for i in lXciTargetFiles:
                write("create_ip_run [get_files {0}]".format(i))
            for i in lXciBasenames:
                write("launch_run {0}_synth_1".format(i))
 def write( self , aScriptVariables , aComponentPaths , aCommandList , aLibs, aMaps ):
   with SmartOpen( self.CommandLineArgs.output ) as write:
     for addrtab in aCommandList["addrtab"]:
       write( addrtab.FilePath )
    def write(self, aScriptVariables, aComponentPaths, aCommandList, aLibs,
              aMaps):
        if not "device_name" in aScriptVariables:
            raise RuntimeError("Variable 'device_name' not defined.")

        # Hack alert : Alessandro
        code, output = commands.getstatusoutput('vsim -version')

        if 'modelsim' in output.lower():
            print('ModelSim detected')
            targetSimulator = 'ModelSim'
            simulator = 'modelsim'
        elif 'questa' in output.lower():
            print('Questa detected')
            targetSimulator = 'Questa'
            simulator = 'questa'
        else:
            raise RuntimeError("Failed to detect Modelsim/Questasim")

        with SmartOpen(self.CommandLineArgs.output) as write:
            write("# Autogenerated project build script")
            write(time.strftime("# %c"))
            write()

            # Hack alert : Alessandro
            write("set xlib $::env(XILINX_SIMLIBS)")

            lWorkingDir = os.path.abspath(
                os.path.join(
                    os.path.split(self.CommandLineArgs.output)[0], "top"))

            write("set outputDir {0}".format(lWorkingDir))
            write("file mkdir $outputDir")

            write(
                "create_project top $outputDir -part {device_name}{device_package}{device_speed} -force"
                .format(**aScriptVariables))

            write('''
set obj [get_projects top]
set_property "default_lib" "xil_defaultlib" $obj
set_property "simulator_language" "Mixed" $obj
set_property "source_mgmt_mode" "DisplayOnly" $obj
set_property "target_language" "VHDL" $obj
''')

            write("set_property target_simulator " + targetSimulator +
                  " [current_project]")

            write("file mkdir $xlib")
            lUnisim_nodebug = aScriptVariables.get('unisim_nodebug')
            if lUnisim_nodebug == '1':  # If the encrypted library uses unisim
                if simulator == "questa":  # Yeah... Incorrectly documented by Vivado They change the variable name used for questa on this option only.
                    write(
                        "config_compile_simlib -cfgopt {questasim.vhdl.unisim: -nodebug}"
                    )
                else:
                    write("config_compile_simlib -cfgopt {" + simulator +
                          ".vhdl.unisim: -nodebug}")
            write("compile_simlib -simulator " + simulator +
                  " -directory $xlib")
            write(
                "set_property compxlib.compiled_library_dir $xlib [current_project]"
            )

            write()
            # write('set f [open "xil_ip_compile.tcl" w]' )
            for src in reversed(aCommandList["src"]):
                lPath, lBasename = os.path.split(src.FilePath)
                lName, lExt = os.path.splitext(lBasename)

                if lExt == ".xci" or lExt == ".edn":
                    write("import_files -norecurse -fileset sources_1 {0}".
                          format(src.FilePath))
                    if lExt == ".xci":
                        write("upgrade_ip [get_ips {0}]".format(lName))
                        write("generate_target simulation [get_files {0}]".
                              format(lBasename))
                    # write('puts $f "vcom {0}"'.format( os.path.join( lWorkingDir , "top.srcs/sources_1/ip" , lName, "sim" , lName + ".vhd" ) )  )
            # write("close $f")
#TOPLVL
            write('''
exec mkdir -p {0}/{0}.srcs/sources_1/ip/built'''.format(
                aScriptVariables['device_top']))
            write('''
set_property top top [get_filesets sim_1]
launch_simulation -scripts_only
cd {0}
exec echo exit | vsim -c -do top_compile.do -modelsimini modelsim.ini
'''.format(os.path.join(lWorkingDir, "top.sim/sim_1/behav")))
    def write(self, aScriptVariables, aComponentPaths, aCommandList, aLibs,
              aMaps):

        with SmartOpen(self.CommandLineArgs.output) as write:
            write("# Autogenerated project build script")
            write(time.strftime("# %c"))
            write()

            for setup in aCommandList["setup"]:
                write("source {0}".format(setup.FilePath))

            write("vlib work")

            for lib in aLibs:
                write("vlib {0}".format(lib))

            for ma in aMaps:
                write("vmap {0} {1}".format(ma[0], ma[1]))
                write("vcom -work {0} -refresh -force_refresh".format(ma[0]))

            for src in reversed(aCommandList["src"]):
                if src.Include:

                    lPath, lBasename = os.path.split(src.FilePath)
                    lName, lExt = os.path.splitext(lBasename)
                    lMap = src.Map

                    if lExt == ".xco":
                        file = os.path.abspath(
                            os.path.join(lPath, lName + ".vhd"))
                    elif lExt == ".xci":
                        # Hack required. The Vivado generated hdl files sometimes have 'sim' in their path, sometimes don't
                        file = None
                        lIpPath = os.path.abspath(
                            os.path.join(
                                os.path.split(self.CommandLineArgs.output)[0],
                                "top/top.srcs/sources_1/ip"))
                        for d in ["", "sim"]:
                            for e in ["v", "vhd"]:
                                lPathToIp = os.path.join(
                                    lIpPath, lName, d, lName + "." + e)
                                print(lPathToIp)
                                if not os.path.exists(os.path.join(lPathToIp)):
                                    continue

                                file = lPathToIp
                                break
                            if file is not None: break

                        if file is None:
                            raise IOError(
                                'No simulation source found for core ' +
                                lBasename)

                        # file = os.path.abspath( os.path.join( os.path.split( self.CommandLineArgs.output )[0] , "top/top.srcs/sources_1/ip" , lName, "sim" , lName + ".vhd" ) )
                        print(file)
                    else:
                        file = src.FilePath

                    if os.path.splitext(file)[1] == ".vhd":
                        if src.Vhdl2008:
                            cmd = "vcom -2008"
                        else:
                            cmd = "vcom"
                    elif os.path.splitext(file)[1] == ".v":
                        cmd = "vlog"

                    elif lMap != None:
                        continue

                    else:
                        #if os.path.splitext(file)[1] != ".ucf":
                        #raise SystemExit("Unknown source file type in Modelsim build: {0}".format(src.FilePath) )
                        print(
                            "# IGNORING unknown source file type in Modelsim build: {0}"
                            .format(src.FilePath))
                        continue

                    if src.Lib:
                        cmd = "{0} -work {1}".format(cmd, src.Lib)

                write("{0} {1}".format(cmd, file))

        # Hacky hack: add newly generated libraries to modelsim.ini
        lSimLibDirectory = os.path.abspath(
            os.path.join(
                os.path.split(self.CommandLineArgs.output)[0],
                "top/top.sim/sim_1/behav/msim"))
        lSimLibs = next(os.walk(lSimLibDirectory))[1]

        print('found libs', lSimLibs)

        print("Adapting modelsim.ini")
        import ConfigParser

        lModelsimIni = ConfigParser.RawConfigParser()
        lModelsimIni.read("modelsim.ini")
        print(lModelsimIni.sections())
        for l in lSimLibs:
            lModelsimIni.set("Library", l, os.path.join(lSimLibDirectory, l))

        os.rename("modelsim.ini", "modelsim.ini.bak")
        with SmartOpen("modelsim.ini") as newIni:
            lModelsimIni.write(newIni.file)
示例#9
0
 def write(self, aScriptVariables, aComponentPaths, aCommandList, aLibs,
           aMaps):
     with SmartOpen(self.CommandLineArgs.output) as write:
         for src in aCommandList["src"]:
             if src.Include:
                 write(src.FilePath)
 def write( self , aScriptVariables , aComponentPaths , aCommandList , aLibs ):
   with SmartOpen( self.CommandLineArgs.output ) as write:
     for lComponentPath in aComponentPaths:
       write( self.Pathmaker.getpath( lComponentPath ) )