Line 1... |
Line 1... |
################################################################################
|
# Copyright 2012-2015, Sinclair R.F., Inc.
|
#
|
# Base classes and utility function for generating general-purpose and interrupt
|
# Copyright 2012-2014, Sinclair R.F., Inc.
|
# peripherals.
|
#
|
|
################################################################################
|
|
|
|
import re
|
import re
|
|
|
|
from ssbccUtil import IntValue
|
from ssbccUtil import IsIntExpr
|
from ssbccUtil import IsIntExpr
|
from ssbccUtil import IsPosInt
|
from ssbccUtil import IsPosInt
|
from ssbccUtil import IsPowerOf2
|
from ssbccUtil import IsPowerOf2
|
from ssbccUtil import ParseIntExpr
|
from ssbccUtil import ParseIntExpr
|
from ssbccUtil import SSBCCException
|
from ssbccUtil import SSBCCException
|
Line 170... |
Line 169... |
raise SSBCCException('Cannot be less than %d' % lowLimit);
|
raise SSBCCException('Cannot be less than %d' % lowLimit);
|
if (highLimit != None) and value > highLimit:
|
if (highLimit != None) and value > highLimit:
|
raise SSBCCException('Cannot be more than %d' % highLimit);
|
raise SSBCCException('Cannot be more than %d' % highLimit);
|
return value;
|
return value;
|
|
|
|
def IntValueMethod(self,value):
|
|
"""
|
|
"""
|
|
return IntValue(value);
|
|
|
def RateMethod(self,config,value):
|
def RateMethod(self,config,value):
|
"""
|
"""
|
Return the string to evaluate the provided value or ratio of two values.
|
Return the string to evaluate the provided value or ratio of two values.
|
The value can be an integer (including underscores), a constant, or a
|
The value can be an integer (including underscores), a constant, or a
|
parameter. Ratios are restated to do rounding instead of truncation.\n
|
parameter. Ratios are restated to do rounding instead of truncation.\n
|
Line 226... |
Line 230... |
raise SSBCCException('%s must be %s or greater' % (v,lowLimit,));
|
raise SSBCCException('%s must be %s or greater' % (v,lowLimit,));
|
if (highLimit != None) and (v > highLimit):
|
if (highLimit != None) and (v > highLimit):
|
raise SSBCCException('%s must be %s or smaller' % (v,highLimit,));
|
raise SSBCCException('%s must be %s or smaller' % (v,highLimit,));
|
return v;
|
return v;
|
|
|
No newline at end of file
|
No newline at end of file
|
|
################################################################################
|
|
#
|
|
# Base class for interrupt peripherals.
|
|
#
|
|
################################################################################
|
|
|
|
class SSBCCinterruptPeripheral(SSBCCperipheral):
|
|
"""
|
|
Base class for interrupt peripherals.
|
|
"""
|
|
|
|
instance = None;
|
|
|
|
def __init__(self,config,loc):
|
|
"""
|
|
Perform tasks common to all interrupt peripherals:
|
|
Ensure only one interrupt peripheral is defined.
|
|
Declare the O_INTERRUPT_DIS and O_INTERRUPT_ENA output ports.
|
|
These are set/reset outports and only require 2 instructions.
|
|
These 2-instruction sequences are automatically generated by the ".ena"
|
|
and ".dis" macros.
|
|
...\n
|
|
Note: The "param_list" normally part of a peripheral __init__ method is
|
|
missing. First, it isn't required here. Second, that helps ensure
|
|
that this class is not instantiated by itself as a peripheral.
|
|
"""
|
|
# Ensure only one interrupt peripheral gets defined.
|
|
if SSBCCinterruptPeripheral.instance:
|
|
raise SSBCCException('Interrupt peripheral already defined before line %d' % loc);
|
|
SSBCCinterruptPeripheral.instance = self;
|
|
# Add the signals required by the interrupt handler.
|
|
config.AddSignal('s_interrupt',1,loc);
|
|
config.AddSignal('s_interrupted',1,loc);
|
|
# Add the outports to disable and enable interrupts.
|
|
self.ix_outport_interrupt_dis = config.NOutports();
|
|
config.AddOutport(('O_INTERRUPT_DIS',True,),loc);
|
|
self.ix_outport_interrupt_ena = config.NOutports();
|
|
config.AddOutport(('O_INTERRUPT_ENA',True,),loc);
|
|
|
|
################################################################################
|
|
#
|
|
# Utilties for interrupt peripherals.
|
|
#
|
|
################################################################################
|
|
|
|
def InterruptPeripheralAssigned():
|
|
"""
|
|
Indicate whether or not an interrupt peripheral has been generated.
|
|
"""
|
|
return True if SSBCCinterruptPeripheral.instance else False;
|
|
|
No newline at end of file
|
No newline at end of file
|