2017-08-20 22 views
0

在Verilog中有这样一个访问其他模块的东西的方式,因为我知道它被称为“分层路径”,这里是一个的Verilog RTL如何使用凿子/斯卡拉的“层级路径”?

module A; 
    reg a; 
endmodule 
module tb; 
    A u_A(); 
    wire b; 
    assign b = u_A.a; // hierarchical path 
endmodule 

你能ENLIGHT我如何访问注册/其他电线凿子/斯卡拉模块?

回答

1

AFAIK,这在凿子3中是不可能的。如果你尝试,你会得到一个错误

An exception or error caused a run to abort: Connection between sink ([email protected]) and source ([email protected]) failed @: Source is unreadable from current module. 
chisel3.internal.ChiselException: Connection between sink ([email protected]) and source ([email protected]) 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 
}