Line 1... |
Line 1... |
################################################################################
|
# Copyright 2012-2015, Sinclair R.F., Inc.
|
#
|
# Utilities required by ssbcc.
|
# Copyright 2012-2013, Sinclair R.F., Inc.
|
|
#
|
|
# Utilities required by ssbcc
|
|
#
|
|
################################################################################
|
|
|
|
import math
|
import math
|
import os
|
import os
|
import re
|
import re
|
import sys
|
import sys
|
|
|
|
from ssbccPeripheral import SSBCCinterruptPeripheral
|
from ssbccUtil import *
|
from ssbccUtil import *
|
|
|
class SSBCCconfig():
|
class SSBCCconfig():
|
"""
|
"""
|
Container for ssbcc configuration commands, the associated parsing, and
|
Container for ssbcc configuration commands, the associated parsing, and
|
Line 61... |
Line 57... |
loc file name and line number for error messages
|
loc file name and line number for error messages
|
"""
|
"""
|
self.AddSymbol(name,loc);
|
self.AddSymbol(name,loc);
|
if name in self.constants:
|
if name in self.constants:
|
raise SSBCCException('CONSTANT "%s" already declared at %s' % (name,loc,));
|
raise SSBCCException('CONSTANT "%s" already declared at %s' % (name,loc,));
|
if not IsIntExpr(value):
|
if not ((type(value) == int) or IsIntExpr(value)):
|
raise SSBCCException('Could not evaluate expression "%s" for constant at %s' % (value,loc,));
|
raise SSBCCException('Could not evaluate expression "%s" for constant at %s' % (value,loc,));
|
self.constants[name] = ParseIntExpr(value);
|
self.constants[name] = ParseIntExpr(value);
|
|
|
def AddDefine(self,name):
|
def AddDefine(self,name):
|
"""
|
"""
|
Line 120... |
Line 116... |
def AddOutport(self,port,loc):
|
def AddOutport(self,port,loc):
|
"""
|
"""
|
Add an OUTPORT symbol to the processor.\n
|
Add an OUTPORT symbol to the processor.\n
|
port tuple as follows:
|
port tuple as follows:
|
port[0] - name of the OUTPORT symbol
|
port[0] - name of the OUTPORT symbol
|
port[1] - True if the outport is a strobe-only outport, false
|
port[1] - True if the outport is a strobe-only outport, False
|
otherwise
|
otherwise
|
port[2:] - zero or more tuples as follows:
|
port[2:] - zero or more tuples as follows:
|
(o_signal,width,type,[initialization],)
|
(o_signal,width,type,[initialization],)
|
where
|
where
|
o_signal is the name of the output signal
|
o_signal is the name of the output signal
|
Line 332... |
Line 328... |
peripherals.\n
|
peripherals.\n
|
path path to add to the list
|
path path to add to the list
|
"""
|
"""
|
self.peripheralpaths.insert(-1,path);
|
self.peripheralpaths.insert(-1,path);
|
|
|
|
def InterruptVector(self):
|
|
"""
|
|
Indicate whether or not interrupts have been enabled and, if so, what the
|
|
interrupt address is.\n
|
|
Note: The interrupt address cannot be zero because .main starts at address
|
|
0 and it must have a non-empty body.\n
|
|
Note: Returning "None" when there is not interrupt address ensures both a
|
|
"False" evaluation and that the value cannot be turned into an
|
|
integer for an address.
|
|
"""
|
|
if not self.Exists('interruptAddress'):
|
|
return None;
|
|
else:
|
|
return self.Get('interruptAddress');
|
|
|
def IsCombined(self,name):
|
def IsCombined(self,name):
|
"""
|
"""
|
Indicate whether or not the specified memory type has already been listed
|
Indicate whether or not the specified memory type has already been listed
|
in a "COMBINE" configuration command. The memory type should be one of
|
in a "COMBINE" configuration command. The memory type should be one of
|
DATA_STACK, INSTRUCTION, or RETURN_STACK.\n
|
DATA_STACK, INSTRUCTION, or RETURN_STACK.\n
|