Allow choosing a non-default solver in assertFormal
[nmutil.git] / src / nmutil / clz.py
index fed98cf44ed40b58505458d2b2549807540a5850..2fda8c2b578a5a335cc33bcdca5fac3083c4d483 100644 (file)
@@ -1,5 +1,14 @@
 from nmigen import Module, Signal, Elaboratable, Cat, Repl
 import math
+""" This module is much more efficient than PriorityEncoder
+    although it is functionally identical.
+    see https://bugs.libre-soc.org/show_bug.cgi?id=326
+
+    This work is funded through NLnet under Grant 2019-02-012
+
+    License: LGPLv3+
+
+"""
 
 class CLZ(Elaboratable):
     def __init__(self, width):
@@ -46,8 +55,7 @@ class CLZ(Elaboratable):
                 left, lv = pairs[i+1]
                 right, rv = pairs[i]
                 width = right.width + 1
-                new_pair = Signal(width, name="cnt_%d_%d" %
-                                  (iteration, i))
+                new_pair = Signal(width, name="cnt_%d_%d" % (iteration, i))
                 if rv == lv:
                     with m.If(left[-1] == 1):
                         with m.If(right[-1] == 1):
@@ -62,7 +70,6 @@ class CLZ(Elaboratable):
                     with m.Else():
                         comb += new_pair.eq(left)
 
-
                 ret.append((new_pair, lv+rv))
         return ret
 
@@ -80,4 +87,3 @@ class CLZ(Elaboratable):
 
         return m
 
-