| 1 |
115 |
jeremybenn |
/* is-find.test.S. l.ff1 and l.fl1 instruction test of Or1ksim
|
| 2 |
|
|
*
|
| 3 |
|
|
* Copyright (C) 1999-2006 OpenCores
|
| 4 |
|
|
* Copyright (C) 2010 Embecosm Limited
|
| 5 |
|
|
*
|
| 6 |
|
|
* Contributors various OpenCores participants
|
| 7 |
|
|
* Contributor Jeremy Bennett
|
| 8 |
|
|
*
|
| 9 |
|
|
* This file is part of OpenRISC 1000 Architectural Simulator.
|
| 10 |
|
|
*
|
| 11 |
|
|
* This program is free software; you can redistribute it and/or modify it
|
| 12 |
|
|
* under the terms of the GNU General Public License as published by the Free
|
| 13 |
|
|
* Software Foundation; either version 3 of the License, or (at your option)
|
| 14 |
|
|
* any later version.
|
| 15 |
|
|
*
|
| 16 |
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
| 17 |
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
| 18 |
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
| 19 |
|
|
* more details.
|
| 20 |
|
|
*
|
| 21 |
|
|
* You should have received a copy of the GNU General Public License along
|
| 22 |
|
|
* with this program. If not, see .
|
| 23 |
|
|
*/
|
| 24 |
|
|
|
| 25 |
|
|
/* ----------------------------------------------------------------------------
|
| 26 |
116 |
jeremybenn |
* Coding conventions are described in inst-set-test.S
|
| 27 |
115 |
jeremybenn |
* ------------------------------------------------------------------------- */
|
| 28 |
|
|
|
| 29 |
|
|
/* ----------------------------------------------------------------------------
|
| 30 |
|
|
* Test coverage
|
| 31 |
|
|
*
|
| 32 |
|
|
* The l.ff1 and l.fl1 should fine the first and last bits in a register
|
| 33 |
|
|
* respectively.
|
| 34 |
|
|
*
|
| 35 |
|
|
* Problems in this area were reported in Bug 1772. Having fixed the problem,
|
| 36 |
|
|
* this is (in good software engineering style), a regression test to go with
|
| 37 |
|
|
* the fix.
|
| 38 |
|
|
*
|
| 39 |
|
|
* This is not a comprehensive test of any instruction (yet).
|
| 40 |
|
|
*
|
| 41 |
|
|
* Of course what is really needed is a comprehensive instruction test...
|
| 42 |
|
|
* ------------------------------------------------------------------------- */
|
| 43 |
|
|
|
| 44 |
|
|
|
| 45 |
|
|
#include "inst-set-test.h"
|
| 46 |
|
|
|
| 47 |
|
|
/* ----------------------------------------------------------------------------
|
| 48 |
|
|
* A macro to carry out a test of find
|
| 49 |
|
|
*
|
| 50 |
|
|
* Arguments
|
| 51 |
|
|
* opc: The opcode
|
| 52 |
|
|
* op: First operand value
|
| 53 |
|
|
* res: Expected result
|
| 54 |
|
|
* str: Output string
|
| 55 |
|
|
* ------------------------------------------------------------------------- */
|
| 56 |
|
|
#define TEST_FIND(opc, op, res, str) \
|
| 57 |
|
|
LOAD_CONST (r4,33) /* Invalid result */ ;\
|
| 58 |
|
|
LOAD_CONST (r5,op) /* Load number to analyse */ ;\
|
| 59 |
|
|
opc r4,r5 ;\
|
| 60 |
|
|
CHECK_RES (str, r4, res)
|
| 61 |
|
|
|
| 62 |
|
|
|
| 63 |
|
|
.section .text
|
| 64 |
|
|
.global _start
|
| 65 |
|
|
_start:
|
| 66 |
|
|
|
| 67 |
|
|
/* ----------------------------------------------------------------------------
|
| 68 |
|
|
* Test of find first 1, l.ff1
|
| 69 |
|
|
* ------------------------------------------------------------------------- */
|
| 70 |
|
|
_ff1:
|
| 71 |
|
|
LOAD_STR (r3, "l.ff1\n")
|
| 72 |
|
|
l.jal _puts
|
| 73 |
|
|
l.nop
|
| 74 |
|
|
|
| 75 |
|
|
/* Try a range of candidates. */
|
| 76 |
|
|
TEST_FIND (l.ff1, 0x00000001, 1, "ff1 (0x00000001) = 1: ")
|
| 77 |
|
|
TEST_FIND (l.ff1, 0x80000000, 32, "ff1 (0x80000000) = 32: ")
|
| 78 |
|
|
TEST_FIND (l.ff1, 0x55555555, 1, "ff1 (0x55555555) = 1: ")
|
| 79 |
|
|
TEST_FIND (l.ff1, 0xaaaaaaaa, 2, "ff1 (0xaaaaaaaa) = 2: ")
|
| 80 |
|
|
TEST_FIND (l.ff1, 0x00018000, 16, "ff1 (0x00018000) = 16: ")
|
| 81 |
|
|
TEST_FIND (l.ff1, 0xc0000000, 31, "ff1 (0xc0000000) = 31: ")
|
| 82 |
|
|
TEST_FIND (l.ff1, 0x00000000, 0, "ff1 (0x00000000) = 0: ")
|
| 83 |
|
|
|
| 84 |
|
|
/* ----------------------------------------------------------------------------
|
| 85 |
|
|
* Test of find first 1, l.fl1
|
| 86 |
|
|
* ------------------------------------------------------------------------- */
|
| 87 |
|
|
_fl1:
|
| 88 |
|
|
LOAD_STR (r3, "l.fl1\n")
|
| 89 |
|
|
l.jal _puts
|
| 90 |
|
|
l.nop
|
| 91 |
|
|
|
| 92 |
|
|
/* Try a range of candidates. */
|
| 93 |
|
|
TEST_FIND (l.fl1, 0x00000001, 1, "fl1 (0x00000001) = 1: ")
|
| 94 |
|
|
TEST_FIND (l.fl1, 0x80000000, 32, "fl1 (0x80000000) = 32: ")
|
| 95 |
|
|
TEST_FIND (l.fl1, 0x55555555, 31, "fl1 (0x55555555) = 31: ")
|
| 96 |
|
|
TEST_FIND (l.fl1, 0xaaaaaaaa, 32, "fl1 (0xaaaaaaaa) = 32: ")
|
| 97 |
|
|
TEST_FIND (l.fl1, 0x00018000, 17, "fl1 (0x00018000) = 17: ")
|
| 98 |
|
|
TEST_FIND (l.fl1, 0xc0000000, 32, "fl1 (0xc0000000) = 32: ")
|
| 99 |
|
|
TEST_FIND (l.fl1, 0x00000000, 0, "fl1 (0x00000000) = 0: ")
|
| 100 |
|
|
|
| 101 |
|
|
/* ----------------------------------------------------------------------------
|
| 102 |
|
|
* All done
|
| 103 |
|
|
* ------------------------------------------------------------------------- */
|
| 104 |
|
|
_exit:
|
| 105 |
|
|
LOAD_STR (r3, "Test completed\n")
|
| 106 |
|
|
l.jal _puts
|
| 107 |
|
|
l.nop
|
| 108 |
|
|
|
| 109 |
|
|
TEST_EXIT
|