def fixup_cell_names(design):
    """
    Scans Yosys' JSON data structure and replaces cell instance names that
    contains dots in names with other character.
    """

    # Process modules
    modules = design["modules"]
    for mod_name, mod_data in modules.items():
        print(mod_name)

        # Process cells
        cells = mod_data["cells"]
        for cell_name in list(cells.keys()):

            # Fixup name
            if "." in cell_name:
                new_name = cell_name.replace(".", "_")
                assert new_name not in cells, new_name

                cells[new_name] = cells[cell_name]
                del cells[cell_name]

    return design