gpt4 book ai didi

chisel - 如何测试 RawModule?

转载 作者:行者123 更新时间:2023-12-02 05:05:54 28 4
gpt4 key购买 nike

我正在使用凿子 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com