Skip to content

Commit

Permalink
Fix the compiling errors when NO_DIFF is set
Browse files Browse the repository at this point in the history
  • Loading branch information
poemonsense committed Sep 13, 2023
1 parent 6b10cfb commit aa6350b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/scala/DPIC.scala
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,14 @@ object DPIC {
Files.write(Paths.get(outputHeaderFile), interfaceCpp.mkString("\n").getBytes(StandardCharsets.UTF_8))

interfaceCpp.clear()
interfaceCpp += "#ifndef CONFIG_NO_DIFFTEST"
interfaceCpp += ""
interfaceCpp += "#include \"difftest.h\""
interfaceCpp += "#include \"difftest-dpic.h\""
interfaceCpp += interfaces.map(_._3).mkString("")
interfaceCpp += ""
interfaceCpp += "#endif // CONFIG_NO_DIFFTEST"
interfaceCpp += ""
val outputFile = outputDir + "/difftest-dpic.cpp"
Files.write(Paths.get(outputFile), interfaceCpp.mkString("\n").getBytes(StandardCharsets.UTF_8))
}
Expand Down
6 changes: 6 additions & 0 deletions src/test/csrc/common/golden.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@

#include "golden.h"
#include "ram.h"
#ifndef CONFIG_NO_DIFFTEST
#include <goldenmem.h>
#endif // CONFIG_NO_DIFFTEST

extern "C" uint8_t pte_helper(uint64_t satp, uint64_t vpn, uint64_t *pte, uint8_t *level) {
uint64_t pg_base = satp << 12, pte_addr;
PTE *pte_p = (PTE *)pte;
for (*level = 0; *level < 3; (*level)++) {
pte_addr = pg_base + VPNi(vpn, *level) * sizeof(uint64_t);
#ifdef CONFIG_NO_DIFFTEST
pte_p->val = pmem_read(pte_addr);
#else
read_goldenmem(pte_addr, &pte_p->val, 8);
#endif // CONFIG_NO_DIFFTEST
pg_base = pte_p->ppn << 12;
// pf
if (!pte_p->v) {
Expand Down
2 changes: 2 additions & 0 deletions src/test/csrc/verilator/emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ int Emulator::tick() {
}
#endif

#ifndef CONFIG_NO_DIFFTEST
// if ref trace is enabled in co-sim args
// let simulator print debug info
if (args.enable_ref_trace) {
Expand All @@ -620,6 +621,7 @@ int Emulator::tick() {
difftest[i]->proxy->update_config(&ref_config);
}
}
#endif // CONFIG_NO_DIFFTEST

if (args.enable_fork && is_fork_child() && cycles != 0) {
if (cycles == lightsss->get_end_cycles()) {
Expand Down

0 comments on commit aa6350b

Please sign in to comment.