aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-09-22 22:45:18 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-09-22 22:45:18 +0300
commitb1d67364b4b4832b8efed112f7b0ead1a0b3cd3b (patch)
tree7926bfb428703515438c08b98c61cbffd34b3cbb /include
parent32f9719e29762001f73460acd31f2a6da8fd6298 (diff)
downloadgran-b1d67364b4b4832b8efed112f7b0ead1a0b3cd3b.tar.gz
gran-b1d67364b4b4832b8efed112f7b0ead1a0b3cd3b.zip
start experimenting with processor grids
Diffstat (limited to 'include')
-rw-r--r--include/gran/bus/simple_bus.h2
-rw-r--r--include/gran/cpu/riscv/simple_riscv64.h (renamed from include/gran/cpu/riscv/simple_riscv32.h)8
-rw-r--r--include/gran/grid/node.h14
-rw-r--r--include/gran/grid/router.h10
-rw-r--r--include/gran/packet.h2
-rw-r--r--include/gran/uart/simple_uart.h8
-rw-r--r--include/gran/vec.h46
7 files changed, 85 insertions, 5 deletions
diff --git a/include/gran/bus/simple_bus.h b/include/gran/bus/simple_bus.h
index 41a8d2e..62dd7d2 100644
--- a/include/gran/bus/simple_bus.h
+++ b/include/gran/bus/simple_bus.h
@@ -8,6 +8,6 @@
struct component *create_simple_bus();
stat simple_bus_add(struct component *bus, struct component *component,
- uintptr_t addr, size_t size);
+ uint64_t addr, uint64_t size);
#endif /* GRAN_SIMPLE_BUS_H */
diff --git a/include/gran/cpu/riscv/simple_riscv32.h b/include/gran/cpu/riscv/simple_riscv64.h
index 3cbd842..8f66013 100644
--- a/include/gran/cpu/riscv/simple_riscv32.h
+++ b/include/gran/cpu/riscv/simple_riscv64.h
@@ -1,13 +1,15 @@
/* SPDX-License-Identifier: copyleft-next-0.3.1 */
/* Copyright 2023 Kim Kuparinen < kimi.h.kuparinen@gmail.com > */
-#ifndef GRAN_SIMPLE_RISCV32
-#define GRAN_SIMPLE_RISCV32
+#ifndef GRAN_SIMPLE_RISCV64
+#define GRAN_SIMPLE_RISCV64
#include <gran/component.h>
-struct component *create_simple_riscv32(uint32_t start_pc,
+struct component *create_simple_riscv64(uint32_t start_pc,
struct component *imem,
struct component *dmem);
+void simple_riscv64_set_reg(struct component *cpu, size_t reg, uint64_t val);
+
#endif /* GRAN_SIMPLE_RISCV */
diff --git a/include/gran/grid/node.h b/include/gran/grid/node.h
new file mode 100644
index 0000000..637ac91
--- /dev/null
+++ b/include/gran/grid/node.h
@@ -0,0 +1,14 @@
+#ifndef GRAN_GRID_NODE_H
+#define GRAN_GRID_NODE_H
+
+#include <gran/component.h>
+#include <stdint.h>
+
+struct component *create_grid_node(uint8_t u, uint8_t v, uint8_t x, uint8_t y);
+
+stat grid_node_connect(struct component *node,
+ struct component *left, struct component *right,
+ struct component *up, struct component *down,
+ struct component *lower, struct component *ascend);
+
+#endif /* GRAN_GRID_NODE_H */
diff --git a/include/gran/grid/router.h b/include/gran/grid/router.h
new file mode 100644
index 0000000..cff0fa1
--- /dev/null
+++ b/include/gran/grid/router.h
@@ -0,0 +1,10 @@
+#ifndef GRAN_NODE_ROUTER_H
+#define GRAN_NODE_ROUTER_H
+
+#include <gran/component.h>
+
+struct component *create_node_router(uint8_t u, uint8_t v, uint8_t x, uint8_t y);
+stat node_router_add(struct component *router, struct component *component, uint32_t addr, uint32_t size);
+stat node_router_ascend(struct component *router, struct component *node);
+
+#endif /* GRAN_NODE_ROUTER_H */
diff --git a/include/gran/packet.h b/include/gran/packet.h
index d18dfd6..ab07b56 100644
--- a/include/gran/packet.h
+++ b/include/gran/packet.h
@@ -39,7 +39,7 @@ enum packet_state packet_state(struct packet *pkt);
void packet_set_state(struct packet *pkt, enum packet_state state);
size_t packet_size(struct packet *pkt);
-uintptr_t packet_addr(struct packet *pkt);
+uint64_t packet_addr(struct packet *pkt);
void *packet_data(struct packet *pkt);
void destroy_packet(struct packet *pkt);
diff --git a/include/gran/uart/simple_uart.h b/include/gran/uart/simple_uart.h
new file mode 100644
index 0000000..75906fa
--- /dev/null
+++ b/include/gran/uart/simple_uart.h
@@ -0,0 +1,8 @@
+#ifndef GRAN_SIMPLE_UART_H
+#define GRAN_SIMPLE_UART_H
+
+#include <gran/component.h>
+
+struct component *create_simple_uart();
+
+#endif /* GRAN_SIMPLE_UART_H */
diff --git a/include/gran/vec.h b/include/gran/vec.h
new file mode 100644
index 0000000..08a608a
--- /dev/null
+++ b/include/gran/vec.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: copyleft-next-0.3.1 */
+
+#ifndef VEC_H
+#define VEC_H
+
+#include <stddef.h>
+
+struct vec {
+ size_t n;
+ size_t s;
+ size_t ns;
+ void *buf;
+};
+
+struct vec vec_create(size_t s);
+void vec_destroy(struct vec *v);
+void vec_reset(struct vec *v);
+
+size_t vec_len(struct vec *v);
+void *vec_at(struct vec *v, size_t i);
+void *vec_back(struct vec *v);
+void *vec_pop(struct vec *v);
+void vec_append(struct vec *v, void *n);
+
+typedef int (*vec_comp_t)(const void *, const void *);
+void vec_sort(struct vec *v, vec_comp_t comp);
+
+#define foreach_vec(iter, v) \
+ for (size_t iter = 0; iter < vec_len(&v); ++iter)
+
+#define vect_at(type, v, i) \
+ *(type *)vec_at(&v, i)
+
+#define vect_append(type, v, e) \
+ vec_append(&v, (type *)(e))
+
+#define vect_back(type, v) \
+ *(type *)vec_back(&v)
+
+#define vect_pop(type, v) \
+ *(type *)vec_pop(&v)
+
+#define vec_uninit(v) \
+ (v.buf == NULL)
+
+#endif /* VEC_H */