

def translate(model, o=sys.stdout, enable_blackbox=False, verilator_xinit='zeros'):
    translation_queue = collections.OrderedDict()
    append_queue = []

    def collect_all_models(m):
        translation_queue[m.class_name] = m
        for subm in m.get_submodules():
            collect_all_models(subm)
    collect_all_models(model)
    for (k, v) in translation_queue.items():
        if isinstance(v, verilog.VerilogModel):
            x = verilog.import_module(v, o)
            if (x not in append_queue):
                append_queue.append(x)
        else:
            translate_module(v, o, enable_blackbox, verilator_xinit)
    verilog.import_sources(append_queue, o)

dataset/ETHPy150Open cornell-brg/pymtl/pymtl/tools/translation/verilog.py translate/original