From f14ea0bd66d8f9bbf85db5d12d3b1b93188ce173 Mon Sep 17 00:00:00 2001 From: Artem Gureev Date: Mon, 18 Dec 2023 22:22:53 +0700 Subject: [PATCH 1/2] Change Variable Printing 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` --- src/seqn/trans.lisp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/seqn/trans.lisp b/src/seqn/trans.lisp index 51e6547fe..77d45e816 100644 --- a/src/seqn/trans.lisp +++ b/src/seqn/trans.lisp @@ -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 @@ -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 From 64b425d3555b06412e873e1de39bddc40af4011e Mon Sep 17 00:00:00 2001 From: Artem Gureev Date: Mon, 18 Dec 2023 22:03:15 +0700 Subject: [PATCH 2/2] Fix Multiplication Intepretation Typo Fixes typo when instead of inputs to the multiplication, the to-vampir compilation tried to access car and cadr of the morphism. --- src/seqn/trans.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/seqn/trans.lisp b/src/seqn/trans.lisp index 51e6547fe..c214a15e8 100644 --- a/src/seqn/trans.lisp +++ b/src/seqn/trans.lisp @@ -258,7 +258,7 @@ removed already and hence we cannot count as usual" (defmethod to-vampir ((obj seqn-multiply) inputs constraints) (declare (ignore constraints)) - (list (infix-creation :* (car obj) (cadr obj)))) + (list (infix-creation :* (car inputs) (cadr inputs)))) (defmethod to-vampir ((obj seqn-divide) inputs constraints) (declare (ignore constraints))