OpenCores
URL https://opencores.org/ocsvn/ssbcc/ssbcc/trunk

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [ssbcc] - Diff between revs 3 and 9

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 3 Rev 9
Line 43... Line 43...
    except:
    except:
      raise SSBCCException('Error opening "%s"' % filename);
      raise SSBCCException('Error opening "%s"' % filename);
 
 
  import argparse
  import argparse
  argListParser = argparse.ArgumentParser(description='SSBCC system builder');
  argListParser = argparse.ArgumentParser(description='SSBCC system builder');
  argListParser.add_argument('-D', metavar='symbol', type=str, action='append', help='Define symbol');
  argListParser.add_argument('-D', metavar='D_name', type=str, action='append', help='Define symbol (must start with "D_")');
  argListParser.add_argument('-G', metavar='parameter_name=value', type=str, action='append', help='Override parameter value');
  argListParser.add_argument('-G', metavar='parameter_name=value', type=str, action='append', help='Override parameter value');
  argListParser.add_argument('-I', metavar='include_dir', type=str, action='append', help='Add search directory for included files and peripherals');
  argListParser.add_argument('-I', metavar='include_dir', type=str, action='append', help='Add search directory for included files and peripherals');
  argListParser.add_argument('-M', metavar='macropath', action='append', help='Macro search path');
  argListParser.add_argument('-M', metavar='macropath', action='append', help='Macro search path');
  argListParser.add_argument('-P', metavar='peripheral_name[="parameters"]', type=str, action='append', help='Add peripheral');
  argListParser.add_argument('-P', metavar='peripheral_name[="parameters"]', type=str, action='append', help='Add peripheral');
  argListParser.add_argument('-o', metavar='outCoreName', type=str, help='output core name');
  argListParser.add_argument('-o', metavar='outCoreName', type=str, help='output core name');
Line 72... Line 72...
 
 
  if argList.display_opcode:
  if argList.display_opcode:
    config.functions['display_opcode'] = True;
    config.functions['display_opcode'] = True;
 
 
  if argList.D:
  if argList.D:
    for symbol in argList.D:
    for name in argList.D:
      config.AddSymbol(symbol);
      if not re.match('D_',name):
 
        raise SSBCCException('Bad define name "%s" should start with "D_"' % name);
 
      config.AddDefine(name);
 
 
  if argList.I:
  if argList.I:
    for pathString in argList.I:
    for pathString in argList.I:
      if not os.path.isdir(pathString):
      if not os.path.isdir(pathString):
        raise SSBCCException('Bad path string:  "%s"' % pathString);
        raise SSBCCException('Bad path string:  "%s/%s"' % (os.getcwd(),pathString,));
      config.AppendIncludePath(pathString);
      config.AppendIncludePath(pathString);
      config.InsertPeripheralPath(pathString);
      config.InsertPeripheralPath(pathString);
 
 
  if argList.o:
  if argList.o:
    config.Set('outCoreName',argList.o);
    config.Set('outCoreName',argList.o);
Line 197... Line 199...
      config.ProcessCombine(loc,line);
      config.ProcessCombine(loc,line);
    # CONSTANTS
    # CONSTANTS
    elif re.match(r'\s*CONSTANT\b',line):
    elif re.match(r'\s*CONSTANT\b',line):
      if not config.Exists('architecture'):
      if not config.Exists('architecture'):
        raise SSBCCException('"CONSTANT"s cannot be defined before the "ARCHITECTURE" is defined at %s' % loc);
        raise SSBCCException('"CONSTANT"s cannot be defined before the "ARCHITECTURE" is defined at %s' % loc);
      cmd = re.findall(r'\s*CONSTANT\s+(C_\w+)\s+(\w+)\s*$',line);
      cmd = re.findall(r'\s*CONSTANT\s+(C_\w+)\s+(-?[1-9]\d*|\w+)\s*$',line);
      if not cmd:
      if not cmd:
        raise SSBCCException('Malformed "CONSTANT" configuration command on %s: "%s"' % (loc,line,));
        raise SSBCCException('Malformed "CONSTANT" configuration command on %s: "%s"' % (loc,line,));
      cmd = cmd[0];
      cmd = cmd[0];
      config.AddConstant(cmd[0],cmd[1],loc);
      config.AddConstant(cmd[0],cmd[1],loc);
    # DATA_STACK
    # DATA_STACK
Line 365... Line 367...
  # Compile the processor code and read the tables it generated.
  # Compile the processor code and read the tables it generated.
  #
  #
  ################################################################################
  ################################################################################
 
 
  # Generate peripheral libraries (if any).
  # Generate peripheral libraries (if any).
  for ix in range(len(config.peripheral)):
  for p in config.peripheral:
    config.peripheral[ix].GenAssembly(config);
    p.GenAssembly(config);
 
 
  # Compute the file name to store the assembler output
  # Compute the file name to store the assembler output
  assemblerOutput = os.path.splitext(argList.filename.name)[0]+'.9x8-meta'
  assemblerOutput = os.path.splitext(argList.filename.name)[0]+'.9x8-meta'
 
 
  # Compute the command to invoke the compiler.
  # Compute the command to invoke the compiler.
  if not compiler:
  if not compiler:
    raise SSBCCException('ASSEMBLY configuration command is missing');
    raise SSBCCException('ASSEMBLY configuration command is missing');
  cmd = os.path.join(config.Get('corepath'), compiler[0]);
  cmd = os.path.join(config.Get('corepath'), compiler[0]);
  for name in config.constants:
  for name in config.constants:
    cmd += (' -C %s=%s' % (name,config.constants[name],));
    cmd += (' -C %s=%s' % (name,config.constants[name],));
 
  for name in config.defines:
 
    cmd += (' -D %s' % name);
  for ix in range(len(config.parameters)):
  for ix in range(len(config.parameters)):
    cmd += (' -G %s' % config.parameters[ix][0]);
    cmd += (' -G %s' % config.parameters[ix][0]);
  for ix in range(config.NInports()):
  for ix in range(config.NInports()):
    cmd += (' -I %s=%d' % (config.inports[ix][0],ix));
    cmd += (' -I %s=%d' % (config.inports[ix][0],ix));
  for ix in range(config.NOutports()):
  for ix in range(config.NOutports()):
Line 546... Line 550...
      genOutports(fpOutCore,config);
      genOutports(fpOutCore,config);
    # peripherals
    # peripherals
    elif fillCommand == 'peripherals':
    elif fillCommand == 'peripherals':
      if not config.peripheral:
      if not config.peripheral:
        fpOutCore.write('//\n// No peripherals\n//\n');
        fpOutCore.write('//\n// No peripherals\n//\n');
      for ix in range(len(config.peripheral)):
      for p in config.peripheral:
        if ix != 0:
        if p != config.peripheral[0]:
          fpOutCore.write('\n');
          fpOutCore.write('\n');
        config.peripheral[ix].GenHDL(fpOutCore,config);
        p.GenHDL(fpOutCore,config);
    # "s_memory" declaration
    # "s_memory" declaration
    elif fillCommand == 's_memory':
    elif fillCommand == 's_memory':
      if config.NMemories() == 0:
      if config.NMemories() == 0:
        fpOutCore.write('wire [7:0] s_memory = 8\'h00;\n');
        fpOutCore.write('wire [7:0] s_memory = 8\'h00;\n');
      else:
      else:

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.