def visit_Slice(self, node): if not isinstance(node.value, Signal): slice_proxy = Signal(value_bits_sign(node.value)) if self.target_context: a = _Assign(node.value, slice_proxy) else: a = _Assign(slice_proxy, node.value) self.comb.append(self.visit_Assign(a)) node = _Slice(slice_proxy, node.start, node.stop) return NodeTransformer.visit_Slice(self, node)
def visit_expr_call(self, node): if isinstance(node.func, ast.Name): callee = self.symdict[node.func.id] else: raise NotImplementedError if callee == transel.bitslice: if len(node.args) != 2 and len(node.args) != 3: raise TypeError("bitslice() takes 2 or 3 arguments") val = self.visit_expr(node.args[0]) low = eval_ast(node.args[1], self.symdict) if len(node.args) == 3: up = eval_ast(node.args[2], self.symdict) else: up = low + 1 return _Slice(val, low, up) else: raise NotImplementedError
def visit_Slice(self, node): return _Slice(self.visit(node.value), node.start, node.stop)