diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-03-02 17:46:57 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-03-02 17:46:57 +0200 |
| commit | ad6107d33a8a222d9062aae45d0e8d8483939d5d (patch) | |
| tree | 42896a55a89e1f0fac2d1963752836095fab5ae7 /tests/simple_ideal_noc/test.c | |
| parent | e991095180f774e3582329447c291a11499989ba (diff) | |
| download | gran-ad6107d33a8a222d9062aae45d0e8d8483939d5d.tar.gz gran-ad6107d33a8a222d9062aae45d0e8d8483939d5d.zip | |
add an idealized NoC
+ Purely virtual, doesn't exist, but would be 'theoretically' ideal.
Diffstat (limited to 'tests/simple_ideal_noc/test.c')
| -rw-r--r-- | tests/simple_ideal_noc/test.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/simple_ideal_noc/test.c b/tests/simple_ideal_noc/test.c new file mode 100644 index 0000000..2e4a22c --- /dev/null +++ b/tests/simple_ideal_noc/test.c @@ -0,0 +1,52 @@ +__attribute__((always_inline)) +static inline char hex_char(unsigned x) +{ + if (x <= 9) + return x + '0'; + + return (x - 10) + 'a'; +} + +__attribute__((always_inline)) +static inline void print_int32(volatile char *uart, unsigned x) +{ + *uart = hex_char((x >> 28) & 0xf); + *uart = hex_char((x >> 24) & 0xf); + *uart = hex_char((x >> 20) & 0xf); + *uart = hex_char((x >> 16) & 0xf); + *uart = hex_char((x >> 12) & 0xf); + *uart = hex_char((x >> 8) & 0xf); + *uart = hex_char((x >> 4) & 0xf); + *uart = hex_char((x >> 0) & 0xf); +} + +__attribute__((always_inline)) +static inline void print_addr(volatile char *uart, unsigned x) +{ + *uart = '('; + print_int32(uart, x); + *uart = ')'; + *uart = '\n'; +} + +void _start(unsigned x, unsigned X) +{ + volatile char *uart = (char *)4096; + volatile unsigned *control = (unsigned *)(1ULL << 32); + + if (x == 2) { + goto do_work; + } else { + while (*control != x) {} + } + +do_work: + print_addr(uart, x); + *control = x + 1; + + if (x == X - 1) + asm("ebreak"); + + /* otherwise just loop */ + while (1) {} +} |
