about summary refs log tree commit diff
path: root/examples/sum.th
blob: dd79876c06923486083e3d4230772e9e4d3c9e3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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]);
}