Skip to content

Commit cdaeec2

Browse files
test: add rriwinz test
1 parent febf7a4 commit cdaeec2

97 files changed

Lines changed: 18798 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

sims/verilator/run_prog/configure.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ echo " --run software set software list(use ',' select multiple so
1616
c_prg/loop_induction c_prg/minmax_sequence c_prg/product_sequence
1717
nscscc_func nscscc_perf
1818
my_coremark fireye/my_A0
19+
nscscc2025_rriwinz
1920
"
2021
echo " --disable-trace-comp disable trace compare in simulation(default: enable)
2122
"
@@ -514,6 +515,12 @@ do
514515
mkdir -p ./obj/
515516
mkdir -p ./log/
516517
;;
518+
nscscc2025_rriwinz)
519+
RUN_FUNC=y
520+
DEAD_CLOCK_EN=y
521+
mkdir -p ./obj/
522+
mkdir -p ./log/
523+
;;
517524
*)
518525
echo "Software $software unavailable!!"
519526
exit
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
obj_path = ./obj
2+
inst_srcs = $(wildcard ./inst/*.S)
3+
EXP = 24
4+
5+
default:
6+
make all
7+
make tidy
8+
@echo "=====\nNote: do \"make EXP=N\"(N={0,6-16,18-19,21-23}) for corresponding EXP\n====="
9+
10+
all:
11+
mkdir -p ${obj_path}
12+
make ${obj_path}/inst_ram.coe ${obj_path}/test.s
13+
14+
tidy:
15+
rm -f ${obj_path}/convert ${obj_path}/main.data ${obj_path}/data_ram.coe ${obj_path}/data_ram.mif
16+
rm -f ${obj_path}/start.s ${obj_path}/start.o ${obj_path}/init.s ${obj_path}/init.o
17+
make -C inst clean
18+
19+
${obj_path}/test.s: ${obj_path}/main.elf
20+
loongarch32r-linux-gnusf-objdump -alD ${obj_path}/main.elf > ${obj_path}/test.s
21+
22+
${obj_path}/libinst.a: ${inst_srcs}
23+
make -C inst EXP=$(EXP) libinst.a
24+
25+
${obj_path}/start.o: ${obj_path}/start.s
26+
loongarch32r-linux-gnusf-as -mabi=ilp32 ${obj_path}/start.s -o ${obj_path}/start.o
27+
${obj_path}/init.o: ${obj_path}/init.s
28+
loongarch32r-linux-gnusf-as -mabi=ilp32 ${obj_path}/init.s -o ${obj_path}/init.o
29+
30+
${obj_path}/inst_ram.coe ${obj_path}/inst_ram.mif: ${obj_path}/main.bin ${obj_path}/main.data ${obj_path}/convert
31+
cd ${obj_path} && ./convert
32+
33+
${obj_path}/convert: convert.c
34+
gcc ./convert.c -o ${obj_path}/convert
35+
36+
${obj_path}/main.bin: ${obj_path}/main.elf
37+
loongarch32r-linux-gnusf-objcopy -O binary -j .text ${obj_path}/main.elf ${obj_path}/main.bin
38+
${obj_path}/main.data: ${obj_path}/main.elf
39+
loongarch32r-linux-gnusf-objcopy -O binary -j .data ${obj_path}/main.elf ${obj_path}/main.data
40+
41+
${obj_path}/main.elf: bin.lds ${obj_path}/libinst.a ${obj_path}/start.o ${obj_path}/init.o
42+
loongarch32r-linux-gnusf-ld ${obj_path}/start.o ${obj_path}/init.o ${obj_path}/libinst.a -T bin.lds -o ${obj_path}/main.elf
43+
44+
${obj_path}/start.s: start.S
45+
@mkdir -p ${obj_path}
46+
loongarch32r-linux-gnusf-gcc \
47+
-Iinclude -nostdinc -nostdlib -D_KERNEL -fno-builtin -D__loongarch32 \
48+
-DMEMSTART=0x10000000 -DMEMSIZE=0x04000 -DCPU_COUNT_PER_US=1000 -DEXP=$(EXP) \
49+
-S start.S > ${obj_path}/start.s
50+
${obj_path}/init.s: init.S
51+
@mkdir -p ${obj_path}
52+
loongarch32r-linux-gnusf-gcc \
53+
-Iinclude -nostdinc -nostdlib -D_KERNEL -fno-builtin -D__loongarch32\
54+
-DMEMSTART=0x10000000 -DMEMSIZE=0x04000 -DCPU_COUNT_PER_US=1000 -DEXP=$(EXP) \
55+
-S init.S > ${obj_path}/init.s
56+
57+
clean:
58+
rm -rf obj
59+
60+
help:
61+
@echo "################################################################"
62+
@echo "### help for compiling func"
63+
@echo "################################################################"
64+
@echo "### options:"
65+
@echo "### make : get compiled result, which is saved in ./obj"
66+
@echo "### make clean: remove *.o, *.a, and ./obj"
67+
@echo "### make help : show help information"
68+
@echo "###############################################################"
69+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
本目录是大赛提供的功能测试程序的目录,包括编译所需的源代码和目标文件。
2+
3+
本目录需要在Linux环境下,运行终端,进入本目录,执行Makefile脚本进行编译。
4+
5+
6+
1. 目录的结构如下:
7+
8+
+--./ : 功能测试编译目录
9+
|
10+
|--inst/ : 82个功能点源码,最终测试中实际只测试n82一个功能点
11+
|
12+
|--include/ : 编译所需的头文件目录
13+
|
14+
|--obj/ : 编译生成的目标文件目录
15+
|
16+
|--bin.lds.S : 链接脚本生成文件
17+
|
18+
|--convert.c : RAM初始化文件的转换代码
19+
|
20+
|--start.S : 测试程序的启动代码
21+
|
22+
|--Makefile : 编译脚本
23+
|
24+
|--rules.make : 编译规则,供Makefile调用
25+
|
26+
|--Readme_first.txt : 本文档
27+
28+
29+
2. 编译方法
30+
31+
(1) 编译前,请保证已经配置好交叉编译环境。
32+
33+
(2) 在当前目录下打开终端,执行make,即可在obj目录下生成测试所需的所有文件。
34+
35+
(3) 想清除所有编译文件请执行make clean。
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
3+
OUTPUT_ARCH(loongarch)
4+
ENTRY(_start)
5+
SECTIONS
6+
{
7+
8+
. = 0x1c000000;
9+
.text :
10+
{
11+
_start = . ;
12+
kernel_entry = . ;
13+
*(.text)
14+
*(.rodata*)
15+
*(.reginfo)
16+
*(.init)
17+
*(.stub)
18+
19+
*(.gnu.warning)
20+
rodata_end = .;
21+
} =0
22+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
void binary_out(FILE* out,unsigned char* mem)
4+
{
5+
char tmp;
6+
int i,j;
7+
unsigned char num[8];
8+
num[0] = 1;
9+
num[1] = 2;
10+
num[2] = 4;
11+
num[3] = 8;
12+
num[4] = 16;
13+
num[5] = 32;
14+
num[6] = 64;
15+
num[7] = 128;
16+
for(i=3;i>=0;i--)
17+
{
18+
for(j=7;j>=0;j--)
19+
{
20+
if( (mem[i] & num[j] ) != 0)
21+
tmp = '1';
22+
else
23+
tmp = '0';
24+
fprintf(out,"%c",tmp);
25+
}
26+
}
27+
fprintf(out,"\n");
28+
return;
29+
}
30+
31+
int main(void)
32+
{
33+
FILE *in;
34+
FILE *out;
35+
36+
int i,j,k;
37+
unsigned char mem[32];
38+
39+
in = fopen("main.bin", "rb");
40+
out = fopen("inst_ram.coe","w");
41+
42+
fprintf(out, "memory_initialization_radix = 16;\n");
43+
fprintf(out, "memory_initialization_vector =\n");
44+
while(!feof(in)) {
45+
if(fread(mem,1,4,in)!=4) {
46+
fprintf(out, "%02x%02x%02x%02x\n", mem[3], mem[2], mem[1], mem[0]);
47+
break;
48+
}
49+
fprintf(out, "%02x%02x%02x%02x\n", mem[3], mem[2], mem[1],mem[0]);
50+
}
51+
fclose(in);
52+
fclose(out);
53+
54+
in = fopen("main.data", "rb");
55+
out = fopen("data_ram.coe","w");
56+
57+
fprintf(out, "memory_initialization_radix = 16;\n");
58+
fprintf(out, "memory_initialization_vector =\n");
59+
while(!feof(in)) {
60+
if(fread(mem,1,4,in)!=4) {
61+
fprintf(out, "%02x%02x%02x%02x\n", mem[3], mem[2], mem[1], mem[0]);
62+
break;
63+
}
64+
fprintf(out, "%02x%02x%02x%02x\n", mem[3], mem[2], mem[1],mem[0]);
65+
}
66+
fclose(in);
67+
fclose(out);
68+
69+
in = fopen("main.data", "rb");
70+
out = fopen("data_ram.mif","w");
71+
72+
while(!feof(in)) {
73+
if(fread(mem,1,4,in)!=4) {
74+
binary_out(out,mem);
75+
break;
76+
}
77+
binary_out(out,mem);
78+
}
79+
fclose(in);
80+
fclose(out);
81+
82+
in = fopen("main.bin", "rb");
83+
out = fopen("inst_ram.mif","w");
84+
85+
while(!feof(in)) {
86+
if(fread(mem,1,4,in)!=4) {
87+
binary_out(out,mem);
88+
break;
89+
}
90+
binary_out(out,mem);
91+
}
92+
fclose(in);
93+
fclose(out);
94+
95+
in = fopen("main.bin","rb");
96+
out = fopen("rom.vlog","w");
97+
fprintf(out,"@1c000000\n");
98+
while(!feof(in)) {
99+
if (fread(mem,1,1,in) != 1) {
100+
fprintf(out,"%02x\n", mem[0]);
101+
break;
102+
}
103+
fprintf(out,"%02x\n", mem[0]);
104+
}
105+
fclose(in);
106+
fclose(out);
107+
108+
109+
return 0;
110+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#ifndef _SYS_ASM_H
2+
#define _SYS_ASM_H
3+
4+
#include "regdef.h"
5+
#include "sysdep.h"
6+
7+
/** ecode defined in LA32r */
8+
#define INT 0x0
9+
#define PIL 0x1
10+
#define PIS 0x2
11+
#define PIF 0x3
12+
#define PME 0x4
13+
#define PPI 0x7
14+
#define ADE 0x8
15+
#define ALE 0x9
16+
#define SYS 0xb
17+
#define BRK 0xc
18+
#define INE 0xd
19+
#define IPE 0xe
20+
#define FPD 0xf
21+
#define FPE 0x12
22+
#define TLBR 0x3f
23+
24+
#define ADEF_SUBCODE 0x0
25+
#define ADEM_SUBCODE 0x1
26+
27+
/* Macros to handle different pointer/register sizes for 32/64-bit code. */
28+
#ifdef __loongarch64
29+
# define PTRLOG 3
30+
# define SZREG 8
31+
# define SZFREG 8
32+
# define REG_L ld.d
33+
# define REG_S st.d
34+
# define FREG_L fld.d
35+
# define FREG_S fst.d
36+
#elif defined __loongarch32
37+
# define PTRLOG 2
38+
# define SZREG 4
39+
# define SZFREG 4
40+
# define REG_L ld.w
41+
# define REG_S st.w
42+
# define FREG_L fld.w
43+
# define FREG_S fst.w
44+
#else
45+
# error __loongarch_xlen must equal 32 or 64
46+
#endif
47+
48+
/* Declare leaf routine. */
49+
#define LEAF(symbol) \
50+
.text; \
51+
.globl symbol; \
52+
.align 3; \
53+
cfi_startproc ; \
54+
.type symbol, @function; \
55+
symbol:
56+
57+
# define ENTRY(symbol) LEAF(symbol)
58+
59+
/* Mark end of function. */
60+
#undef END
61+
#define END(function) \
62+
cfi_endproc ; \
63+
.size function,.-function;
64+
65+
/* Stack alignment. */
66+
#define ALMASK ~15
67+
68+
#endif /* sys/asm.h */

0 commit comments

Comments
 (0)