【问题标题】:Scopes in Chisel and scalaChisel 和 scala 中的范围
【发布时间】:2017-05-24 03:02:50
【问题描述】:

我是 chisel 的新手,我已经设计了基本电路和一个简单的 risc-v 处理器,但我仍然无法弄清楚示波器在 Scala/Chisel 中是如何工作的。考虑以下简单的计数器:

package example

import chisel3._

class GenericCounter(n: Int) extends Module {
  val io = IO(new Bundle {
    val ld   = Input(UInt(1.W))
    val cld  = Input(UInt(log2Ceil(n).W))
    val cout = Output(UInt(log2Ceil(n).W))
  })

  val cnt = RegInit(0.asUInt(n.W))

  when(io.ld === 1.U){
    cnt := io.cld
  } .otherwise{
    cnt :=  Mux(cnt===100.U, 0.U, cnt + 1.U)
  }
  io.cout := cnt
}

在尝试编译上述代码时,编译器给出了一个错误,即 log2ceil 未定义。但如果我使用 util.log2ceil 它工作正常。这适用于所有 util 函数,例如 Cat、isPow2 等。我知道 import chisel3._ 应该已经导入了所有必要的函数,但似乎我在这里遗漏了一些东西。有人可以帮帮我吗?

【问题讨论】:

    标签: scala chisel register-transfer-level


    【解决方案1】:

    在 Scala 中,导入包的所有内容不会导入任何子包的内容。因此如果你想导入chisel.util的内容,你也应该写import chisel3.util._

    【讨论】:

      猜你喜欢
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-21
      • 1970-01-01
      • 1970-01-01
      • 2023-03-12
      • 2021-10-19
      相关资源
      最近更新 更多