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

Subversion Repositories fwrisc

[/] [fwrisc/] [trunk/] [ve/] [fwrisc/] [tests/] [riscv-compliance/] [riscv-test-suite/] [rv32i/] [src/] [I-RF_x0-01.S] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 mballance
# RISC-V Compliance Test I-RF_x0-01
2
#
3
# Copyright (c) 2017, Codasip Ltd.
4
# Copyright (c) 2018, Imperas Software Ltd. Additions
5
# All rights reserved.
6
#
7
# Redistribution and use in source and binary forms, with or without
8
# modification, are permitted provided that the following conditions are met:
9
#      * Redistributions of source code must retain the above copyright
10
#        notice, this list of conditions and the following disclaimer.
11
#      * Redistributions in binary form must reproduce the above copyright
12
#        notice, this list of conditions and the following disclaimer in the
13
#        documentation and/or other materials provided with the distribution.
14
#      * Neither the name of the Codasip Ltd., Imperas Software Ltd. nor the
15
#        names of its contributors may be used to endorse or promote products
16
#        derived from this software without specific prior written permission.
17
#
18
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
19
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Codasip Ltd., Imperas Software Ltd.
22
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
#
29
# Specification: RV32I Base Integer Instruction Set, Version 2.0
30
# Description: Testing x0 is hardwired 0.
31
 
32
#include "compliance_test.h"
33
#include "compliance_io.h"
34
#include "test_macros.h"
35
 
36
# Test Virtual Machine (TVM) used by program.
37
RV_COMPLIANCE_RV32M
38
 
39
# Test code region
40
RV_COMPLIANCE_CODE_BEGIN
41
 
42
    RVTEST_IO_INIT
43
    RVTEST_IO_ASSERT_GPR_EQ(x0, 0x00000000)
44
    RVTEST_IO_WRITE_STR("# Test Begin Reserved regs ra(x1) a0(x10) t0(x5)\n")
45
 
46
    # ---------------------------------------------------------------------------------------------
47
    RVTEST_IO_WRITE_STR("# Test part A1 - test computational instructions - register-immediate\n");
48
 
49
    # Address for test results
50
    la      x31, test_A1_res
51
 
52
    # Test
53
    lui     x0, 0xABCDE
54
    addi    x0, x0, 1
55
    ori     x0, x0, 0x7F0
56
    andi    x0, x0, 0x53F
57
    xori    x0, x0, 0xFFFFF803
58
    slli    x0, x0, 5
59
    srai    x0, x0, 2
60
    srli    x0, x0, 4
61
 
62
    # Store results
63
    sw      x0, 0(x31)
64
 
65
    //
66
    // Assert
67
    //
68
    RVTEST_IO_CHECK()
69
    RVTEST_IO_ASSERT_GPR_EQ(x0, 0x00000000)
70
 
71
    RVTEST_IO_WRITE_STR("# Test part A1  - Complete\n");
72
 
73
    # ---------------------------------------------------------------------------------------------
74
    RVTEST_IO_WRITE_STR("# Test part A2 - test computational instructions - register-register\n");
75
 
76
    # Address for test results
77
    la      x31, test_A2_res
78
 
79
    # Register initialization
80
    li      x1,  0x1
81
    li      x2,  0x7F0
82
    li      x3,  0x53F
83
    li      x4,  0xFFFFF803
84
    li      x5,  0x5
85
    li      x6,  0x2
86
    li      x7,  0x4
87
    li      x8,  0x18
88
 
89
    # Test
90
    auipc   x0, 0xABCDE
91
    add     x0, x0, x1
92
    or      x0, x0, x2
93
    and     x0, x0, x3
94
    xor     x0, x0, x4
95
    sll     x0, x0, x5
96
    sra     x0, x0, x6
97
    srl     x0, x0, x7
98
    sub     x0, x0, x8
99
 
100
    # Store results
101
    sw      x0, 0(x31)
102
 
103
    RVTEST_IO_ASSERT_GPR_EQ(x0, 0x00000000)
104
 
105
    RVTEST_IO_WRITE_STR("# Test part A2  - Complete\n");
106
 
107
    # ---------------------------------------------------------------------------------------------
108
    RVTEST_IO_WRITE_STR("# Test part A3 - test compare instructions\n");
109
 
110
    # Address for test results
111
    la      x31, test_A3_res
112
 
113
    # Register initialization
114
    li     x1,  0x1
115
    li     x2,  0x2
116
 
117
    # Test and store
118
    slt     x0, x1, x2
119
    sw      x0, 0(x31)
120
 
121
    sltu    x0, x1, x2
122
    sw      x0, 4(x31)
123
 
124
    slti    x0, x1, 2
125
    sw      x0, 8(x31)
126
 
127
    sltiu   x0, x1, 2
128
    sw      x0, 12(x31)
129
 
130
    RVTEST_IO_WRITE_STR("# Test part A3  - Complete\n");
131
 
132
    # ---------------------------------------------------------------------------------------------
133
    RVTEST_IO_WRITE_STR("# Test part A4 - test jump and link instructions\n");
134
 
135
    # Address for test results
136
    la      x31, test_A4_res
137
 
138
    # Test and store
139
    jal     x0, 1f
140
1:
141
    sw      x0, 0(x31)
142
 
143
    la      x1, 1f
144
    jalr    x0, x1, 0
145
1:
146
    sw      x0, 4(x31)
147
 
148
    RVTEST_IO_WRITE_STR("# Test part A4  - Complete\n");
149
 
150
    # ---------------------------------------------------------------------------------------------
151
    RVTEST_IO_WRITE_STR("# Test part A5 - test load instructions\n");
152
 
153
    # Addresses for test data and results
154
    la      x1, test_A5_data
155
    la      x31, test_A5_res
156
 
157
    # Test and store
158
    lw      x0, 0(x1)
159
    sw      x0, 0(x31)
160
 
161
    lh      x0, 0(x1)
162
    sw      x0, 4(x31)
163
 
164
    lb      x0, 0(x1)
165
    sw      x0, 8(x31)
166
 
167
    lbu     x0, 0(x1)
168
    sw      x0, 12(x31)
169
 
170
    RVTEST_IO_WRITE_STR("# Test part A5  - Complete\n");
171
 
172
    RVTEST_IO_WRITE_STR("# Test End\n")
173
 
174
 # ---------------------------------------------------------------------------------------------
175
    # HALT
176
    RV_COMPLIANCE_HALT
177
 
178
RV_COMPLIANCE_CODE_END
179
 
180
# Input data section.
181
    .data
182
    .align 4
183
test_A5_data:
184
    .word 0x42524E4F
185
 
186
# Output data section.
187
RV_COMPLIANCE_DATA_BEGIN
188
    .align 4
189
 
190
test_A1_res:
191
    .fill 1, 4, -1
192
test_A2_res:
193
    .fill 1, 4, -1
194
test_A3_res:
195
    .fill 4, 4, -1
196
test_A4_res:
197
    .fill 2, 4, -1
198
test_A5_res:
199
    .fill 4, 4, -1
200
 
201
RV_COMPLIANCE_DATA_END

powered by: WebSVN 2.1.0

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