Ejemplo n.º 1
0
def formBaseInfo(conf):
  b = conf or build.load()
  comment = raw_input('Add some comment: ')
#  conf['gitMessage'] += comment
  content = 'encoding: utf-8\ncomment: {}\ndevice: {}\nPROM size: {} kilobytes\nspi: {}'.format(
                            comment, b.get('device'), b.get('size'), b.get('spi'))
  print content
  conf['gitMessage'] += comment.decode(sys.stdin.encoding or 'utf-8').encode('utf-8')
  return content.decode(sys.stdin.encoding or 'utf-8').encode('utf-8')
Ejemplo n.º 2
0
def kungfu(**configScript):
  alog.info('Processing...')
  alog.debug('args: '+ str(sys.argv))
  alog.debug('config: ' + str(configScript))

  validateLocation()
  configBuild = build.load(cacheEnable=False)
  build.dump(configBuild)
  config = mergeConfig(configScript, configBuild)

  parser = argparse.ArgumentParser(description='HDL Manager')
  parser.add_argument('-tb', action = 'store_true', help = 'export project to active-hdl')
  parser.add_argument('-top', help = 'top module name')
  parser.add_argument('-syn', nargs ='?', const = 'batch', help = 'synthesis step')
  parser.add_argument('-impl', action = 'store_true', help = 'implementation step')
  parser.add_argument('-mcs', nargs = '?', const = 'config', help = 'generate .mcs from .bit file')
  parser.add_argument('-upload', action = 'store_true', help = 'upload firmware to WebDav server')
  parser.add_argument('-d', action = 'store_true', help = 'debug flag')
  arguments = parser.parse_args()


  setValidTop(arguments, config)
  setValidUcf(config)
  setUpload(arguments, config)
  config['dsnName'] = os.path.basename(os.path.dirname(os.getcwd()))
  config['mode'] = 'synplify_gui' if arguments.syn == 'gui' else 'synplify_batch'
  if arguments.mcs and arguments.mcs != 'config': config['size'] = arguments.mcs

  if arguments.d:
    pprint.pprint(config)
    config['debug'] = True

  printInfo(config)


  if arguments.tb:
    aldec.export(config)
    return
  elif arguments.syn:
    synthesis.run(config)
  elif arguments.impl:
    implement.run(config)
  elif arguments.mcs:
    implement.bit2mcs(config)
    return
  elif arguments.upload:
    pass
  elif not config.get('debug'):
    synthesis.run(config)
    implement.run(config)

  if config['upload']:
    #TODO: refactor
    webdav.upload_fw('{0}/{1}.bit'.format(implementPath, config['top']), config = config)
    webdav.upload_fw('{0}/{1}.mcs'.format(implementPath, config['top']), config = config)
    git.synchWithBuild(config)
Ejemplo n.º 3
0
def extend(config):
  """
  Precondition: cwd= <dsn_name>/script
  Output: dictionary { keys=main, dep, tb, other values=list of path files}
  """
  config['rootPath'] = os.path.abspath('..').replace('\\', '/')
  config['dsnName'] = os.path.split(config['rootPath'])[1]
  
  allSrc = []
  for i in ['../src', '../TestBench', '../script', '../resource']:
    allSrc += structure.search(directory = i, ignoreDir = hdlGlobals.ignoreRepoDir)
  config['allSrc'] = allSrc


  mainSrcUncopied = structure.search(directory = aldecPath+'/src',
                                     onlyExt = hdlGlobals.hdlFileExt,
                                     ignoreDir = hdlGlobals.ignoreRepoDir)
  config['srcUncopied'] = mainSrcUncopied

  config['TestBenchSrc'] = structure.search(directory='../TestBench', ignoreDir = hdlGlobals.ignoreRepoDir)
  

  config['netlistSrc'] = structure.search(directory = aldecPath + '/src',
                                          onlyExt = '.sedif .edn .edf .edif .ngc'.split())

  config['filesToCompile'] = config['mainSrc'] + config['depSrc'] + config['TestBenchSrc'] + mainSrcUncopied

  #TODO: refactor me
  #add cores src (ignore other folders) to project navigator
  path = os.path.abspath(os.getcwd())
  pathAsList = path.replace('\\', '/').split('/')
  if pathAsList[-3] == 'cores':
    repoPath = '/'.join(pathAsList[:-3])
  else:
    repoPath = '/'.join(pathAsList[:-2])
  config['repoPath'] = repoPath
#  print repoPath
  repoSrc = []
  for root, dirs, files in os.walk(repoPath):
    if config['dsnName'] in dirs:
      dirs.remove(config['dsnName'])
    for i in ['aldec', 'synthesis', 'implement', '.svn', '.git', 'TestBench', 'script', 'resource']:
      if i in dirs:
        dirs.remove(i)
    for f in files:
      if 'src' in root+'/'+f:
        repoSrc.append(os.path.abspath(root+'/'+f).replace('\\', '/'))
  config['repoSrc'] = repoSrc
  config['build'] = build.load()
Ejemplo n.º 4
0
def main():
  parser = argparse.ArgumentParser(parents=[git.commands()], description='Helper to create designs')
  parser.add_argument('-doc', action='store_true', help='extended documentation in browser')
  parser.add_argument('-n', '--name', dest='name', default='', help='set design name and create structure (default name - current directory)')
  parser.add_argument('-v', '--version', dest='version', action='store_true', help='display package version')
  parser.add_argument('-tb', action = 'store_true', help = 'export project to active-hdl')
  parser.add_argument('-prog', action = 'store_true', help = 'run programmator')
  parser.add_argument('-edit', choices = ['default_build', 'toolchain'], help = 'edit default build.yaml file')
  args = parser.parse_args()

  if args.prog:
    if os.path.basename(os.getcwd()) == 'script':
      if not os.path.exists('../programmator'):
        os.mkdir('../programmator')
      os.chdir('../programmator')
    subprocess.Popen('python {}/Lib/site-packages/autohdl/programmator/programmator.py'.format(sys.prefix))
    sys.exit()

  if args.version:
    print 'autohdl version: ' + pkg_info.getVersion()
  elif args.doc:
    doc.handler('index')
  elif args.tb:
    hdlManager.kungfu()
  elif args.git:
    config = build.load()
    if not config:
      alog.info('Using default build.yaml (to see content: hdl.py -edit default_build)')
      config = build.default()
    config.update({'git':args.git})
    git.handle(config)
  elif args.edit:
    if args.edit == 'default_build':
      subprocess.Popen('notepad {}/Lib/site-packages/autohdl/data/build.yaml'.format(sys.prefix))
    elif args.edit == 'toolchain':
      subprocess.Popen('notepad {}/Lib/site-packages/autohdl_cfg/toolchain.yaml'.format(sys.prefix))
  else:
#    dsn = structure.Design(iName = args.name)
    dsn = structure.generate(path = args.name)
    git.initialize(args.name if args.name else '.')
    print dsn
Ejemplo n.º 5
0
def setValidUcf(config):

  ucfFromScript = getFullPathToUcf(config['ucf'])
  if ucfFromScript:
    config['ucf'] = ucfFromScript
    alog.info('Using ucf file from script')
    return

  ucfNameAsTop = getFullPathToUcf(config['top'])
  if ucfNameAsTop:
    config['ucf'] = ucfNameAsTop
    alog.info('Using ucf name same as top module')
    return

  ucfFromBuild = getFullPathToUcf(build.load().get('ucf'))
  if ucfFromBuild:
    config['ucf'] = ucfFromBuild
    alog.info('Using ucf file from build.yaml')
    return

  alog.warning('Ucf file undefined')
Ejemplo n.º 6
0
def setValidTop(arguments, config):
  try:
    topAsScriptName = os.path.splitext(os.path.basename(sys.modules['__main__'].__file__))[0]
  except AttributeError as e:
    alog.debug(e)
    topAsScriptName = ''

  if validateTop(arguments.top, config):
    config['top'] = arguments.top
    alog.info('Using top module name from arguments list')
  elif validateTop(config.get('top'), config):
    alog.info('Using top module name from script')
  elif topAsScriptName and validateTop(topAsScriptName, config):
    config['top'] = topAsScriptName
    alog.info('Using top module name same as script name')
  else:
    top = build.load().get('top')
    if validateTop(top, config):
      alog.info('Using top module from build.yaml')
      config['top'] = top
    else:
      alog.error('Top module name undefined!')