From 94e88e887cf2ee4c6b445924d26e134a90bcbd50 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Tue, 5 Nov 2013 10:18:00 +0100 Subject: Reorganized folders. --- tests/Makefile | 18 ++++++++++++++++++ tests/clock_div.mj | 4 ++++ tests/cm2.mj | 4 ++++ tests/fulladder.mj | 4 ++++ tests/nadder.mj | 19 +++++++++++++++++++ tests/ram.mj | 15 +++++++++++++++ 6 files changed, 64 insertions(+) create mode 100644 tests/Makefile create mode 100644 tests/clock_div.mj create mode 100644 tests/cm2.mj create mode 100644 tests/fulladder.mj create mode 100644 tests/nadder.mj create mode 100644 tests/ram.mj (limited to 'tests') 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(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, 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(a:[n],b:[n]) = (o:[n]) where + if n = 0 then + o = [] + else + o = (a[0] or b[0]).(or_n(a[1..], b[1..])) + end if +end where + +main(ra:[addr], we, wa:[addr], c:[word]) = (o:[word]) where + o = ram(ra, we, wa, or_n(o, c)) +end where + -- cgit v1.2.3