t27c on a real machine
You will learn
The same compiler on a real machine, printing what it really prints.
The player in lesson 7 runs the compiler in your browser. This recording is the native t27c, written in Rust, run on a real machine on the same hello_world.t27: it reports the spec's status, the tests and invariants it emits, and the Verilog module with its parameters. Every byte in the recording was printed by the command; only the typing is staged.
Try it
Find the line where t27c prints the Verilog module's parameters.

t27c 0.4.0 on specs/demos/hello_world.t27: spec-status IMPLEMENTED, the two tests and two invariants the Zig backend emits, and the Verilog module with its parameters.
specs/demos/hello_world.t27
// SPDX-License-Identifier: Apache-2.0
// Hello World Spec for T27 Language Explorer
// This spec demonstrates every major construct in the T27 language
// with explanatory comments about why each part is shaped the way it is.
// Module declaration: every T27 program lives in a module namespace.
// Modules provide encapsulation and prevent name collisions.
module HelloWorld {
use base::types;
// Public constant: specs must declare what reaches hardware.
// Types are mandatory because the compiler needs to know memory layout
// and hardware interface requirements at compile time.
pub const MAGIC_NUMBER : u32 = 0xDEADBEEF;
pub const VERSION : u8 = 1;
pub const FLAG_ENABLE : bool = true;
// Packed struct: memory layout is guaranteed to match hardware expectations.
// The 'packed' keyword ensures no padding bytes are inserted between fields,
// which is critical for hardware communication protocols and memory-mapped registers.
pub struct ConfigPacked {
pub width : u8,
pub height : u8,
pub depth : u8,
pub enable : bool,
}
// Public function with explicit signature: every function must declare its
// parameter types and return type. This is required for type safety and
// hardware interface generation - the compiler needs to know exactly what
// data moves between modules and what operations are valid.
pub fn create_config(width : u8, height : u8, depth : u8) -> ConfigPacked {
// Function body with explicit construction
let config : ConfigPacked = ConfigPacked {
width = width,
height = height,
depth = depth,
enable = FLAG_ENABLE,
};
return config;
}
// Public function that demonstrates computation and type conversion.
// Explicit signatures ensure type safety across hardware boundaries.
pub fn calculate_area(config : ConfigPacked) -> u16 {
// Type conversion is explicit: u8 * u8 -> u16 prevents overflow
let area : u16 = cast(config.width) * cast(config.height);
return area;
}
// Public function demonstrating conditional logic and early returns.
// Explicit return type ensures the function always produces valid hardware data.
pub fn is_config_valid(config : ConfigPacked) -> bool {
// Early return with explicit type checking
if config.width == 0u8 {
return false;
}
if config.height == 0u8 {
return false;
}
if config.depth == 0u8 {
return false;
}
return config.enable;
}
// Test block: tests verify specific behaviors with concrete examples.
// Tests are essential for regression checking and specification validation.
test basic_config_creation
let config = create_config(8u8, 16u8, 3u8)
assert config.width == 8u8
assert config.height == 16u8
assert config.depth == 3u8
assert config.enable == true
// Test block demonstrating computation verification.
// Tests catch logical errors and ensure the implementation matches specification.
test area_calculation
let small_config = create_config(5u8, 7u8, 2u8)
let area = calculate_area(small_config)
assert area == 35u16 // 5 * 7 = 35
// Invariant block: invariants express properties that tests cannot verify.
// While tests check specific cases, invariants declare general truths that
// must hold across all possible executions - they are mathematical assertions
// about the module's behavior that the compiler can leverage for optimization
// and formal verification.
invariant config_field_bounds
// All numeric fields must be within reasonable hardware limits
assert MAGIC_NUMBER <= 0xFFFFFFFFu32
assert VERSION <= 255u8
assert create_config(255u8, 255u8, 255u8).width <= 255u8
// Invariant block demonstrating logical consistency.
// Invariants can express complex relationships between data structures
// that would be impossible to test exhaustively.
invariant area_consistency
// The calculated area must always be positive for valid configs
let test_config = create_config(10u8, 20u8, 1u8)
let area = calculate_area(test_config)
assert area > 0u16
}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.