Skip to content

Commit

Permalink
Refactor DiffTest with Chisel-generated interfaces (#136)
Browse files Browse the repository at this point in the history
Disable L2 TLB check is disabled temporarily to avoid warnings.
  • Loading branch information
poemonsense authored Sep 8, 2023
1 parent f905bc9 commit 4c1b283
Show file tree
Hide file tree
Showing 42 changed files with 2,508 additions and 2,600 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu EMU_CXX_EXTRA_FLAGS="-DFIRST_INST_ADDRESS=0x80000000"
make emu
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --no-diff
- name: Basic Difftest
Expand All @@ -64,8 +64,6 @@ jobs:
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu EMU_CXX_EXTRA_FLAGS="-DFIRST_INST_ADDRESS=0x80000000"
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
- name: Difftest with Snapshot
Expand All @@ -75,7 +73,7 @@ jobs:
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu EMU_SNAPSHOT=1 EMU_CXX_EXTRA_FLAGS="-DFIRST_INST_ADDRESS=0x80000000"
make emu EMU_SNAPSHOT=1
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
- name: Difftest with Trace
Expand All @@ -85,7 +83,7 @@ jobs:
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu EMU_TRACE=1 EMU_CXX_EXTRA_FLAGS="-DFIRST_INST_ADDRESS=0x80000000"
make emu EMU_TRACE=1
./build/emu -b 10 -e 12 -i ./ready-to-run/microbench.bin --dump-wave --diff ./ready-to-run/riscv64-nemu-interpreter-so
- name: Difftest with two threads
Expand All @@ -95,5 +93,5 @@ jobs:
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu EMU_THREADS=2 EMU_CXX_EXTRA_FLAGS="-DFIRST_INST_ADDRESS=0x80000000"
make emu EMU_THREADS=2
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,21 @@ REMOTE ?= localhost
SIM_CSRC_DIR = $(abspath ./src/test/csrc/common)
SIM_CXXFILES = $(shell find $(SIM_CSRC_DIR) -name "*.cpp")

PLUGIN_CSRC_DIR = $(abspath ./src/test/csrc/plugin)
PLUGIN_CXXFILES = $(shell find $(PLUGIN_CSRC_DIR) -name "*.cpp")
# generated-src
GEN_CSRC_DIR = $(BUILD_DIR)/generated-src
GEN_CXXFILES = $(shell find $(GEN_CSRC_DIR) -name "*.cpp")

DIFFTEST_CSRC_DIR = $(abspath ./src/test/csrc/difftest)
DIFFTEST_CXXFILES = $(shell find $(DIFFTEST_CSRC_DIR) -name "*.cpp")

PLUGIN_CHEAD_DIR = $(abspath ./src/test/csrc/plugin/include)
PLUGIN_CSRC_DIR = $(abspath ./src/test/csrc/plugin)
PLUGIN_INC_DIR = $(abspath $(PLUGIN_CSRC_DIR)/include)

PLUGIN_DASM_DIR = $(abspath $(PLUGIN_CSRC_DIR)/spikedasm)
PLUGIN_DASM_CXXFILES = $(shell find $(PLUGIN_CSRC_DIR)/spikedasm -name "*.cpp")

PLUGIN_RUNAHEAD_DIR = $(abspath $(PLUGIN_CSRC_DIR)/runahead)
PLUGIN_RUNAHEAD_CXXFILES = $(shell find $(PLUGIN_CSRC_DIR)/runahead -name "*.cpp")

SIM_VSRC = $(shell find ./src/test/vsrc/common -name "*.v" -or -name "*.sv")

Expand Down
36 changes: 26 additions & 10 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
import mill._, scalalib._
import coursier.maven.MavenRepository
/***************************************************************************************
* Copyright (c) 2020-2023 Institute of Computing Technology, Chinese Academy of Sciences
*
* DiffTest is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
*
* See the Mulan PSL v2 for more details.
***************************************************************************************/

import os.Path
import mill._
import scalalib._
import publish._

object ivys {
val sv = "2.12.13"
val chisel3 = ivy"edu.berkeley.cs::chisel3:3.5.0"
val chisel3Plugin = ivy"edu.berkeley.cs:::chisel3-plugin:3.5.0"
val scala = "2.13.10"
val chisel3 = ivy"edu.berkeley.cs::chisel3:3.5.6"
val chisel3Plugin = ivy"edu.berkeley.cs:::chisel3-plugin:3.5.6"
val scalatest = ivy"org.scalatest::scalatest:3.2.2"
}

trait CommonDiffTest extends ScalaModule with SbtModule {
override def scalaVersion = ivys.sv
override def scalaVersion = ivys.scala

override def scalacOptions = Seq("-Xsource:2.11")
override def scalacPluginIvyDeps = Agg(ivys.chisel3Plugin)

override def ivyDeps = Agg(ivys.chisel3)

override def scalacPluginIvyDeps = Agg(ivys.chisel3Plugin)
}

object difftest extends SbtModule with CommonDiffTest {
object difftest extends CommonDiffTest {
override def millSourcePath = os.pwd
}
68 changes: 22 additions & 46 deletions config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
#define NUM_CORES 1
#endif

#include "diffstate.h"

#if defined(CPU_NUTSHELL)
#elif defined(CPU_XIANGSHAN)
#elif defined(CPU_ROCKET_CHIP)
#else
// This is the default CPU
#define CPU_NUTSHELL
#endif

// -----------------------------------------------------------------------
// Memory and device config
// -----------------------------------------------------------------------
Expand All @@ -32,7 +42,9 @@
#define PMEM_BASE 0x80000000UL

// first valid instruction's address, difftest starts from this instruction
#ifndef FIRST_INST_ADDRESS
#if defined(CPU_NUTSHELL)
#define FIRST_INST_ADDRESS 0x80000000UL
#elif defined(CPU_XIANGSHAN) || defined(CPU_ROCKET_CHIP)
#define FIRST_INST_ADDRESS 0x10000000UL
#endif

Expand All @@ -44,7 +56,11 @@
// flash access address align mask
#define FLASH_ALIGH_MASK 0xfffffff8

#if defined(CPU_ROCKET_CHIP)
#define DEFAULT_EMU_FLASH_SIZE 0x10000UL
#else
#define DEFAULT_EMU_FLASH_SIZE (32 * 1024UL) // 4 MB
#endif
extern unsigned long EMU_FLASH_SIZE;

// Use sdl to show screen
Expand All @@ -55,52 +71,14 @@ extern unsigned long EMU_FLASH_SIZE;
// -----------------------------------------------------------------------
// Difftest interface config
// -----------------------------------------------------------------------
#ifndef DIFF_PROXY
#define DIFF_PROXY NemuProxy
#ifndef REF_PROXY
#define REF_PROXY NemuProxy
#endif

// max physical register file size
#define DIFFTEST_MAX_PRF_SIZE 256

// max commit width
#define DIFFTEST_COMMIT_WIDTH 6

// max store width
//
// max num of stores turn from predicted to non-predicted in 1 cycle
#define DIFFTEST_STORE_WIDTH 2

// max store buffer resp width, for golden mem check
#define DIFFTEST_SBUFFER_RESP_WIDTH 3

// max itlb width
#define DIFFTEST_ITLB_WIDTH 4

// max ldtlb width
#define DIFFTEST_LDTLB_WIDTH 2

// max sttlb width
#define DIFFTEST_STTLB_WIDTH 2

// max ptw width
#define DIFFTEST_PTW_WIDTH 2

// commit inst history length
#define DEBUG_INST_TRACE_SIZE 32

// commit inst group history length
#define DEBUG_GROUP_TRACE_SIZE 16

// max refill entry num in difftest_core_state_t
#define DIFFTEST_REFFILL_EVENT_ENTRY_NUM 10

// -----------------------------------------------------------------------
// Checkpoint config
// -----------------------------------------------------------------------

// time to fork a new checkpoint process
#define FORK_INTERVAL 1 // unit: second

// max number of checkpoint process at a time
#define SLOT_SIZE 2

Expand Down Expand Up @@ -133,7 +111,7 @@ extern unsigned long EMU_FLASH_SIZE;
#define DEBUG_L1TLB

// whether to check l2tlb response
#define DEBUG_L2TLB
// #define DEBUG_L2TLB

// -----------------------------------------------------------------------
// Simulator run ahead config
Expand Down Expand Up @@ -188,11 +166,11 @@ extern unsigned long EMU_FLASH_SIZE;

// whether to maintain goldenmem
#if NUM_CORES>1
#define DEBUG_GOLDENMEM
#define DEBUG_GOLDENMEM
#endif

#ifdef DEBUG_REFILL
#define DEBUG_GOLDENMEM
#define DEBUG_GOLDENMEM
#endif

#define RUNAHEAD_UNIT_TEST
Expand All @@ -202,6 +180,4 @@ extern unsigned long EMU_FLASH_SIZE;
#define QUERY_MEM_ACCESS
#endif

extern unsigned long EMU_RAM_SIZE;

#endif
Loading

0 comments on commit 4c1b283

Please sign in to comment.