1. 程式人生 > >Chisel3 - bind - PortBinding

Chisel3 - bind - PortBinding

tencent 雙向 輸出 傳遞 sun tac ima 輸入 是否

https://mp.weixin.qq.com/s/NaInHsJgOwG03BLNF-wlxQ 介紹Module輸入輸出端口如何進行綁定。 ?技術分享圖片? 1. IO() 在定義一個模塊時,使用Bundle的匿名子類型來定義模塊的輸入輸出端口,然後將其傳遞給IO()方法。 IO()方法定義在BaseModule中,其記錄自定義Bundle匿名子類型中各個數據成員的綁定信息。亦即把輸入輸出端口綁定到所在的模塊上。 ?技術分享圖片? a. 不能重復綁定:requireIsChiselType(iodef, "io type") b. 獲取一個iodef的克隆:iodef.cloneTypeFull
c. 調用_bindIoInPlace執行綁定動作 d. 返回iodefClone PS. require(!_closed, "Can‘t add more ports after module close")中的closed是指模塊是否已經完成定義,已經完成後則不可以再添加輸入輸出端口,這個後面再講。 2. _bindIoInPlace 這個方法實際執行綁定動作: ?技術分享圖片? a. _bindIoInPlace為BaseModule類的方法,所以PortBinding(this)中的this是指當前模塊; b. PortBinding(this)使用當前模塊構造一個PortBinding:
?技術分享圖片? c. iodef的類型為Bundle的子類型,所以有bind方法,調用其bind方法進行綁定 綁定的對象(target)為PortBinding,而這個PortBinding中含有對當前模塊的引用。從而把iodef和當期模塊綁定到一起。 d. 把iodef加入到當前模塊的IO端口中:_ports += iodef,這樣實現了從模塊到端口的引用。 結合iodef到模塊的binding,就成了雙向引用,可以互相查找。

Chisel3 - bind - PortBinding