A small complete program
You will learn
How the pieces of this course make one spec that becomes a circuit.
The lesson spec has a module line, a width constant, test values and on_comb, a function of two u8 inputs. gen-verilog turns it into a module whose ports are a clock, a reset and an enable, the two 8-bit inputs a and b, a ready output and the 8-bit output result. An assign line sets result from on_comb, so the sum itself waits for no clock edge. The tests check the example sums as constants; the site runner does not call on_comb, so the check of the circuit itself is left to a simulator.
Try it
Open the verilog tab of the lesson spec in the player and find the input, output and assign lines.

An 8-bit adder written in t27, with the Verilog ports and assign line the real compiler wrote for it. Lesson 26 of the t27 basics course.
specs/basics/26_a_small_program.t27
// SPDX-License-Identifier: Apache-2.0
; t27 basics, lesson 26: A small complete program.
; An 8-bit adder in t27, its tests, and the Verilog ports t27c writes for it.
module basics_26_a_small_program;
pub const WIDTH : u8 = 8;
pub const A_EXAMPLE : u8 = 100;
pub const B_EXAMPLE : u8 = 55;
pub const SUM_EXAMPLE : u8 = 155;
fn on_comb(a: u8, b: u8) -> u8 {
return a + b;
}
test the_example_sum_fits_in_a_byte {
assert A_EXAMPLE + B_EXAMPLE == SUM_EXAMPLE;
assert SUM_EXAMPLE <= 255;
}
All lessons
Module 1 · A spec file
What a .t27 file holds: a module line, prose lines and comments.
Module 2 · Values and types
Constants, the width of a whole number, and true, false and text.
Module 3 · Arrays, trits and expressions
Lists of values, the three values of a trit, and what operators compute.
Module 4 · Tests and functions
A test block, several small tests in one spec, and a function with typed inputs.
Module 5 · Inside a function
Names with let and var, choices with if and switch, and loops.
Module 6 · Visibility and your own types
What pub shares with other modules, and the structs and enums you declare.
Module 7 · Modules, rules and gen-ts
Reading another module, stating a rule that always holds, and a spec turned into TypeScript.
Module 8 · The compiler and tri
The backends t27c writes, the stages it reads a spec in, and the tri command.
Module 9 · Errors, a program, what next
Reading a compiler error, one small complete program, and the course to take next.