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] - Blame information for rev 346

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
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
 *   op:        First operand value
52
 *   res:       Expected result
53
 * ------------------------------------------------------------------------- */
54 118 jeremybenn
#define TEST_FF1(op, res)                                                \
55 115 jeremybenn
        LOAD_CONST (r4,33)              /* Invalid result */            ;\
56
        LOAD_CONST (r5,op)              /* Load number to analyse */    ;\
57 118 jeremybenn
        l.ff1   r4,r5                                                   ;\
58
        PUSH    (r4)                    /* Save for later */            ;\
59
                                                                        ;\
60
        PUTS ("  ff1 (0x")                                              ;\
61
        PUTH (op)                                                       ;\
62
        PUTS (") = 0x")                                                 ;\
63
        PUTHQ (res)                                                     ;\
64
        PUTS (": ")                                                     ;\
65
                                                                        ;\
66
        CHECK_RES1 (r4, res)
67 115 jeremybenn
 
68
 
69 118 jeremybenn
/* ----------------------------------------------------------------------------
70
 * A macro to carry out a test of find
71
 *
72
 * Arguments
73
 *   op:        First operand value
74
 *   res:       Expected result
75
 * ------------------------------------------------------------------------- */
76
#define TEST_FL1(op, res)                                                \
77
        LOAD_CONST (r4,33)              /* Invalid result */            ;\
78
        LOAD_CONST (r5,op)              /* Load number to analyse */    ;\
79
        l.fl1   r4,r5                                                   ;\
80
        PUSH    (r4)                    /* Save for later */            ;\
81
                                                                        ;\
82
        PUTS ("  fl1 (0x")                                              ;\
83
        PUTH (op)                                                       ;\
84
        PUTS (") = 0x")                                                 ;\
85
        PUTHQ (res)                                                     ;\
86
        PUTS (": ")                                                     ;\
87
                                                                        ;\
88
        CHECK_RES1 (r4, res)
89
 
90
 
91
/* ----------------------------------------------------------------------------
92
 * Start of code
93
 * ------------------------------------------------------------------------- */
94 115 jeremybenn
        .section .text
95
        .global _start
96
_start:
97
 
98
/* ----------------------------------------------------------------------------
99
 * Test of find first 1, l.ff1
100
 * ------------------------------------------------------------------------- */
101
_ff1:
102
        LOAD_STR (r3, "l.ff1\n")
103
        l.jal   _puts
104
        l.nop
105
 
106
        /* Try a range of candidates. */
107 118 jeremybenn
        TEST_FF1 (0x00000001,  1)
108
        TEST_FF1 (0x80000000, 32)
109
        TEST_FF1 (0x55555555,  1)
110
        TEST_FF1 (0xaaaaaaaa,  2)
111
        TEST_FF1 (0x00018000, 16)
112
        TEST_FF1 (0xc0000000, 31)
113
        TEST_FF1 (0x00000000,  0)
114 115 jeremybenn
 
115
/* ----------------------------------------------------------------------------
116
 * Test of find first 1, l.fl1
117
 * ------------------------------------------------------------------------- */
118
_fl1:
119
        LOAD_STR (r3, "l.fl1\n")
120
        l.jal   _puts
121
        l.nop
122
 
123
        /* Try a range of candidates. */
124 118 jeremybenn
        TEST_FL1 (0x00000001,  1)
125
        TEST_FL1 (0x80000000, 32)
126
        TEST_FL1 (0x55555555, 31)
127
        TEST_FL1 (0xaaaaaaaa, 32)
128
        TEST_FL1 (0x00018000, 17)
129
        TEST_FL1 (0xc0000000, 32)
130
        TEST_FL1 (0x00000000,  0)
131 115 jeremybenn
 
132
/* ----------------------------------------------------------------------------
133
 * All done
134
 * ------------------------------------------------------------------------- */
135
_exit:
136
        LOAD_STR (r3, "Test completed\n")
137
        l.jal   _puts
138
        l.nop
139
 
140 118 jeremybenn
        TEST_EXIT

powered by: WebSVN 2.1.0

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