2

我正在使用 sbt 从源代码构建一些 riscv 繁荣,但 sbt 抱怨它“找不到参数 valName::freechips.rocketchip.diplomacy.ValName 的隐含值”。详细的错误信息如下:

[error] F:\hiMCU\my_proj\src\main\scala\freechips\rocketchip\tile\BaseTile.scala:170:42: could not find implicit value for parameter valName: freechips.rocketchip.diplomacy.ValName
[error] Error occurred in an application involving default arguments.
[error]   protected val tlMasterXbar = LazyModule(new TLXbar)

sbt 抱怨的代码如下:

abstract class BaseTile private (val crossing: ClockCrossingType, q: Parameters)
    extends LazyModule()(q)
    with CrossesToOnlyOneClockDomain
    with HasNonDiplomaticTileParameters
{
    // Public constructor alters Parameters to supply some legacy compatibility keys
    def this(tileParams: TileParams, crossing: ClockCrossingType, lookup: LookupByHartIdImpl, p: Parameters) = {
        this(crossing, p.alterMap(Map(
            TileKey -> tileParams,
            TileVisibilityNodeKey -> TLEphemeralNode()(ValName("tile_master")),
            LookupByHartId -> lookup
    )))
}

def module: BaseTileModuleImp[BaseTile]
def masterNode: TLOutwardNode
def slaveNode: TLInwardNode
def intInwardNode: IntInwardNode    // Interrupts to the core from external devices
def intOutwardNode: IntOutwardNode  // Interrupts from tile-internal devices (e.g. BEU)
def haltNode: IntOutwardNode        // Unrecoverable error has occurred; suggest reset
def ceaseNode: IntOutwardNode       // Tile has ceased to retire instructions
def wfiNode: IntOutwardNode         // Tile is waiting for an interrupt

protected val tlOtherMastersNode = TLIdentityNode()
protected val tlSlaveXbar = LazyModule(new TLXbar)
protected val tlMasterXbar = LazyModule(new TLXbar)
protected val intXbar = LazyModule(new IntXbar)
....
}

LazyModule 对象代码如下:

object LazyModule
{
    protected[diplomacy] var scope: Option[LazyModule] = None
    private var index = 0

    def apply[T <: LazyModule](bc: T)(implicit valName: ValName, sourceInfo: SourceInfo): T = {
        // Make sure the user put LazyModule around modules in the correct order
        // If this require fails, probably some grandchild was missing a LazyModule
        // ... or you applied LazyModule twice
        require (scope.isDefined, s"LazyModule() applied to ${bc.name} twice ${sourceLine(sourceInfo)}")
        require (scope.get eq bc, s"LazyModule() applied to ${bc.name} before ${scope.get.name} ${sourceLine(sourceInfo)}")
        scope = bc.parent
        bc.info = sourceInfo
        if (!bc.suggestedNameVar.isDefined) bc.suggestName(valName.name)
        bc
    }
}

我认为 sbt 应该找到一些类型为 freechips.rocketchip.diplomacy.ValName 的 val,但它没有找到这种类型的 val。

4

2 回答 2

0

您通常不需要手动创建ValName,Scala 编译器可以根据您分配给的 val 的名称自动实现它们LazyModule。您没有在示例中包含您的导入,但是您可以尝试导入ValName吗?

import freechips.rocketchip.diplomacy.ValName

在大多数火箭芯片代码中,这是通过通配符导入diplomacy包中的所有内容

import freechips.rocketchip.diplomacy._
于 2019-07-26T22:16:46.843 回答
0

您需要在实例化 sValName的范围内有一个类型的对象LazyModule

implicit val valName = ValName("MyXbars")

有关 Scala 隐式的更多详细信息,请参阅https://docs.scala-lang.org/tutorials/tour/implicit-parameters.html.html

于 2019-07-26T02:24:48.103 回答