2017-08-20 18 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 
}