aboutsummaryrefslogtreecommitdiff
path: root/tests/starved_grid/test.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-09-26 15:39:40 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-09-26 15:39:40 +0300
commit1a02154274b4925692ee0ad07d0bb8468ca9d69c (patch)
treea9af8e4b92e39ad25c1654a3ae7ba99faa6a3b85 /tests/starved_grid/test.c
parentef2b77be011e2b4b415d1c5bb4901431d81dfaee (diff)
downloadgran-1a02154274b4925692ee0ad07d0bb8468ca9d69c.tar.gz
gran-1a02154274b4925692ee0ad07d0bb8468ca9d69c.zip
starvation seems to work
+ With the limitation that a grid node can only attempt one move per clock, which *seems* to be the easiest strategy to implement in hardware, but I should try experimenting with more complex routing/priority assignment schemes to speed up the system overall
Diffstat (limited to 'tests/starved_grid/test.c')
-rw-r--r--tests/starved_grid/test.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/starved_grid/test.c b/tests/starved_grid/test.c
new file mode 100644
index 0000000..c91868c
--- /dev/null
+++ b/tests/starved_grid/test.c
@@ -0,0 +1,46 @@
+#define X 16
+#define Y 16
+
+void _start(unsigned short x, unsigned short y)
+{
+ volatile unsigned long *counter = (unsigned long *)((unsigned long)1 << 48);
+ volatile char *uart = (char *)4096;
+
+ /* very hacky, not recommended but good enough for testing */
+ if (x == 0 && y == 2) {
+ *counter = 0;
+ *uart = '0';
+ *uart = '\n';
+ }
+ else
+ while (*counter != (((unsigned long)x << 16) | y))
+ ;
+
+ *uart = '(';
+ /* [0 - 16] as two octal numbers */
+ *uart = ((x >> 3) & 0x7) + '0';
+ *uart = ((x >> 0) & 0x7) + '0';
+
+ *uart = ',';
+ *uart = ' ';
+
+ *uart = ((y >> 3) & 0x7) + '0';
+ *uart = ((y >> 0) & 0x7) + '0';
+
+ *uart = ')';
+ *uart = '\n';
+
+ if (x == 15 && y == 15)
+ asm ("ebreak\n");
+
+ if (y == 15) {
+ x++;
+ y = 0;
+ }
+ else
+ y++;
+
+ *counter = ((unsigned long)x << 16) | y;
+ while (1)
+ ;
+}