// SPDX-License-Identifier: Apache-2.0 ; specs/widgets/tc-full-adder.t27 -- lesson 8 of the course "The ternary machine" (specs/course/ternary-computing.t27) ; Source of truth for public/widgets/tc-full-adder/ (gHashTag/trinity): scripts/widget-pages-from-spec.mjs compiles this ; file, checks its constants, evaluates the tests below and writes the page; the page hands every constant to ; tool.js as window.T27_WIDGET. tool.js draws through ../ternary-kit.js and computes nothing: every number comes ; from public/widgets/tc-full-adder/logic.js, the fn bodies of the gHashTag/t27 spec in logic.t27, compiled to wasm. ; ASCII only (L3), English only (LANG-EN). ; phi^2 + 1/phi^2 = 3 | TRINITY module widget_tc_full_adder; pub const KIND : str = "widget-tool"; pub const ID : str = "tc-full-adder"; pub const TITLE : str = "The full adder: a carry comes in, a carry goes out"; pub const DESCRIPTION : str = "Add a carry from the place below. Three trits sum to -3..3, still one sum trit and one carry trit: 27 cases, every one shown."; pub const IMAGE_ALT : str = "Full adder card: +1 + +1 + +1 = 3, written as a carry of +1 and a sum of 0. The 27 input cases are laid out in a strip, the carry of each one coloured."; pub const HOOK : str = "Three trits never overflow one carry trit: -3..3 is always 3 x carry + sum."; pub const CATEGORY : str = "compiler"; pub const DATA_SOURCES : [2]str = ["gHashTag/t27 specs/ternary/trits.t27 (t27#8979): every value on the page is its fn bodies, compiled to wasm (logic.js), with 18 tests and 4108 runtime asserts", "D. Knuth, The Art of Computer Programming, vol. 2, section 4.1: balanced ternary"]; pub const READS_LOCAL_FILES : bool = false; pub const SENDS_NOTHING : bool = true; pub const K_CARD_WIDTH : u16 = 1200; pub const K_CARD_HEIGHT : u16 = 630; pub const SAY_LOADING : str = "Loading"; pub const SAY_CARRY : str = "carry out"; pub const SAY_SUM : str = "sum"; pub const SAY_CIN : str = "carry in"; pub const SAY_EQ : str = "{0} = 3 x {1} + {2}"; pub const SAY_CASES : str = "All 27 cases: inputs, carry, sum"; pub const SAY_SOURCE : str = "Logic: t27 spec ternary/trits.t27, compiled"; test the_card_is_the_share_size { assert K_CARD_WIDTH == 1200; assert K_CARD_HEIGHT == 630; assert K_CARD_WIDTH * 21 == K_CARD_HEIGHT * 40; } test the_widget_starts_where_its_card_says { assert SENDS_NOTHING == true; assert READS_LOCAL_FILES == false; }