示例#1
0
    def __init__(self,
                 outputSymbols,
                 enable=MNRLDefs.ENABLE_ON_ACTIVATE_IN,
                 id=None,
                 report=False,
                 latched=False,
                 reportId=None,
                 attributes={}):

        symbolSet = dict()

        # outputSymbols is a tuple:
        # ("outputId","symbolSet")
        outputDefs = []
        try:
            for output_id, symbol_set in outputSymbols:
                if isinstance(output_id, basestring):
                    symbolSet[output_id] = symbol_set
                    outputDefs.append((output_id, 1))
                else:
                    raise mnrlerror.PortDefError("output")
        except ValueError:
            raise mnrlerror.InvalidStateOutputSymbols()

        super(State, self).__init__(id=id,
                                    enable=enable,
                                    report=report,
                                    inputDefs=[(MNRLDefs.H_STATE_INPUT, 1)],
                                    outputDefs=outputDefs,
                                    attributes=attributes)

        self.reportId = reportId
        self.latched = latched
        self.outputSymbols = symbolSet
示例#2
0
文件: mnrl.py 项目: tjt7a/mnrl
 def __validate_ports(self, port_def, inout):
     '''Returns a dictionary of ports. Keys are the port id's; each maps to a
     width and list of connections tuple.'''
     portDefs = dict()
     try:
         for port_id, width in port_def:
             # check that the port_id is a string
             if isinstance(port_id, str):
                 if port_id in portDefs:
                     raise mnrlerror.DuplicatePortId(port_id)
                 else:
                     if isinstance(width, int):
                         portDefs[port_id] = (width, [])
                     else:
                         raise mnrlerror.InvalidPortWidth(width)
             else:
                 raise mnrlerror.PortIdError(port_id,
                                             "the ID is not a string")
     except ValueError:
         raise mnrlerror.PortDefError(inout)
     return portDefs