def calculate_megs_per_device(config):
    """
    given config dict, calculate device density in Mbits
    """
    rows = config["dram_structure"]["rows"]
    cols = config["dram_structure"]["columns"]
    width = config["dram_structure"]["device_width"]
    bgs = config["dram_structure"]["bankgroups"]
    banks_per_group = config["dram_structure"]["banks_per_group"]
    banks = bgs * banks_per_group
    bytes_per_bank = rows * cols * width
    mega_bytes_per_device = bytes_per_bank * banks / 1024 /1024
    return mega_bytes_per_device