Skip to content

Conversation

@klin02
Copy link
Member

@klin02 klin02 commented Nov 7, 2025

  • submodule(difftest): refactor DiffTop, PhyReg, Refill, PGO_BOLT

    Latest difftest introduces following notable change:

    1. CPU as submodule of Difftest
      Difftest now allows instantiating the CPU as a submodule and exposing
      additional IOs. LazyModules must explicitly provide clock and reset
      signals.
      (PRs: feat(top): allow extra CPU IO with connectTopIOs difftest#713, feat(top): support extra Clock and Reset for RawModule difftest#757, feat(top): support createTopIOs with explicit name difftest#758)

    2. Replace ArchReg + WriteBack with PhyReg + RenameTable
      The old embedded-into-CPU Difftest logic is removed. The new PhyReg +
      RenameTable interface eliminates additional phy-to-arch logic and multi-
      read-port overhead inside the CPU and removes interface of ArchReg/WriteBack.
      (PRs: feat(difftest): support DiffPhyRegState and DiffArchRenameTable difftest#714, refactor(difftest): remove DiffWriteback and privatize DiffArchReg difftest#754)

    3. RefillEvent interface modification
      Refill checking now support masked refill-check to support low-power
      read.
      (PRs: fix(difftest): remove unused idtfr from RefillEvent difftest#719, feat(refill-check): add mask to refill check difftest#723)

    4. PGO_BOLT option for emu compilation
      A new PGO_BOLT mode is provided to accelerate EMU compilation under
      profile-guided optimization.
      (PR: feat(verilator,gsim): add PGO_BOLT option difftest#756)

  • feat(top): adapt difftest interfaces for FPGA difftest
    This change moves XSDiffTop instantiation into the Difftest for fpgaDiff.
    DiffTop will generated with a SimTop wrapper, where DiffTest outputs,
    together with XSTop's IO ports, AXI4 buses of memory/peripheral/DMA will
    be exposed for external connection.

    Temporarily, we still expose XSNoCDiffTop with appended Difftest IOs, and
    generate XSTop and XSNoCTop with internal Difftest DPI-C, so as to avoid
    extra TopIOs and mixed generated files. We will try to refactor them like
    DiffTop later.(i.e. generate with a seperated Difftest)

  • feat(difftest): replace ArchReg and Writeback with PhyRegState
    This change refactors Difftest interfaces, replacing the previous
    ArchReg and WriteBack with PhyRegState and ArchRenameTable.

    By default, Difftest still extracts PhyReg and RenameTable into
    ArchReg on the hardware side, so that the extra multi-read area
    is accounted for within Difftest.

    When acceleration is enabled, this extraction is deferred to the
    software side, eliminating the extra hardware area overhead.

    Since 128-bit ArchVecReg are now treated as two 64-bit registers
    in Difftest, we add corresponding register splitting in XiangShan.
    The address indexs (InstrCommit.otherwpdest and RenameTable) are
    also converted from index to 2*index and 2*index + 1 for reg
    splitting.

    Note XiangShan separates V0 and Vf register files. When mering the
    two regfiles and renameTable for Difftest, the indexs of Vf must
    add offset of V0RegSize to ensure correct indexing.

  • fix(difftest): add masked RefillEvent, disable for now

    After Frontend new ICache #3051, we have supported low-power read (read only 5 out of 8
    8B-banks) in ICacheDataArray, and in V3, it was further modified to
    dynamically compute the mask based on the taken branch location.

    Though, previous DiffRefillEvent does not support masked comparison,
    instead it checks entire 512bit, so it will fail if we enable checks on
    cacheid >=3 (fix(difftest): only check existed refill events difftest#712). As we're refactoring ICache
    recently, we need this check to ensure the refactored code is working
    properly.

    This commit removes unused idtfr and introduces masked refill-check
    for Difftest, where each mask bit controls comparison of 8B data.

    However, as the newly added masked Refill fails CI, we disable it for
    now, and wait for later fixup.

    Co-authored-by: ngc7331 [email protected]

  • fix(Makefile): unify PLDM and FPGA args under DEBUG_ARGS

    This change unifies the args handling for PLDM and FPGA_DIFF into a shared
    DEBUG_ARGS options, with PLDM=1 or FPGA=1 used to distinguish between the
    two environments.

    For PLDM, we continue to enable the full Difftest by default as it used to
    be. For FPGA, we set it default to BASIC_DIFF and remove additional debug
    printing to reduce overhead. Any extra options can be supplied via
    DEBUG_ARGS as needed.

    Example usage:
    PLDM=1 DEBUG_ARGS="--difftest-config ZESN --perf-level CRITICAL"
    FPGA=1 DEBUG_ARGS="--difftest-config ESBIFDU --difftest-exclude Vec"

  • fix(pdb): resolve API incompatibility with difftest update

    This PR updates the xspdb to adapt to the API changes.
    Co-authored-by: SFangYy [email protected]
    Co-authored-by: Zhicheng Yao [email protected]

@klin02 klin02 requested a review from Tang-Haojin as a code owner November 7, 2025 08:56
@ngc7331 ngc7331 added the module: tool non-RTL tools like difftest, gsim, XSpdb, Makefiles, scripts, CI/CD, etc. label Nov 7, 2025
@klin02 klin02 marked this pull request as draft November 7, 2025 12:51
@klin02 klin02 changed the title feat(top): adapt difftest interfaces for FPGA difftest Bump DiffTest for TopIO and DiffPhyRegState Nov 12, 2025
@klin02 klin02 force-pushed the fix-difftop branch 4 times, most recently from 50f48b0 to 4ed3505 Compare November 13, 2025 09:32
@klin02 klin02 force-pushed the fix-difftop branch 2 times, most recently from d445354 to 349b9f2 Compare November 14, 2025 12:38
@klin02 klin02 changed the title Bump DiffTest for TopIO and DiffPhyRegState submodule(difftest): refactor DiffTop, PhyReg and Refill Nov 14, 2025
@XiangShanRobot
Copy link

[Generated by IPC robot]
commit: d0e9746

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
d0e9746 1.818 0.441 2.631 1.236 2.155 0.000 2.154 2.352 0.936 1.410 1.564 3.114 2.539 2.268 3.329

master branch:

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
0997713 1.807
3a1d39b 1.818 0.441 2.631 1.227 2.155 1.807 2.154 2.352 0.936 1.410 1.564 3.114 2.539 2.268 3.329
bd14dcb 1.818 0.441 2.631 1.239 2.155 1.807 2.154 2.352 0.936 1.410 1.564 3.114 2.539 2.268 3.329
a8177c6 1.818 0.441 2.631 1.226 2.155 1.807 2.154 2.352 0.936 1.410 1.564 3.114 2.539 2.268 3.329
2c0d73d 1.818 0.441 2.631 1.224 2.155 1.807 2.154 2.352 0.936 1.410 1.564 3.114 2.539 2.268 3.329
4c5c796 1.819 0.441 2.630 1.230 2.153 1.808 2.156 2.352 0.936 1.412 1.585 3.114 2.542 2.269 3.329
ee71eee 1.819 0.441 2.630 1.238 2.153 1.808 2.156 2.352 0.936 1.412 1.585 3.114 2.542 2.269 3.329
1e9f1b4 1.819 0.441 2.630 1.231 2.153 1.808 2.156 2.352 0.936 1.412 1.585 3.114 2.542 2.269 3.329

@XiangShanRobot
Copy link

[Generated by IPC robot]
commit: dee5eec

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
dee5eec 1.818 0.441 2.631 1.229 2.155 0.000 2.154 2.352 0.936 1.410 1.564 3.114 2.539 2.268 3.329

master branch:

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
43ec013 1.807 0.936
884071a 2.631 1.807 1.410
c92872b 1.818 0.441 2.631 1.230 2.155 1.807 2.154 2.352 0.936 1.410 1.564 3.114 2.539 2.268 3.329
0997713 1.818 1.241 2.155 1.807 2.154 0.936 1.564 3.114 2.268 3.329
3a1d39b 1.818 0.441 2.631 1.227 2.155 1.807 2.154 2.352 0.936 1.410 1.564 3.114 2.539 2.268 3.329
bd14dcb 1.818 0.441 2.631 1.239 2.155 1.807 2.154 2.352 0.936 1.410 1.564 3.114 2.539 2.268 3.329
a8177c6 1.818 0.441 2.631 1.226 2.155 1.807 2.154 2.352 0.936 1.410 1.564 3.114 2.539 2.268 3.329
2c0d73d 1.818 0.441 2.631 1.224 2.155 1.807 2.154 2.352 0.936 1.410 1.564 3.114 2.539 2.268 3.329

@klin02 klin02 marked this pull request as ready for review November 18, 2025 06:39
@XiangShanRobot
Copy link

[Generated by IPC robot]
commit: 1985c22

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
1985c22 1.824 0.440 2.630 1.235 2.151 0.000 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319

master branch:

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
d834f7f 1.824 0.440 2.630 1.232 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
10c65c4 1.824 0.440 2.630 1.225 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
fb8b285 1.824 0.440 2.630 1.234 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
6759232 1.824 0.440 2.630 1.223 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
3815b53 1.821 0.440 2.630 1.234 2.151 1.807 2.153 2.353 0.934 1.382 1.540 3.108 2.545 2.274 3.337
2ffa3e7 1.821 0.440 2.630 1.225 2.151 1.807 2.153 2.353 0.934 1.382 1.540 3.108 2.545 2.274 3.337
74565ee 0.440 2.630 1.218 1.807 2.153 2.353 0.934 1.382 1.540 3.108 2.545 3.337
a1c1051 1.821 0.440 2.630 1.221 2.151 1.807 2.153 2.353 0.934 1.382 1.540 3.108 2.545 2.274 3.337

@klin02 klin02 force-pushed the fix-difftop branch 2 times, most recently from 6dd13e0 to 2bbc465 Compare December 4, 2025 17:14
@XiangShanRobot
Copy link

[Generated by IPC robot]
commit: 2bbc465

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
2bbc465 1.824 0.440 2.630 1.227 2.151 0.000 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319

master branch:

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
baaefe3 1.824 0.440 2.630 1.228 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
c26b502 1.824 0.440 2.630 1.223 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
d834f7f 1.824 0.440 2.630 1.232 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
10c65c4 1.824 0.440 2.630 1.225 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
fb8b285 1.824 0.440 2.630 1.234 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
6759232 1.824 0.440 2.630 1.223 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
3815b53 1.821 0.440 2.630 1.234 2.151 1.807 2.153 2.353 0.934 1.382 1.540 3.108 2.545 2.274 3.337
2ffa3e7 1.821 0.440 2.630 1.225 2.151 1.807 2.153 2.353 0.934 1.382 1.540 3.108 2.545 2.274 3.337

@klin02 klin02 marked this pull request as ready for review December 5, 2025 03:40
@klin02 klin02 requested a review from SFangYy as a code owner December 5, 2025 03:40
Copy link
Collaborator

@SFangYy SFangYy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xspdb ack

Copy link
Member

@Tang-Haojin Tang-Haojin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top LGTM

Copy link
Member

@Maxpicca-Li Maxpicca-Li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@klin02 klin02 force-pushed the fix-difftop branch 2 times, most recently from aa2d97f to 96a0ebe Compare December 9, 2025 03:19
@XiangShanRobot
Copy link

[Generated by IPC robot]
commit: 96a0ebe

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
96a0ebe 1.824 0.440 2.630 1.233 2.151 0.000 2.154 2.351 0.932 1.382 1.615 3.113 2.543 2.274 3.319

master branch:

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
c06233b 1.824 0.440 2.630 1.218 2.151 1.806 2.154 2.351 0.932 1.382 1.615 3.113 2.543 2.274 3.319
97830c3 1.824 0.440 2.630 1.230 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
c9d8b82 1.824 0.440 2.630 1.230 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
baaefe3 1.824 0.440 2.630 1.228 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
c26b502 1.824 0.440 2.630 1.223 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
d834f7f 1.824 0.440 2.630 1.232 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
10c65c4 1.824 0.440 2.630 1.225 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
fb8b285 1.824 0.440 2.630 1.234 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
6759232 1.824 0.440 2.630 1.223 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319

@XiangShanRobot
Copy link

[Generated by IPC robot]
commit: 5bafc05

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
5bafc05 1.824 0.440 2.630 1.221 2.151 1.806 2.154 2.351 0.932 1.382 1.615 3.113 2.543 2.274 3.319

master branch:

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
c06233b 1.824 0.440 2.630 1.218 2.151 1.806 2.154 2.351 0.932 1.382 1.615 3.113 2.543 2.274 3.319
97830c3 1.824 0.440 2.630 1.230 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
c9d8b82 1.824 0.440 2.630 1.230 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
baaefe3 1.824 0.440 2.630 1.228 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
c26b502 1.824 0.440 2.630 1.223 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
d834f7f 1.824 0.440 2.630 1.232 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
10c65c4 1.824 0.440 2.630 1.225 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
fb8b285 1.824 0.440 2.630 1.234 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
6759232 1.824 0.440 2.630 1.223 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319

@XiangShanRobot
Copy link

[Generated by IPC robot]
commit: db2dd83

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
db2dd83 1.824 0.440 2.630 1.227 2.151 1.806 2.154 2.351 0.932 1.382 1.615 3.113 2.543 2.274 3.319

master branch:

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
c06233b 1.824 0.440 2.630 1.218 2.151 1.806 2.154 2.351 0.932 1.382 1.615 3.113 2.543 2.274 3.319
97830c3 1.824 0.440 2.630 1.230 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
c9d8b82 1.824 0.440 2.630 1.230 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
baaefe3 1.824 0.440 2.630 1.228 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
c26b502 1.824 0.440 2.630 1.223 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
d834f7f 1.824 0.440 2.630 1.232 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
10c65c4 1.824 0.440 2.630 1.225 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319
fb8b285 1.824 0.440 2.630 1.234 2.151 1.806 2.154 2.352 0.932 1.382 1.615 3.113 2.546 2.274 3.319

klin02 and others added 6 commits December 11, 2025 11:33
Latest difftest introduces following notable change:

1. CPU as submodule of Difftest
   Difftest now allows instantiating the CPU as a submodule and exposing
   additional IOs. LazyModules must explicitly provide clock and reset
   signals.
   (PRs: difftest#713, difftest#757, difftest#758)

2. Replace ArchReg + WriteBack with PhyReg + RenameTable
   The old embedded-into-CPU Difftest logic is removed. The new PhyReg +
   RenameTable interface eliminates additional phy-to-arch logic and multi-
   read-port overhead inside the CPU and removes interface of ArchReg/WriteBack.
   (PRs: difftest#714, difftest#754)

3. RefillEvent interface modification
   Refill checking now support masked refill-check to support low-power
   read.
   (PRs: difftest#719, difftest#723)

4. PGO_BOLT option for emu compilation
   A new PGO_BOLT mode is provided to accelerate EMU compilation under
   profile-guided optimization.
   (PR: difftest#756, difftest#761)
This change moves XSDiffTop instantiation into the Difftest for fpgaDiff.
DiffTop will generated with a SimTop wrapper, where DiffTest outputs,
together with XSTop's IO ports, AXI4 buses of memory/peripheral/DMA will
be exposed for external connection.

Temporarily, we still expose XSNoCDiffTop with appended Difftest IOs, and
generate XSTop and XSNoCTop with internal Difftest DPI-C, so as to avoid
extra TopIOs and mixed generated files. We will try to refactor them like
DiffTop later.(i.e. generate with a seperated Difftest)
This change refactors Difftest interfaces, replacing the previous
ArchReg and WriteBack with PhyRegState and ArchRenameTable.

By default, Difftest still extracts PhyReg and RenameTable into
ArchReg on the hardware side, so that the extra multi-read area
is accounted for within Difftest.

When acceleration is enabled, this extraction is deferred to the
software side, eliminating the extra hardware area overhead.

Since 128-bit ArchVecReg are now treated as two 64-bit registers
in Difftest, we add corresponding register splitting in XiangShan.
The address indexs (InstrCommit.otherwpdest and RenameTable) are
also converted from `index` to `2*index` and `2*index + 1` for reg
splitting.

Note XiangShan separates V0 and Vf register files. When mering the
two regfiles and renameTable for Difftest, the indexs of Vf must
add offset of V0RegSize to ensure correct indexing.
After #3051, we have supported low-power read (read only 5 out of 8
8B-banks) in ICacheDataArray, and in V3, it was further modified to
dynamically compute the mask based on the taken branch location.

Though, previous DiffRefillEvent does not support masked comparison,
instead it checks entire 512bit, so it will fail if we enable checks on
cacheid >=3 (OpenXiangShan/difftest#712). As we're refactoring ICache
recently, we need this check to ensure the refactored code is working
properly.

This commit removes unused idtfr and introduces masked refill-check
for Difftest, where each mask bit controls comparison of 8B data.

However, as the newly added masked Refill fails CI, we disable it for
now, and wait for later fixup.

Co-authored-by: ngc7331 <[email protected]>
This change unifies the args handling for PLDM and FPGA_DIFF into a shared
DEBUG_ARGS options, with PLDM=1 or FPGA=1 used to distinguish between the
two environments.

For PLDM, we continue to enable the full Difftest by default as it used to
be. For FPGA, we set it default to BASIC_DIFF and remove additional debug
printing to reduce overhead. Any extra options can be supplied via
DEBUG_ARGS as needed.

Example usage:
  PLDM=1 DEBUG_ARGS="--difftest-config ZESN --perf-level CRITICAL"
  FPGA=1 DEBUG_ARGS="--difftest-config ESBIFDU --difftest-exclude Vec"
This PR updates the xspdb to adapt to the API changes.

---------

Co-authored-by: Zhicheng Yao <[email protected]>
@XiangShanRobot
Copy link

[Generated by IPC robot]
commit: 73dd834

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
73dd834 1.824 0.439 2.630 1.229 2.151 1.806 2.154 2.351 0.932 1.400 1.615 3.113 2.543 2.274 3.319

master branch:

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
5b5aae7 1.824 0.439 2.630 1.227 2.151 1.806 2.154 2.351 0.932 1.400 1.615 3.113 2.543 2.274 3.319
c06233b 1.824 0.440 2.630 1.218 2.151 1.806 2.154 2.351 0.932 1.382 1.615 3.113 2.543 2.274 3.319

@good-circle good-circle merged commit 6ddbd50 into master Dec 12, 2025
23 of 24 checks passed
@good-circle good-circle deleted the fix-difftop branch December 12, 2025 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: tool non-RTL tools like difftest, gsim, XSpdb, Makefiles, scripts, CI/CD, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants