feat(v4): HEAT-OP[0..31] and ANTICLOCK, read by HEAT-OP@ and ANTICLOCK@
#189 -- Captain Bob, 2026-11-12: "Add HEAT-OP. If it's a huge performance hit, we'll revert it. If not ... it stands"; a full 33-cell array, as DECOMPOSITION.md section 7 draws it; the Stadium feed is Phase 1's. - node.h/node.c: v4_node_heat_regs_attach; a data fetch from base+k gives opcode k's count, base+32 the anti-clock (the low cell at 32 bits); a store changes nothing. Reset detaches them. - host_map.h: HEAT_REG at word 13824, in what was free between the dictionary space and SEND_TEXT; the compile-time check covers it. Nothing moved. map-*.f18: HEAT-OP 13824, ANTICLOCK 13856. - image.h/image.c/mkmap.c: the image carries the address; v4_image_born attaches the node's own counts. - system.f18: HEAT-OP@ ( op -- n ), op mod 32; ANTICLOCK@ ( -- n ). word_count 318 -> 320 (hosted 317 -> 319): dict_hash changes. - v4-dictionary.tsv: both words; DECOMPOSITION.md 7 records the build. Also in this batch: - Makefile: make init installs qemu-user -- hosted-check needs it (Captain Bob: "Add to make init now"). - .claude/memory/rules.md, rule 5: stop and ask when something comes up (Captain Bob: "you are supposed to stop and ask"). Tests first (logs/20261113-005047/heat-op): test_node did not compile; test_host_quit 3 of 1337 failed. Suite: 199 programs, 7448554 checks, 0 failures; hosted-check, the three alike. Timing: no measurable cost. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
@@ -243,6 +243,41 @@ static void test_workload_never_false_alarms(void)
|
||||
CHECK(n.b < (v4_cell)V4_NODE_WORDS, "B left the address space");
|
||||
}
|
||||
|
||||
/* HEAT-OP[0..31] and ANTICLOCK (DECOMPOSITION.md section 7; Captain Bob, 2026-11-12: "Add
|
||||
* HEAT-OP", a full array; #189). After v4_node_heat_regs_attach(n, base, op, anticlock), a data
|
||||
* fetch from base + k (k < 32) gives op[k] and from base + 32 the anti-clock, as cells (the low cell
|
||||
* of a count at 32-bit cells); a store there changes nothing -- they are read-only and not memory.
|
||||
* Detached (reset): base .. base + 32 are memory. */
|
||||
static void test_heat_regs(void)
|
||||
{
|
||||
static v4_node n;
|
||||
v4_uheat_t op[32], ac = 777;
|
||||
const v4_cell base = 900;
|
||||
unsigned k, right = 0;
|
||||
|
||||
for (k = 0; k < 32; k++) op[k] = 1000u + k;
|
||||
v4_node_reset(&n);
|
||||
v4_node_store(&n, base + 5, 55);
|
||||
CHECK(v4_node_fetch(&n, base + 5) == 55, "detached: base + 5 is memory");
|
||||
CHECK(n.heat_reg == -1, "reset leaves the heat registers detached");
|
||||
|
||||
v4_node_heat_regs_attach(&n, base, op, &ac);
|
||||
for (k = 0; k < 32; k++) if (v4_node_fetch(&n, base + (v4_cell)k) == (v4_cell)(1000u + k)) right++;
|
||||
CHECK(right == 32, "HEAT-OP[k] reads opcode k's count (%u of 32)", right);
|
||||
CHECK(v4_node_fetch(&n, base + 32) == 777, "ANTICLOCK reads the anti-clock");
|
||||
op[20]++; ac++;
|
||||
CHECK(v4_node_fetch(&n, base + 20) == 1021 && v4_node_fetch(&n, base + 32) == 778, "they read the counts as they are now");
|
||||
v4_node_store(&n, base + 20, 5);
|
||||
v4_node_store(&n, base + 32, 5);
|
||||
CHECK(op[20] == 1021 && ac == 778, "a store does not change a count");
|
||||
CHECK(n.mem[base + 20] == 0 && n.mem[base + 32] == 0, "nor memory");
|
||||
CHECK(v4_node_fetch(&n, base - 1) == 0 && v4_node_fetch(&n, base + 33) == 0, "the cells beside them are memory");
|
||||
op[3] = ((v4_uheat_t)1 << 40) + 9u;
|
||||
CHECK(v4_node_fetch(&n, base + 3) == (v4_cell)(v4_ucell)op[3], "a count is read as a cell (its low cell at 32 bits)");
|
||||
v4_node_reset(&n);
|
||||
CHECK(n.heat_reg == -1, "a reset detaches them");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("v4 node tests: V4_CELL_BITS=%d, %u words\n",
|
||||
@@ -259,6 +294,7 @@ int main(void)
|
||||
test_out_of_range_word_address_touches_nothing();
|
||||
test_ends_are_distinguishable();
|
||||
test_workload_never_false_alarms();
|
||||
test_heat_regs();
|
||||
|
||||
printf(" %d checks, %d failures\n", checks, failures);
|
||||
return failures ? 1 : 0;
|
||||
|
||||
Reference in New Issue
Block a user