use binary test rather than comparison against 1,
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 5 Mar 2019 11:06:54 +0000 (11:06 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 5 Mar 2019 11:06:54 +0000 (11:06 +0000)
and invert the if-else, removing the comparator against zero

TLB/src/Cam.py

index 2d1e782885afc634e3b97f84a9ab60ca19a954b0..16a7814b4ca8bb1de870b31ba8e3ce807ea0c290 100644 (file)
@@ -68,7 +68,7 @@ class Cam():
 
         # Set the key value for every CamEntry
         for index in range(self.cam_size):
-            with m.If(self.enable == 1):
+            with m.If(self.enable):
 
                 # Read Operation
                 with m.If(self.write_enable == 0):
@@ -87,18 +87,18 @@ class Cam():
                 m.d.comb += self.encoder.i[index].eq(entry_array[index].match)
 
                 # Process out data based on encoder address
-                with m.If(self.encoder.n == 0):
-                    m.d.comb += [
-                        self.single_match.eq(1),
-                        self.match_address.eq(self.encoder.o)
-                    ]
-                with m.Else():
+                with m.If(self.encoder.n):
                     m.d.comb += [
                         self.read_warning.eq(0),
                         self.single_match.eq(0),
                         self.multiple_match.eq(0),
                         self.match_address.eq(0)
                     ]
+                with m.Else():
+                    m.d.comb += [
+                        self.single_match.eq(1),
+                        self.match_address.eq(self.encoder.o)
+                    ]
 
             with m.Else():
                 m.d.comb += [