Skip to content

Commit

Permalink
Fix the compiling errors when NO_DIFF is set (#152)
Browse files Browse the repository at this point in the history
* CI: add test for compiling without difftest
  • Loading branch information
poemonsense authored Sep 14, 2023
1 parent db56194 commit 5a5ecbc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ jobs:
rm -r difftest
cp -r $GITHUB_WORKSPACE .
- name: Simulation without DiffTest
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu NO_DIFF=1 EMU_TRACE=1
./build/emu -b 0 -e 100 -i ./ready-to-run/microbench.bin --dump-wave -C 10000
- name: Simulation with No Diff
run: |
cd $GITHUB_WORKSPACE/../xs-env
Expand Down
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 5a5ecbc

Please sign in to comment.