One LUT, up close
You will learn
What a 6-input lookup table is, and how 64 bits describe any gate.
A LUT6 is a tiny memory with 6 address inputs and 64 one-bit entries. Any logic function of 6 inputs is just its truth table written into those 64 bits, the INIT value. Paste an INIT and the widget reads it back as a truth table and an expression. Then play the guessing game on LUTs taken from a real routed design: XOR, AND, a multiplexer, or something with no short name.
Try it
Try the XOR6 and majority examples, then play five rounds of Guess the gate. In the spec frame, full_adder is built from xor2 and maj3: which one makes the carry, and how many neurons does the spec say it takes?

Paste a 64-bit LUT6 INIT or FASM lines: truth table, minimal expression, the gate's name, what each feature sets. Then guess the gate on 4738 LUTs from a routed design.
specs/ternary/ternary_full_adder.t27
module TernaryFullAdder;
// Ternary primitives (binary values embedded as {0 -> N=-1, 1 -> P=+1}).
fn tmul(ta: u8, tb: u8) -> i8 {
if (ta == 1) { return 0; }
if (tb == 1) { return 0; }
if (ta == tb) { return 1; }
return -1;
}
fn dot27(a: u64, b: u64) -> i16 {
var acc : i16 = 0;
var i : u32 = 0;
while (i < 27) {
var ta : u8 = ((a >> (i << 1)) & 3) as u8;
var tb : u8 = ((b >> (i << 1)) & 3) as u8;
acc = acc + tmul(ta, tb) as i16;
i = i + 1;
}
return acc;
}
fn sign0(v: i16) -> u8 { if (v > 0) { return 2; } if (v < 0) { return 0; } return 1; }
fn negate(t: u8) -> u8 { if (t == 2) { return 0; } if (t == 0) { return 2; } return 1; }
fn pack2(t0: u8, t1: u8) -> u64 {
var z : u64 = 6004799503160661;
var cleared : u64 = z & 18446744073709551600;
return cleared | (t0 as u64) | ((t1 as u64) << 2);
}
fn pack3(t0: u8, t1: u8, t2: u8) -> u64 {
var z : u64 = 6004799503160661;
var cleared : u64 = z & 18446744073709551552;
return cleared | (t0 as u64) | ((t1 as u64) << 2) | ((t2 as u64) << 4);
}
fn bneuron(x: u64, w: u64, bias: i16) -> u8 { return sign0(dot27(x, w) + bias); }
// XOR of two binary-embedded trits: a 2-layer network (not linearly separable).
fn xor2(a: u8, b: u8) -> u8 {
var x : u64 = pack2(a, b);
var w : u64 = pack2(2, 2);
var h1 : u8 = bneuron(x, w, -1);
var h2 : u8 = bneuron(x, w, 1);
return bneuron(pack2(h2, negate(h1)), w, -1);
}
// Majority of three trits = sign(a+b+c): a single neuron with all-+1 weights.
fn maj3(a: u8, b: u8, c: u8) -> u8 {
return sign0(dot27(pack3(a, b, c), 12009599006321322));
}
// Binary full adder over trit-embedded bits. sum = a XOR b XOR cin (composed
// from the 2-layer XOR); carry = majority(a, b, cin) (a single neuron). Output
// packs the two result trits: sum in bits[1:0], carry in bits[3:2]. A real
// arithmetic building block built entirely from the spec-first ternary stack.
pub fn full_adder(a: u8, b: u8, cin: u8) -> u8 {
var s : u8 = xor2(xor2(a, b), cin);
var carry : u8 = maj3(a, b, cin);
return (carry << 2) | s;
}
test fa_000 { assert_eq(full_adder(0, 0, 0), 0); }
test fa_100 { assert_eq(full_adder(2, 0, 0), 2); }
test fa_110 { assert_eq(full_adder(2, 2, 0), 8); }
test fa_111 { assert_eq(full_adder(2, 2, 2), 10); }
test fa_011 { assert_eq(full_adder(0, 2, 2), 8); }
test fa_101 { assert_eq(full_adder(2, 0, 2), 8); }
// W697: the hardware boundary, derived from the CALL GRAPH.
//
// This spec has several functions that take a parameter and return a value,
// so W696's count rule left it AMBIGUOUS. But exactly ONE of them is called
// by no other function -- it is the root, and every other candidate is a
// helper it reaches. With one root the choice is forced by structure rather
// than by count, and forwarding to it still invents nothing.
//
// The call graph is built from FUNCTION BODIES ONLY. Counting `test` blocks
// as callers makes the rule vacuous -- every function is called by its own
// test, so nothing is ever a root.
//
// Measured: the rule resolved 14 of 136 ambiguous specs, 6 of them with
// types that can cross a module boundary. It is narrow because most of the
// rest are libraries of INDEPENDENT functions, which have several roots and
// correctly stay ambiguous.
fn on_comb(a: u8, b: u8, cin: u8) -> u8 { return full_adder(a, b, cin); }
endmodule
All lessons
Module 1 · The chip
What an FPGA is, which chip we use, and how its pins meet the board.
Module 2 · Numbers in hardware
Bits, trits and number formats, and what arithmetic costs in logic.
Module 3 · Your t27 program
Write a spec, test it, and see why compiling is not the same as being right.
Module 4 · Inside t27c
How the compiler reads a spec and what it writes, including the native t27b.
Module 5 · From spec to hardware
The Verilog t27c writes, the cells it becomes, and what one LUT does.
Module 6 · Reading synthesis
What yosys reports about your design, and which warnings matter.
Module 7 · Place, route, timing
Where the cells land on the die, and whether the clock is met.
Module 8 · The bitstream
How a routed design becomes the bits the chip loads, with no Vivado.
Module 9 · On the board
Ask the chip who it is, load the bits, and check them.