From: Jacob Lifshay Date: Thu, 28 Oct 2021 03:36:51 +0000 (-0700) Subject: format code X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7faf4ab7387d4560b84dba5484a46414cd184d73;p=ieee754fpu.git format code --- diff --git a/src/ieee754/part/simd_scope.py b/src/ieee754/part/simd_scope.py index 057901b3..6741cf20 100644 --- a/src/ieee754/part/simd_scope.py +++ b/src/ieee754/part/simd_scope.py @@ -19,6 +19,7 @@ use as: from nmigen.hdl.ast import Signal + class SimdScope: """The global scope object for SimdSignal and friends @@ -101,7 +102,7 @@ class SimdScope: ################## def Signal(self, shape=None, *, name=None, reset=0, reset_less=False, - attrs=None, decoder=None, src_loc_at=0): + attrs=None, decoder=None, src_loc_at=0): if self.scalar: # scalar mode, just return a nmigen Signal. THIS IS IMPORTANT. # when passing in SimdShape it should go "oh, this is @@ -117,28 +118,29 @@ class SimdScope: # SIMD mode. shape here can be either a SimdShape, # a Shape, or anything else that Signal can take (int or # a tuple (int,bool) for (width,sign) - s = SimdSignal(mask=self, # should contain *all* context needed, - # which goes all the way through to - # the layout() function, passing - # 1) elwid 2) vec_el_counts - shape=shape, # should contain the *secondary* + s = SimdSignal(mask=self, # should contain *all* context needed, + # which goes all the way through to + # the layout() function, passing + # 1) elwid 2) vec_el_counts + shape=shape, # should contain the *secondary* # part of the context needed for # the layout() function: # 3) lane_shapes 4) fixed_width - name=name, reset=reset, - reset_less=reset_less, attrs=attrs, - decoder=decoder, src_loc_at=src_loc_at) + name=name, reset=reset, + reset_less=reset_less, attrs=attrs, + decoder=decoder, src_loc_at=src_loc_at) # set the module context so that the SimdSignal can create # its own submodules during AST creation s.set_module(self.module) return s # XXX TODO - def Signal_like(self): pass - #if self.scalar: - # scalar mode, just return nmigen Signal.like. THIS IS IMPORTANT. + def Signal_like(self): + # if self.scalar: + # scalar mode, just return nmigen Signal.like. THIS IS IMPORTANT. # else - # simd mode. + # simd mode. + pass # XXX TODO def Shape(self, width=1, signed=False): @@ -155,5 +157,5 @@ class SimdScope: # the names are preserved to ensure parameter-compatibility # with Shape() return SimdShape(self, width=width, # actually widths_at_elwid - signed=signed, - fixed_width=None) + signed=signed, + fixed_width=None) diff --git a/src/ieee754/part/test/test_partsig_scope.py b/src/ieee754/part/test/test_partsig_scope.py index d889a82c..81bd7d0c 100644 --- a/src/ieee754/part/test/test_partsig_scope.py +++ b/src/ieee754/part/test/test_partsig_scope.py @@ -26,7 +26,6 @@ def create_simulator(module, traces, test_name): return Simulator(module) - class TestCatMod(Elaboratable): def __init__(self, width, elwid, vec_el_counts): self.m = Module() @@ -35,8 +34,8 @@ class TestCatMod(Elaboratable): shape2 = SimdShape(s, fixed_width=width*2) shape3 = SimdShape(s, fixed_width=width*3) self.a = s.Signal(shape) - self.b = s.Signal(shape2) # TODO: shape*2 - self.o = s.Signal(shape3) # TODO: shape*3 + self.b = s.Signal(shape2) # TODO: shape*2 + self.o = s.Signal(shape3) # TODO: shape*3 self.cat_out = self.o.sig def elaborate(self, platform): @@ -83,11 +82,11 @@ class TestCat(unittest.TestCase): apart, bpart = [], [] ajump, bjump = alen // 4, blen // 4 for i in range(4): - apart.append((a >> (ajump*i) & ((1<> (bjump*i) & ((1<> (ajump*i) & ((1 << ajump)-1))) + bpart.append((b >> (bjump*i) & ((1 << bjump)-1))) - print ("apart bpart", hex(a), hex(b), - list(map(hex, apart)), list(map(hex, bpart))) + print("apart bpart", hex(a), hex(b), + list(map(hex, apart)), list(map(hex, bpart))) yield module.a.lower().eq(a) yield module.b.lower().eq(b) @@ -104,22 +103,22 @@ class TestCat(unittest.TestCase): for i in runlengths: # a first for _ in range(i): - print ("runlength", i, - "ai", ai, - "apart", hex(apart[ai]), - "j", j) + print("runlength", i, + "ai", ai, + "apart", hex(apart[ai]), + "j", j) y |= apart[ai] << j - print (" y", hex(y)) + print(" y", hex(y)) j += ajump ai += 1 # now b for _ in range(i): - print ("runlength", i, - "bi", bi, - "bpart", hex(bpart[bi]), - "j", j) + print("runlength", i, + "bi", bi, + "bpart", hex(bpart[bi]), + "j", j) y |= bpart[bi] << j - print (" y", hex(y)) + print(" y", hex(y)) j += bjump bi += 1