Skip to content

Commit b5c2f4c

Browse files
authored
feat: support parameterized addr width with CHI_ADDR_WIDTH (#4620)
By default, XiangShan uses a fixed 48-bit physical address width, which is not configurable. However, some SoCs require support for different address widths (e.g., CHI buses support 44-52-bit addressing). To accommodate these SoC needs, this pr introduces a parameterized physical address width configured via `CHI_ADDR_WIDTH`. Key notes: 1. `CHI_ADDR_WIDTH` only modifies the address width for interactions between CoupledL2 and the CHI bus. Addresses within CoupledL2 and XSCore remain 48-bit, incurring some area overhead but functionally correct. 2. If `CHI_ADDR_WIDTH` < 48, CoupledL2 truncates the upper bits of addresses. As for snoops, truncated bits are treated as zero. Therefore It is critical to configure PMA at compile time to prevent XiangShan from generating address beyond the `CHI_ADDR_WIDTH`-defined address space.
1 parent 9680387 commit b5c2f4c

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ ifeq ($(ENABLE_NS),1)
106106
COMMON_EXTRA_ARGS += --enable-ns
107107
endif
108108

109+
# CHI physical address width
110+
ifneq ($(CHI_ADDR_WIDTH),)
111+
COMMON_EXTRA_ARGS += --chi-addr-width $(CHI_ADDR_WIDTH)
112+
endif
113+
109114
# L2 cache size in KB
110115
ifneq ($(L2_CACHE_SIZE),)
111116
COMMON_EXTRA_ARGS += --l2-cache-size $(L2_CACHE_SIZE)

src/main/scala/top/ArgParser.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ object ArgParser {
210210
nextOption(config.alter((site, here, up) => {
211211
case SoCParamsKey => up(SoCParamsKey).copy(SeperateDM = true)
212212
}), tail)
213+
case "--chi-addr-width" :: value :: tail =>
214+
nextOption(config.alter((site, here, up) => {
215+
case coupledL2.tl2chi.CHIAddrWidthKey => value.toInt
216+
}), tail)
213217
case "--wfi-resume" :: value :: tail =>
214218
nextOption(config.alter((site, here, up) => {
215219
case XSTileKey => up(XSTileKey).map(_.copy(wfiResume = value.toBoolean))

src/main/scala/xiangshan/L2Top.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import freechips.rocketchip.tile.{BusErrorUnit, BusErrorUnitParams, BusErrors, M
2727
import freechips.rocketchip.tilelink._
2828
import coupledL2.{EnableCHI, L2ParamKey, PrefetchCtrlFromCore}
2929
import coupledL2.tl2tl.TL2TLCoupledL2
30-
import coupledL2.tl2chi.{CHIIssue, PortIO, TL2CHICoupledL2}
30+
import coupledL2.tl2chi.{CHIIssue, PortIO, TL2CHICoupledL2, CHIAddrWidthKey, NonSecureKey}
3131
import huancun.BankBitsKey
3232
import system.HasSoCParameter
3333
import top.BusPerfMonitor
@@ -114,6 +114,8 @@ class L2TopInlined()(implicit p: Parameters) extends LazyModule
114114
)
115115
case EnableCHI => p(EnableCHI)
116116
case CHIIssue => p(CHIIssue)
117+
case CHIAddrWidthKey => p(CHIAddrWidthKey)
118+
case NonSecureKey => p(NonSecureKey)
117119
case BankBitsKey => log2Ceil(coreParams.L2NBanks)
118120
case MaxHartIdBits => p(MaxHartIdBits)
119121
case LogUtilsOptionsKey => p(LogUtilsOptionsKey)

0 commit comments

Comments
 (0)