chisel - 将寄存器中的值与 int 进行比较

标签 chisel rocket-chip

我正在尝试获取 reg 的值并将其与 if 语句中的数字进行比较

  val refill_addr    = Reg(UInt(width = paddrBits))
if ( refill_addr >  20000.U) 
   cacheable := true
   else 
       cacheable := false

但我收到此错误

[error] /home/a/i-rocket-chip/src/main/scala/rocket/ICache.scala:365:18: type mismatch;
[error]  found   : chisel3.core.Bool
[error]  required: Boolean
[error] if ( refill_addr >  20000.U) 
[error]                  ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed

最佳答案

您应该在此处使用 when/.otherwise 而不是 if/else

when 是一种 Chisel(硬件)构造,最终将映射到一个或多个多路复用器。 if 是一个 Scala 构造,可用于硬件的编译时生成。

when (refill_addr >  20000.U) {
  cacheable := true
} .otherwise {
  cacheable := false
}

有关更多信息,there was a similar question here .

关于chisel - 将寄存器中的值与 int 进行比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56329835/

相关文章:

chisel - 如何从 chisel 代码生成 FIRRTL?

fpga - Chisel3 REPL peek 值是正确的,但期望在测试中失败

chisel - 执行存储到 Rocket Chip Core 的 L1 Dcache 时的响应信号

chisel - 检索 RegInit 的重置值

chisel - firrtl.Driver 已被弃用 - 但我们应该使用什么来代替呢?

scala - 如何将凿子 dsptools 与浮子一起使用

chisel - Chisel 模块中的条件端口

chisel - 如何获取 UInt Vec 中 Max 元素的索引,Chisel

scala - bool Scala/Chisel 的选项方法