t27.aiEnglish

Размещение: где оказываются ячейки

Вы узнаете

Что делают размещение и трассировка и куда они поставили настоящий дизайн.

Синтез говорит, какие ячейки нужны. Размещение и трассировка решают, где каждая сидит на кристалле и какие провода их соединяют. В открытом маршруте обе задачи решает nextpnr-xilinx. Карта рисует каждую размещённую ячейку настоящего запуска на XC7A200T: маленький дизайн — маленькое скопление на огромном чипе.

Попробуйте

Подгоните дизайн по размеру, затем нажимайте на ячейки разных типов и читайте их имена BEL. В спеке найдите RegionKind: какие два из пяти его видов — столбцы и какой тест проверяет, что столбец BRAM шириной в 1?

Открыть интерактивный урок →

Placement map: where nextpnr put every cell on the XC7A200T
Placement map: where nextpnr put every cell on the XC7A200T ↗

Every LUT, FF, CARRY4, IO and clock buffer of a real nextpnr-xilinx run, drawn on its site of the Artix-7 200T die. Drop your routed JSON and it draws yours.

specs/fpga/placement.t27

// SPDX-License-Identifier: Apache-2.0
// t27/specs/fpga/placement.t27
// T27 Placement Constraint Generator Specification
// Auto-generates placement hints and routing constraints from HIR connectivity
// Groups related modules into floorplan regions for optimal routing
// Uses flat arrays + count fields (parser-compatible)
// phi^2 + 1/phi^2 = 3 | TRINITY

module Placement {

    // === Region kind ===

    pub const RegionKind = enum(i8) {
        clock_region = 0,
        io_bank = 1,
        bram_column = 2,
        dsp_column = 3,
        logic_cluster = 4,
    }

    // === Placement region ===

    pub struct PlacementRegion {
        name : &str,
        kind : i8,
        x0 : u32,
        y0 : u32,
        x1 : u32,
        y1 : u32,
    }

    fn region(name: &str, kind: i8, x0: u32, y0: u32, x1: u32, y1: u32) -> PlacementRegion {
        return PlacementRegion{
            .name = name,
            .kind = kind,
            .x0 = x0,
            .y0 = y0,
            .x1 = x1,
            .y1 = y1,
        };
    }

    fn logic_cluster(name: &str, x0: u32, y0: u32, x1: u32, y1: u32) -> PlacementRegion {
        return region(name, 4, x0, y0, x1, y1);
    }

    fn bram_column(name: &str, col: u32, y0: u32, y1: u32) -> PlacementRegion {
        return region(name, 2, col, y0, col + 1, y1);
    }

    fn dsp_column(name: &str, col: u32, y0: u32, y1: u32) -> PlacementRegion {
        return region(name, 3, col, y0, col + 1, y1);
    }

    // === Placement hint ===

    pub struct PlacementHint {
        module_name : &str,
        region_name : &str,
        priority : u32,
    }

    fn hint(module_name: &str, region_name: &str, priority: u32) -> PlacementHint {
        return PlacementHint{
            .module_name = module_name,
            .region_name = region_name,
            .priority = priority,
        };
    }

    // === Routing constraint ===

    pub struct RouteConstraint {
        source : &str,
        sink : &str,
        max_delay_ps : u32,
        kind : i8,
    }

    fn route_constraint(source: &str, sink: &str, max_delay_ps: u32) -> RouteConstraint {
        return RouteConstraint{
            .source = source,
            .sink = sink,
            .max_delay_ps = max_delay_ps,
            .kind = 0,
        };
    }

    // === Floorplan ===

pub struct Floorplan {
    name : &str,
    device : &str,
    _dummy : u32,
}

    fn floorplan(name: &str, device: &str) -> Floorplan {
        return Floorplan{
            .name = name,
            .device = device,
        };
    }

    // === Query functions ===

    fn region_width(r: PlacementRegion) -> u32 {
        if r.x1 > r.x0 {
            return r.x1 - r.x0;
        }
        return 0;
    }

    fn region_height(r: PlacementRegion) -> u32 {
        if r.y1 > r.y0 {
            return r.y1 - r.y0;
        }
        return 0;
    }

    fn region_area(r: PlacementRegion) -> u32 {
        return region_width(r) * region_height(r);
    }

    fn regions_overlap(a: PlacementRegion, b: PlacementRegion) -> bool {
        return a.x0 < b.x1 and a.x1 > b.x0 and a.y0 < b.y1 and a.y1 > b.y0;
    }

    // === Validation ===

    fn validate_region(r: PlacementRegion) -> u32 {
        var errors : u32 = 0;
        if r.name == "" {
            errors = errors + 1;
        }
        if r.x1 < r.x0 {
            errors = errors + 1;
        }
        if r.y1 < r.y0 {
            errors = errors + 1;
        }
        return errors;
    }

    fn validate_hint(h: PlacementHint) -> u32 {
        var errors : u32 = 0;
        if h.module_name == "" {
            errors = errors + 1;
        }
        if h.region_name == "" {
            errors = errors + 1;
        }
        return errors;
    }

    // === Tests ===

    test region_creation
        given r = region("core", 4, 10, 20, 30, 40)
        then r.name == "core"
        and r.kind == 4
        and region_width(r) == 20
        and region_height(r) == 20

    test logic_cluster_creation
        given r = logic_cluster("logic0", 0, 0, 10, 10)
        then r.kind == 4

    test bram_column_creation
        given r = bram_column("bram0", 5, 0, 50)
        then r.kind == 2
        and region_width(r) == 1

    test dsp_column_creation
        given r = dsp_column("dsp0", 8, 0, 50)
        then r.kind == 3

    test region_area
        given r = logic_cluster("big", 0, 0, 20, 30)
        then region_area(r) == 600

    test regions_overlap_yes
        given a = logic_cluster("a", 0, 0, 10, 10)
        and b = logic_cluster("b", 5, 5, 15, 15)
        then regions_overlap(a, b) == true

    test regions_overlap_no
        given a = logic_cluster("a", 0, 0, 10, 10)
        and b = logic_cluster("b", 20, 20, 30, 30)
        then regions_overlap(a, b) == false

    test hint_creation
        given h = hint("uart_tx", "io_region", 1)
        then h.module_name == "uart_tx"
        and h.region_name == "io_region"
        and h.priority == 1

    test route_constraint_creation
        given rc = route_constraint("uart_tx", "uart_rx", 500)
        then rc.source == "uart_tx"
        and rc.max_delay_ps == 500

    test floorplan_creation
        given f = floorplan("arty_soc", "xc7a100t")
        then f.name == "arty_soc"
        and f.device == "xc7a100t"

    test validate_region_ok
        given r = logic_cluster("ok", 0, 0, 10, 10)
        then validate_region(r) == 0

    test validate_region_bad_coords
        given r = region("bad", 0, 30, 0, 20, 10)
        then validate_region(r) > 0

    test validate_hint_ok
        given h = hint("mod", "reg", 1)
        then validate_hint(h) == 0

    test validate_hint_empty
        given h = PlacementHint{.module_name = "", .region_name = "", .priority = 0}
        then validate_hint(h) > 0

    // === Invariants ===

    invariant area_non_negative
        given r = logic_cluster("inv", 0, 0, 10, 10)
        assert region_area(r) >= 0

    invariant validate_non_negative
        given r = logic_cluster("inv", 0, 0, 10, 10)
        assert validate_region(r) >= 0

    bench region_area_latency
        measure: nanoseconds to region_area(logic_cluster("bench", 0, 0, 50, 50))
        target: < 50ns

    bench floorplan_construction
        measure: nanoseconds to floorplan("bench", "xc7a100t")
        target: < 100ns
}

// phi^2 + 1/phi^2 = 3 | TRINITY

Открыть спеку урока в плеере ↗

Все уроки