aboutsummaryrefslogtreecommitdiffstats
path: root/techlibs/ice40/cells_box.v
diff options
context:
space:
mode:
Diffstat (limited to 'techlibs/ice40/cells_box.v')
-rw-r--r--techlibs/ice40/cells_box.v24
1 files changed, 15 insertions, 9 deletions
diff --git a/techlibs/ice40/cells_box.v b/techlibs/ice40/cells_box.v
index e2a54a42c..d0eb8708c 100644
--- a/techlibs/ice40/cells_box.v
+++ b/techlibs/ice40/cells_box.v
@@ -1,12 +1,18 @@
(* abc_box_id = 1 *)
-module SB_CARRY (output CO, input CI, I0, I1);
- assign CO = (I0 && I1) || ((I0 || I1) && CI);
-endmodule
+module ICE40_CARRY_LUT (output CO, O, input CI, I1, I2);
+ assign CO = (I1 && I2) || ((I1 || I2) && CI);
-(* abc_box_id = 2 *)
-module SB_LUT4 (output O, input I0, I1, I2, I3);
- parameter [15:0] LUT_INIT = 0;
- // Indicate this is a black-box
- assign O = 1'b0;
-endmodule
+ wire I0, I3;
+ assign I0 = 1'b0;
+ assign I3 = CI;
+ // I0: 1010 1010 1010 1010
+ // I1: 1100 1100 1100 1100
+ // I2: 1111 0000 1111 0000
+ // I3: 1111 1111 0000 0000
+ localparam [15:0] LUT_INIT = 16'b 0110_1001_1001_0110;
+ wire [7:0] s3 = I3 ? LUT_INIT[15:8] : LUT_INIT[7:0];
+ wire [3:0] s2 = I2 ? s3[ 7:4] : s3[3:0];
+ wire [1:0] s1 = I1 ? s2[ 3:2] : s2[1:0];
+ assign O = I0 ? s1[1] : s1[0];
+endmodule