Commit Graph

11120 Commits

Author SHA1 Message Date
lihuijin 94e0a62c97 timing(loadQueueRAW): fix timing for query.valid
The RAW query generation logic can ignore s2_nuke, because
s2_nuke will trigger a revoke in the next cycle.
2025-09-29 16:50:32 +08:00
lihuijin 49aa37a6cf timing(LRQ): fix timing for uop.exceptionVec
uop.exceptionVes does not need to be preserved in loadQueueReplay,
as uops with exceptions will be flushed by ROB.
2025-09-29 16:50:31 +08:00
good-circle 43b5ed6b1e timing(LLPTW): move address generation logic to one cycle earlier 2025-09-29 16:50:31 +08:00
Xu, Zefan 56b0a66fa5 timing(LLPTW): refactor block_hptw_req to improve timing
Commit 03938367 imports block_hptw_req to solve conflicts of syncing entries between sending mem req or sending hptw request. But block_hptw_req also made a bad timing path.

This patch use a different way to solve that. As mem req has higher priority, we could put hptw req before mem req.
2025-09-29 16:50:31 +08:00
good-circle 23d106b61a timing(PTW): fix timing for pmp check
pervious: cache.io.resp.bits.bypassed -> ptw.io.req.valid -> determine whether to use satp.mode or vsatp.mode by io.req.bits.req_info.s2xlate -> pmp.addr
now pmp.addr should always use satp rather than current_satp which do not rely on ptw.io.req.valid
2025-09-29 16:50:31 +08:00
tianxin a82f3b8040 timing(bitmap): fix BitampCache lookup and l0BitmapReg updata timing
* BitampCache hit and lookup logic divided into two stage
* Add a separate stage to update l0BitmapReg
2025-09-29 16:50:31 +08:00
lihuijin 5253033665 timing(LRQ): LRQ temporal optimization
There is no need to check any exception when enqueue ReplayQueue,
because it will be flushed by rob later.
2025-09-25 17:43:29 +08:00
lihuijin fe6ca12098 Revert "timing(LRQ & BankedDataArray): adjust ecc_error_delay to the previous pipeline"
This reverts commit c373238ea9.
2025-09-24 15:32:51 +08:00
lihuijin de54591860 Revert "timing(LoadQueueReplay): move needReplay generation to LDU"
This reverts commit f3ef084d67.
2025-09-24 15:32:20 +08:00
lihuijin c373238ea9 timing(LRQ & BankedDataArray): adjust ecc_error_delay to the previous pipeline 2025-09-19 18:27:12 +08:00
lihuijin f3ef084d67 timing(LoadQueueReplay): move needReplay generation to LDU 2025-09-16 17:45:41 +08:00
Tang Haojin be7a8a40a4
feat(build): add `DISABLE_XMR` to use `bore` instead of `tapAndRead` (#4976) 2025-09-15 13:18:32 +08:00
Xin Tian 143ba1cb97
fix(Bitmap): fix not need bitmap check logic in LLPTW (#5018)
* add CSRs *PBMTE Mux logic for pte.isPf to use
* add allStage condition for gStagePf
2025-09-14 23:09:54 +08:00
Yinan Xu dcc9cd806f
fix(difftest): bump and align parseArg return values (#5009)
* We also add the customized coverage firtool arguments
2025-09-08 10:00:02 +08:00
lwd 61747267a4
fix(Vsegment): fix address generation of misaligned split (#5006)
during the `s_pm` state, we set `isMisalignReg` from `isMisalignWire`.
Therefore, when `state === s_pm`, `isMisalignReg` has not yet been set,
so we need to modify it to `isMisalignReg`.
2025-09-06 13:58:25 +08:00
Yanqin Li b9e88a5bf7
fix(prefetch): the statistic of prefetch hit (#5005) 2025-09-05 16:21:57 +08:00
Haoyuan Feng 78340947d6
ci(config): set EnableSramCtl by default for lowpower (#5002) 2025-09-05 10:03:12 +08:00
Xin Tian 2ae6ec20ad
fix(Bitmap): add first_s2xlate_fault init when LLPTW handle jmp_bitmap_check request (#4996)
- The Bug occurs when L2TLB handle allStage and noS2xlate request in
same time
2025-09-02 15:18:27 +08:00
Xu, Zefan 2d515db2aa
fix(MMU): TLB freeze when ptw resp in particular cycle (#4983)
There is a situation:
* Cycle 0:
    * tlb_req_0
* Cycle 1:
    * tlb_req_0 -> need_gpa_wire
    * tlb_req_1
    * ptw_resp
* Cycle 2:
    * need_gpa_wire -> need_gpa
    * tlb_req_1 & ptw_resp -> p_hit (Bypass)

In this situation, need_gpa is set and would not be cleared, while the
origin tlb_req is responsed by bypass, so the TLB freezed.

This patch tries to fix this issue, by adding a p_hit_fast to get
whether bypass hit in Cycle 1.
2025-09-01 16:51:45 +08:00
Zhaoyang You 6139b84703
fix(excp): add SWC to exception priorities (#4923)
The software-check exception caused by Zicfilp has higher priority than
an illegal-instruction exception but lower priority than instruction
access-fault
2025-09-01 11:14:50 +08:00
Guanghui Cheng 9745b37f2f
fix(CSR): fix dpc for trapping to dmode (#4979) 2025-08-29 15:30:03 +08:00
xu_zh b2daf0a5c3
misc(issue_template): update label names & fix typo (#4960) 2025-08-26 15:07:47 +08:00
Muzi f1cd48aae8
fix(FTB): X state in FTB (#4971)
Drop previous write request when new update request needs to read sram
at the same time.
2025-08-26 00:22:15 +08:00
Tang Haojin 5adaa47ba5
submodule(difftest): bump difftest (#4967) 2025-08-23 01:01:24 +08:00
SFangYy db3800c43f
feat(pdb): Add XSPdb, a GDB-like interactive debugger for XiangShan (#4906)
### 1. Purpose of this Pull Request 
XSPdb is a specialized Python pdb-based debugging tool for RISC-V IP
cores, customized for Xiangshan's difftest interface. It provides
GDB-like interactive debugging capabilities, integrating: Terminal
command-line interface, RTL-level waveform toggling, Automated script
replay, System snapshot save/restore, Register initialization
configuration

### 2. Changes Made

* **New Tool (`XSPdb`)**: The core Python scripts for XSPdb have been
added under `scripts/xspdb/`. This tool provides an interactive
debugging console with standard pdb commands (e.g., breakpoints, step,
continue, register inspection).
* **Build System Integration**: A new Makefile, `pdb.mk`, has been
created to define the build targets and logic required for XSPdb.
* **Makefile Modification**: The root Makefile has been updated to
include `pdb.mk`, integrating the new `pdb` target into the main build
system.

### 3. Usage 

The new tool can be built and used via a new `make` target.
1. **Build the XSPdb package**: 
```bash
    make pdb NOOP_HOME=$(pwd)
 ```
2.  **Run a simulation with the XSPdb**:
```bash
   make pdb-run NOOP_HOME=$(pwd)
 ```

---------

Co-authored-by: Zhicheng Yao <yaozhicheng@ict.ac.cn>
2025-08-23 00:59:13 +08:00
Yanqin Li ed04ad453a
ci(perf): add template for v2 and v3 test (#4953)
1. add perf template for unified test
2. test v2 and v3 separately
3. add benchmark type for 0.3c/0.8c/1.0c
2025-08-20 17:00:48 +08:00
Jiuyue Ma 5fac58b138
fix(PTW): Fix X-prop caused by using un-initialized stage1Hit in Mux() (#4916)
When use `-xprop=xmerge` policy, the un-initialized `stage1Hit` in Mux()
will cause the X-state propagate to output port `io.resp.valid`. Fix it
by moving `idle` check out of Mux(), which means the `io.resp.valid`
only valid when `!idle`.

The generated RTL will changed from:

```
  wire             io_resp_valid_0 =
    stage1Hit
      ? ~idle & hptw_resp_stage2
      : ~idle & mem_addr_update & ~need_last_s2xlate
        & (guestFault | w_mem_resp & find_pte | s_pmp_check & accessFault | onlyS2xlate);
```

to:

```
  wire             io_resp_valid_0 =
    ~idle
    & (stage1Hit
         ? hptw_resp_stage2
         : mem_addr_update & ~need_last_s2xlate
           & (guestFault | w_mem_resp & find_pte | s_pmp_check & accessFault
              | onlyS2xlate));
```

Signed-off-by: Jiuyue Ma <majiuyue@bosc.ac.cn>
2025-08-19 17:04:30 +08:00
Xin Tian 005fbf7a9e
feat(config): modify CVM-related configs (#4957)
* set the default value of HasBitmapCheck to true
* modify the requirement for HasMEMencryption and KeyIDBits
2025-08-19 11:00:23 +08:00
lwd 835923c23f
fix(VSegmentUnit): fof instruction writeback origin vl (#4956)
This PR fix the mismatch of reference and dut when execute segment fault
only first instruction.

#4820 fix no-segment instruction.
2025-08-18 18:25:04 +08:00
Anzo 39824ca683
fix(VSegmentUnit): adjust the fullva bit width of the tlb req (#4954)
In order for the virtual address check to pass, we need to save the
complete vaddr.


71802692d9
this adjustment did not completely solve the problem.
2025-08-18 18:24:56 +08:00
Zhaoyang You a4d7d3c638
fix(pma): fix pmaAddr regOut and rdata (#4936) 2025-08-18 15:01:39 +08:00
Xin Tian 5be6ba1b46
fix(Bitmap): fix jmp_bitmap_check logic in PtwCache (#4935)
* In PtwCache, l0 & sp entries with onlypf should not trigger
jmp_bitmap_check.
2025-08-18 10:52:56 +08:00
Ziyue Zhang ef913a6ad6
fix(vlbusytable): remove wakeUpInt to avoid load fast wakes up vsetvli (#4941) 2025-08-14 15:15:33 +08:00
Zhaoyang You 7189933c87
fix(Config): fix pma base addr (#4940) 2025-08-13 09:42:18 +08:00
Zhaoyang You 482b1daff8
fix(pma): fix pma RegOut (#4929) 2025-08-06 16:49:16 +08:00
zhou tao ff4344e4e5
fix(ifu): fix IBuffer enqueue check for nc instructions. (#4922)
The nc (non-cacheable) attribute instructions go through the MMIO
channel. Unlike standard MMIO instructions, nc instructions can be
executed speculatively. For MMIO instructions, there's no need to check
whether the IBuffer is full when enqueuing. However, nc instructions
must check for IBuffer fullness.
This PR primarily fixes the issue where nc instructions were incorrectly
allowed to enqueue into the IBuffer even when it was full.
2025-08-05 10:21:08 +08:00
Anzo 75f7e54474
fix(misalign): fixed a hang issue caused by vector misalign (#4914)
EMU Test / Changes Detection (push) Has been cancelled Details
Release Jobs / build-xsdev-image (push) Has been cancelled Details
EMU Test / Generate Verilog (push) Has been cancelled Details
EMU Test / EMU - Basics (push) Has been cancelled Details
EMU Test / EMU - CHI (push) Has been cancelled Details
EMU Test / Docker Build (push) Has been cancelled Details
EMU Test / EMU - Performance (push) Has been cancelled Details
EMU Test / EMU - MC (push) Has been cancelled Details
EMU Test / SIMV - Basics (push) Has been cancelled Details
EMU Test / Upload Artifacts (push) Has been cancelled Details
EMU Test / Check Submodules (push) Has been cancelled Details
EMU Test / Check Format (push) Has been cancelled Details
Nightly Regression / Nightly Regression(master) - Checkpoints (push) Has been cancelled Details
Nightly Regression / Nightly Regression(kunminghu-v3) - Checkpoints (push) Has been cancelled Details
2025-08-02 19:47:21 +08:00
Tang Haojin 99d41d3bc1
feat(config): add CVM-related yaml configs (#4924)
EMU Test / Changes Detection (push) Has been cancelled Details
Release Jobs / build-xsdev-image (push) Has been cancelled Details
EMU Test / Generate Verilog (push) Has been cancelled Details
EMU Test / EMU - Basics (push) Has been cancelled Details
EMU Test / EMU - CHI (push) Has been cancelled Details
EMU Test / Docker Build (push) Has been cancelled Details
EMU Test / EMU - Performance (push) Has been cancelled Details
EMU Test / EMU - MC (push) Has been cancelled Details
EMU Test / SIMV - Basics (push) Has been cancelled Details
EMU Test / Upload Artifacts (push) Has been cancelled Details
EMU Test / Check Submodules (push) Has been cancelled Details
EMU Test / Check Format (push) Has been cancelled Details
2025-08-01 00:54:47 +08:00
Anzo 0e987bc1ed
fix(BusyTable): remove dontTouch to make Verilog cleaner (#4919)
EMU Test / Changes Detection (push) Waiting to run Details
EMU Test / Generate Verilog (push) Blocked by required conditions Details
EMU Test / EMU - Basics (push) Blocked by required conditions Details
EMU Test / EMU - CHI (push) Blocked by required conditions Details
EMU Test / Docker Build (push) Blocked by required conditions Details
EMU Test / EMU - Performance (push) Blocked by required conditions Details
EMU Test / EMU - MC (push) Blocked by required conditions Details
EMU Test / SIMV - Basics (push) Blocked by required conditions Details
EMU Test / Upload Artifacts (push) Blocked by required conditions Details
EMU Test / Check Submodules (push) Blocked by required conditions Details
EMU Test / Check Format (push) Blocked by required conditions Details
Release Jobs / build-xsdev-image (push) Waiting to run Details
Some instances of this module may have io.out not connected. Under
normal circumstances, Chisel would not generate these modules, but due
to dontTouch here, these modules without io connections are still
generated. We do not yet understand the specific reason for this.

However, such Verilog cannot be synthesized on some FPGA platforms, so
in order to ensure the uniformity of RTL, we need to remove this code.
2025-07-31 18:28:50 +08:00
Guanghui Cheng 067f755de5
fix(CSR): initialize [m|h|s]context to 0 (#4915) 2025-07-31 18:25:39 +08:00
Xin Tian 3f1da1da00
fix(Bitmap): fix X-prop caused by using RRArbiter in Bitmap module (#4920)
EMU Test / Changes Detection (push) Waiting to run Details
EMU Test / Generate Verilog (push) Blocked by required conditions Details
EMU Test / EMU - Basics (push) Blocked by required conditions Details
EMU Test / EMU - CHI (push) Blocked by required conditions Details
EMU Test / Docker Build (push) Blocked by required conditions Details
EMU Test / EMU - Performance (push) Blocked by required conditions Details
EMU Test / EMU - MC (push) Blocked by required conditions Details
EMU Test / SIMV - Basics (push) Blocked by required conditions Details
EMU Test / Upload Artifacts (push) Blocked by required conditions Details
EMU Test / Check Submodules (push) Blocked by required conditions Details
EMU Test / Check Format (push) Blocked by required conditions Details
Release Jobs / build-xsdev-image (push) Waiting to run Details
2025-07-30 20:10:40 +08:00
Haoyuan Feng 0a6e7c0298
fix(TLB): vaddr should be extended to PAddrBitsMax (#4913)
EMU Test / Changes Detection (push) Waiting to run Details
EMU Test / Generate Verilog (push) Blocked by required conditions Details
EMU Test / EMU - Basics (push) Blocked by required conditions Details
EMU Test / EMU - CHI (push) Blocked by required conditions Details
EMU Test / Docker Build (push) Blocked by required conditions Details
EMU Test / EMU - Performance (push) Blocked by required conditions Details
EMU Test / EMU - MC (push) Blocked by required conditions Details
EMU Test / SIMV - Basics (push) Blocked by required conditions Details
EMU Test / Upload Artifacts (push) Blocked by required conditions Details
EMU Test / Check Submodules (push) Blocked by required conditions Details
EMU Test / Check Format (push) Blocked by required conditions Details
Release Jobs / build-xsdev-image (push) Waiting to run Details
In the previous design, vaddr was sign-extended to PAddrBits to prevent
cases where the physical address width exceeds the virtual address
width. However, in the SV48x4 mode, the actual width of vaddr is 50
bits, which ended up being truncated to 48 bits.

In the onlyStage2 case, the generated guest physical address (gpaddr)
should match vaddr. But due to the truncation, gpaddr was also limited
to 48 bits, and the upper 2 bits were lost (set to zero).

To fix this bug, and to better support future extensions—vaddr is now
extended to the maximum physical address width (PAddrBitsMax) as defined
by the RISC-V specification.
2025-07-30 10:16:39 +08:00
Haoyuan Feng aa71c71fab
fix(TLB): fix GPA matching bug in Napot cases (#4911) 2025-07-30 10:15:50 +08:00
Anzo 71802692d9
fix(VSegmentUnit): adjust the fullva bit width of the tlb req (#4892)
EMU Test / Changes Detection (push) Waiting to run Details
EMU Test / Generate Verilog (push) Blocked by required conditions Details
EMU Test / EMU - Basics (push) Blocked by required conditions Details
EMU Test / EMU - CHI (push) Blocked by required conditions Details
EMU Test / Docker Build (push) Blocked by required conditions Details
EMU Test / EMU - Performance (push) Blocked by required conditions Details
EMU Test / EMU - MC (push) Blocked by required conditions Details
EMU Test / SIMV - Basics (push) Blocked by required conditions Details
EMU Test / Upload Artifacts (push) Blocked by required conditions Details
EMU Test / Check Submodules (push) Blocked by required conditions Details
EMU Test / Check Format (push) Blocked by required conditions Details
Release Jobs / build-xsdev-image (push) Waiting to run Details
2025-07-29 16:03:46 +08:00
xu_zh 2cf64d6d43
fix(ICache,Ifu): set memBackTypeMM and memPageTypeNC correctly (#4898)
EMU Test / Changes Detection (push) Has been cancelled Details
Release Jobs / build-xsdev-image (push) Has been cancelled Details
EMU Test / Generate Verilog (push) Has been cancelled Details
EMU Test / EMU - Basics (push) Has been cancelled Details
EMU Test / EMU - CHI (push) Has been cancelled Details
EMU Test / Docker Build (push) Has been cancelled Details
EMU Test / EMU - Performance (push) Has been cancelled Details
EMU Test / EMU - MC (push) Has been cancelled Details
EMU Test / SIMV - Basics (push) Has been cancelled Details
EMU Test / Upload Artifacts (push) Has been cancelled Details
EMU Test / Check Submodules (push) Has been cancelled Details
EMU Test / Check Format (push) Has been cancelled Details
Nightly Regression / Nightly Regression(master) - Checkpoints (push) Has been cancelled Details
Nightly Regression / Nightly Regression(kunminghu-v3) - Checkpoints (push) Has been cancelled Details
`MemBackTypeMM`: requesting region backed by main memory (`!pmp.mmio`)
(don't care pbmt)
`MemPageTypeNC`: requesting `pbmt=nc` region (don't care backtype)

We need to tell L2 Cache about this via Tilelink to make it work.

This PR:
- ICache: Always work on main memory (`!pmp.mmio && pbmt=pmp`)
  - `MemBackTypeMM` is always true
  - `MemPageTypeNC` is always false (keep default value)
- Ifu/InstrUncache: Might be working on main memory, but pbmt=nc/io. Or
on real mmio region
  - `MemBackTypeMM = !f3_pmp_mmio`
  - `MemPageTypeNC = f3_itlb_pbmt === Pbmt.nc`

---------

Co-authored-by: Yanqin Li <maxpicca@qq.com>
2025-07-25 21:00:38 +08:00
Xin Tian 53170f2ffd
fix(Bitmap): fix some bugs related to memory isolation (#4870)
* add bitmap wakeup the page table cache check hit state;
* modify the calculation of Bitmap permission data address, all of which
are accurate to 4K pages, and only return ITLB/DTLB page tables with 4K
granularity when permission check is enabled.
* fixed the issue that two requests in Bitmap check were merged and
missed the update permission;
* modify the permission query results of Super Page that are no longer
cached in PageTableCache;
* fixed the issue of l0Pets splicing format of PageTableCache output;
* fixed the issue that bitmap_checkfailed registers in PTW and HPTW were
not reset;
* fixed the issue that bitmapCacheEntry was not initialized;
* fixed the issue of Napot entry jmp_bitmap_check process;
* In BitmapCheck use parameters to selsct cf bits;
2025-07-25 20:43:49 +08:00
Yanqin Li 2c85bb852a
fix(DCache): there also needs memBackTypeMM setting (#4907)
EMU Test / Changes Detection (push) Waiting to run Details
EMU Test / Generate Verilog (push) Blocked by required conditions Details
EMU Test / EMU - Basics (push) Blocked by required conditions Details
EMU Test / EMU - CHI (push) Blocked by required conditions Details
EMU Test / Docker Build (push) Blocked by required conditions Details
EMU Test / EMU - Performance (push) Blocked by required conditions Details
EMU Test / EMU - MC (push) Blocked by required conditions Details
EMU Test / SIMV - Basics (push) Blocked by required conditions Details
EMU Test / Upload Artifacts (push) Blocked by required conditions Details
EMU Test / Check Submodules (push) Blocked by required conditions Details
EMU Test / Check Format (push) Blocked by required conditions Details
Release Jobs / build-xsdev-image (push) Waiting to run Details
In MSHR of DCache, there also needs memBackTypeMM setting, because the
default value of memBackTypeMM is 1.
2025-07-25 14:19:40 +08:00
xu_zh 2a3b755a18
fix(Ifu,InstrUncache): flush mmio fsm (#4903)
EMU Test / Changes Detection (push) Waiting to run Details
EMU Test / Generate Verilog (push) Blocked by required conditions Details
EMU Test / EMU - Basics (push) Blocked by required conditions Details
EMU Test / EMU - CHI (push) Blocked by required conditions Details
EMU Test / Docker Build (push) Blocked by required conditions Details
EMU Test / EMU - Performance (push) Blocked by required conditions Details
EMU Test / EMU - MC (push) Blocked by required conditions Details
EMU Test / SIMV - Basics (push) Blocked by required conditions Details
EMU Test / Upload Artifacts (push) Blocked by required conditions Details
EMU Test / Check Submodules (push) Blocked by required conditions Details
EMU Test / Check Format (push) Blocked by required conditions Details
Release Jobs / build-xsdev-image (push) Waiting to run Details
This should not happen on a normal MMIO req (mmio is sent only when last
instruction is commited, so no redirect will happen).

But on a pbmt=nc area, we can do speculative fetch: #3944, so it can be
cancelled by backend/ifu redirects, we should reset MMIO fsm and cancel
(or flush) requests from InstrUncache.
2025-07-24 17:09:26 +08:00
cz4e 78672dae11
fix(MainPipe): fix `s3_data_error_beu` generate logic avoid x state (#4899)
EMU Test / Changes Detection (push) Waiting to run Details
EMU Test / Generate Verilog (push) Blocked by required conditions Details
EMU Test / EMU - Basics (push) Blocked by required conditions Details
EMU Test / EMU - CHI (push) Blocked by required conditions Details
EMU Test / Docker Build (push) Blocked by required conditions Details
EMU Test / EMU - Performance (push) Blocked by required conditions Details
EMU Test / EMU - MC (push) Blocked by required conditions Details
EMU Test / SIMV - Basics (push) Blocked by required conditions Details
EMU Test / Upload Artifacts (push) Blocked by required conditions Details
EMU Test / Check Submodules (push) Blocked by required conditions Details
EMU Test / Check Format (push) Blocked by required conditions Details
Release Jobs / build-xsdev-image (push) Waiting to run Details
2025-07-24 15:07:50 +08:00
Haoyuan Feng 2a4e953c6a
fix(L2TLB): fix check condition for Napot pages (#4900)
The Napot extension requires that the lower 4 bits of the page table's
PPN satisfy 4'b1000. However, `pte_in.getPPN()` contains the original
PPN value, while ptw_resp.ppn has already been truncated once. So we
should use `pte_in.getPPN()` here to check Napot pages.
2025-07-24 14:33:47 +08:00