1 #include "riscv_test.h"
2 #include "sv_test_macros.h"
4 RVTEST_RV64U # Define TVM used by program.
6 // TODO: add extra "code" argument and "testdata" argument,
7 // replace "addw" with "code"
8 // TODO: move SV_ELWIDTH_TEST to sv_test_macros.h
9 // TODO: probably remove testing of x15 and x16 (or pass in as extra args?)
11 #define SV_ELWIDTH_TEST( wid1, wid2, wid3, expect1, expect2, expect3 ) \
13 SV_LDD_DATA( x12, testdata , 0); \
14 SV_LDD_DATA( x13, testdata+8 , 0); \
15 SV_LDD_DATA( x14, testdata+16, 0); \
16 SV_LDD_DATA( x15, testdata+24, 0); \
17 SV_LDD_DATA( x16, testdata+32, 0); \
18 SV_LDD_DATA( x17, testdata+40, 0); \
20 li x28, 0xa5a5a5a5a5a5a5a5; \
21 li x29, 0xa5a5a5a5a5a5a5a5; \
22 li x30, 0xa5a5a5a5a5a5a5a5; \
25 SET_SV_3CSRS( SV_REG_CSR( 1, 15, wid1, 15, 1), \
26 SV_REG_CSR( 1, 12, wid2, 12, 1), \
27 SV_REG_CSR( 1, 28, wid3, 28, 1)); \
36 TEST_SV_IMM( x28, expect1 ); \
37 TEST_SV_IMM( x29, expect2 ); \
38 TEST_SV_IMM( x30, expect3 ); \
39 TEST_SV_IMM( x15, 0x0000005242322212); \
40 TEST_SV_IMM( x16, 0x0000005141312111);
43 # SV test: vector-vector add
45 # sets up x3 and x4 with data, sets VL to 2, and carries out
46 # an "add 1 to x3". which actually means "add 1 to x3 *AND* add 1 to x4"
49 RVTEST_CODE_BEGIN # Start of test code.
51 # TODO: add "addw" argument, add testdata argument
52 SV_ELWIDTH_TEST( 0, 0, 0,
53 0xffffffff8b6bab8b, 0xffffffff88684828, 0x0000000000000000 )
54 SV_ELWIDTH_TEST( 0, 0, 3,
55 0x886848288b6bab8b, 0xa5a5a5a500000000, 0xa5a5a5a5a5a5a5a5 )
56 SV_ELWIDTH_TEST( 1, 1, 0,
57 0xffffffffffffff8b, 0xffffffffffffffab, 0x000000000000006b )
58 SV_ELWIDTH_TEST( 1, 1, 3,
59 0xffffffabffffff8b, 0xa5a5a5a50000006b, 0xa5a5a5a5a5a5a5a5 )
60 SV_ELWIDTH_TEST( 1, 1, 2,
61 0xa5a5006bffabff8b, 0xa5a5a5a5a5a5a5a5, 0xa5a5a5a5a5a5a5a5 )
62 SV_ELWIDTH_TEST( 1, 1, 1,
63 0xa5a5a5a5a56bab8b, 0xa5a5a5a5a5a5a5a5, 0xa5a5a5a5a5a5a5a5 )
65 RVTEST_PASS # Signal success.
68 RVTEST_CODE_END # End of test code.
71 # This section is optional, and this data is NOT saved in the output.
75 .dword 0x0000005949398979
76 .dword 0x0000005747372717
77 .dword 0x0000000000000000
78 .dword 0x0000005242322212
79 .dword 0x0000005141312111
80 .dword 0x0000000000000000
82 # Output data section.
83 RVTEST_DATA_BEGIN # Start of test output data region.
89 RVTEST_DATA_END # End of test output data region.