От спеки к Verilog
Вы узнаете
Как функция t27 становится логикой, а тактируемая функция — регистрами.
Verilog — это текст, по которому синтезатор строит схему. t27c пишет его из спеки. Функция с именем on_clock становится блоком always по фронту такта, а каждая переменная модуля — регистром со сбросом. Откройте clocked_counter.t27 в плеере: 8-битный счётчик в несколько строк и Verilog, в который он превращается. В его заголовке записано, что из него построил yosys.
Попробуйте
Откройте clocked_counter.t27 в плеере и найдите блок always на вкладке Verilog.

A terminal in your browser running the t27 compiler as WebAssembly: t27c gen verilog prints the Verilog it emits for hello_world.t27, and t27c test runs the spec's tests.
specs/ternary/clocked_counter.t27
module ClockedCounter;
// #1764: the sequential-state primitive for the spec-first ternary datapath.
//
// Until now `gen-verilog` was combinational-only: it emitted no
// `always @(posedge clk)` and module-level `var` state was never registered.
// A function named `on_clock` is the opt-in clocked process — it lowers to an
// `always @(posedge clk or negedge rst_n)` that registers every scalar
// module-level `var`: on `!rst_n` each `var` takes its declared init value, and
// while `en` is asserted the body runs with nonblocking (`<=`) assignments.
//
// This `count` register is the minimal proof of that mechanism: reset,
// en-gating (freeze) and per-cycle advance. It is the building block a streamed
// ternary MAC needs to accumulate across cycles (the Phase-2 MVP gate).
//
// Because an `on_clock` fn is present, each scalar module `var` (here `count`)
// is exposed as an `output reg` data port — so the registered state is
// observable and the design SYNTHESIZES to real flip-flops (yosys synth_xilinx:
// 8 FDCE + 2 CARRY4). Without an output port a synthesizer dead-code-eliminates
// the whole design to zero cells. This is the first spec-first design that maps
// to non-zero real hardware.
//
// Specs without an `on_clock` fn are unaffected — their generated Verilog is
// byte-identical to before this feature.
var count : u8 = 0
fn on_clock() {
count = count + 1
}
test "on_clock_increments" {
assert_eq(count, 0);
on_clock();
assert_eq(count, 1);
on_clock();
assert_eq(count, 2);
}
Все уроки
Модуль 1 · Чип
Что такое FPGA, какой чип у нас и как его выводы встречаются с платой.
Модуль 2 · Числа в железе
Биты, триты и форматы чисел, и сколько стоит арифметика в логике.
Модуль 3 · Ваша программа на t27
Напишите спеку, проверьте её и увидьте, почему «компилируется» не значит «верно».
Модуль 4 · Внутри t27c
Как компилятор читает спеку и что он пишет, включая нативный t27b.
Модуль 5 · От спеки к железу
Verilog, который пишет t27c, ячейки, в которые он превращается, и что делает одна LUT.
Модуль 6 · Читаем синтез
Что yosys сообщает о вашем дизайне и какие предупреждения важны.
Модуль 7 · Размещение, трассировка, тайминг
Где ячейки оказываются на кристалле и успевает ли тактовая частота.
Модуль 8 · Битстрим
Как оттрассированный дизайн становится битами, которые загружает чип, без Vivado.
Модуль 9 · На плате
Спросите чип, кто он, загрузите биты и проверьте их.