Line 1... |
Line 1... |
################################################################################
|
################################################################################
|
#
|
#
|
# Copyright 2013, Sinclair R.F., Inc.
|
# Copyright 2013-2014, Sinclair R.F., Inc.
|
#
|
#
|
################################################################################
|
################################################################################
|
|
|
import re;
|
import re;
|
|
|
Line 52... |
Line 52... |
|
|
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.
|
|
allowables = (
|
|
('inport', r'I_\w+$', None, ),
|
|
('ratemethod', r'\S+$', lambda v : self.RateMethod(config,v), ),
|
|
);
|
|
names = [a[0] for a in allowables];
|
for param_tuple in param_list:
|
for param_tuple in param_list:
|
param = param_tuple[0];
|
param = param_tuple[0];
|
param_arg = param_tuple[1];
|
if param not in names:
|
if param == 'inport':
|
raise SSBCCException('Unrecognized parameter "%s" at %s' % (param,loc,));
|
self.AddAttr(config,param,param_arg,'I_\w+$',loc);
|
param_test = allowables[names.index(param)];
|
elif param == 'ratemethod':
|
self.AddAttr(config,param,param_tuple[1],param_test[1],loc,param_test[2]);
|
self.AddRateMethod(config,param,param_arg,loc);
|
|
else:
|
|
raise SSBCCException('Unrecognized parameter at %s: %s' % (loc,param,));
|
|
# Ensure the required parameters are provided.
|
# Ensure the required parameters are provided.
|
for paramname in ('inport','ratemethod',):
|
for paramname in names:
|
if not hasattr(self,paramname):
|
if not hasattr(self,paramname):
|
raise SSBCCException('Required parameter "%s" is missing at %s' % (paramname,loc,));
|
raise SSBCCException('Required parameter "%s" is missing at %s' % (paramname,loc,));
|
# Add the I/O port, internal signals, and the INPORT and OUTPORT symbols for this peripheral.
|
# Add the I/O port, internal signals, and the INPORT and OUTPORT symbols for this peripheral.
|
name = 's__%s__expired' % self.inport;
|
name = 's__%s__expired' % self.inport;
|
config.AddSignal(name, 1, loc);
|
config.AddSignal(name, 1, loc);
|