def print_c_header_block(block, out_path):

    LOGGER.debug("Print block %s C header...", block.block_type)

    file_name = get_filename(out_path, block)

    if os.path.exists(file_name):
        os.remove(file_name)

    c_structs = generate_array_structs(block.registers)

    struct_fields = generate_struct_fields(block.registers)

    pos_mask_macros = generate_pos_mask_macros(block.registers)

    template = get_template("c_header_block.h")

    content = template.render({
        "block_type": block.block_type,
        "c_structs": c_structs,
        "struct_fields": struct_fields,
        "pos_mask_macros": pos_mask_macros
    })

    with open(file_name, "w") as bfh:
        bfh.write(content)

    return
def print_c_header_sys(top_sys, out_path):
    LOGGER.debug("Print top sys C header...")

    file_name = os.path.join(out_path, "regs_" + top_sys.name.lower() + ".h")

    if os.path.exists(file_name):
        os.remove(file_name)

    include_macro_name = "REGS_" + top_sys.name.upper() + "_H"
    include_filenames = []
    for block in top_sys.blocks:
        include_filename = "regs_" + block.block_type.lower() + ".h"
        include_filenames.append(include_filename)

    block_instances_data = []
    for block_instance in top_sys.block_instances:
        block_instances_data.append({
            "name": block_instance.name.upper(),
            "base_address": block_instance.base_address,
            "type": block_instance.block_type
        })

    template = get_template("c_header_sys.h")

    content = template.render({
        "include_macro_name": include_macro_name,
        "include_filenames": include_filenames,
        "block_instances": block_instances_data
    })

    with open(file_name, "w") as sfh:
        sfh.write(content)

    return
def print_uvm_block(block, out_path):
    uvm_block_name = block.block_type.lower() + "_reg_model"
    file_name = os.path.join(out_path, uvm_block_name + ".sv")

    if os.path.exists(file_name):
        os.remove(file_name)

    template = get_template("reg_model.sv")

    registers = get_full_registers(block.registers)

    structs = get_struct_list(block.registers)

    uvm_block = get_uvm_block(block)

    content = template.render({
        "uvm_block": uvm_block,
        "address_width": block.addr_width,
        "data_width": block.data_width,
        "registers": registers,
        "structs": structs
    })

    with open(file_name, "w") as bfh:
        bfh.write(content)

    return
def print_c_test(top_sys, out_path):
    LOGGER.debug("Print top sys C test...")

    file_name = os.path.join(
        out_path,
        "test.c")

    if os.path.exists(file_name):
        os.remove(file_name)

    template = get_template("c_test.c")

    test_parameters_list = []
    for block_instance in top_sys.block_instances:
        test_parameters = generate_test_parameters(block_instance)
        test_parameters_list.append(test_parameters)

    content = template.render(
        {
            "test_parameters_list": test_parameters_list
        }
    )

    with open(file_name, "w") as sfh:
        sfh.write(content)

    return
def print_uvm_sys(top_sys, out_path):
    uvm_sys_name = top_sys.name.lower() + "_reg_model"
    file_name = os.path.join(
        out_path,
        uvm_sys_name + ".sv")

    if os.path.exists(file_name):
        os.remove(file_name)

    template = get_template("sys_model.sv")

    content = template.render(
        {
            "top_sys": top_sys
        }
    )

    with open(file_name, "w") as bfh:
        bfh.write(content)

    return
Example #6
0
def print_sv_defines(top_sys, out_path):

    LOGGER.debug("Print register_defines.svh")

    sv_def_name = top_sys.name.lower() + "_register_defines"
    file_name = os.path.join(out_path, sv_def_name + ".svh")

    if os.path.exists(file_name):
        os.remove(file_name)

    template = get_template("register_defines.svh")

    instances = get_instances(top_sys.block_instances)

    content = template.render({
        "sv_def_name": top_sys.name.lower() + "_register_defines",
        "instances": instances
    })

    LOGGER.debug("Output to %s", file_name)
    with open(file_name, "w") as bfh:
        bfh.write(content)

    return