chisel - 如何测试 RawModule?

标签 chisel

我正在使用凿子 RawModule 作为我正在构建的模块的 AXI 接口(interface)(以便我可以使用 axi aclk 和 aresetn。)但是,我无法执行使用 peekpoke 测试仪的正常策略。测试具有时钟的原始模块的推荐策略是什么?

最佳答案

PeekPokeTester目前仅限于使用 MultiIOModule 或其子类型。您可以通过将 RawModule 包装在 MultiIOModule 中并将 IO(包括隐式时钟/重置)从包装 MultiIOModule 桥接到你的RawModule

Chisel 的新测试和验证库(取代 chisel-testers/chisel3.iotesters)预计将原生支持此功能,并存在相关的跟踪问题:ucb-bar/chisel-testers2#14 .

编辑:将 RawModule 包装在 MultiIOModule 中的示例:

import chisel3._
import chisel3.stage.ChiselStage

sealed trait CommonIO { this: RawModule =>
  val a = IO(Input(Bool()))
  val b = IO(Output(Bool()))
}

class Foo extends RawModule with CommonIO {
  val clk = IO(Input(Clock()))
  val rst = IO(Input(Reset()))
  b := withClockAndReset(clk, rst){ RegNext(a, true.B) }
}

class Wrapper extends MultiIOModule with CommonIO {
  val foo = Module(new Foo)
  foo.a := a
  b := foo.b
  foo.clk := clock
  foo.rst := reset
}

(new ChiselStage)
  .execute(Array("-X", "verilog"),
           Seq(chisel3.stage.ChiselGeneratorAnnotation(() => new Wrapper)))

这会产生以下 FIRRTL:

circuit Wrapper :
  module Foo :
    input a : UInt<1>
    output b : UInt<1>
    input clk : Clock
    input rst : Reset

    reg _T : UInt<1>, clk with : (reset => (rst, UInt<1>("h01")))
    _T <= a
    b <= _T

  module Wrapper :
    input clock : Clock
    input reset : UInt<1>
    input a : UInt<1>
    output b : UInt<1>

    inst foo of Foo
    foo.a <= a
    b <= foo.b
    foo.clk <= clock
    foo.rst <= reset

注意:

  1. 使用withClockAndReset使用clkrst作为RegNext的时钟和复位连接
  2. 必须显式建立隐式 Wrapper.clockWrapper.reset 的连接。 withClockAndReset 在这里不起作用。

关于chisel - 如何测试 RawModule?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57683775/

相关文章:

scala - 如何使用chisel模块作为包

chisel - 当我们应该在 chisel3 中使用 ":="而不是 "="时,同样的情况是 "when"和 "if"

chisel - Chisel/FIRRTL 工具链是否进行 bool 表达式优化?

scala - 如何在 I/O 端口中使用 chisel3.experimental.ChiselEnum?

cpu-architecture - MemReq 和 MemResp 在 RoccIO 中如何工作 - RISCV

chisel - 使用 Cat 运算符(operator)维护 FIRRTL 上的连接顺序

scala - 使用 scala 设计过滤器 - For 循环展开

scala - bool Scala/Chisel 的选项方法

simulation - Chisel PeekPokeTester 中的 Printf 与同一 RTL 上的 verilator 的行为不同

Chisel 分配给 UInt 的各个位