Пример #1
0
    def tocode(self):
        flatname = util.toFlatname(self.name)
        scope = self.getScope(self.name)
        code = ''
        if self.isTopmodule(scope):
            if signaltype.isInput(self.termtype): code += 'input '
            elif signaltype.isInout(self.termtype): code += 'inout '
            elif signaltype.isOutput(self.termtype): code += 'output '
        else:
            if signaltype.isInput(self.termtype): code += 'wire '
            elif signaltype.isInout(self.termtype): code += 'wire '
            elif signaltype.isOutput(self.termtype) and not signaltype.isReg(self.termtype): code += 'wire '

        if signaltype.isReg(self.termtype): code += 'reg '
        if signaltype.isRegArray(self.termtype): code += 'reg '
        if signaltype.isWire(self.termtype): code += 'wire '
        if signaltype.isWireArray(self.termtype): code += 'wire '
        if signaltype.isInteger(self.termtype): code += 'integer '
        if signaltype.isFunction(self.termtype): code += 'wire '
        if signaltype.isRename(self.termtype): code += 'wire '

        if (not signaltype.isInteger(self.termtype) and
            self.msb is not None and self.lsb is not None):
            code += '[' + self.msb.tocode(None) + ':' + self.lsb.tocode(None) + '] '
        code += flatname # signal name
        if self.lenmsb is not None and self.lenlsb is not None:
            code += ' [' + self.lenmsb.tocode() + ':' + self.lenlsb.tocode(flatname) + ']'
        code += ';\n'
        return code
Пример #2
0
 def getAssignType(self, termname, bind):
     termtype = self.getTermtype(termname)
     if signaltype.isWire(termtype):
         return 'assign'
     if signaltype.isWireArray(termtype):
         return 'assign'
     if signaltype.isReg(termtype):
         if bind.isClockEdge(): return 'clockedge'
         return 'combination'
     if signaltype.isRegArray(termtype):
         if bind.isClockEdge(): return 'clockedge'
         return 'combination'
     if signaltype.isInteger(termtype):
         if bind.isClockEdge(): return 'clockedge'
         return 'combination'
     if signaltype.isParameter(termtype):
         return 'parameter'
     if signaltype.isLocalparam(termtype):
         return 'localparam'
     if signaltype.isOutput(termtype):
         return 'assign'
     if signaltype.isInput(termtype):
         return 'assign'
     if signaltype.isFunction(termtype):
         return 'assign'
     if signaltype.isRename(termtype):
         return 'assign'
     if signaltype.isGenvar(termtype):
         return 'genvar'
     raise verror.DefinitionError('Unexpected Assignment Type: %s : %s' % (str(termname), str(termtype)))
Пример #3
0
 def getAssignType(self, termname, bind):
     termtype = self.getTermtype(termname)
     if signaltype.isWire(termtype):
         return 'assign'
     if signaltype.isWireArray(termtype):
         return 'assign'
     if signaltype.isReg(termtype):
         if bind.isClockEdge(): return 'clockedge'
         return 'combination'
     if signaltype.isRegArray(termtype):
         if bind.isClockEdge(): return 'clockedge'
         return 'combination'
     if signaltype.isInteger(termtype):
         if bind.isClockEdge(): return 'clockedge'
         return 'combination'
     if signaltype.isParameter(termtype):
         return 'parameter'
     if signaltype.isLocalparam(termtype):
         return 'localparam'
     if signaltype.isOutput(termtype):
         return 'assign'
     if signaltype.isInput(termtype):
         return 'assign'
     if signaltype.isFunction(termtype):
         return 'assign'
     if signaltype.isRename(termtype):
         return 'assign'
     if signaltype.isGenvar(termtype):
         return 'genvar'
     raise verror.DefinitionError('Unexpected Assignment Type: %s : %s' %
                                  (str(termname), str(termtype)))