try:
# Check provided shape by calling Shape.cast and checking for exception
Shape.cast(shape, src_loc_at=1 + src_loc_at)
- except Exception as error:
+ except Exception:
raise TypeError("Field {!r} has invalid shape: should be castable to Shape "
"or a list of fields of a nested record"
.format(field))
try:
depth_bits = log2_int(depth, need_pow2=exact_depth)
depth = 1 << depth_bits
- except ValueError as e:
+ except ValueError:
raise ValueError("AsyncFIFO only supports depths that are powers of 2; requested "
"exact depth {} is not"
.format(depth)) from None
try:
depth_bits = log2_int(max(0, depth - 1), need_pow2=exact_depth)
depth = (1 << depth_bits) + 1
- except ValueError as e:
+ except ValueError:
raise ValueError("AsyncFIFOBuffered only supports depths that are one higher "
"than powers of 2; requested exact depth {} is not"
.format(depth)) from None
return self(arg)
elif len(value.operands) == 2:
lhs, rhs = value.operands
- lhs_mask = (1 << len(lhs)) - 1
- rhs_mask = (1 << len(rhs)) - 1
if value.operator == "+":
return f"({sign(lhs)} + {sign(rhs)})"
if value.operator == "-":
gen_index = self.emitter.def_var("rhs_index", f"{index_mask} & {self(value.index)}")
gen_value = self.emitter.gen_var("rhs_proxy")
if value.elems:
- gen_elems = []
for index, elem in enumerate(value.elems):
if index == 0:
self.emitter.append(f"if {index} == {gen_index}:")
def on_Cat(self, value):
def gen(arg):
gen_arg = self.emitter.def_var("cat", arg)
- gen_parts = []
offset = 0
for part in value.parts:
part_mask = (1 << len(part)) - 1
index_mask = (1 << len(value.index)) - 1
gen_index = self.emitter.def_var("index", f"{self.rrhs(value.index)} & {index_mask}")
if value.elems:
- gen_elems = []
for index, elem in enumerate(value.elems):
if index == 0:
self.emitter.append(f"if {index} == {gen_index}:")