aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/gran/mesh/node.h31
-rw-r--r--include/gran/mesh/node1d.h24
-rw-r--r--include/gran/mesh/node2d.h32
3 files changed, 56 insertions, 31 deletions
diff --git a/include/gran/mesh/node.h b/include/gran/mesh/node.h
deleted file mode 100644
index 53ee08b..0000000
--- a/include/gran/mesh/node.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef GRAN_GRID_NODE_H
-#define GRAN_GRID_NODE_H
-
-#include <gran/component.h>
-#include <stdint.h>
-
-struct component *create_mesh_node(uint16_t x, uint16_t y);
-
-stat mesh_node_connect(struct component *node,
- struct component *n,
- struct component *s,
- struct component *e,
- struct component *w,
- struct component *l);
-
-static inline uint64_t mesh_addr(uint16_t x, uint16_t y, uint32_t off)
-{
- return off
- | ((uint64_t)x << 32)
- | ((uint64_t)y << 48)
- ;
-}
-
-static inline void addr_mesh(uint64_t addr, uint16_t *x, uint16_t *y, uint32_t *off)
-{
- if (off) *off = addr & 0xffffffff;
- if (x) *x = (addr >> 32) & 0xffff;
- if (y) *y = (addr >> 48) & 0xffff;
-}
-
-#endif /* GRAN_GRID_NODE_H */
diff --git a/include/gran/mesh/node1d.h b/include/gran/mesh/node1d.h
new file mode 100644
index 0000000..6c8151e
--- /dev/null
+++ b/include/gran/mesh/node1d.h
@@ -0,0 +1,24 @@
+#ifndef MESH_NODE1D_H
+#define MESH_NODE1D_H
+
+#include <stdint.h>
+#include <gran/component.h>
+
+struct component *create_mesh_node1d(uint16_t cluster, uint16_t elems);
+stat mesh_node1d_connect(struct component *node1d, struct component *component, uint16_t elem);
+stat mesh_node1d_connect_left(struct component *node1d, struct component *left);
+stat mesh_node1d_connect_right(struct component *node1d, struct component *right);
+
+static inline void addr_mesh1d(uint64_t addr, uint16_t *cluster, uint16_t *elem, uint32_t *off)
+{
+ if (off) *off = addr & 0xffffffff;
+ if (elem) *elem = (addr >> 32) & 0xffff;
+ if (cluster) *cluster = (addr >> 48) & 0xffff;
+}
+
+static inline uint64_t mesh1d_addr(uint16_t cluster, uint16_t elem, uint32_t off)
+{
+ return ((uint64_t)cluster << 48) | ((uint64_t)elem << 32) | off;
+}
+
+#endif /* MESH_NODE1D_H */
diff --git a/include/gran/mesh/node2d.h b/include/gran/mesh/node2d.h
new file mode 100644
index 0000000..fe43e59
--- /dev/null
+++ b/include/gran/mesh/node2d.h
@@ -0,0 +1,32 @@
+#ifndef GRAN_MESH_NODE2D_H
+#define GRAN_MESH_NODE2D_H
+
+#include <gran/component.h>
+#include <stdint.h>
+
+struct component *create_mesh_node2d(uint8_t x, uint8_t y, uint16_t elems);
+
+stat mesh_node2d_connect(struct component *c, struct component *e, uint16_t elem);
+stat mesh_node2d_connect_north(struct component *c, struct component *e);
+stat mesh_node2d_connect_south(struct component *c, struct component *e);
+stat mesh_node2d_connect_east(struct component *c, struct component *e);
+stat mesh_node2d_connect_west(struct component *c, struct component *e);
+
+static inline uint64_t mesh2d_addr(uint8_t x, uint8_t y, uint16_t elem, uint32_t off)
+{
+ return off
+ | ((uint64_t)elem << 32)
+ | ((uint64_t)x << 48)
+ | ((uint64_t)y << 56)
+ ;
+}
+
+static inline void addr_mesh2d(uint64_t addr, uint8_t *x, uint8_t *y, uint16_t *elem, uint32_t *off)
+{
+ if (off) *off = addr & 0xffffffff;
+ if (elem) *elem = (addr >> 32) & 0xffff;
+ if (x) *x = (addr >> 48) & 0xff;
+ if (y) *y = (addr >> 56) & 0xff;
+}
+
+#endif /* GRAN_MESH_NODE_H */