简体   繁体   English

sbt找不到参数valName的隐式值

[英]sbt could not find implicit value for parameter valName

I'm using sbt to build some of the riscv boom from the source code, but the sbt complains that it "could not find implicit value for parameter valName: : freechips.rocketchip.diplomacy.ValName". 我正在使用sbt从源代码构建一些riscv繁荣,但是sbt抱怨说它“找不到参数valName的隐式值:: freechips.rocketchip.diplomacy.ValName”。 The detailed error message are as below: 详细的错误消息如下:

[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)

The code where sbt complains is as below: 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)
....
}

The LazyModule object code is as below: 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
    }
}

I think the sbt should find some val of type freechips.rocketchip.diplomacy.ValName, but it didn't find such kind of val. 我认为sbt应该找到一些类型为freechips.rocketchip.diplomacy.ValName的val,但是没有找到这种val。

You need to have an object of type ValName in the scope where your LazyModule s are instantiated: 你需要有类型的对象ValName在你的范围LazyModule s的实例:

implicit val valName = ValName("MyXbars")

For more details on Scala's implicit please see https://docs.scala-lang.org/tutorials/tour/implicit-parameters.html.html 有关Scala隐式的更多详细信息,请参见https://docs.scala-lang.org/tutorials/tour/implicit-parameters.html.html

You generally shouldn't need to manually create a ValName , the Scala compiler can materialize them automatically based on the name of the val you're assigning the LazyModule to. 通常,您不需要手动创建ValName ,Scala编译器可以根据将LazyModule分配给的val的名称自动实现它们。 You didn't include your imports in your example, but can you try importing ValName ? 您没有在示例中包括导入,但是可以尝试导入ValName吗?

import freechips.rocketchip.diplomacy.ValName

In most of rocket-chip code, this is imported via wildcard importing everything in the diplomacy package 在大多数火箭芯片代码中,这是通过通配符导入的,其中导入diplomacy包中的所有内容

import freechips.rocketchip.diplomacy._

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM