Exemple #1
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)))
Exemple #2
0
    def _discretion(self, visited_binddict, visited_sources):
        terms = collections.OrderedDict()
        parameter = collections.OrderedDict()
        assign = collections.OrderedDict()
        always_clockedge = collections.OrderedDict()
        always_combination = collections.OrderedDict()

        # discretion the signal desclaration
        for source in visited_sources:
            termtype = self.getTermtype(source)
            if signaltype.isParameter(termtype): continue
            if signaltype.isLocalparam(termtype): continue
            terms[source] = self.terms[source]

        for left, rights in visited_binddict.items():
            for right in rights:
                assign_type = self.getAssignType(left, right)
                if assign_type == 'clockedge':
                    if not left in always_clockedge: always_clockedge[left] = set([])
                    always_clockedge[left].add(right)
                elif assign_type == 'combination':
                    if not left in always_combination: always_combination[left] = set([])
                    always_combination[left].add(right)
                elif assign_type == 'assign':
                    if not left in assign: assign[left] = set([])
                    assign[left].add(right)
                elif assign_type == 'parameter':
                    parameter[left] = right
                    continue
                elif assign_type == 'localparam':
                    parameter[left] = right
                    continue
                if not left in terms: terms[left] = self.terms[left]
        return terms, parameter, assign, always_clockedge, always_combination
Exemple #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)))
Exemple #4
0
    def resolveConstant(self):
        # 2-pass
        for bk, bv in sorted(self.binddict.items(), key=lambda x: len(x[0])):
            termtype = self.getTerm(bk).termtype
            if signaltype.isParameter(termtype) or signaltype.isLocalparam(
                    termtype):
                rslt = self.optimizeConstant(bv[0].tree)
                if isinstance(rslt, DFEvalValue):
                    self.constlist[bk] = rslt

        for bk, bv in sorted(self.binddict.items(), key=lambda x: len(x[0])):
            termtype = self.getTerm(bk).termtype
            if signaltype.isParameter(termtype) or signaltype.isLocalparam(
                    termtype):
                rslt = self.optimizeConstant(bv[0].tree)
                if isinstance(rslt, DFEvalValue):
                    self.constlist[bk] = rslt

        self.resolved_binddict = copy.deepcopy(self.binddict)
        for bk, bv in sorted(self.binddict.items(), key=lambda x: len(x[0])):
            new_bindlist = []
            for bind in bv:
                new_bind = copy.deepcopy(bind)
                if bk in self.constlist:
                    new_bind.tree = self.constlist[bk]
                new_bindlist.append(new_bind)
            self.resolved_binddict[bk] = new_bindlist

        self.resolved_terms = copy.deepcopy(self.terms)
        for tk, tv in sorted(self.resolved_terms.items(),
                             key=lambda x: len(x[0])):
            if tv.msb is not None:
                rslt = self.optimizeConstant(tv.msb)
                self.resolved_terms[tk].msb = rslt
            if tv.lsb is not None:
                rslt = self.optimizeConstant(tv.lsb)
                self.resolved_terms[tk].lsb = rslt
            if tv.dims is not None:
                dims = []
                for l, r in tv.dims:
                    l = self.optimizeConstant(l)
                    r = self.optimizeConstant(r)
                    dims.append((l, r))
                self.resolved_terms[tk].dims = tuple(dims)
Exemple #5
0
    def resolveConstant(self):
        # 2-pass
        for bk, bv in sorted(self.binddict.items(), key=lambda x:len(x[0])):
            termtype = self.getTerm(bk).termtype
            if signaltype.isParameter(termtype) or signaltype.isLocalparam(termtype):
                rslt = self.optimizeConstant(bv[0].tree)
                if isinstance(rslt, DFEvalValue):
                    self.constlist[bk] = rslt

        for bk, bv in sorted(self.binddict.items(), key=lambda x:len(x[0])):
            termtype = self.getTerm(bk).termtype
            if signaltype.isParameter(termtype) or signaltype.isLocalparam(termtype):
                rslt = self.optimizeConstant(bv[0].tree)
                if isinstance(rslt, DFEvalValue):
                    self.constlist[bk] = rslt

        self.resolved_binddict = copy.deepcopy(self.binddict)
        for bk, bv in sorted(self.binddict.items(), key=lambda x:len(x[0])):
            new_bindlist = []
            for bind in bv:
                new_bind = copy.deepcopy(bind)
                if bk in self.constlist:
                    new_bind.tree = self.constlist[bk]
                new_bindlist.append(new_bind)
            self.resolved_binddict[bk] = new_bindlist

        self.resolved_terms = copy.deepcopy(self.terms)
        for tk, tv in sorted(self.resolved_terms.items(), key=lambda x:len(x[0])):
            if tv.msb is not None: 
                rslt = self.optimizeConstant(tv.msb)
                self.resolved_terms[tk].msb = rslt
            if tv.lsb is not None: 
                rslt = self.optimizeConstant(tv.lsb)
                self.resolved_terms[tk].lsb = rslt
            if tv.lenmsb is not None: 
                rslt = self.optimizeConstant(tv.lenmsb)
                self.resolved_terms[tk].lenmsb = rslt
            if tv.lenlsb is not None: 
                rslt = self.optimizeConstant(tv.lenlsb)
                self.resolved_terms[tk].lenlsb = rslt
Exemple #6
0
    def _discretion(self, visited_binddict, visited_sources):
        terms = collections.OrderedDict()
        parameter = collections.OrderedDict()
        assign = collections.OrderedDict()
        always_clockedge = collections.OrderedDict()
        always_combination = collections.OrderedDict()

        # discretion the signal desclaration
        for source in visited_sources:
            termtype = self.getTermtype(source)
            if signaltype.isParameter(termtype):
                continue
            if signaltype.isLocalparam(termtype):
                continue
            terms[source] = self.terms[source]

        for left, rights in visited_binddict.items():
            for right in rights:
                assign_type = self.getAssignType(left, right)
                if assign_type == 'clockedge':
                    if not left in always_clockedge:
                        always_clockedge[left] = set([])
                    always_clockedge[left].add(right)
                elif assign_type == 'combination':
                    if not left in always_combination:
                        always_combination[left] = set([])
                    always_combination[left].add(right)
                elif assign_type == 'assign':
                    if not left in assign:
                        assign[left] = set([])
                    assign[left].add(right)
                elif assign_type == 'parameter':
                    parameter[left] = right
                    continue
                elif assign_type == 'localparam':
                    parameter[left] = right
                    continue
                if not left in terms:
                    terms[left] = self.terms[left]
        return terms, parameter, assign, always_clockedge, always_combination