format code
authorJacob Lifshay <programmerjake@gmail.com>
Thu, 28 Oct 2021 03:36:51 +0000 (20:36 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Thu, 28 Oct 2021 03:36:51 +0000 (20:36 -0700)
src/ieee754/part/simd_scope.py
src/ieee754/part/test/test_partsig_scope.py

index 057901b3c93679fcf18b1e74630ec471f5604e40..6741cf201c085f4190fb503c3748a6fc83012fd5 100644 (file)
@@ -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)
index d889a82cb7b75844323eb5e2c718cfc4593c5c7d..81bd7d0c1c7972e8624389a48afa45085bb15024 100644 (file)
@@ -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<<ajump)-1)))
-                        bpart.append((b >> (bjump*i) & ((1<<bjump)-1)))
+                        apart.append((a >> (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