Blockpic Language Specification

Blockpic is a domain-specific language (DSL) for engineering block diagram typesetting, designed to produce diagrams with the aesthetics of Xilinx UG474 technical documentation.

1. Overview

Blockpic focuses on clear, functional, and aesthetically minimalist diagrams. It prioritizes orthogonal routing, precise port placement, and a standard color palette for hardware logic primitives.

2. Core Concepts

2.1 Blocks and Primitives

A Block is the primary logical element. Each block has: - Label: A unique logical designation identifier (e.g. AND1) used for defining wire connections and layout references. - Name: An optional display name attribute (e.g. name: "My Gate";) shown inside the block shape on the diagram. If omitted, the block’s Label is used for rendering. - Kind: The type of block (e.g., AND, OR, FLIPFLOP, MUX, LUT, CUSTOM). - Input Pins: Named input ports. - Output Pins: Named output ports. - Parameters: Key-value pairs for configuration (e.g., init: 0x1234). Supported parameters include: - show_port_names: Controls pin/port name visibility (fallback check). Set show_port_names: "true" to force rendering. - Hint: An optional block display hint. Supported values include: - show-ports: Forces rendering of input and output port names. - hide-ports: Forces hiding of input and output port names. - Dimensions: Optional width and height. - Custom Rendering: Support for custom rendering functions (Phase 2).

2.2 Pins (Ports)

Pins are the connection points on blocks. - Type: input or output. - Position Hint: left, right, top, bottom.

2.3 Wires

Wires connect an output pin of a source block to an input pin of a destination block. - Source: (block_name, pin_name). - Destination: (block_name, pin_name). - Routing Hints: Hints for the router (e.g., straight, L-shape, Z-shape, feedback). - Signal Directionality: Wires must render an arrowhead at the destination pin to clearly indicate the flow of the signal. - Feedback Routing: Support for backward-flowing signals (e.g., in Mealy/Moore state machines), routing wires around blocks to return to an earlier stage in the data path. - Bus Attributes: - Thickness: Specifies if the wire is a bus and its relative thickness. - Crossline: Supports a crossline indicator (often used with a number to indicate bus width).

2.4 Aesthetics (UG474 Style)

2.5 Shape Library and IEEE Standards

Blockpic strictly adheres to ANSI/IEEE Std 91-1984 for logic symbols. It supports both distinctive-shape and rectangular-shape symbols.

2.5.1 Basic Logic Gates

2.5.2 Dependency Notation (for Complex Blocks)

For MSI components like Registers and Counters, Blockpic supports IEEE dependency notation to represent internal logic relationships: - G (AND): Gate dependency. - C (Control): Timing/Clock dependency (often used with the > dynamic indicator for edge-triggering). - S (Set) / R (Reset): Asynchronous set and reset. - EN (Enable): Output enable. - M (Mode): Mode dependency. - V (OR): OR dependency.

2.5.3 Functional Indicators and Text Decorations

3. Syntax (Draft)

Blockpic uses a custom DSL designed for readability.

diagram MyLogic {
    config {
        style: "Xilinx";
        font: "Helvetica", 9pt;
    }

    // Block declarations
    block LUT6_A {
        kind: "LUT";
        params: { init: "0x8000000000000000" };
        inputs: I0, I1, I2, I3, I4, I5;
        outputs: O;
        size: (40, 60);
    }

    block DFF_1 {
        kind: "FLIPFLOP";
        inputs: D, CLK [bottom], CE [left];
        outputs: Q;
    }

    // Wire declarations
    wire LUT6_A.O -> DFF_1.D {
        hint: "Z-shape";
    }

    wire BUS_IN.O -> LUT6_A.I0 {
        thickness: 2;
        crossline: 8; // Indicates an 8-bit bus
    }

    // Optional Layout
    layout {
        LUT6_A at (10, 10);
        DFF_1 at (100, 10);
    }
}

4. Layout and Rendering

5. Roadmap

Phase 1: Core Language and Renderer

Phase 2: Advanced Features

Phase 3: Tooling

5. Rendering Engine and Implementation

6. Project Structure and Task Management