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/int.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 zpu/hdl/zpu4/test/interrupt/int.c (limited to 'zpu/hdl/zpu4/test/interrupt/int.c') 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 From 1362bd4ace3ce962ed744a153e5f969154bb6682 Mon Sep 17 00:00:00 2001 From: oharboe Date: Sun, 4 May 2008 19:29:07 +0000 Subject: * Make code synthesize on Synopsis zpu/hdl/zpu4/src/zpu_core_small.vhd zpu/hdl/zpu4/src/io.vhd --- zpu/hdl/zpu4/test/interrupt/int.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'zpu/hdl/zpu4/test/interrupt/int.c') diff --git a/zpu/hdl/zpu4/test/interrupt/int.c b/zpu/hdl/zpu4/test/interrupt/int.c index 2be6483..1b6ec01 100644 --- a/zpu/hdl/zpu4/test/interrupt/int.c +++ b/zpu/hdl/zpu4/test/interrupt/int.c @@ -6,7 +6,10 @@ int counter; -/* Example of single, fixed interval non-maskable, nested interrupt */ +/* Example of single, fixed interval non-maskable, nested interrupt. The interrupt signal is + * held high for enough cycles to guarantee that it will be noticed, i.e. longer than + * any io access + 4 cycles roughly. + */ void _zpu_interrupt(void) { /* interrupts are enabled so we need to finish up quickly, -- cgit v1.1 From 6c7ee841131808466eb0c93e5c8f112771004fbf Mon Sep 17 00:00:00 2001 From: oharboe Date: Tue, 6 May 2008 06:39:21 +0000 Subject: * Small ZPU now supports interrupts * added simulation example demonstrating interrupts --- zpu/hdl/zpu4/test/interrupt/int.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'zpu/hdl/zpu4/test/interrupt/int.c') diff --git a/zpu/hdl/zpu4/test/interrupt/int.c b/zpu/hdl/zpu4/test/interrupt/int.c index 1b6ec01..6ab28f7 100644 --- a/zpu/hdl/zpu4/test/interrupt/int.c +++ b/zpu/hdl/zpu4/test/interrupt/int.c @@ -4,11 +4,15 @@ #include -int counter; +volatile int counter; /* Example of single, fixed interval non-maskable, nested interrupt. The interrupt signal is * held high for enough cycles to guarantee that it will be noticed, i.e. longer than * any io access + 4 cycles roughly. + * + * Any non-trivial interrupt controller would have support for + * acknowledging interrupts(i.e. keep interrupts asserted until + * software acknowledges them via memory mapped IO). */ void _zpu_interrupt(void) { @@ -29,6 +33,7 @@ int main(int argc, char **argv) } else { puts("Got interrupt\n"); + t=counter; } } -- cgit v1.1