summaryrefslogtreecommitdiff
path: root/tb/sim
diff options
context:
space:
mode:
Diffstat (limited to 'tb/sim')
-rw-r--r--tb/sim/fibonacci.c13
-rw-r--r--tb/sim/fibonacci.py15
2 files changed, 28 insertions, 0 deletions
diff --git a/tb/sim/fibonacci.c b/tb/sim/fibonacci.c
new file mode 100644
index 0000000..f02398a
--- /dev/null
+++ b/tb/sim/fibonacci.c
@@ -0,0 +1,13 @@
+void reset()
+{
+ int a = 1, b = 1, *p = (int*)0x00010000;
+
+ for(int i = 0; i < 20; ++i)
+ {
+ int c = a + b;
+
+ *p++ = a;
+ a = b;
+ b = c;
+ }
+}
diff --git a/tb/sim/fibonacci.py b/tb/sim/fibonacci.py
new file mode 100644
index 0000000..48a17d8
--- /dev/null
+++ b/tb/sim/fibonacci.py
@@ -0,0 +1,15 @@
+BASE = 0x0001_0000
+COUNT = 20
+
+mem_dumps = [range(BASE, BASE + 4 * COUNT)]
+
+def final():
+ words = []
+ a, b = 1, 1
+
+ for _ in range(COUNT):
+ words.append(a)
+ c = a + b
+ a, b = b, c
+
+ assert_mem(BASE, words)