Skip to content

gds_software.dfd.compile

Compiler: DFDModel -> GDSSpec / SystemIR.

Semantic Types

Public Functions

Compile a DFDModel into a GDSSpec.

Registers: types, spaces, entities, blocks, wirings.

Source code in packages/gds-software/gds_software/dfd/compile.py
def compile_dfd(model: DFDModel) -> GDSSpec:
    """Compile a DFDModel into a GDSSpec.

    Registers: types, spaces, entities, blocks, wirings.
    """
    spec = GDSSpec(name=model.name, description=model.description)

    # 1. Register types
    spec.collect(SignalType, DataType, ContentType)

    # 2. Register spaces
    spec.collect(SignalSpace, DataSpace, ContentSpace)

    # 3. Register entities (one per data store)
    for store in model.data_stores:
        spec.register_entity(_build_store_entity(store))

    # 4. Register blocks
    for ext in model.external_entities:
        spec.register_block(_build_external_block(ext))

    for proc in model.processes:
        spec.register_block(_build_process_block(proc, model))

    for store in model.data_stores:
        spec.register_block(_build_store_mechanism(store, model))

    # 5. Register spec wirings
    all_block_names = [b.name for b in spec.blocks.values()]
    wires: list[Wire] = []

    for flow in model.data_flows:
        source_block = flow.source
        target_block = flow.target
        # Determine the space based on source type
        if flow.source in model.external_names:
            space = "DFD SignalSpace"
        elif flow.source in model.store_names:
            space = "DFD ContentSpace"
            source_block = _store_block_name(flow.source)
        else:
            space = "DFD DataSpace"

        if flow.target in model.store_names:
            target_block = _store_block_name(flow.target)

        wires.append(Wire(source=source_block, target=target_block, space=space))

    spec.register_wiring(
        SpecWiring(
            name=f"{model.name} Wiring",
            block_names=all_block_names,
            wires=wires,
            description=f"Auto-generated wiring for DFD {model.name!r}",
        )
    )

    return spec

Compile a DFDModel directly to SystemIR.

Builds the composition tree and delegates to GDS compile_system().

Source code in packages/gds-software/gds_software/dfd/compile.py
def compile_dfd_to_system(model: DFDModel) -> SystemIR:
    """Compile a DFDModel directly to SystemIR.

    Builds the composition tree and delegates to GDS compile_system().
    """
    root = _build_composition_tree(model)
    return compile_system(model.name, root)