summaryrefslogtreecommitdiffstats
path: root/zpu/hdl/zpu4/test
diff options
context:
space:
mode:
authoroharboe <oharboe>2008-05-01 18:49:10 +0000
committeroharboe <oharboe>2008-05-01 18:49:10 +0000
commited14271c9743490ebc4947ba7904adaa0d16e279 (patch)
treea15289fc3d891b23b835fdaea4d46b1b51c75684 /zpu/hdl/zpu4/test
parent47fd50b7c9654cf750e6c2024c9169a9eab2d6ad (diff)
downloadzpu-ed14271c9743490ebc4947ba7904adaa0d16e279.zip
zpu-ed14271c9743490ebc4947ba7904adaa0d16e279.tar.gz
wip for interrupts
Diffstat (limited to 'zpu/hdl/zpu4/test')
-rw-r--r--zpu/hdl/zpu4/test/interrupt/build.sh4
-rw-r--r--zpu/hdl/zpu4/test/interrupt/int.c32
2 files changed, 36 insertions, 0 deletions
diff --git a/zpu/hdl/zpu4/test/interrupt/build.sh b/zpu/hdl/zpu4/test/interrupt/build.sh
new file mode 100644
index 0000000..3d617e9
--- /dev/null
+++ b/zpu/hdl/zpu4/test/interrupt/build.sh
@@ -0,0 +1,4 @@
+zpu-elf-gcc -O3 -phi `pwd`/int.c -o int.elf -Wl,--relax -Wl,--gc-sections -g
+zpu-elf-objdump --disassemble-all >int.dis int.elf
+zpu-elf-objcopy -O binary int.elf int.bin
+java -classpath ../../../../sw/simulator/zpusim.jar com.zylin.zpu.simulator.tools.MakeRam int.bin >int.ram
diff --git a/zpu/hdl/zpu4/test/interrupt/int.c b/zpu/hdl/zpu4/test/interrupt/int.c
new file mode 100644
index 0000000..2be6483
--- /dev/null
+++ b/zpu/hdl/zpu4/test/interrupt/int.c
@@ -0,0 +1,32 @@
+/*
+ * Shows usage of interrupts. Goes along with zpu_core_small_wip.vhd.
+ */
+#include <stdio.h>
+
+
+int counter;
+
+/* Example of single, fixed interval non-maskable, nested interrupt */
+void _zpu_interrupt(void)
+{
+ /* interrupts are enabled so we need to finish up quickly,
+ * lest we will get infinite recursion!*/
+ counter++;
+}
+
+int main(int argc, char **argv)
+{
+ int t;
+ t=counter;
+ for (;;)
+ {
+ if (t==counter)
+ {
+ puts("No interrupt\n");
+ } else
+ {
+ puts("Got interrupt\n");
+ }
+ }
+
+}
OpenPOWER on IntegriCloud