ZLANG HDL / EXAMPLES

From a counter to a transmitter

Counter, complex multiplication, streaming FFT, and an 802.11a-derived transmitter, with source links and validation limits.

FUNDAMENTALS

An eight-bit Counter

A real source example showing clock/reset declarations, storage, a combinational output, and an explicit next-state update.

Recorded compiler exampleZLang 0.1.0a24Source c768da0bce8b ↗

ZLang source

Public source
examples/counter.zhl
module Counter {
    clock clk
    reset rst

    reg count : u8 = 0
    out y     : u8

    y = count
    count <- truncate(count + 1)
}

The original example, unchanged from the linked revision.

Compiler check

Recorded output
zlang examples/counter.zhl --top Counter --check
zlang: ok: examples/counter.zhl (top Counter; syntax and semantics valid)

Recorded process exit status: 0. Syntax and semantic checking only.

Generated SystemVerilog

Recorded output
zlang examples/counter.zhl --top Counter --systemverilog build/Counter.sv
`default_nettype none
module Counter (
  input wire logic clk,
  input wire logic rst,
  output logic [7:0] y
);
  // Generated from backend-independent typed ZLang IR.
  logic [7:0] count;
  always_ff @(posedge clk) begin
    if (rst) begin
      count <= 8'd0;
    end else begin
      count <= 8'(({{1{1'b0}}, count} + 9'd1));
    end
  end
  assign y = count;
endmodule
`default_nettype wire

Recorded process exit status: 0. Output file: build/Counter.sv.

Source and event schedule on GitHub ↗
DSP / IMPLEMENTATION INTENT

Complex multiplication & streaming FFT

The FFT examples include complex multiplication and streaming transforms. The multiplication excerpt below limits DSP use to three, latency to one cycle, and initiation interval to one cycle.

Implementation intent · excerpt
product = implement {
    a * b
    intent {
        dsp <= 3
        latency == 1
        ii == 1
        minimize lut
    }
}

Resource constraints do not substitute for target-specific synthesis measurements. The example README lists supported widths, targets, and validation results.

Read the FFT example notes ↗
STREAMING / COMPILER VALIDATION PROJECT

An 802.11a-derived transmit path

Packet framing → scrambler → convolutional encoder → interleaver → constellation mapper → IFFT → cyclic prefix → complex samples.

This project tests the compiler and RTL backend using the profiles listed in its README. It does not establish complete 802.11 conformance or provide a production radio.

Inspect the project and validation contract ↗

Examples pinned to public source c768da0bce8b. Wi-Fi reference attribution and MIT license are preserved in the linked project.

Hardware projects

Explore ZTPU, ZRISC-V32, and ZRISC-V64, with their project status and availability.

Hardware project overviews →