diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-02-23 01:32:47 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-02-23 01:32:47 +0200 |
| commit | 00ea50354b38c6cd9ebb08c8141f48dd5392cd23 (patch) | |
| tree | 3fd3435d30f0a32518a8dfe8ecc6c843f0e4c16f /include | |
| parent | 1a02154274b4925692ee0ad07d0bb8468ca9d69c (diff) | |
| download | gran-00ea50354b38c6cd9ebb08c8141f48dd5392cd23.tar.gz gran-00ea50354b38c6cd9ebb08c8141f48dd5392cd23.zip | |
initial torus stuff
+ Not quite deadlock free for 2D/3D for whatever reason
Diffstat (limited to 'include')
| -rw-r--r-- | include/gran/packet.h | 7 | ||||
| -rw-r--r-- | include/gran/torus3d/node.h | 35 |
2 files changed, 42 insertions, 0 deletions
diff --git a/include/gran/packet.h b/include/gran/packet.h index 5f8bd9c..2fec036 100644 --- a/include/gran/packet.h +++ b/include/gran/packet.h @@ -22,6 +22,7 @@ struct packet { uint64_t from; uint64_t to; uint64_t mask; + uint64_t timestamp; uint8_t data[64]; enum packet_flags flags; }; @@ -178,14 +179,20 @@ static inline uint64_t packet_convu64(struct packet *pkt) return res; } +/* not good, should be taken from the local clock domain or something + * but eh for now */ +extern uint64_t ticker; + static inline struct packet create_packet(uint64_t from, uint64_t to, uint64_t size, void *data, enum packet_flags flags) { assert(size <= 64); assert(packet_align(from) == from); + uint64_t aligned = packet_align(to); uint64_t mask = packet_mask(to, size); struct packet pkt = (struct packet){ + .timestamp = ticker++, .from = from, .to = aligned, .mask = mask, diff --git a/include/gran/torus3d/node.h b/include/gran/torus3d/node.h new file mode 100644 index 0000000..bd02a1f --- /dev/null +++ b/include/gran/torus3d/node.h @@ -0,0 +1,35 @@ +#ifndef GRAN_TORUS3D_NODE_H +#define GRAN_TORUS3D_NODE_H + +#include <gran/component.h> +#include <stdint.h> + +struct component *create_torus3d_node(uint8_t x, uint8_t y, uint8_t z); + +stat torus3d_node_connect(struct component *node, + struct component *x_in, + struct component *y_in, + struct component *z_in, + struct component *child, + struct component *x_out, + struct component *y_out, + struct component *z_out); + +static inline void addr_torus3d(uint64_t addr, uint8_t *x, uint8_t *y, uint8_t *z, uint32_t *off) +{ + if (off) *off = addr & 0xffffffff; + if (x) *x = (addr >> 32) & 0xff; + if (y) *y = (addr >> 40) & 0xff; + if (z) *z = (addr >> 48) & 0xff; + assert(((addr >> 56) & 0xff) == 0); +} + +static inline uint64_t torus3d_addr(uint8_t x, uint8_t y, uint8_t z, uint32_t off) +{ + return off | ((uint64_t)x << 32) + | ((uint64_t)y << 40) + | ((uint64_t)z << 48) + ; +} + +#endif /* GRAN_TORUS3D_NODE_H */ |
