1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
|
;; Copyright (C) 2017, Regents of the University of Texas
;; Written by Cuong Chau
;; License: A 3-clause BSD license. See the LICENSE file distributed with
;; ACL2.
;; Cuong Chau <ckcuong@cs.utexas.edu>
;; November 2018
(in-package "ADE")
(include-book "link-joint")
(include-book "vector-module")
;; ======================================================================
;; Construct a DE module generator for a storage-free branch joint. Prove the
;; value lemma for this module generator.
(defconst *branch$go-num* 1)
(defun branch$data-ins-len (data-size)
(declare (xargs :guard (natp data-size)))
(+ 4 (mbe :logic (nfix data-size)
:exec data-size)))
(defun branch$ins-len (data-size)
(declare (xargs :guard (natp data-size)))
(+ (branch$data-ins-len data-size)
*branch$go-num*))
;; DE module generator of BRANCH
(module-generator
branch* (data-size)
(si 'branch data-size)
(list* 'full-in 'empty-out0- 'empty-out1- 'select
(append (sis 'data-in 0 data-size)
(sis 'go 0 *branch$go-num*)))
(list* 'act 'act0 'act1
(sis 'data-out 0 data-size))
()
(list
'(g0 (select~) b-not (select))
'(g1 (ready-out0-) b-or (empty-out0- select))
'(g2 (ready-out1-) b-or (empty-out1- select~))
(list 'branch-cntl0
'(act0)
'joint-cntl
(list 'full-in 'ready-out0- (si 'go 0)))
(list 'branch-cntl1
'(act1)
'joint-cntl
(list 'full-in 'ready-out1- (si 'go 0)))
'(branch-cntl (act) b-or (act0 act1))
(list 'branch-op
(sis 'data-out 0 data-size)
(si 'v-buf data-size)
(sis 'data-in 0 data-size)))
(declare (xargs :guard (natp data-size))))
;; DE netlist generator. A generated netlist will contain an instance of
;; BRANCH.
(defund branch$netlist (data-size)
(declare (xargs :guard (natp data-size)))
(cons (branch* data-size)
(union$ (v-buf$netlist data-size)
*joint-cntl*
:test 'equal)))
;; Recognizer for BRANCH
(defund branch& (netlist data-size)
(declare (xargs :guard (and (alistp netlist)
(natp data-size))))
(b* ((subnetlist (delete-to-eq (si 'branch data-size) netlist)))
(and (equal (assoc (si 'branch data-size) netlist)
(branch* data-size))
(joint-cntl& subnetlist)
(v-buf& subnetlist data-size))))
;; Sanity check
(local
(defthmd check-branch$netlist-64
(and (net-syntax-okp (branch$netlist 64))
(net-arity-okp (branch$netlist 64))
(branch& (branch$netlist 64) 64))))
;; Extract the input and output signals for BRANCH
(progn
;; Extract the input data
(defun branch$data-in (inputs data-size)
(declare (xargs :guard (and (true-listp inputs)
(natp data-size))))
(take (mbe :logic (nfix data-size)
:exec data-size)
(nthcdr 4 inputs)))
(defthm len-branch$data-in
(equal (len (branch$data-in inputs data-size))
(nfix data-size)))
(in-theory (disable branch$data-in))
;; Extract the "act0" signal
(defund branch$act0 (inputs data-size)
(b* ((full-in (nth 0 inputs))
(empty-out0- (nth 1 inputs))
(select (nth 3 inputs))
(go-signals (nthcdr (branch$data-ins-len data-size) inputs))
(go-branch (nth 0 go-signals))
(ready-out0- (f-or empty-out0- select)))
(joint-act full-in ready-out0- go-branch)))
(defthm branch$act0-inactive
(implies (or (not (nth 0 inputs))
(equal (nth 1 inputs) t))
(not (branch$act0 inputs data-size)))
:hints (("Goal" :in-theory (enable branch$act0))))
;; Extract the "act1" signal
(defund branch$act1 (inputs data-size)
(b* ((full-in (nth 0 inputs))
(empty-out1- (nth 2 inputs))
(select (nth 3 inputs))
(go-signals (nthcdr (branch$data-ins-len data-size) inputs))
(go-branch (nth 0 go-signals))
(ready-out1- (f-or empty-out1- (f-not select))))
(joint-act full-in ready-out1- go-branch)))
(defthm branch$act1-inactive
(implies (or (not (nth 0 inputs))
(equal (nth 2 inputs) t))
(not (branch$act1 inputs data-size)))
:hints (("Goal" :in-theory (enable branch$act1))))
;; Extract the "act" signal
(defund branch$act (inputs data-size)
(f-or (branch$act0 inputs data-size)
(branch$act1 inputs data-size)))
(defthm branch$act-inactive
(implies (or (not (nth 0 inputs))
(and (equal (nth 1 inputs) t)
(equal (nth 2 inputs) t)))
(not (branch$act inputs data-size)))
:hints (("Goal" :in-theory (enable branch$act))))
)
;; The value lemma for BRANCH
(defthm branch$value
(b* ((inputs (list* full-in empty-out0- empty-out1- select
(append data-in go-signals))))
(implies (and (branch& netlist data-size)
(true-listp data-in)
(equal (len data-in) data-size)
(true-listp go-signals)
(equal (len go-signals) *branch$go-num*))
(equal (se (si 'branch data-size) inputs st netlist)
(list* (branch$act inputs data-size)
(branch$act0 inputs data-size)
(branch$act1 inputs data-size)
(v-threefix data-in)))))
:hints (("Goal"
:do-not-induct t
:expand (:free (inputs data-size)
(se (si 'branch data-size) inputs st netlist))
:in-theory (e/d (de-rules
branch&
branch*$destructure
branch$act
branch$act0
branch$act1)
(de-module-disabled-rules)))))
|