summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile18
-rw-r--r--tests/clock_div.mj4
-rw-r--r--tests/cm2.mj4
-rw-r--r--tests/fulladder.mj4
-rw-r--r--tests/nadder.mj19
-rw-r--r--tests/ram.mj15
6 files changed, 64 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..443e86a
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,18 @@
+.SECONDARY:
+
+MINIJAZZ=../minijazz/mjc.byte
+SCHED=../sched/main.byte
+SIM=../csim/csim
+
+%.sim: %.dumb
+ $(SIM) $<
+
+%.dumb %_sch.net: %.net
+ $(SCHED) $<
+
+%.net: %.mj
+ $(MINIJAZZ) $<
+
+clean:
+ rm *.net
+ rm *.dumb
diff --git a/tests/clock_div.mj b/tests/clock_div.mj
new file mode 100644
index 0000000..ad1e919
--- /dev/null
+++ b/tests/clock_div.mj
@@ -0,0 +1,4 @@
+main() = (o) where
+ o = reg(c);
+ c = not (reg (o))
+end where \ No newline at end of file
diff --git a/tests/cm2.mj b/tests/cm2.mj
new file mode 100644
index 0000000..8863bf1
--- /dev/null
+++ b/tests/cm2.mj
@@ -0,0 +1,4 @@
+main(x) = (s, r) where
+ s = reg (x xor s);
+ r = x and s
+end where \ No newline at end of file
diff --git a/tests/fulladder.mj b/tests/fulladder.mj
new file mode 100644
index 0000000..c4b6b0e
--- /dev/null
+++ b/tests/fulladder.mj
@@ -0,0 +1,4 @@
+main(a,b,c) = (s, r) where
+ s = (a xor b) xor c;
+ r = (a and b) or ((a xor b) and c);
+end where \ No newline at end of file
diff --git a/tests/nadder.mj b/tests/nadder.mj
new file mode 100644
index 0000000..0c95386
--- /dev/null
+++ b/tests/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, b) = (o, c) where
+ (o, c) = adder<1>(a,b,0)
+end where \ No newline at end of file
diff --git a/tests/ram.mj b/tests/ram.mj
new file mode 100644
index 0000000..5bd4f29
--- /dev/null
+++ b/tests/ram.mj
@@ -0,0 +1,15 @@
+const addr = 2
+const word = 4
+
+or_n<n>(a:[n],b:[n]) = (o:[n]) where
+ if n = 0 then
+ o = []
+ else
+ o = (a[0] or b[0]).(or_n<n-1>(a[1..], b[1..]))
+ end if
+end where
+
+main(ra:[addr], we, wa:[addr], c:[word]) = (o:[word]) where
+ o = ram<addr, word>(ra, we, wa, or_n<word>(o, c))
+end where
+