diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-11-12 16:15:59 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-11-12 16:15:59 +0100 |
commit | b6b536727b7e3cb0dc0463ab6a4bdec757ff466b (patch) | |
tree | 70da98d1c5155740d766b5712ff6aa044ef78e4b /tests | |
parent | f4deea25fd83783c087d7b5023b68bc27f30476f (diff) | |
download | SystDigit-Projet-b6b536727b7e3cb0dc0463ab6a4bdec757ff466b.tar.gz SystDigit-Projet-b6b536727b7e3cb0dc0463ab6a4bdec757ff466b.zip |
Minor changes.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/clock_emile.mj | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/clock_emile.mj b/tests/clock_emile.mj new file mode 100644 index 0000000..9b58d54 --- /dev/null +++ b/tests/clock_emile.mj @@ -0,0 +1,78 @@ +cm_2 (i) = (s,r) where + s = reg (i xor s); + r = i and s +end where + +add<n> (i,a:[n]) = (s:[n],r) where + if n = 1 then + s = a ^ i; + r = a & i + else + (s_a,r) = add<n-1>(i & a[0], a[1..]); + s = (i ^ a[0]) . s_a + end if +end where + +cb<n> (i) = (s:[n],r) where + if n = 1 then + (s,r) = cm_2 (i) + else + c = reg ( i ^ s[0] ); + (s_a,r) = cb<n-1>(i & c); + s = c . s_a + end if +end where + +and_n<n> (a : [n]) = o where + if n = 1 then + o = a[0] + else if n = 0 then + o = 1 + else + o = and_n<n/2>(a[..(n/2)-1]) & and_n<n-n/2>(a[n/2..]) + end if end if +end where + +nxor2_n<n> (a : [n], b : [n]) = o : [n] where + if n = 0 then + o = [] + else o = (a[0] ^ not b[0]) . nxor2_n<n-1> (a[1..], b[1..]) + end if +end where + +eq_m1<n> (i : [n]) = b where + b = and_n<n>(nxor2_n<n>(i,0b110111)) +end where + +eq_m2<n> (i : [n]) = b where + b = and_n<n>(nxor2_n<n>(i,0b11101)) +end where + +cm_m_aux<n> (r,i) = s : [n] where + if n = 0 then + s = [] + else + c = reg ( mux(r,c ^ i,0) ); + s = c . cm_m_aux<n-1>(r,i & c) + end if +end where + +cm_m1<n> (i) = (s:[n],r) where + c = reg ( mux(r, i ^ c,0) ); + s = c . cm_m_aux<n-1>(r,i & c); + r = eq_m1<n>(s) & i +end where + +cm_m2<n> (i) = (s:[n],r) where + c = reg ( mux(r, i ^ c,0) ); + s = c . cm_m_aux<n-1>(r,i & c); + r = eq_m2<n>(s) & i +end where + +main() = (secs:[6],mins:[6],hours:[5],r_d) where + (secs,r_s) = cm_m1<6>(1); + (mins,r_m) = cm_m1<6>(r_s); + (hours,r_d) = cm_m2<5>(r_m); +end where + + |