Esempio n. 1
0
    def generate_testcase(self, outfile, reg):
        if reg.is_readable() and reg.is_writeable():
            var_name = writer.declare_variable(outfile, "val", reg.size)
            value = 0xffffffffffffffff if reg.size == 64 else 0xffffffff

            for fs_idx, fs in enumerate(reg.fieldsets):
                for f_idx, f in enumerate(fs.fields):
                    writer.set_field(outfile, reg, f, 0)
                    writer.get_field(outfile, reg, f, var_name)

                    writer.if_statement(outfile, var_name + " == 0")

                    writer.set_field(outfile, reg, f, value, indent=1)
                    writer.get_field(outfile, reg, f, var_name, indent=1)

                    writer.if_statement(outfile, var_name + " != 0", indent=1)

                    msg = "RES0 in " + reg.name + "[%u] is settable"
                    fmt = "{es}_{rname}_{fname}_msb\n".format(
                        es=reg.execution_state
                        if reg.execution_state else "external",
                        rname=reg.name.lower(),
                        fname=f.name.lower())
                    writer.print_warning(outfile,
                                         msg,
                                         format_str=fmt,
                                         indent=2)

                    writer.endif(outfile, indent=1)
                    writer.endif(outfile)
                    writer.write_newline(outfile)
Esempio n. 2
0
    def generate_testcase(self, outfile, reg):
        if reg.is_readable():
            var1 = writer.declare_variable(outfile, "val", reg.size)

            for fs_idx, fs in enumerate(reg.fieldsets):
                for f_idx, f in enumerate(fs.fields):
                    writer.get_field(outfile, reg, f, var1)
                    writer.if_statement(outfile, var1 + " != 1")

                    msg = "RES1 field " + reg.name + "." + f.name + " != 1"
                    writer.print_warning(outfile, msg, indent=1)

                    writer.endif(outfile)
                    writer.write_newline(outfile)
Esempio n. 3
0
    def generate_testcase(self, outfile, reg):
        if reg.is_readable():
            var1 = writer.declare_variable(outfile, "val", reg.size)
            var2 = writer.declare_variable(outfile, "exceptions", reg.size)

            writer.reset_exception_counter(outfile)
            writer.get_register(outfile, reg, var1)
            writer.get_exception_counter(outfile, var2)

            writer.if_statement(outfile, var2 + " > 0")
            msg = "Reading {reg} caused an exception".format(reg=reg.name)
            writer.print_info(outfile, msg, indent=1)

            writer.else_statement(outfile)
            msg = "{reg} = 0x%016x".format(reg=reg.name)
            writer.print_info(outfile, msg, format_str=var1, indent=1)

            writer.endif(outfile)
    def generate_testcase(self, outfile, instr):
        mnemonic = instr.access_mechanisms["mrs_register"][0].operand_mnemonic
        var1 = writer.declare_variable(outfile, "exception_count", 32)
        writer.write_newline(outfile)

        writer.reset_exception_counter(outfile)
        msg = "SYS {m}, #0x0 ...".format(m=mnemonic)
        writer.print_debug(outfile, msg)
        writer.execute_sys_instruction(outfile, instr, 0x0)
        writer.get_exception_counter(outfile, var1)
        writer.if_statement(outfile, var1 + " == 0")
        msg = "SYS {m}, #0x0 executed without an exception".format(m=mnemonic)
        writer.print_warning(outfile, msg, indent=1)
        writer.endif(outfile)
        writer.write_newline(outfile)

        writer.reset_exception_counter(outfile)
        msg = "SYS {m}, #0xFFFFFFFFFFFFFFFF ...".format(m=mnemonic)
        writer.print_debug(outfile, msg)
        writer.execute_sys_instruction(outfile, instr, 0xFFFFFFFFFFFFFFFF)
        writer.get_exception_counter(outfile, var1)
        writer.if_statement(outfile, var1 + " == 0")
        msg = "SYS {m}, #0xFFFFFFFFFFFFFFFF executed without an exception".format(m=mnemonic)
        writer.print_warning(outfile, msg, indent=1)
        writer.endif(outfile)
        writer.write_newline(outfile)

        writer.reset_exception_counter(outfile)
        msg = "SYSL {m} ...".format(m=mnemonic)
        writer.print_debug(outfile, msg)
        writer.execute_sysl_instruction(outfile, instr)
        writer.get_exception_counter(outfile, var1)
        writer.if_statement(outfile, var1 + " == 0")
        msg = "SYSL {m} executed without an exception".format(m=mnemonic)
        writer.print_warning(outfile, msg, indent=1)
        writer.endif(outfile)
        writer.write_newline(outfile)

        return
    def generate_testcase(self, outfile, reg):
        var1 = writer.declare_variable(outfile, "init", reg.size)
        var2 = writer.declare_variable(outfile, "ones", reg.size)
        var3 = writer.declare_variable(outfile, "zeros", reg.size)
        var4 = writer.declare_variable(outfile, "exceptions", reg.size)
        var5 = writer.declare_variable(outfile, "read_exceptions", reg.size)
        var6 = writer.declare_variable(outfile, "write_exceptions", reg.size)

        writer.write_newline(outfile)

        msg = "Reading initial {r}...".format(r=reg.name)
        writer.print_debug(outfile, msg)
        writer.reset_exception_counter(outfile)
        writer.get_register(outfile, reg, var1)
        writer.get_exception_counter(outfile, var4)
        writer.if_statement(outfile, var4 + " > 0")
        writer.assign_variable(outfile, var5, var5 + " + " + var4, indent=1)
        writer.endif(outfile)
        writer.write_newline(outfile)

        msg = "Clearing {r}...".format(r=reg.name)
        writer.print_debug(outfile, msg)
        writer.reset_exception_counter(outfile)
        writer.set_register(outfile, reg, 0x0000000000000000)
        writer.get_exception_counter(outfile, var4)
        writer.if_statement(outfile, var4 + " > 0")
        writer.assign_variable(outfile, var6, var6 + " + " + var4, indent=1)
        writer.endif(outfile)
        writer.write_newline(outfile)

        msg = "Writing 1s to {r}...".format(r=reg.name)
        writer.print_debug(outfile, msg)
        writer.reset_exception_counter(outfile)
        writer.set_register(outfile, reg, 0xFFFFFFFFFFFFFFFF)
        writer.get_exception_counter(outfile, var4)
        writer.if_statement(outfile, var4 + " > 0")
        writer.assign_variable(outfile, var6, var6 + " + " + var4, indent=1)
        writer.endif(outfile)
        writer.write_newline(outfile)

        msg = "Reading {r}...".format(r=reg.name)
        writer.print_debug(outfile, msg)
        writer.reset_exception_counter(outfile)
        writer.get_register(outfile, reg, var2)
        writer.get_exception_counter(outfile, var4)
        writer.if_statement(outfile, var4 + " > 0")
        writer.assign_variable(outfile, var5, var5 + " + " + var4, indent=1)
        writer.endif(outfile)
        writer.write_newline(outfile)

        msg = "Writing 0s to {r}...".format(r=reg.name)
        writer.print_debug(outfile, msg)
        writer.reset_exception_counter(outfile)
        writer.set_register(outfile, reg, 0x0000000000000000)
        writer.get_exception_counter(outfile, var4)
        writer.if_statement(outfile, var4 + " > 0")
        writer.assign_variable(outfile, var6, var6 + " + " + var4, indent=1)
        writer.endif(outfile)
        writer.write_newline(outfile)

        msg = "Reading {r}...".format(r=reg.name)
        writer.print_debug(outfile, msg)
        writer.reset_exception_counter(outfile)
        writer.get_register(outfile, reg, var3)
        writer.get_exception_counter(outfile, var4)
        writer.if_statement(outfile, var4 + " > 0")
        writer.assign_variable(outfile, var5, var5 + " + " + var4, indent=1)
        writer.endif(outfile)
        writer.write_newline(outfile)

        writer.if_statement(
            outfile, var1 + " == " + var2 + " && " + var2 + " == " + var3)
        msg = "System register {r} is not writable".format(r=reg.name)
        writer.if_statement(outfile,
                            var5 + " > 0 && " + var6 + " > 0",
                            indent=1)
        writer.print_debug(outfile, msg, indent=2)
        sub_msg = "    Unimplemented / Protected: Exceptions on writes and reads"
        writer.print_debug(outfile, sub_msg, indent=2)

        writer.else_if_statement(outfile, var5 + " > 0", indent=1)
        writer.print_warning(outfile, msg, indent=2)
        sub_msg = "    Unreadable: Exceptions only on reads"
        writer.print_warning(outfile, sub_msg, indent=2)

        writer.else_if_statement(outfile, var6 + " > 0", indent=1)
        writer.print_warning(outfile, msg, indent=2)
        sub_msg = "    Unwritable: Exceptions only on writes"
        writer.print_warning(outfile, sub_msg, indent=2)

        writer.else_statement(outfile, indent=1)
        writer.print_warning(outfile, msg, indent=2)
        sub_msg = "    Static: No exceptions on reads or writes"
        writer.print_warning(outfile, sub_msg, indent=2)
        writer.endif(outfile, indent=1)

        writer.else_if_statement(
            outfile, var2 + " == 0xFFFFFFFFFFFFFFFF && " + var3 + " == 0x0")
        msg = "System register {r} is fully writable".format(r=reg.name)
        writer.print_warning(outfile, msg, indent=1)

        writer.else_statement(outfile)
        msg = "System register {r} is partially writable".format(r=reg.name)
        writer.print_warning(outfile, msg, indent=1)
        msg = "RES0 Mask: %lx"
        fmt = "~" + var2
        writer.print_warning(outfile, msg, format_str=fmt, indent=1)
        msg = "RES1 Mask: %lx"
        fmt = var3
        writer.print_warning(outfile, msg, format_str=fmt, indent=1)
        writer.endif(outfile)

        writer.write_newline(outfile)
        msg = "    {r}: %lx -> %lx -> %lx".format(r=reg.name)
        fmt = var1 + ", " + var2 + ", " + var3
        writer.print_debug(outfile, msg, format_str=fmt)

        return