Three cells for the destructive slice: tried, impossible here
Writing the sum back into A's cell would drop the separate S cells and cost no
extra instructions -- the driver would even get simpler. So it was worth
trying, and it does not work: %synth reports
no program up to 5 layers
and raising the layer bound to 8 does not help either:
no program up to 8 layers
So the obstacle is not runtime cost, it is feasibility: three cells cannot do
' two inputs plus a carry in -> a sum plus a new carry' in this instruction
model, the same class of limit that stopped clb_bit_and. Keeping the four cell
slice (and the 25 cell bit-per-cell adder) is the right call, and the file is
committed with that conclusion written into it so nobody retries it blind.
The layer bound is now 8 rather than 5 (src/synth.cc), since 5 was low enough to
call some feasible tables impossible; a feasible table still costs the same,
only a hopeless search takes 60% longer before giving up.
Cache untouched: restored from git after the experiments, asm/test.r8asm still
assembles from it in a fraction of a second, 7/7 hits, 1666 characters.
This commit is contained in:
1 parent
bdad1f46de
commit
8c969a38be
2 files changed
+37
-1
No files matched your search
@@ -0,0 +1,36 @@
|
||||
%include "asm/lib.r8asm"
|
||||
|
||||
; 破坏性切片:和写回 a 自己的格子,所以只要 3 个 cell。
|
||||
; p1..p3 = a(变成和), b(用完清 0), 进位(进->出)
|
||||
;
|
||||
; 目标:sum = a^b^Ci 写进 a,进位 = ab|aCi|bCi,a 里原来的值不留;
|
||||
; b 结束为 0。表按定义逐项算:
|
||||
; (a,b,Ci) = (0,0,0)->0 (1,0,0)->1 (0,1,0)->1 (1,1,0)->4
|
||||
; (0,0,1)->1 (1,0,1)->4 (0,1,1)->4 (1,1,1)->5
|
||||
%synth bit_add_nc3_synth
|
||||
params 3
|
||||
stat 0 1 1 4 1 4 4 5
|
||||
metric flat
|
||||
%endsynth
|
||||
|
||||
%macro bit_add_nc3 3
|
||||
bit_add_nc3_synth %1 %2 %3
|
||||
%endmacro
|
||||
|
||||
; 8 位破坏性加法:只传三个基址
|
||||
; %1 = A 基址(A 被结果覆盖),%2 = B 基址(保留,B 的位会被清),%3 = 进位
|
||||
; 最高位的进位丢掉,前提是 A+B <= 255。
|
||||
%macro raw_add_nc3_bits8 3
|
||||
.anchor before_raw_add_nc3_bits8
|
||||
erase %3
|
||||
|
||||
bit_add_nc3 %1 %2 %3
|
||||
bit_add_nc3 %1 + 1 %2 + 1 %3
|
||||
bit_add_nc3 %1 + 2 %2 + 2 %3
|
||||
bit_add_nc3 %1 + 3 %2 + 3 %3
|
||||
bit_add_nc3 %1 + 4 %2 + 4 %3
|
||||
bit_add_nc3 %1 + 5 %2 + 5 %3
|
||||
bit_add_nc3 %1 + 6 %2 + 6 %3
|
||||
bit_add_nc3 %1 + 7 %2 + 7 %3
|
||||
.tp before_raw_add_nc3_bits8
|
||||
%endmacro
|
||||
+1
-1
@@ -120,7 +120,7 @@ r8asm_synth_run(const std::vector<int> &in, const std::vector<int> &out,
|
||||
// 1) fewest layers -- cheap, and its tape length gives the cost search a
|
||||
// bound to work under
|
||||
typename V::options opt;
|
||||
opt.max_depth = 5;
|
||||
opt.max_depth = 8;
|
||||
const auto layers = v.solve(tt, opt);
|
||||
std::vector<std::array<int, 3>> out_ins;
|
||||
if (!layers.found) {
|
||||
|
||||
Reference in new issue
Block a user