From ed14271c9743490ebc4947ba7904adaa0d16e279 Mon Sep 17 00:00:00 2001 From: oharboe Date: Thu, 1 May 2008 18:49:10 +0000 Subject: wip for interrupts --- zpu/hdl/zpu4/test/interrupt/build.sh | 4 ++++ zpu/hdl/zpu4/test/interrupt/int.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 zpu/hdl/zpu4/test/interrupt/build.sh create mode 100644 zpu/hdl/zpu4/test/interrupt/int.c (limited to 'zpu/hdl/zpu4/test') 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 + + +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"); + } + } + +} -- cgit v1.1