diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-03-16 15:10:47 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-03-16 15:10:47 +0800 |
| commit | 161eb7764bb9054aa21080b5100a4e743ab91fd6 (patch) | |
| tree | bfe5e44e6074feee02368bc5954fc06cf714f1f0 | |
| parent | ac1bfb6ae8253d71904a273b20a1d0e5d4803fd4 (diff) | |
| download | rcc-project-161eb7764bb9054aa21080b5100a4e743ab91fd6.tar.gz rcc-project-161eb7764bb9054aa21080b5100a4e743ab91fd6.tar.xz | |
format output
| -rw-r--r-- | rv64cpu/tb/unit/tb_alu.cc | 16 | ||||
| -rw-r--r-- | rv64cpu/tb/unit/tb_decoder.cc | 9 | ||||
| -rw-r--r-- | rv64cpu/tb/unit/tb_regfile.cc | 8 |
3 files changed, 20 insertions, 13 deletions
diff --git a/rv64cpu/tb/unit/tb_alu.cc b/rv64cpu/tb/unit/tb_alu.cc index 60afd4e..04eaaed 100644 --- a/rv64cpu/tb/unit/tb_alu.cc +++ b/rv64cpu/tb/unit/tb_alu.cc @@ -44,13 +44,11 @@ void test_alu(Valu* alu, uint8_t op, uint64_t rs1, uint64_t rs2, uint64_t expect if (alu->alu_result == expected) { std::cout << "\033[32m"; std::cout << "[PASS] " << test_name << " | " - << rs1 << " op " << rs2 << " = " << expected << std::endl; - std::cout << "\033[0m"; + << rs1 << " op " << rs2 << " = " << expected << "\033[0m" << std::endl; } else { std::cout << "\033[31m"; std::cerr << "[FAIL] " << test_name << " | " - << "Expected: " << expected << ", Got: " << alu->alu_result << std::endl; - std::cout << "\033[0m"; + << "Expected: " << expected << ", Got: " << alu->alu_result << "\033[0m" << std::endl; assert(false); } } @@ -59,7 +57,9 @@ int main(int argc, char** argv) { Verilated::commandArgs(argc, argv); Valu* alu = new Valu; - std::cout << "Running ALU Unit Test ..." << std::endl; + std::cout << "----------------------------------" << std::endl; + std::cout << " ALU Unit Test" << std::endl; + std::cout << "----------------------------------" << std::endl; test_alu(alu, ALU_ADD, 100, 50, 150, "ADD_Positive"); test_alu(alu, ALU_SUB, 100, 50, 50, "SUB_Positive"); @@ -73,7 +73,7 @@ int main(int argc, char** argv) { uint64_t minus_one = (uint64_t)-1; uint64_t five = 5; - + test_alu(alu, ALU_SLTU, minus_one, five, 0, "SLTU (Unsigned: -1 < 5 is False)"); test_alu(alu, ALU_SLT, minus_one, five, 1, "SLT (Signed: -1 < 5 is True)"); @@ -104,7 +104,9 @@ int main(int argc, char** argv) { // SLT Edge Cases test_alu(alu, ALU_SLT, 0x8000000000000000ULL, 0x7FFFFFFFFFFFFFFFULL, 1, "SLT_Min_max"); test_alu(alu, ALU_SLT, 0x7FFFFFFFFFFFFFFFULL, 0x8000000000000000ULL, 0, "SLT_Max_Min"); - std::cout << "All tests passed!" << std::endl; + std::cout << "----------------------------------" << std::endl; + std::cout << "\033[32mAll tests passed!\033[0m" << std::endl; + std::cout << "----------------------------------" << std::endl; delete alu; return 0; diff --git a/rv64cpu/tb/unit/tb_decoder.cc b/rv64cpu/tb/unit/tb_decoder.cc index 1fbb7be..aa6788c 100644 --- a/rv64cpu/tb/unit/tb_decoder.cc +++ b/rv64cpu/tb/unit/tb_decoder.cc @@ -52,9 +52,9 @@ int main(int argc, char** argv) { Verilated::commandArgs(argc, argv); Vdecoder* dut = new Vdecoder; - std::cout << "═══════════════════════════════════════════════" << std::endl; - std::cout << " Decoder Unit Test Suite" << std::endl; - std::cout << "═══════════════════════════════════════════════" << std::endl; + std::cout << "----------------------------------" << std::endl; + std::cout << " Decoder Unit Test" << std::endl; + std::cout << "----------------------------------" << std::endl; // 1. R-type: ADD x1, x2, x3 // funct7=0000000 rs2=00011 rs1=00010 funct3=000 rd=00001 op=0110011 @@ -285,13 +285,14 @@ int main(int argc, char** argv) { CHECK(dut, reg_write_en, 0, "Illegal"); // Results - std::cout << "═══════════════════════════════════════════════" << std::endl; + std::cout << "----------------------------------" << std::endl; if (fail_count == 0) { std::cout << "\033[32mAll " << test_count << " tests passed!\033[0m" << std::endl; } else { std::cout << "\033[31m" << fail_count << " check(s) FAILED out of " << test_count << " tests.\033[0m" << std::endl; } + std::cout << "----------------------------------" << std::endl; delete dut; return (fail_count > 0) ? 1 : 0; diff --git a/rv64cpu/tb/unit/tb_regfile.cc b/rv64cpu/tb/unit/tb_regfile.cc index 2491eb6..3d08dd5 100644 --- a/rv64cpu/tb/unit/tb_regfile.cc +++ b/rv64cpu/tb/unit/tb_regfile.cc @@ -42,7 +42,9 @@ int main(int argc, char** argv) { dut->rs1_addr = 0; dut->rs2_addr = 0; - std::cout << "Starting register file unit test" << std::endl; + std::cout << "----------------------------------" << std::endl; + std::cout << " Register File Unit Test" << std::endl; + std::cout << "----------------------------------" << std::endl; // Test 1: Reset dut->rst = 1; @@ -180,7 +182,9 @@ int main(int argc, char** argv) { assert(sweep_ok); std::cout << "\033[32m[PASS] All 31 mutable registers write/read successfully without collision\033[0m" << std::endl; - std::cout << "Register file unit test complete\033[0m" << std::endl; + std::cout << "----------------------------------" << std::endl; + std::cout << "\033[32mAll 8 tests passed!\033[0m" << std::endl; + std::cout << "----------------------------------" << std::endl; delete dut; exit(0); |
