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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [ssbccUtil.py] - Diff between revs 8 and 9

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

Rev 8 Rev 9
Line 103... Line 103...
      dv = int(vv,base);
      dv = int(vv,base);
    except:
    except:
      raise SSBCCException('Malformed parameter value:  "%s"' % save_v);
      raise SSBCCException('Malformed parameter value:  "%s"' % save_v);
    ov += dv;
    ov += dv;
  if length > 0 and ov >= 2**length:
  if length > 0 and ov >= 2**length:
    raise SSBCCException('Paramter length and value don\'t match:  "%s"' % save_v);
    raise SSBCCException('Parameter length and value don\'t match:  "%s"' % save_v);
  return ov;
  return ov;
 
 
def IsIntExpr(value):
def IsIntExpr(value):
  """
  """
  Test the string to see if it is a well-formatted integer or multiplication of
  Test the string to see if it is a well-formatted integer or multiplication of
  two integers.
  two integers.
  Allow underscores as per Verilog.
  Allow underscores as per Verilog.
  """
  """
  if re.match(r'[1-9][0-9_]*',value):
  if re.match(r'-?[1-9][0-9_]*',value):
    return True;
    return True;
  elif re.match(r'\([1-9][0-9_]*(\*[1-9][0-9_]*)+\)',value):
  elif re.match(r'\(-?[1-9][0-9_]*(\*[1-9][0-9_]*)+\)',value):
    return True;
    return True;
  else:
  else:
    return False;
    return False;
 
 
def IsPosInt(v):
def IsPosInt(v):
Line 170... Line 170...
  integers.
  integers.
  Allow underscores as per Verilog.
  Allow underscores as per Verilog.
  Note:  If this routine is called, then the value should have already been
  Note:  If this routine is called, then the value should have already been
         verified to be a well-formatted integer string.
         verified to be a well-formatted integer string.
  """
  """
 
  if type(value) == int:
 
    return value;
  if not IsIntExpr(value):
  if not IsIntExpr(value):
    raise Exception('Program Bug -- shouldn\'t call with a badly formatted integer expression');
    raise Exception('Program Bug -- shouldn\'t call with a badly formatted integer expression');
  return eval(re.sub('_','',value));
  return eval(re.sub('_','',value));
 
 
################################################################################
################################################################################

powered by: WebSVN 2.1.0

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