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));
|
|
|
################################################################################
|
################################################################################
|