From 07b7563e0748b1aff6f4d28b0172095b2fdcdfcc Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Tue, 5 Nov 2013 13:47:12 +0100 Subject: Added netlist simplification passes (not yet quite complete !) --- tests/clockHMS.mj | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/clockHMS.mj (limited to 'tests/clockHMS.mj') diff --git a/tests/clockHMS.mj b/tests/clockHMS.mj new file mode 100644 index 0000000..27f96ea --- /dev/null +++ b/tests/clockHMS.mj @@ -0,0 +1,69 @@ +repeat(a) = (x:[n]) where + if n = 1 then + x = a + else + if n - (2 * (n / 2)) = 1 then + u = repeat(a); + x = a . u . u + else + u = repeat(a); + x = u . u + end if + end if +end where + +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_n, c_n1) = fulladder(a[0], b[0], c_in); + (s_n1, c_out) = adder(a[1..], b[1..], c_n1); + o = s_n . s_n1 + end if +end where + +equal(a:[n]) = (eq) where + if n = 0 then + eq = 1 + else + if m - (2 * (m / 2)) = 1 then + eq = a[0] & equal(a[1..]); + else + eq = (not a[0]) & equal(a[1..]); + end if + end if +end where + +reg_n(a:[n]) = (r:[n]) where + if n = 0 then + r = [] + else + r = (reg a[0]) . (reg_n(r[1..])) + end if +end where + +and_each(a, b:[n]) = (o:[n]) where + if n = 0 then + o = [] + else + o = (b[0] and a) . and_each(a, b[1..]) + end if +end where + +count_mod(in:[n]) = (out:[n]) where + neq = not (equal(in)); + (incr, carry) = adder(in, 1 . repeat(0), 0); + out = and_each(neq, incr) +end where + +main() = (ret:[2],out:[2]) where + out = count_mod<2, 3>(ret); + ret = reg_n<2>(out) +end where + -- cgit v1.2.3