OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [testsuite/] [test-code-or1k/] [inst-set-test/] [is-find-test.S] - Diff between revs 116 and 118

Only display areas with differences | Details | Blame | View Log

Rev 116 Rev 118
/* is-find.test.S. l.ff1 and l.fl1 instruction test of Or1ksim
/* is-find.test.S. l.ff1 and l.fl1 instruction test of Or1ksim
 *
 *
 * Copyright (C) 1999-2006 OpenCores
 * Copyright (C) 1999-2006 OpenCores
 * Copyright (C) 2010 Embecosm Limited
 * Copyright (C) 2010 Embecosm Limited
 *
 *
 * Contributors various OpenCores participants
 * Contributors various OpenCores participants
 * Contributor Jeremy Bennett 
 * Contributor Jeremy Bennett 
 *
 *
 * This file is part of OpenRISC 1000 Architectural Simulator.
 * This file is part of OpenRISC 1000 Architectural Simulator.
 *
 *
 * This program is free software; you can redistribute it and/or modify it
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 3 of the License, or (at your option)
 * Software Foundation; either version 3 of the License, or (at your option)
 * any later version.
 * any later version.
 *
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * more details.
 *
 *
 * You should have received a copy of the GNU General Public License along
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see .
 * with this program.  If not, see .
 */
 */
/* ----------------------------------------------------------------------------
/* ----------------------------------------------------------------------------
 * Coding conventions are described in inst-set-test.S
 * Coding conventions are described in inst-set-test.S
 * ------------------------------------------------------------------------- */
 * ------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------------
/* ----------------------------------------------------------------------------
 * Test coverage
 * Test coverage
 *
 *
 * The l.ff1 and l.fl1 should fine the first and last bits in a register
 * The l.ff1 and l.fl1 should fine the first and last bits in a register
 * respectively.
 * respectively.
 *
 *
 * Problems in this area were reported in Bug 1772. Having fixed the problem,
 * Problems in this area were reported in Bug 1772. Having fixed the problem,
 * this is (in good software engineering style), a  regression test to go with
 * this is (in good software engineering style), a  regression test to go with
 * the fix.
 * the fix.
 *
 *
 * This is not a comprehensive test of any instruction (yet).
 * This is not a comprehensive test of any instruction (yet).
 *
 *
 * Of course what is really needed is a comprehensive instruction test...
 * Of course what is really needed is a comprehensive instruction test...
 * ------------------------------------------------------------------------- */
 * ------------------------------------------------------------------------- */
#include "inst-set-test.h"
#include "inst-set-test.h"
/* ----------------------------------------------------------------------------
/* ----------------------------------------------------------------------------
 * A macro to carry out a test of find
 * A macro to carry out a test of find
 *
 *
 * Arguments
 * Arguments
 *   opc:       The opcode
 
 *   op:        First operand value
 *   op:        First operand value
 *   res:       Expected result
 *   res:       Expected result
 *   str:       Output string
 
 * ------------------------------------------------------------------------- */
 * ------------------------------------------------------------------------- */
#define TEST_FIND(opc, op, res, str)                                     \
#define TEST_FF1(op, res)                                                \
        LOAD_CONST (r4,33)              /* Invalid result */            ;\
        LOAD_CONST (r4,33)              /* Invalid result */            ;\
        LOAD_CONST (r5,op)              /* Load number to analyse */    ;\
        LOAD_CONST (r5,op)              /* Load number to analyse */    ;\
        opc     r4,r5                                           ;\
        l.ff1   r4,r5                                                   ;\
        CHECK_RES (str, r4, res)
        PUSH    (r4)                    /* Save for later */            ;\
 
                                                                        ;\
 
        PUTS ("  ff1 (0x")                                              ;\
 
        PUTH (op)                                                       ;\
 
        PUTS (") = 0x")                                                 ;\
 
        PUTHQ (res)                                                     ;\
 
        PUTS (": ")                                                     ;\
 
                                                                        ;\
 
        CHECK_RES1 (r4, res)
 
 
 
 
 
/* ----------------------------------------------------------------------------
 
 * A macro to carry out a test of find
 
 *
 
 * Arguments
 
 *   op:        First operand value
 
 *   res:       Expected result
 
 * ------------------------------------------------------------------------- */
 
#define TEST_FL1(op, res)                                                \
 
        LOAD_CONST (r4,33)              /* Invalid result */            ;\
 
        LOAD_CONST (r5,op)              /* Load number to analyse */    ;\
 
        l.fl1   r4,r5                                                   ;\
 
        PUSH    (r4)                    /* Save for later */            ;\
 
                                                                        ;\
 
        PUTS ("  fl1 (0x")                                              ;\
 
        PUTH (op)                                                       ;\
 
        PUTS (") = 0x")                                                 ;\
 
        PUTHQ (res)                                                     ;\
 
        PUTS (": ")                                                     ;\
 
                                                                        ;\
 
        CHECK_RES1 (r4, res)
 
 
 
 
 
/* ----------------------------------------------------------------------------
 
 * Start of code
 
 * ------------------------------------------------------------------------- */
        .section .text
        .section .text
        .global _start
        .global _start
_start:
_start:
/* ----------------------------------------------------------------------------
/* ----------------------------------------------------------------------------
 * Test of find first 1, l.ff1
 * Test of find first 1, l.ff1
 * ------------------------------------------------------------------------- */
 * ------------------------------------------------------------------------- */
_ff1:
_ff1:
        LOAD_STR (r3, "l.ff1\n")
        LOAD_STR (r3, "l.ff1\n")
        l.jal   _puts
        l.jal   _puts
        l.nop
        l.nop
        /* Try a range of candidates. */
        /* Try a range of candidates. */
        TEST_FIND (l.ff1, 0x00000001,  1, "ff1 (0x00000001) =  1: ")
        TEST_FF1 (0x00000001,  1)
        TEST_FIND (l.ff1, 0x80000000, 32, "ff1 (0x80000000) = 32: ")
        TEST_FF1 (0x80000000, 32)
        TEST_FIND (l.ff1, 0x55555555,  1, "ff1 (0x55555555) =  1: ")
        TEST_FF1 (0x55555555,  1)
        TEST_FIND (l.ff1, 0xaaaaaaaa,  2, "ff1 (0xaaaaaaaa) =  2: ")
        TEST_FF1 (0xaaaaaaaa,  2)
        TEST_FIND (l.ff1, 0x00018000, 16, "ff1 (0x00018000) = 16: ")
        TEST_FF1 (0x00018000, 16)
        TEST_FIND (l.ff1, 0xc0000000, 31, "ff1 (0xc0000000) = 31: ")
        TEST_FF1 (0xc0000000, 31)
        TEST_FIND (l.ff1, 0x00000000,  0, "ff1 (0x00000000) =  0: ")
        TEST_FF1 (0x00000000,  0)
 
 
/* ----------------------------------------------------------------------------
/* ----------------------------------------------------------------------------
 * Test of find first 1, l.fl1
 * Test of find first 1, l.fl1
 * ------------------------------------------------------------------------- */
 * ------------------------------------------------------------------------- */
_fl1:
_fl1:
        LOAD_STR (r3, "l.fl1\n")
        LOAD_STR (r3, "l.fl1\n")
        l.jal   _puts
        l.jal   _puts
        l.nop
        l.nop
        /* Try a range of candidates. */
        /* Try a range of candidates. */
        TEST_FIND (l.fl1, 0x00000001,  1, "fl1 (0x00000001) =  1: ")
        TEST_FL1 (0x00000001,  1)
        TEST_FIND (l.fl1, 0x80000000, 32, "fl1 (0x80000000) = 32: ")
        TEST_FL1 (0x80000000, 32)
        TEST_FIND (l.fl1, 0x55555555, 31, "fl1 (0x55555555) = 31: ")
        TEST_FL1 (0x55555555, 31)
        TEST_FIND (l.fl1, 0xaaaaaaaa, 32, "fl1 (0xaaaaaaaa) = 32: ")
        TEST_FL1 (0xaaaaaaaa, 32)
        TEST_FIND (l.fl1, 0x00018000, 17, "fl1 (0x00018000) = 17: ")
        TEST_FL1 (0x00018000, 17)
        TEST_FIND (l.fl1, 0xc0000000, 32, "fl1 (0xc0000000) = 32: ")
        TEST_FL1 (0xc0000000, 32)
        TEST_FIND (l.fl1, 0x00000000,  0, "fl1 (0x00000000) =  0: ")
        TEST_FL1 (0x00000000,  0)
 
 
/* ----------------------------------------------------------------------------
/* ----------------------------------------------------------------------------
 * All done
 * All done
 * ------------------------------------------------------------------------- */
 * ------------------------------------------------------------------------- */
_exit:
_exit:
        LOAD_STR (r3, "Test completed\n")
        LOAD_STR (r3, "Test completed\n")
        l.jal   _puts
        l.jal   _puts
        l.nop
        l.nop
 
        TEST_EXIT
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.