From 0f84b003914e2d9f14ef787c6e45db4fdc0a9929 Mon Sep 17 00:00:00 2001 From: Nakidai Date: Wed, 22 Apr 2026 16:11:33 +0300 Subject: Add adder example --- examples/sum.th | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 examples/sum.th diff --git a/examples/sum.th b/examples/sum.th new file mode 100644 index 0000000..dd79876 --- /dev/null +++ b/examples/sum.th @@ -0,0 +1,15 @@ +and = 0; +xor = 1; +bits = 4; +a = [bits]node(xor, 0); +b = [bits]node(xor, 1); +c = node(and) <- node(xor, 2); +out = [bits+1]node(xor); +p = [bits]node(xor) <- a <- b; +g = [bits]node(and) <- a <- b; +out[0:bits] <- ([bits]node(and) <- p); +foreach (out) { + @ <- (node(and) <- p[0:@0] <- c); + for (i = 0; i < @0; ++i) + @ <- (node(and) <- p[i+1:@0] <- g[i]); +} -- cgit 1.4.1