> compile NEMU
ysyx_22040000 李心杨 Linux calcite 6.1.71 #1-NixOS SMP PREEMPT_DYNAMIC Fri Jan 5 14:18:41 UTC 2024 x86_64 GNU/Linux 22:17:14 up 2 days 11:12, 2 users, load average: 1.39, 0.69, 0.39
This commit is contained in:
parent
f5cdb499b8
commit
c995a80ce8
7 changed files with 815 additions and 4 deletions
11
nemu/.vscode/property.json
vendored
Normal file
11
nemu/.vscode/property.json
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"toolChain": "xilinx",
|
||||||
|
"prjName": {
|
||||||
|
"PL": "template"
|
||||||
|
},
|
||||||
|
"soc": {
|
||||||
|
"core": "none"
|
||||||
|
},
|
||||||
|
"enableShowLog": false,
|
||||||
|
"device": "none"
|
||||||
|
}
|
|
@ -66,7 +66,8 @@ include $(NEMU_HOME)/tests/Makefile
|
||||||
all-tests: TEST_OBJS = $(filter-out $(OBJ_DIR)/src/nemu-main.o, $(OBJS))
|
all-tests: TEST_OBJS = $(filter-out $(OBJ_DIR)/src/nemu-main.o, $(OBJS))
|
||||||
all-tests: CFLAGS += $(shell pkg-config --cflags check)
|
all-tests: CFLAGS += $(shell pkg-config --cflags check)
|
||||||
all-tests: LDFLAGS += $(shell pkg-config --libs check)
|
all-tests: LDFLAGS += $(shell pkg-config --libs check)
|
||||||
|
all-tests: INC_PATH += $(NEMU_HOME)/src/isa/$(GUEST_ISA)/local-include
|
||||||
all-tests: $(TEST_SRCS:%.c=$(OBJ_DIR)/%)
|
all-tests: $(TEST_SRCS:%.c=$(OBJ_DIR)/%)
|
||||||
|
|
||||||
test: $(addprefix $(OBJ_DIR), $(TEST_NAMES))
|
test: all-tests
|
||||||
@$(OBJ_DIR)/tests/expr_test
|
@$(OBJ_DIR)/tests/expr_test
|
||||||
|
|
769
nemu/compile_commands.events.json
Normal file
769
nemu/compile_commands.events.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -36,5 +36,15 @@ void isa_reg_display() {
|
||||||
}
|
}
|
||||||
|
|
||||||
word_t isa_reg_str2val(const char *s, bool *success) {
|
word_t isa_reg_str2val(const char *s, bool *success) {
|
||||||
return 0;
|
assert(s);
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 32 && strcmp(s, regs[i]) != 0; i++)
|
||||||
|
;
|
||||||
|
|
||||||
|
if (i == 32) {
|
||||||
|
success = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return gpr(i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
$?[a-zA-Z]{2,3} { yylval = isa_reg_str2val(yytext, &success); if(!success) { return YYerror; } }
|
$$?[a-zA-Z]{2,3} { yylval = isa_reg_str2val(yytext + 1, &success); if(!success) { return YYerror; } }
|
||||||
0[xX][0-9a-fA-F]+ { yylval = strtoul(yytext, NULL, 16); return HEX_NUMBER; }
|
0[xX][0-9a-fA-F]+ { yylval = strtoul(yytext, NULL, 16); return HEX_NUMBER; }
|
||||||
[0-9]+ { yylval = strtoul(yytext, NULL, 10); return NUMBER; }
|
[0-9]+ { yylval = strtoul(yytext, NULL, 10); return NUMBER; }
|
||||||
[+\-*/()] { return *yytext; }
|
[+\-*/()] { return *yytext; }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
TEST_SRCS += tests/expr_test.c
|
TEST_SRCS += tests/expr_test.c
|
||||||
YACC = bison
|
YACC = bison
|
||||||
|
|
||||||
$(OBJ_DIR)/% %: %.c $(TEST_OBJS) app
|
$(OBJ_DIR)/%: %.c $(TEST_OBJS) app
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
@echo + CC $<
|
@echo + CC $<
|
||||||
@$(CC) $(CFLAGS) -o $@.o -c $<
|
@$(CC) $(CFLAGS) -o $@.o -c $<
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include "macro.h"
|
||||||
#include "sys/types.h"
|
#include "sys/types.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -9,6 +10,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <addrexp.h>
|
#include <addrexp.h>
|
||||||
#include <addrexp_lex.h>
|
#include <addrexp_lex.h>
|
||||||
|
#include <reg.h>
|
||||||
|
|
||||||
char buf[65536] = {}, ref_buf[65536] = {};
|
char buf[65536] = {}, ref_buf[65536] = {};
|
||||||
static char code_buf[65536 + 128] = {}; // a little larger than `buf`
|
static char code_buf[65536 + 128] = {}; // a little larger than `buf`
|
||||||
|
@ -162,6 +164,22 @@ START_TEST(test_expr_negative_operand) {
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
extern const char *regs[];
|
||||||
|
START_TEST(test_expr_plain_register) {
|
||||||
|
int i;
|
||||||
|
char buf[5] = {};
|
||||||
|
// NOTE: need to fix this if want to support more arch
|
||||||
|
buf[0] = '$';
|
||||||
|
for (i = 0; i < 32; i++) {
|
||||||
|
strcpy(buf + 1, regs[i]);
|
||||||
|
gpr(i) = i;
|
||||||
|
}
|
||||||
|
for (i = 1; i < 5; i++) {
|
||||||
|
buf[i] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
START_TEST(test_expr_register) {
|
START_TEST(test_expr_register) {
|
||||||
yy_scan_string(reg_exprs[_i].expr);
|
yy_scan_string(reg_exprs[_i].expr);
|
||||||
uint32_t value;
|
uint32_t value;
|
||||||
|
@ -184,6 +202,8 @@ Suite *expr_suite(void) {
|
||||||
tcase_add_loop_test(tc_core, test_expr_random_100, 0, 20);
|
tcase_add_loop_test(tc_core, test_expr_random_100, 0, 20);
|
||||||
tcase_add_loop_test(tc_core, test_expr_negative_operand, 0,
|
tcase_add_loop_test(tc_core, test_expr_negative_operand, 0,
|
||||||
sizeof(exprs) / sizeof(exprs[0]));
|
sizeof(exprs) / sizeof(exprs[0]));
|
||||||
|
tcase_add_loop_test(tc_core, test_expr_plain_register, 0,
|
||||||
|
sizeof(reg_exprs) / sizeof(reg_exprs[0]));
|
||||||
tcase_add_loop_test(tc_core, test_expr_register, 0,
|
tcase_add_loop_test(tc_core, test_expr_register, 0,
|
||||||
sizeof(reg_exprs) / sizeof(reg_exprs[0]));
|
sizeof(reg_exprs) / sizeof(reg_exprs[0]));
|
||||||
suite_add_tcase(s, tc_core);
|
suite_add_tcase(s, tc_core);
|
||||||
|
|
Loading…
Add table
Reference in a new issue