from typing import Dict


def get_dsp_usage(PC, PF, cfg: Dict, name: str, board_cfg: Dict):
    """Calculate the DSP usage of a single layer."""
    layer_cfg = cfg["layers"][name]
    layer_type = layer_cfg["TYPE"]
    K = layer_cfg["K"]
    dsp_key = f"b{cfg['global']['BW']}w{cfg['global']['WBW']}"

    if K == 3:
        if layer_type == "STANDARD":
            return board_cfg[dsp_key]["STANDARD_3x3_DSP"] * PC * PF
        if layer_type == "DEPTHWISE_SEPARABLE":
            return (
                board_cfg[dsp_key]["DEPTHWISE_3x3_DSP"] * PC
                + board_cfg[dsp_key]["POINTWISE_DSP"] * PC * PF
            )
        assert False
    assert False