Skip to content

Commit

Permalink
Change Variable Printing
Browse files Browse the repository at this point in the history
Changes variable wire printing for to-circuit function. Now the N-th
entry is printed as `inN` and the test-call right had side is `out`
  • Loading branch information
agureev committed Dec 19, 2023
1 parent a9c86b4 commit f14ea0b
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/seqn/trans.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ and skip 0es, making non-zero entries into wires"
(wires (loop for i from 1 to wire-count
collect (vamp:make-wire
:var (intern
(format nil "X~a" (- wire-count i))
(format nil "in~a" (- wire-count i))
:keyword)))))
(list
(vamp:make-alias
Expand All @@ -46,14 +46,18 @@ and skip 0es, making non-zero entries into wires"

(defun test-call (circuit)
"Given a compiled VampIR function with name foo and arguments x1...xn prints
an equality as foo x1 ... xn = y"
(let ((inputs (vamp:inputs circuit))
(name (vamp:name circuit)))
(list (vamp:make-equality
:lhs (if (zerop (length inputs))
(vamp:make-wire :var name)
(vamp:make-application :func name :arguments inputs))
:rhs (vamp:make-wire :var :y)))))
an equality as foo in1 ... in2 = out"
(let* ((inputs (vamp:inputs circuit))
(name (vamp:name circuit)))
(flet ((app (x) (vamp:make-application :func name :arguments x)))
(list (vamp:make-equality
:lhs (cond ((zerop (length inputs))
(vamp:make-wire :var name))
((= (length inputs) 1)
(app (list (vamp:make-wire :var :in))))
(t
(app inputs)))
:rhs (vamp:make-wire :var :out))))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SeqN to Vamp-IR Compilation
Expand Down

0 comments on commit f14ea0b

Please sign in to comment.