Example #1
0
 def accessSlice(self, node):
     if isinstance(node.value, ast.Call) and \
        node.value.func.obj in (intbv, modbv) and \
        _isConstant(node.value.args[0], self.tree.symdict):
         c = self.getVal(node)
         self.write("%s'h" % c._nrbits)
         self.write("%x" % c._val)
         return
     addSignBit = isinstance(node.ctx, ast.Load) and (self.context == _context.SIGNED)
     if addSignBit:
         self.write("$signed({1'b0, ")
     self.context = None
     self.visit(node.value)
     lower, upper = node.slice.lower, node.slice.upper
     # special shortcut case for [:] slice
     if lower is None and upper is None:
         return
     self.write("[")
     if lower is None:
         self.write("%s" % node.obj._nrbits)
     else:
         self.visit(lower)
     self.write("-1:")
     if upper is None:
         self.write("0")
     else:
         self.visit(upper)
     self.write("]")
     if addSignBit:
         self.write("})")
Example #2
0
 def accessSlice(self, node):
     if isinstance(node.value, ast.Call) and \
        node.value.func.obj in (intbv, modbv) and \
        _isConstant(node.value.args[0], self.tree.symdict):
         c = self.getVal(node)
         self.write("%s'h" % c._nrbits)
         self.write("%x" % c._val)
         return
     addSignBit = isinstance(node.ctx, ast.Load) and (self.context
                                                      == _context.SIGNED)
     if addSignBit:
         self.write("$signed({1'b0, ")
     self.context = None
     self.visit(node.value)
     lower, upper = node.slice.lower, node.slice.upper
     # special shortcut case for [:] slice
     if lower is None and upper is None:
         return
     self.write("[")
     if lower is None:
         self.write("%s" % node.obj._nrbits)
     else:
         self.visit(lower)
     self.write("-1:")
     if upper is None:
         self.write("0")
     else:
         self.visit(upper)
     self.write("]")
     if addSignBit:
         self.write("})")
 def visitSlice(self, node, context=None, *args):
     if isinstance(node.expr, astNode.CallFunc) and \
        node.expr.node.obj is intbv and \
        _isConstant(node.expr.args[0], self.ast.symdict):
         c = self.getVal(node)
         self.write("%s'h" % c._nrbits)
         self.write("%x" % c._val)
         return
     addSignBit = (node.flags == 'OP_APPLY') and (context == _context.SIGNED)
     if addSignBit:
         self.write("$signed({1'b0, ")
     self.visit(node.expr)
     # special shortcut case for [:] slice
     if node.lower is None and node.upper is None:
         return
     self.write("[")
     if node.lower is None:
         self.write("%s" % node.obj._nrbits)
     else:
         self.visit(node.lower)
     self.write("-1:")
     if node.upper is None:
         self.write("0")
     else:
         self.visit(node.upper)
     self.write("]")
     if addSignBit:
         self.write("})")