Drop the inputs/outputs declarations: the table already says it

A synth block used to spell out which parameter is an input and which is an
output.  That was redundant: with map, 2^K entries already mean %1..%K are the
inputs and the value's bits land on the parameters after them; with a raw
table, nothing needs saying at all.  So 'inputs' and 'outputs' now fail with a
message pointing at map/stat, and the map form derives both.

Added 'stat' as the fully explicit form: 2^params values, one per input
combination, which is exactly the state table the search consumes.
examples/full_add_stat.r8asm is the same adder written that way and produces a
byte-identical tape to the map version (95 characters), both pass the eight
combination check.
This commit is contained in:
starcells committed 2026-11-06 10:33:34 +08:00
1 parent 6fcdc4a1ea
commit a2b715ae29
7 files changed
+129 -56

No files matched your search

+8 -5
View File
@@ -13,13 +13,15 @@
#include "r8forge/r8veritas.hh"
// %synth: run the searcher on a truth table and return the block list as
// {sacrifice, mask, or_mode} triples. `layout` is the cell address of each
// parameter (empty means adjacent, 0..n-1).
// {sacrifice, mask, or_mode} triples. Either `map` (2^K output values, the
// inputs implied to be %1..%K and the outputs the ones after them) or `stat`
// (the whole 2^params state table) says what to compute. `layout` is the cell
// address of each parameter (empty means adjacent, 0..n-1).
std::vector<std::array<int, 3>>
r8asm_synth_program(int params, const std::vector<int> &in,
const std::vector<int> &out, const std::vector<int> &map,
const std::string &name, const std::vector<int> &layout,
int mode);
const std::vector<int> &stat, const std::string &name,
const std::vector<int> &layout, int mode);
class r8asm {
using data = int16_t;
@@ -122,7 +124,8 @@ private:
int params = 0;
std::vector<int> in; // param index per input bit, bit 0 first
std::vector<int> out; // param index per output bit, bit 0 first
std::vector<int> map; // 2^|in| entries: output bits of that input
std::vector<int> map; // 2^K entries: output bits of that input
std::vector<int> stat; // or the whole table: 2^params values
std::vector<int> layout; // optional: cell address of each parameter
int mode = 0; // 0 = shortest tape, 1 = fewest layers only
};