You need to enable JavaScript to run this app. 如何在ChipYard SOC框架中正确修改BOOM核心参数?
优惠活动
大模型
产品
解决方案
定价
更多

如何在ChipYard SOC框架中正确修改BOOM核心参数?

解决ChipYard中BOOM核心参数覆盖的Scala语法错误

问题背景

想要在ChipYard框架的自定义配置中覆盖BOOM核心参数,编写了KirinLargeBoomCustomOverrideConfig类,但编译时出现Scala语法错误。

原错误代码

class KirinLargeBoomCustomOverrideConfig extends Config(
    // The only argument we can pass (ie n) is the number of cores
    // we want to instantiate.

    new boom.common.WithNLargeBooms((n=1) => {
        // This is where we now over-ride the core parameters.
        case "numRobEntries" => 156
    }) ++ 

    // L2 coherent cache is included in the AbstractConfig().
    // But being over-ridden here with custom size of 512K.
    new freechips.rocketchip.subsystem.WithInclusiveCache(capacityKB=512) ++ 

    // The AbstractConfig() includes the freechips.rocketchip.system.BaseConfig.
    // This is the base Rocketchip system.
    new chipyard.config.AbstractConfig
) //class KirinLargeBoomCustomOverrideConfig

编译错误信息

[error] /sim_home/j00533938/chipyard_1.7.1/chipyard/generators/chipyard/src/main/scala/config/KirinConfigs.scala:86:38: not a legal formal parameter.
[error] Note: Tuples cannot be directly destructured in method or function parameters.
[error]       Either create a single parameter accepting the Tuple1,
[error]       or consider a pattern matching anonymous function: `{ case (param1, param1) => ... }
[error]    new boom.common.WithNLargeBooms((n=1) => {
[error]                                      ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed

错误原因

  1. Scala语法错误:(n=1) => { ... }是非法的匿名函数定义,Scala不允许在函数参数列表中直接给参数赋值。
  2. 参数覆盖方式错误:BOOM核心参数需要通过BoomKey(而非字符串键)来进行覆盖,这是RocketChip参数系统的规范。

正确解决方案

以下提供两种可行的写法:

写法一:继承WithNLargeBooms并覆盖boomConfig

这种方式更直观,直接修改BoomConfig的字段:

import chipyard.config.AbstractConfig
import boom.common.{WithNLargeBooms, BoomConfig}
import freechips.rocketchip.subsystem.WithInclusiveCache

class KirinLargeBoomCustomOverrideConfig extends Config(
    // 实例化1个Large BOOM核心,覆盖ROB条目数
    new WithNLargeBooms(1) {
        override val boomConfig: BoomConfig = super.boomConfig.copy(
            numRobEntries = 156
            // 可在此添加其他需覆盖的BOOM参数,例如fetchWidth、issueWidth等
        )
    } ++ 

    // 将L2 inclusive缓存容量设置为512KB
    new WithInclusiveCache(capacityKB = 512) ++ 

    new AbstractConfig
)

写法二:通过参数映射函数覆盖

符合RocketChip参数系统规范,使用PartialFunction匹配参数键:

import chipyard.config.AbstractConfig
import boom.common.{WithNLargeBooms, BoomKey}
import freechips.rocketchip.subsystem.WithInclusiveCache
import freechips.rocketchip.config.Parameters

class KirinLargeBoomCustomOverrideConfig extends Config(
    // 指定1个Large BOOM核心,通过BoomKey覆盖ROB条目数
    new WithNLargeBooms(1)((p: Parameters) => {
        case BoomKey => p(BoomKey).copy(numRobEntries = 156)
    }) ++ 

    new WithInclusiveCache(capacityKB = 512) ++ 

    new AbstractConfig
)

说明

  • 两种写法都能实现BOOM核心参数的覆盖,可根据个人习惯选择;
  • 确保导入了正确的包(如boom.common._),避免类找不到的错误;
  • 如果需要覆盖多个BOOM参数,只需在copy方法中添加对应字段即可。

内容的提问来源于stack exchange,提问作者Javed Osmany

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 04:15:39