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

Subversion Repositories fwrisc

[/] [fwrisc/] [trunk/] [ve/] [fwrisc/] [tests/] [riscv-compliance/] [riscv-test-suite/] [rv32uc/] [rv64uc/] [rvc.S] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 mballance
# See LICENSE for license details.
2
 
3
#*****************************************************************************
4
# rvc.S
5
#-----------------------------------------------------------------------------
6
#
7
# Test RVC corner cases.
8
#
9
 
10
#include "riscv_test.h"
11
#include "compliance_test.h"
12
#include "compliance_io.h"
13
#include "aw_test_macros.h"
14
 
15
 
16
RVTEST_RV64U
17
RVTEST_CODE_BEGIN
18
 
19
  .align 2
20
  .option push
21
  .option norvc
22
 
23
  #define RVC_TEST_CASE(n, r, v, code...) \
24
    TEST_CASE (n, r, v, .option push; .option rvc; code; .align 2; .option pop)
25
 
26
  // Make sure fetching a 4-byte instruction across a page boundary works.
27
  li TESTNUM, 2
28
  li a1, 666
29
  TEST_CASE (2, a1, 667, \
30
        j 1f; \
31
        .align 3; \
32
        data: \
33
          .dword 0xfedcba9876543210; \
34
          .dword 0xfedcba9876543210; \
35
        .align 12; \
36
        .skip 4094; \
37
      1: addi a1, a1, 1)
38
 
39
  li sp, 0x1234
40
  RVC_TEST_CASE (3, a0, 0x1234 + 1020, c.addi4spn a0, sp, 1020)
41
  RVC_TEST_CASE (4, sp, 0x1234 + 496, c.addi16sp sp, 496)
42
  RVC_TEST_CASE (5, sp, 0x1234 + 496 - 512, c.addi16sp sp, -512)
43
 
44
  la a1, data
45
  RVC_TEST_CASE (6, a2, 0xfffffffffedcba99, c.lw a0, 4(a1); addi a0, a0, 1; c.sw a0, 4(a1); c.lw a2, 4(a1))
46
#if __riscv_xlen == 64
47
  RVC_TEST_CASE (7, a2, 0xfedcba9976543211, c.ld a0, 0(a1); addi a0, a0, 1; c.sd a0, 0(a1); c.ld a2, 0(a1))
48
#endif
49
 
50
  RVC_TEST_CASE (8, a0, -15, ori a0, x0, 1; c.addi a0, -16)
51
  RVC_TEST_CASE (9, a5, -16, ori a5, x0, 1; c.li a5, -16)
52
#if __riscv_xlen == 64
53
  RVC_TEST_CASE (10, a0, 0x76543210, ld a0, (a1); c.addiw a0, -1)
54
#endif
55
 
56
  RVC_TEST_CASE (11, s0, 0xffffffffffffffe1, c.lui s0, 0xfffe1; c.srai s0, 12)
57
#if __riscv_xlen == 64
58
  RVC_TEST_CASE (12, s0, 0x000fffffffffffe1, c.lui s0, 0xfffe1; c.srli s0, 12)
59
#else
60
  RVC_TEST_CASE (12, s0, 0x000fffe1, c.lui s0, 0xfffe1; c.srli s0, 12)
61
#endif
62
  RVC_TEST_CASE (14, s0, ~0x11, c.li s0, -2; c.andi s0, ~0x10)
63
  RVC_TEST_CASE (15, s1, 14, li s1, 20; li a0, 6; c.sub s1, a0)
64
  RVC_TEST_CASE (16, s1, 18, li s1, 20; li a0, 6; c.xor s1, a0)
65
  RVC_TEST_CASE (17, s1, 22, li s1, 20; li a0, 6; c.or s1, a0)
66
  RVC_TEST_CASE (18, s1,  4, li s1, 20; li a0, 6; c.and s1, a0)
67
#if __riscv_xlen == 64
68
  RVC_TEST_CASE (19, s1, 0xffffffff80000000, li s1, 0x7fffffff; li a0, -1; c.subw s1, a0)
69
  RVC_TEST_CASE (20, s1, 0xffffffff80000000, li s1, 0x7fffffff; li a0, 1; c.addw s1, a0)
70
#endif
71
  RVC_TEST_CASE (21, s0, 0x12340, li s0, 0x1234; c.slli s0, 4)
72
 
73
  RVC_TEST_CASE (30, ra, 0, \
74
        li ra, 0; \
75
        c.j 1f; \
76
        c.j 2f; \
77
      1:c.j 1f; \
78
      2:j fail; \
79
      1:)
80
 
81
  RVC_TEST_CASE (31, x0, 0, \
82
        li a0, 0; \
83
        c.beqz a0, 1f; \
84
        c.j 2f; \
85
      1:c.j 1f; \
86
      2:j fail; \
87
      1:)
88
 
89
  RVC_TEST_CASE (32, x0, 0, \
90
        li a0, 1; \
91
        c.bnez a0, 1f; \
92
        c.j 2f; \
93
      1:c.j 1f; \
94
      2:j fail; \
95
      1:)
96
 
97
  RVC_TEST_CASE (33, x0, 0, \
98
        li a0, 1; \
99
        c.beqz a0, 1f; \
100
        c.j 2f; \
101
      1:c.j fail; \
102
      2:)
103
 
104
  RVC_TEST_CASE (34, x0, 0, \
105
        li a0, 0; \
106
        c.bnez a0, 1f; \
107
        c.j 2f; \
108
      1:c.j fail; \
109
      2:)
110
 
111
  RVC_TEST_CASE (35, ra, 0, \
112
        la t0, 1f; \
113
        li ra, 0; \
114
        c.jr t0; \
115
        c.j 2f; \
116
      1:c.j 1f; \
117
      2:j fail; \
118
      1:)
119
 
120
  RVC_TEST_CASE (36, ra, -2, \
121
        la t0, 1f; \
122
        li ra, 0; \
123
        c.jalr t0; \
124
        c.j 2f; \
125
      1:c.j 1f; \
126
      2:j fail; \
127
      1:sub ra, ra, t0)
128
 
129
#if __riscv_xlen == 32
130
  RVC_TEST_CASE (37, ra, -2, \
131
        la t0, 1f; \
132
        li ra, 0; \
133
        c.jal 1f; \
134
        c.j 2f; \
135
      1:c.j 1f; \
136
      2:j fail; \
137
      1:sub ra, ra, t0)
138
#endif
139
 
140
  la sp, data
141
  RVC_TEST_CASE (40, a2, 0xfffffffffedcba99, c.lwsp a0, 12(sp); addi a0, a0, 1; c.swsp a0, 12(sp); c.lwsp a2, 12(sp))
142
#if __riscv_xlen == 64
143
  RVC_TEST_CASE (41, a2, 0xfedcba9976543211, c.ldsp a0, 8(sp); addi a0, a0, 1; c.sdsp a0, 8(sp); c.ldsp a2, 8(sp))
144
#endif
145
 
146
  RVC_TEST_CASE (42, t0, 0x246, li a0, 0x123; c.mv t0, a0; c.add t0, a0)
147
 
148
  .option pop
149
 
150
  TEST_PASSFAIL
151
 
152
RVTEST_CODE_END
153
 
154
  .data
155
RV_COMPLIANCE_DATA_BEGIN
156
test_res:
157
    .fill 48, 4, -1
158
RV_COMPLIANCE_DATA_END
159
 

powered by: WebSVN 2.1.0

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