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

Subversion Repositories fwrisc

[/] [fwrisc/] [trunk/] [ve/] [fwrisc/] [tests/] [riscv-compliance/] [riscv-test-suite/] [rv32ua/] [rv64ua/] [lrsc.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
# lrsr.S
5
#-----------------------------------------------------------------------------
6
#
7
# Test LR/SC instructions.
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
# get a unique core id
20
la a0, coreid
21
li a1, 1
22
amoadd.w a2, a1, (a0)
23
 
24
# for now, only run this on core 0
25
1:li a3, 1
26
bgeu a2, a3, 1b
27
 
28
1: lw a1, (a0)
29
bltu a1, a3, 1b
30
 
31
# make sure that sc without a reservation fails.
32
TEST_CASE( 2, a4, 1, \
33
  la a0, foo; \
34
  sc.w a4, x0, (a0); \
35
)
36
 
37
# make sure that sc with the wrong reservation fails.
38
# TODO is this actually mandatory behavior?
39
TEST_CASE( 3, a4, 1, \
40
  la a0, foo; \
41
  la a1, fooTest3; \
42
  lr.w a1, (a1); \
43
  sc.w a4, a1, (a0); \
44
)
45
 
46
#define LOG_ITERATIONS 10
47
 
48
# have each core add its coreid+1 to foo 1024 times
49
la a0, foo
50
li a1, 1<
51
addi a2, a2, 1
52
1: lr.w a4, (a0)
53
add a4, a4, a2
54
sc.w a4, a4, (a0)
55
bnez a4, 1b
56
add a1, a1, -1
57
bnez a1, 1b
58
 
59
# wait for all cores to finish
60
la a0, barrier
61
li a1, 1
62
amoadd.w x0, a1, (a0)
63
1: lw a1, (a0)
64
blt a1, a3, 1b
65
fence
66
 
67
# expected result is 512*ncores*(ncores+1)
68
TEST_CASE( 4, a0, 0, \
69
  lw a0, foo; \
70
  slli a1, a3, LOG_ITERATIONS-1; \
71
1:sub a0, a0, a1; \
72
  addi a3, a3, -1; \
73
  bgez a3, 1b
74
)
75
 
76
# make sure that sc-after-successful-sc fails.
77
TEST_CASE( 5, a1, 1, \
78
  la a0, foo; \
79
1:lr.w a1, (a0); \
80
  sc.w a1, x0, (a0); \
81
  bnez a1, 1b; \
82
  sc.w a1, x0, (a0)
83
)
84
 
85
TEST_PASSFAIL
86
 
87
RVTEST_CODE_END
88
 
89
  .data
90
 
91
  TEST_DATA
92
 
93
coreid: .word 0
94
barrier: .word 0
95
foo: .word 0
96
.skip 1024
97
fooTest3: .word 0
98
 
99
RV_COMPLIANCE_DATA_BEGIN
100
test_res:
101
    .fill 40, 4, -1
102
RV_COMPLIANCE_DATA_END
103
 

powered by: WebSVN 2.1.0

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