summaryrefslogtreecommitdiff
path: root/minijazz/test
diff options
context:
space:
mode:
authorAlex AUVOLAT <alex.auvolat@ens.fr>2013-10-31 15:35:11 +0100
committerAlex AUVOLAT <alex.auvolat@ens.fr>2013-10-31 15:35:11 +0100
commit0b269f32dd9b8d349f94793dad44e728473e9f0a (patch)
tree066a30fee1efe19d897f5e153d7ea9aa3d7448af /minijazz/test
downloadSystDigit-Projet-0b269f32dd9b8d349f94793dad44e728473e9f0a.tar.gz
SystDigit-Projet-0b269f32dd9b8d349f94793dad44e728473e9f0a.zip
First commit ; includes first TP and minijazz compiler
Diffstat (limited to 'minijazz/test')
-rw-r--r--minijazz/test/mem.bin4
-rw-r--r--minijazz/test/nadder.mj19
-rw-r--r--minijazz/test/shifters.mj44
-rw-r--r--minijazz/test/t1.in5
-rw-r--r--minijazz/test/tests.mj19
5 files changed, 91 insertions, 0 deletions
diff --git a/minijazz/test/mem.bin b/minijazz/test/mem.bin
new file mode 100644
index 0000000..124bd7c
--- /dev/null
+++ b/minijazz/test/mem.bin
@@ -0,0 +1,4 @@
+11
+10
+01
+00 \ No newline at end of file
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<n>(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<n-1>(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
diff --git a/minijazz/test/shifters.mj b/minijazz/test/shifters.mj
new file mode 100644
index 0000000..157abfe
--- /dev/null
+++ b/minijazz/test/shifters.mj
@@ -0,0 +1,44 @@
+const word_size = 4
+
+(* Transforme un fil en une nappe de n fils avec la meme valeur *)
+power<n>(i) = (o:[n]) where
+ if n = 1 then
+ o = i
+ else
+ o = power<n-1>(i) . i
+ end if
+end where
+
+mux_n<n>(c, a:[n], b:[n]) = (o:[n]) where
+ if n = 0 then
+ o = []
+ else
+ o_n1 = mux_n<n-1>(c, a[1..n-1], b[1..n-1]);
+ o_n = mux(c, a[0], b[0]);
+ o = o_n . o_n1
+ end if
+end where
+
+lshifter_n<n, p>(sh:[n], a:[p]) = (o:[p]) where
+ if n = 0 then
+ o = []
+ else
+ o = lshifter_n<n-1, p>(sh[1..n-1], u);
+ u = mux_n<p>(sh[0], a, a[2^(n-1)..p-1] . power<2^(n-1)>(false))
+ end if
+end where
+
+rshifter_n<n, p>(sh:[n], arith, a:[p]) = (o:[p]) where
+ if n = 1 then
+ added_bit = mux(arith, false, a[1]);
+ o = mux_n<p>(sh[0], a, added_bit . a[1..p-1])
+ else
+ o = rshifter_n<n-1, p>(sh[1..n-1], arith, u);
+ added_bit = mux(arith, false, a[2^(n-1)]);
+ u = mux_n<p>(sh[0], a, power<2^(n-1)>(added_bit) . a[2^(n-1)..p-1])
+ end if
+end where
+
+main(sh:[2], arith, left, a:[word_size]) = (o:[word_size]) where
+ o = rshifter_n<2, word_size>(sh, arith, a)
+end where \ No newline at end of file
diff --git a/minijazz/test/t1.in b/minijazz/test/t1.in
new file mode 100644
index 0000000..6d94f07
--- /dev/null
+++ b/minijazz/test/t1.in
@@ -0,0 +1,5 @@
+1 1
+1 0
+0 1
+1 1
+0 1 \ No newline at end of file
diff --git a/minijazz/test/tests.mj b/minijazz/test/tests.mj
new file mode 100644
index 0000000..a8f8b63
--- /dev/null
+++ b/minijazz/test/tests.mj
@@ -0,0 +1,19 @@
+Fulladder(a,b,c) = (s, r) where
+ s = (a xor b) xor c;
+ r = (a and b) or ((a xor b) and c);
+end where
+
+minus(x) = (y) where
+ y = x xor c;
+ c = reg (x or y)
+end where
+
+cm2(x) = (s, r) where
+ s = reg (x xor s);
+ r = x and s
+end where
+
+clk2() = (o) where
+ o = reg(c);
+ c = not (reg (o))
+end where \ No newline at end of file