nexus: More efficient CO mapping
authorDavid Shah <dave@ds0.me>
Wed, 2 Dec 2020 17:08:39 +0000 (17:08 +0000)
committerDavid Shah <dave@ds0.me>
Wed, 2 Dec 2020 17:08:39 +0000 (17:08 +0000)
Signed-off-by: David Shah <dave@ds0.me>
techlibs/nexus/arith_map.v

index fd9d61be3527256c8e3b012dfade3504dbaeb75b..ce14a15eaa12e6dbd4d27bccb34e0b74f577a30e 100644 (file)
@@ -88,9 +88,9 @@ module _80_nexus_alu (A, B, CI, BI, X, Y, CO);
                        .COUT(FCO[i+2])
                );
 
-               assign CO[i] = (AA[i] && BB[i]) || (((i == 0) ? CI : CO[i-1]) && (AA[i] || BB[i]));
+               assign CO[i] = (AA[i] && BB[i]) || ((Y[i] ^ AA[i] ^ BB[i]) && (AA[i] || BB[i]));
                if (i+1 < Y_WIDTH) begin
-                       assign CO[i+1] = (AA[i+1] && BB[i+1]) || (CO[i] && (AA[i+1] || BB[i+1]));
+                       assign CO[i + 1] = (AA[i] && BB[i]) || ((Y[i] ^ AA[i] ^ BB[i]) && (AA[i] || BB[i]));
                        assign Y[i+1] = Y1[i];
                end
        end endgenerate