From 0b269f32dd9b8d349f94793dad44e728473e9f0a Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Thu, 31 Oct 2013 15:35:11 +0100 Subject: First commit ; includes first TP and minijazz compiler --- minijazz/test/nadder.mj | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 minijazz/test/nadder.mj (limited to 'minijazz/test/nadder.mj') diff --git a/minijazz/test/nadder.mj b/minijazz/test/nadder.mj new file mode 100644 index 0000000..a5a6a17 --- /dev/null +++ b/minijazz/test/nadder.mj @@ -0,0 +1,19 @@ +fulladder(a,b,c) = (s, r) where + s = (a ^ b) ^ c; + r = (a & b) + ((a ^ b) & c); +end where + +adder(a:[n], b:[n], c_in) = (o:[n], c_out) where + if n = 0 then + o = []; + c_out = 0 + else + (s_n1, c_n1) = adder(a[1..], b[1..], c_in); + (s_n, c_out) = fulladder(a[0], b[0], c_n1); + o = s_n . s_n1 + end if +end where + +main(a:[2], b:[2]) = (o:[2], c) where + (o, c) = adder<2>(a,b,0) +end where \ No newline at end of file -- cgit v1.2.3