Line 1... |
Line 1... |
################################################################################
|
################################################################################
|
#
|
#
|
# Copyright 2012-2013, Sinclair R.F., Inc.
|
# Copyright 2012-2014, Sinclair R.F., Inc.
|
#
|
#
|
################################################################################
|
################################################################################
|
|
|
import math
|
import math
|
import re
|
import re
|
Line 37... |
Line 37... |
|
|
def __init__(self,peripheralFile,config,param_list,loc):
|
def __init__(self,peripheralFile,config,param_list,loc):
|
# Use the externally provided file name for the peripheral
|
# Use the externally provided file name for the peripheral
|
self.peripheralFile = peripheralFile;
|
self.peripheralFile = peripheralFile;
|
# Get the parameters.
|
# Get the parameters.
|
for param in param_list:
|
allowables = (
|
param_name = param_list[0];
|
( 'history', r'[1-9]\d*$', int, ),
|
param_arg = param_list[1:];
|
);
|
if param_name == 'history':
|
names = [a[0] for a in allowables];
|
self.AddAttr(config,param,param_arg,r'[1-9]\d*$',loc,int);
|
for param_tuple in param_list:
|
else:
|
param = param_tuple[0];
|
raise SSBCCException('Unrecognized parameter at %s: %s' % (loc,param,));
|
if param not in names:
|
|
raise SSBCCException('Unrecognized parameter "%s" at %s' % (param,loc,));
|
|
param_test = allowables[names.index(param)];
|
|
self.AddAttr(config,param,param_tuple[1],param_test[1],loc,param_test[2]);
|
# Set optional parameters.
|
# Set optional parameters.
|
if not hasattr(self,'history'):
|
if not hasattr(self,'history'):
|
self.history = 50;
|
self.history = 50;
|
# Configure the system for this peripheral.
|
# Configure the system for this peripheral.
|
config.functions['display_trace'] = True;
|
config.functions['display_trace'] = True;
|
Line 72... |
Line 75... |
outport_pure_strobe += ' || ';
|
outport_pure_strobe += ' || ';
|
outport_pure_strobe += ('(s_T == 8\'h%02X)' % ix);
|
outport_pure_strobe += ('(s_T == 8\'h%02X)' % ix);
|
if len(outport_pure_strobe) == 0:
|
if len(outport_pure_strobe) == 0:
|
outport_pure_strobe = '1\'b0';
|
outport_pure_strobe = '1\'b0';
|
outport_pure_strobe = 'wire s__outport_pure_strobe = ' + outport_pure_strobe + ';';
|
outport_pure_strobe = 'wire s__outport_pure_strobe = ' + outport_pure_strobe + ';';
|
for subs in (
|
for subpair in (
|
(r'\\bix__', 'ix__monitor_stack__',),
|
(r'\\bix__', 'ix__monitor_stack__',),
|
(r'\\bs__', 's__monitor_stack__',),
|
(r'\\bs__', 's__monitor_stack__',),
|
(r'@CORENAME@', config.Get('outCoreName'),),
|
(r'@CORENAME@', config.Get('outCoreName'),),
|
(r'@HISTORY@', str(self.history),),
|
(r'@HISTORY@', str(self.history),),
|
(r'@LAST_INPORT@', '9\'h%03X' % config.NInports(),),
|
(r'@LAST_INPORT@', '9\'h%03X' % config.NInports(),),
|
(r'@LAST_OUTPORT@', '9\'h%03X' % config.NOutports(),),
|
(r'@LAST_OUTPORT@', '9\'h%03X' % config.NOutports(),),
|
(r'@NINSTRUCTIONS@', str(config.Get('nInstructions')['length']),),
|
(r'@NINSTRUCTIONS@', str(config.Get('nInstructions')['length']),),
|
(r'@OUTPORT_PURE_STROBE@', outport_pure_strobe,),
|
(r'@OUTPORT_PURE_STROBE@', outport_pure_strobe,),
|
):
|
):
|
body = re.sub(subs[0],subs[1],body);
|
body = re.sub(subpair[0],subpair[1],body);
|
for ixBank in range(4):
|
for ixBank in range(4):
|
memParam = config.GetMemoryByBank(ixBank);
|
memParam = config.GetMemoryByBank(ixBank);
|
if memParam:
|
if memParam:
|
maxLength = memParam['maxLength'];
|
maxLength = memParam['maxLength'];
|
else:
|
else:
|