Capstone: out-guess yosys
You will learn
Put it together: guess what a real t27 module costs in LUTs.
Everything from this course in one game. Each day Gatle shows one real t27 module and the Verilog your browser compiles from it; you have six guesses at how many LUTs yosys spent on it. Use what you know: widths, multipliers, hierarchy, state. Then look at the other ways people and agents compete on t27.
Try it
Play today's puzzle. Then read the module's Verilog and say why it cost what it did. Run the tests in the spec frame: how many of the 12 instructions in hello_kernel are GF16 operations, and which test says all 12 take 48 bytes?

A daily guessing game: one real t27 module, its Verilog compiled in your browser, six guesses at the LUT count yosys reported for it.
specs/fpga/e2e_demo.t27
// SPDX-License-Identifier: Apache-2.0
// t27/specs/fpga/e2e_demo.t27
// T27 End-to-End Demo Specification
// Exercises the full toolchain: assembler -> ternary core -> GF16 -> VCD trace
// Validates the complete FPGA pipeline from spec to hardware simulation
// Uses flat arrays + count fields (parser-compatible)
// phi^2 + 1/phi^2 = 3 | TRINITY
module E2eDemo {
// === Demo program (trivial ternary kernel) ===
pub struct DemoKernel {
name : &str,
instr_count : u32,
gf16_ops : u32,
alu_ops : u32,
mem_ops : u32,
}
fn hello_kernel() -> DemoKernel {
return DemoKernel{
.name = "hello_trinity",
.instr_count = 12,
.gf16_ops = 4,
.alu_ops = 6,
.mem_ops = 2,
};
}
fn gf16_mac_kernel() -> DemoKernel {
return DemoKernel{
.name = "gf16_mac_demo",
.instr_count = 20,
.gf16_ops = 10,
.alu_ops = 6,
.mem_ops = 4,
};
}
// === Pipeline simulation result ===
pub struct PipeResult {
cycles : u32,
instr_retired : u32,
stalls : u32,
gf16_results : u32,
errors : u32,
}
fn pipe_result_ok(cycles: u32, retired: u32, gf16: u32) -> PipeResult {
return PipeResult{
.cycles = cycles,
.instr_retired = retired,
.stalls = 0,
.gf16_results = gf16,
.errors = 0,
};
}
fn pipe_result_error(cycles: u32, errors: u32) -> PipeResult {
return PipeResult{
.cycles = cycles,
.instr_retired = 0,
.stalls = 0,
.gf16_results = 0,
.errors = errors,
};
}
// === Demo config ===
pub struct DemoConfig {
kernel : DemoKernel,
clock_mhz : u32,
max_cycles : u32,
trace_enabled : bool,
formal_check : bool,
}
fn demo_config(kernel: DemoKernel) -> DemoConfig {
return DemoConfig{
.kernel = kernel,
.clock_mhz = 100,
.max_cycles = 100000,
.trace_enabled = true,
.formal_check = true,
};
}
// === Query functions ===
fn ipc(result: PipeResult) -> u32 {
if result.cycles == 0 {
return 0;
}
return result.instr_retired * 100 / result.cycles;
}
fn cpi(result: PipeResult) -> u32 {
if result.instr_retired == 0 {
return 0;
}
return result.cycles / result.instr_retired;
}
fn gf16_throughput(result: PipeResult, clock_mhz: u32) -> u32 {
if result.cycles == 0 {
return 0;
}
return result.gf16_results * clock_mhz * 1000 / result.cycles;
}
fn sim_time_us(cfg: DemoConfig, cycles: u32) -> u32 {
if cfg.clock_mhz == 0 {
return 0;
}
return cycles / cfg.clock_mhz;
}
fn kernel_size_bytes(kernel: DemoKernel) -> u32 {
return kernel.instr_count * 4;
}
fn passed(result: PipeResult) -> bool {
return result.errors == 0 and result.instr_retired > 0;
}
// === Validation ===
fn validate_kernel(kernel: DemoKernel) -> u32 {
var errors : u32 = 0;
if kernel.name == "" {
errors = errors + 1;
}
if kernel.instr_count == 0 {
errors = errors + 1;
}
return errors;
}
fn validate_config(cfg: DemoConfig) -> u32 {
var errors : u32 = 0;
errors = errors + validate_kernel(cfg.kernel);
if cfg.clock_mhz == 0 {
errors = errors + 1;
}
if cfg.max_cycles == 0 {
errors = errors + 1;
}
return errors;
}
// === Tests ===
test hello_kernel_creation
given k = hello_kernel()
then k.name == "hello_trinity"
and k.instr_count == 12
and k.gf16_ops == 4
and k.alu_ops == 6
and k.mem_ops == 2
test gf16_mac_kernel_creation
given k = gf16_mac_kernel()
then k.name == "gf16_mac_demo"
and k.instr_count == 20
and k.gf16_ops == 10
test pipe_result_ok
given r = pipe_result_ok(100, 95, 10)
then r.cycles == 100
and r.instr_retired == 95
and r.stalls == 0
and r.gf16_results == 10
and r.errors == 0
test pipe_result_error
given r = pipe_result_error(50, 2)
then r.errors == 2
and r.instr_retired == 0
test ipc_calculation
given r = pipe_result_ok(100, 50, 0)
then ipc(r) == 50
test ipc_zero_cycles
given r = pipe_result_ok(0, 0, 0)
then ipc(r) == 0
test cpi_calculation
given r = pipe_result_ok(200, 100, 0)
then cpi(r) == 2
test cpi_zero_retired
given r = pipe_result_ok(100, 0, 0)
then cpi(r) == 0
test gf16_throughput_calc
given r = pipe_result_ok(1000, 500, 100)
then gf16_throughput(r, 100) == 10000
test sim_time_us
given cfg = demo_config(hello_kernel())
then sim_time_us(cfg, 100000) == 1000
test kernel_size_bytes
given k = hello_kernel()
then kernel_size_bytes(k) == 48
test passed_ok
given r = pipe_result_ok(100, 50, 10)
then passed(r) == true
test passed_with_errors
given r = pipe_result_error(100, 1)
then passed(r) == false
test validate_hello_kernel
given k = hello_kernel()
then validate_kernel(k) == 0
test validate_empty_kernel
given k = DemoKernel{.name = "", .instr_count = 0, .gf16_ops = 0, .alu_ops = 0, .mem_ops = 0}
then validate_kernel(k) > 0
test validate_demo_config
given cfg = demo_config(hello_kernel())
then validate_config(cfg) == 0
// === Invariants ===
invariant kernel_size_positive
given k = hello_kernel()
assert kernel_size_bytes(k) > 0
invariant ipc_non_negative
given r = pipe_result_ok(100, 50, 0)
assert ipc(r) >= 0
invariant sim_time_non_negative
given cfg = demo_config(hello_kernel())
assert sim_time_us(cfg, 100000) >= 0
// === Benchmarks ===
bench e2e_latency
measure: nanoseconds for pipe_result_ok(1000, 500, 50)
target: < 100ns
}
// phi^2 + 1/phi^2 = 3 | TRINITY
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.