在verilog中有这样一种方法来访问其他模块的东西,因为我知道它被称为"分层路径",这里是verilog RTL
module A;
reg a;
endmodule
module tb;
A u_A();
wire b;
assign b = u_A.a; // hierarchical path
endmodule
你能否告诉我如何在Chisel / Scala中访问其他模块的Reg / Wire?
答案 0 :(得分:1)
AFAIK,这在chisel3中是不可能的。如果你尝试,你会收到错误
An exception or error caused a run to abort: Connection between sink (chisel3.core.UInt@b) and source (chisel3.core.UInt@1b) failed @: Source is unreadable from current module.
chisel3.internal.ChiselException: Connection between sink (chisel3.core.UInt@b) and source (chisel3.core.UInt@1b) failed @: Source is unreadable from current module
如果要将其暴露给外部模块,则应通过io机制执行此操作。 也就是说,通过使用实验性功能MultiIOModule可以创建直接访问模块的语法外观
import chisel3._
import chisel3.experimental._
class A extends MultiIOModule {
val reg = Reg(UInt(16.W))
val r = IO(Output(reg))
r := reg
}
class B extends MultiIOModule {
val u_A = Module(new A)
val b = Wire(UInt(16.W))
b := u_A.r
}