diff --git a/hw/simulate/Makefile b/hw/simulate/Makefile index 7b665714..6c4f9ef0 100644 --- a/hw/simulate/Makefile +++ b/hw/simulate/Makefile @@ -89,4 +89,4 @@ run-mt: build-mt (cd obj_dir && ./VVortex) clean: - rm -rf obj_dir \ No newline at end of file + rm -rf obj_dir diff --git a/hw/simulate/testbench.cpp b/hw/simulate/testbench.cpp index d037fc18..59fa6edc 100644 --- a/hw/simulate/testbench.cpp +++ b/hw/simulate/testbench.cpp @@ -3,104 +3,103 @@ #include #include -int main(int argc, char **argv) +int main(int argc, char *argv[]) { //#define ALL_TESTS -#ifdef ALL_TESTS - bool passed = true; +//#ifdef ALL_TESTS + if(argc == 1) { + bool passed = true; - std::string tests[] = { - "../../../benchmarks/riscv_tests/rv32ui-p-add.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-addi.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-and.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-andi.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-auipc.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-beq.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-bge.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-bgeu.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-blt.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-bltu.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-bne.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-jal.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-jalr.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-lb.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-lbu.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-lh.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-lhu.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-lui.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-lw.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-or.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-ori.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-sb.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-sh.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-simple.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-sll.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-slli.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-slt.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-slti.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-sltiu.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-sltu.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-sra.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-srai.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-srl.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-srli.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-sub.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-sw.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-xor.hex", - "../../../benchmarks/riscv_tests/rv32ui-p-xori.hex", - "../../../benchmarks/riscv_tests/rv32um-p-div.hex", - "../../../benchmarks/riscv_tests/rv32um-p-divu.hex", - "../../../benchmarks/riscv_tests/rv32um-p-mul.hex", - "../../../benchmarks/riscv_tests/rv32um-p-mulh.hex", - "../../../benchmarks/riscv_tests/rv32um-p-mulhsu.hex", - "../../../benchmarks/riscv_tests/rv32um-p-mulhu.hex", - "../../../benchmarks/riscv_tests/rv32um-p-rem.hex", - "../../../benchmarks/riscv_tests/rv32um-p-remu.hex" - }; + std::string tests[] = { + "../../../benchmarks/riscv_tests/rv32ui-p-add.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-addi.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-and.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-andi.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-auipc.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-beq.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-bge.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-bgeu.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-blt.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-bltu.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-bne.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-jal.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-jalr.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-lb.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-lbu.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-lh.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-lhu.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-lui.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-lw.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-or.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-ori.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-sb.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-sh.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-simple.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-sll.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-slli.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-slt.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-slti.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-sltiu.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-sltu.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-sra.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-srai.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-srl.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-srli.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-sub.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-sw.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-xor.hex", + "../../../benchmarks/riscv_tests/rv32ui-p-xori.hex", + "../../../benchmarks/riscv_tests/rv32um-p-div.hex", + "../../../benchmarks/riscv_tests/rv32um-p-divu.hex", + "../../../benchmarks/riscv_tests/rv32um-p-mul.hex", + "../../../benchmarks/riscv_tests/rv32um-p-mulh.hex", + "../../../benchmarks/riscv_tests/rv32um-p-mulhsu.hex", + "../../../benchmarks/riscv_tests/rv32um-p-mulhu.hex", + "../../../benchmarks/riscv_tests/rv32um-p-rem.hex", + "../../../benchmarks/riscv_tests/rv32um-p-remu.hex" + }; - for (std::string test : tests) { - std::cerr << DEFAULT << "\n---------------------------------------\n"; + for (std::string test : tests) { + std::cerr << DEFAULT << "\n---------------------------------------\n"; - std::cerr << test << std::endl; + std::cerr << test << std::endl; - RAM ram; - Simulator simulator; - simulator.attach_ram(&ram); - simulator.load_ihex(test.c_str()); - bool curr = simulator.run(); + RAM ram; + Simulator simulator; + simulator.attach_ram(&ram); + simulator.load_ihex(test.c_str()); + bool curr = simulator.run(); - if (curr) std::cerr << GREEN << "Test Passed: " << test << std::endl; - if (!curr) std::cerr << RED << "Test Failed: " << test << std::endl; - std::cerr << DEFAULT; - passed = passed && curr; + if (curr) std::cerr << GREEN << "Test Passed: " << test << std::endl; + if (!curr) std::cerr << RED << "Test Failed: " << test << std::endl; + std::cerr << DEFAULT; + passed = passed && curr; + } + + std::cerr << DEFAULT << "\n***************************************\n"; + + if (passed) std::cerr << DEFAULT << "PASSED ALL TESTS\n"; + if (!passed) std::cerr << DEFAULT << "Failed one or more tests\n"; + + return !passed; } - std::cerr << DEFAULT << "\n***************************************\n"; +//#else + if (argc >= 2) { + char* test = argv[2]; + + std::cerr << test << std::endl; - if (passed) std::cerr << DEFAULT << "PASSED ALL TESTS\n"; - if (!passed) std::cerr << DEFAULT << "Failed one or more tests\n"; + RAM ram; + Simulator simulator; + simulator.attach_ram(&ram); + simulator.load_ihex(test); + bool curr = simulator.run(); - return !passed; + if (curr) std::cerr << GREEN << "Test Passed: " << test << std::endl; + if (!curr) std::cerr << RED << "Test Failed: " << test << std::endl; -#else - - char test[] = "../../../runtime/tests/simple/vx_simple.hex"; - //char test[] = "../../../benchmarks/riscv_tests/rv32ui-p-lb.hex"; - //char test[] = "../../../benchmarks/riscv_tests/rv32ui-p-lw.hex"; - //char test[] = "../../../benchmarks/riscv_tests/rv32ui-p-sw.hex"; - - std::cerr << test << std::endl; - - RAM ram; - Simulator simulator; - simulator.attach_ram(&ram); - simulator.load_ihex(test); - bool curr = simulator.run(); - - if (curr) std::cerr << GREEN << "Test Passed: " << test << std::endl; - if (!curr) std::cerr << RED << "Test Failed: " << test << std::endl; - - return !curr; - -#endif -} \ No newline at end of file + return !curr; + } +//#endif +} diff --git a/runtime/tests/dev/Makefile b/runtime/tests/dev/Makefile index a6faf9bd..f0f4719b 100644 --- a/runtime/tests/dev/Makefile +++ b/runtime/tests/dev/Makefile @@ -27,6 +27,9 @@ $(PROJECT).hex: $(PROJECT).elf $(PROJECT).elf: $(SRCS) $(CC) $(CFLAGS) $(SRCS) $(LDFLAGS) -o $(PROJECT).elf +run: $(PROJECT).hex + (cd ../../../hw/simulate/obj_dir && ./VVortex -f ../../../runtime/tests/dev/$(PROJECT).hex) + .depend: $(SRCS) $(CC) $(CFLAGS) -MM $^ > .depend; diff --git a/runtime/tests/hello/Makefile b/runtime/tests/hello/Makefile index 3f7b6ea8..01b2edd4 100644 --- a/runtime/tests/hello/Makefile +++ b/runtime/tests/hello/Makefile @@ -27,6 +27,9 @@ $(PROJECT).hex: $(PROJECT).elf $(PROJECT).elf: $(SRCS) $(CC) $(CFLAGS) $(SRCS) $(LDFLAGS) -o $(PROJECT).elf +run: $(PROJECT).hex + (cd ../../../hw/simulate/obj_dir && ./VVortex -f ../../../runtime/tests/hello/$(PROJECT).hex) + .depend: $(SRCS) $(CC) $(CFLAGS) -MM $^ > .depend; diff --git a/runtime/tests/nlTest/Makefile b/runtime/tests/nlTest/Makefile index 6429a490..bd863989 100644 --- a/runtime/tests/nlTest/Makefile +++ b/runtime/tests/nlTest/Makefile @@ -27,6 +27,9 @@ $(PROJECT).hex: $(PROJECT).elf $(PROJECT).elf: $(SRCS) $(CC) $(CFLAGS) $(SRCS) $(LDFLAGS) -o $(PROJECT).elf +run: $(PROJECT).hex + (cd ../../../hw/simulate/obj_dir && ./VVortex -f ../../../runtime/tests/nlTest/$(PROJECT).hex) + .depend: $(SRCS) $(CC) $(CFLAGS) -MM $^ > .depend; diff --git a/runtime/tests/simple/Makefile b/runtime/tests/simple/Makefile index db04672b..fa134418 100644 --- a/runtime/tests/simple/Makefile +++ b/runtime/tests/simple/Makefile @@ -27,8 +27,11 @@ $(PROJECT).hex: $(PROJECT).elf $(PROJECT).elf: $(SRCS) $(CC) $(CFLAGS) $(SRCS) $(LDFLAGS) -o $(PROJECT).elf +run: $(PROJECT).hex + (cd ../../../hw/simulate/obj_dir && ./VVortex -f ../../../runtime/tests/simple/$(PROJECT).hex) + .depend: $(SRCS) $(CC) $(CFLAGS) -MM $^ > .depend; clean: - rm -rf *.elf *.hex *.dump .depend \ No newline at end of file + rm -rf *.elf *.hex *.dump .depend diff --git a/runtime/tests/vecadd/Makefile b/runtime/tests/vecadd/Makefile index 5bdaa1d9..b6906eeb 100644 --- a/runtime/tests/vecadd/Makefile +++ b/runtime/tests/vecadd/Makefile @@ -28,6 +28,9 @@ $(PROJECT).hex: $(PROJECT).elf $(PROJECT).elf: $(SRCS) $(CC) $(CFLAGS) $(SRCS) $(LDFLAGS) -o $(PROJECT).elf +run: $(PROJECT).hex + (cd ../../../hw/simulate/obj_dir && ./VVortex -f ../../../runtime/tests/vecadd/$(PROJECT).hex) + .depend: $(SRCS) $(CC) $(CFLAGS) -MM $^ > .depend;