feat(v4.0.0): the wire in the engine -- whole messages, put and taken in one step

Queues of whole messages on the wires between nodes (v4/wire.h), the six
addresses and ten operations a node asks of the fabric (MESH.md 7d.3), and the
fabric's pool of queues. Engine only: the nucleus does not use any of it yet.
The ports in the host map move to BUF0_W - 140 so that the new addresses are
not among the nucleus variables, with a compile-time check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rajames
2026-10-08 13:50:15 -04:00
co-authored by Claude Opus 5.5
parent 50be766e7b
commit d5cd64605d
14 changed files with 1267 additions and 22 deletions
+36 -2
View File
@@ -87,13 +87,17 @@ void v4_node_store(v4_node *n, v4_cell addr, v4_cell value)
* neighbour has taken it. */
{
int port = v4_node_port_index(n, addr);
if (port == (int)V4_PORT_WIRE) { n->wire = (value >= 0 && value < (v4_cell)V4_PORTS) ? (unsigned)value : V4_PORTS; return; }
if (port == (int)V4_PORT_A) { n->wire_a = value; return; }
if (port == (int)V4_PORT_B) { n->wire_b = value; return; }
if (port == (int)V4_PORT_DO) { n->do_op = value; n->doing = 1; return; }
if (port >= 0 && port < (int)V4_PORTS) {
n->request = value;
n->ask_port = (unsigned)port;
n->asking = 1;
return;
}
if (port >= 0) { v4_node_fault(n, V4_FAULT_ADDRESS, addr); return; } /* "any" and "which port" are not written to */
if (port >= 0) { v4_node_fault(n, V4_FAULT_ADDRESS, addr); return; } /* "any", "which port", How and Have are not written to */
}
/* The stack registers: a store empties the stack. -1 when not attached. */
if (addr == n->dstack_reg) { v4_dstack_clear(&n->ds); return; }
@@ -122,6 +126,12 @@ v4_cell v4_node_fetch(v4_node *n, v4_cell addr)
if (port == (int)V4_PORTS + 1) return (v4_cell)n->last_from;
if (port == (int)V4_PORTS + 2) { n->since_look = 0; return (v4_cell)n->writers; }
if (port == (int)V4_PORTS + 3) { n->since_look = 0; return (v4_cell)n->readers; }
if (port == (int)V4_PORT_WIRE) return (v4_cell)n->wire;
if (port == (int)V4_PORT_A) return n->wire_a;
if (port == (int)V4_PORT_B) return n->wire_b;
if (port == (int)V4_PORT_DO) return n->do_op;
if (port == (int)V4_PORT_HOW) return n->how;
if (port == (int)V4_PORT_HAVE) { n->have_fetched = 1; return (v4_cell)n->have; }
if (port >= 0) {
/* the word its neighbour wrote; v4_node_read_ready has said it is there */
if (!n->given) return 0;
@@ -180,6 +190,14 @@ void v4_node_port_attach(v4_node *n, v4_cell base)
n->writers = 0;
n->readers = 0;
n->since_look = 0;
n->wire = 0;
n->wire_a = 0;
n->wire_b = 0;
n->doing = 0;
n->do_op = 0;
n->how = 0;
n->have = 0;
n->have_fetched = 0;
}
void v4_node_port_status(v4_node *n, unsigned writers, unsigned readers)
@@ -190,7 +208,7 @@ void v4_node_port_status(v4_node *n, unsigned writers, unsigned readers)
int v4_node_port_index(const v4_node *n, v4_cell addr)
{
if (n->port < 0 || addr < n->port || addr > n->port + (v4_cell)V4_PORTS + 3) return -1;
if (n->port < 0 || addr < n->port || addr > n->port + (v4_cell)V4_PORT_HAVE) return -1;
return (int)(addr - n->port);
}
@@ -225,6 +243,22 @@ void v4_node_port_served(v4_node *n)
n->since_look++;
}
int v4_node_doing(const v4_node *n)
{
return n->doing;
}
void v4_node_done(v4_node *n, v4_cell how)
{
n->how = how;
n->doing = 0;
}
void v4_node_have(v4_node *n, unsigned mask)
{
n->have = mask;
}
unsigned v4_node_words_since_look(const v4_node *n)
{
return n->since_look;