1 |
2 |
mballance |
# RISC-V Compliance Test I-ENDIANESS-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 ENDIANESS of RISC-V processor.
|
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 A - test loading word by LW, LH, LB\n");
|
48 |
|
|
|
49 |
|
|
# Addresses for test data and results
|
50 |
|
|
la x16, test_A_data
|
51 |
|
|
la x17, test_A_res
|
52 |
|
|
|
53 |
|
|
# Test
|
54 |
|
|
lw x1, 0(x16)
|
55 |
|
|
lhu x2, 0(x16)
|
56 |
|
|
lhu x3, 2(x16)
|
57 |
|
|
lbu x4, -1(x16)
|
58 |
|
|
lbu x5, 0(x16)
|
59 |
|
|
lbu x6, 1(x16)
|
60 |
|
|
lbu x7, 2(x16)
|
61 |
|
|
lbu x8, 3(x16)
|
62 |
|
|
|
63 |
|
|
# Store results
|
64 |
|
|
sw x1, 0(x17)
|
65 |
|
|
sw x2, 4(x17)
|
66 |
|
|
sw x3, 8(x17)
|
67 |
|
|
sw x4, 12(x17)
|
68 |
|
|
sw x5, 16(x17)
|
69 |
|
|
sw x6, 20(x17)
|
70 |
|
|
sw x7, 24(x17)
|
71 |
|
|
sw x8, 28(x17)
|
72 |
|
|
|
73 |
|
|
//
|
74 |
|
|
// Assert
|
75 |
|
|
//
|
76 |
|
|
RVTEST_IO_CHECK()
|
77 |
|
|
#RVTEST_IO_ASSERT_GPR_EQ(x1, 0x80000270)
|
78 |
|
|
RVTEST_IO_ASSERT_GPR_EQ(x2, 0x00004567)
|
79 |
|
|
RVTEST_IO_ASSERT_GPR_EQ(x3, 0x00000123)
|
80 |
|
|
RVTEST_IO_ASSERT_GPR_EQ(x4, 0x00000089)
|
81 |
|
|
RVTEST_IO_ASSERT_GPR_EQ(x5, 0x00000045)
|
82 |
|
|
RVTEST_IO_ASSERT_GPR_EQ(x6, 0x00000045)
|
83 |
|
|
RVTEST_IO_ASSERT_GPR_EQ(x7, 0x00000023)
|
84 |
|
|
RVTEST_IO_ASSERT_GPR_EQ(x8, 0x00000001)
|
85 |
|
|
|
86 |
|
|
RVTEST_IO_WRITE_STR("# Test part A1 - Complete\n");
|
87 |
|
|
|
88 |
|
|
RVTEST_IO_WRITE_STR("# Test End\n")
|
89 |
|
|
|
90 |
|
|
# ---------------------------------------------------------------------------------------------
|
91 |
|
|
# HALT
|
92 |
|
|
RV_COMPLIANCE_HALT
|
93 |
|
|
|
94 |
|
|
RV_COMPLIANCE_CODE_END
|
95 |
|
|
|
96 |
|
|
# Input data section.
|
97 |
|
|
.data
|
98 |
|
|
.align 4
|
99 |
|
|
.word 0x89ABCDEF
|
100 |
|
|
test_A_data:
|
101 |
|
|
.word 0x01234567
|
102 |
|
|
|
103 |
|
|
# Output data section.
|
104 |
|
|
RV_COMPLIANCE_DATA_BEGIN
|
105 |
|
|
.align 4
|
106 |
|
|
|
107 |
|
|
test_A_res:
|
108 |
|
|
.fill 8, 4, -1
|
109 |
|
|
|
110 |
|
|
RV_COMPLIANCE_DATA_END
|