| 1 |
; EXPECT: feasible |
| 2 |
; COMMAND-LINE: --lang=sygus2 --sygus-out=status --sygus-repair-const |
| 3 |
(set-logic BV) |
| 4 |
|
| 5 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 6 |
; Utils |
| 7 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 8 |
|
| 9 |
(define-sort Bit () (_ BitVec 1)) |
| 10 |
|
| 11 |
(define-fun bit2bool ((b Bit)) Bool |
| 12 |
(= b #b1) |
| 13 |
) |
| 14 |
|
| 15 |
(define-fun extend ((i (_ BitVec 4))) (_ BitVec 16) |
| 16 |
(concat #b000000000000 i) |
| 17 |
) |
| 18 |
|
| 19 |
(define-fun extractBit ((i (_ BitVec 4)) (x (_ BitVec 16))) Bit |
| 20 |
((_ extract 0 0) (bvlshr x (extend i))) |
| 21 |
) |
| 22 |
|
| 23 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 24 |
; Arch |
| 25 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 26 |
|
| 27 |
(define-fun lut4 ((i0 Bit) (i1 Bit) (i2 Bit) (i3 Bit) (lut_val (_ BitVec 16))) Bit |
| 28 |
(extractBit (concat i0 i1 i2 i3) lut_val) |
| 29 |
) |
| 30 |
|
| 31 |
(define-fun carry ((i0 Bit) (i1 Bit) (ci Bit)) Bit |
| 32 |
(bvor (bvand i0 i1) (bvand i0 ci) (bvand i1 ci)) |
| 33 |
) |
| 34 |
|
| 35 |
(define-fun mux2 ((s Bit) (i0 Bit) (i1 Bit)) Bit |
| 36 |
;(ite (bit2bool s) i0 i1) |
| 37 |
(bvor (bvand s i0) (bvand (bvnot s) i1)) |
| 38 |
) |
| 39 |
|
| 40 |
(define-fun logic-cell ( |
| 41 |
(i0 Bit) (i1 Bit) (i2 Bit) (i3 Bit) (c_in Bit) ; inputs |
| 42 |
(s Bit) (lut_val (_ BitVec 16)) ;configs |
| 43 |
) (_ BitVec 2) ; Cout O |
| 44 |
(let ( |
| 45 |
(c_out (carry i1 i2 c_in)) |
| 46 |
(l_out (lut4 i0 i1 i2 (mux2 s i3 c_in) lut_val)) |
| 47 |
) |
| 48 |
(concat c_out l_out) |
| 49 |
)) |
| 50 |
|
| 51 |
(define-fun plb2 ( |
| 52 |
(i_0_0 Bit) (i_0_1 Bit) (i_0_2 Bit) (i_0_3 Bit) |
| 53 |
(i_1_0 Bit) (i_1_1 Bit) (i_1_2 Bit) (i_1_3 Bit) |
| 54 |
(c_in Bit) |
| 55 |
(s_0 Bit) (lut_val_0 (_ BitVec 16)) ;configs |
| 56 |
(s_1 Bit) (lut_val_1 (_ BitVec 16)) ;configs |
| 57 |
) (_ BitVec 3) |
| 58 |
(let ((lc0 (logic-cell i_0_0 i_0_1 i_0_2 i_0_3 c_in s_0 lut_val_0))) |
| 59 |
(let ((lc1 (logic-cell i_1_0 i_1_1 i_1_2 i_1_3 ((_ extract 1 1) lc0) s_1 lut_val_1))) |
| 60 |
(concat lc1 ((_ extract 0 0) lc0)) |
| 61 |
)) |
| 62 |
) |
| 63 |
|
| 64 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 65 |
; synth |
| 66 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 67 |
|
| 68 |
(define-fun extract2 ((i (_ BitVec 1)) (x (_ BitVec 2))) Bit |
| 69 |
((_ extract 0 0) (bvlshr x (concat #b0 i))) |
| 70 |
) |
| 71 |
|
| 72 |
(synth-fun f ((x (_ BitVec 2)) (y (_ BitVec 2)) (c_in Bit)) (_ BitVec 3) |
| 73 |
((Start (_ BitVec 3)) (Cin Bit) (S Bit) (LUT_VAL (_ BitVec 16))) ( |
| 74 |
(Start (_ BitVec 3) ( |
| 75 |
(plb2 #b0 (extract2 #b0 x) (extract2 #b0 y) #b0 |
| 76 |
#b0 (extract2 #b1 x) (extract2 #b1 y) #b0 |
| 77 |
Cin |
| 78 |
S LUT_VAL |
| 79 |
S LUT_VAL) |
| 80 |
)) |
| 81 |
(Cin Bit ( |
| 82 |
c_in |
| 83 |
(Constant Bit) |
| 84 |
)) |
| 85 |
(S Bit ( |
| 86 |
(Constant Bit) |
| 87 |
)) |
| 88 |
(LUT_VAL (_ BitVec 16) ( |
| 89 |
(Constant (_ BitVec 16)) |
| 90 |
)) |
| 91 |
)) |
| 92 |
|
| 93 |
(declare-var x (_ BitVec 2)) |
| 94 |
(declare-var y (_ BitVec 2)) |
| 95 |
|
| 96 |
(constraint (= |
| 97 |
(bvadd (concat #b0 x) (concat #b0 y)) |
| 98 |
(f x y #b0) |
| 99 |
)) |
| 100 |
|
| 101 |
(constraint (= |
| 102 |
(bvadd (bvadd (concat #b0 x) (concat #b0 y)) #b001) |
| 103 |
(f x y #b1) |
| 104 |
)) |
| 105 |
|
| 106 |
(check-synth) |
| 107 |
|
| 108 |
;(define-fun lut4_ite ((I0 Bit) (I1 Bit) (I2 Bit) (I3 Bit) (LUT_VAL (_ BitVec 16))) Bit |
| 109 |
; (let ((s3 (_ BitVec 8) (ite (bit2bool I3) ((_ extract 15 8) LUT_VAL) ((_ extract 7 0) LUT_VAL)))) |
| 110 |
; (let ((s2 (ite (bit2bool I2) ((_ extract 7 4) s3) ((_ extract 3 0) s3)))) |
| 111 |
; (let ((s1 (ite (bit2bool I1) ((_ extract 3 2) s2) ((_ extract 1 0) s2)))) |
| 112 |
; (let ((s0 (ite (bit2bool I0) ((_ extract 1 1) s1) ((_ extract 0 0) s1)))) |
| 113 |
; s0 |
| 114 |
; ) |
| 115 |
; ) |
| 116 |
; ) |
| 117 |
; ) |
| 118 |
;) |