https://mp.weixin.qq.com/s/9PsBt4_4qHx4i6C5XtuiUw
介绍LazyModule和Node构造方法的执行过程,即实例化过程。
1. NullIntSource
以NullIntSource为例,将其作为顶层的LazyModule考虑:
2. 实例化过程
1) 执行NullIntSource的构造方法,首先要逐层向上执行各个父类的构造方法;
。之后再添加的LazyModule都会加入到这个scope中。
b. 把本LazyModule加入到父LazyModule中:
因为这里把NullIntSource作为顶层LazyModule,所以parent为None,不执行实际添加。
节点;
其中首先执行BaseNode的构造方法,把当前节点加入到LazyModule.scope中:
d. 定义lazy val module:
intnode是一个source节点,没有输入只有输出。module的实现中默认让intnode.out输出0。
3. 总结
a. LazyModule提供一个框架,以容纳内部LazyModule和节点,即实现模块层次结构(hierarchy);
为内部模块提供连接);
c. Node为LazyModule提供参数协商支持,而后提供输入输出连接;不能嵌套,也没有内部逻辑;
4. 附录
NullIntSource.scala:
// See LICENSE.SiFive for license details.
freechips.rocketchip.interrupts
Chisel._
freechips.rocketchip.config.Parameters
freechips.rocketchip.diplomacy._
/** Useful for stubbing out parts of an interrupt interface where certain devices might be missing */
LazyModule
{
(num, ports, sources))
) {
.B } }
}
}
NullIntSource {
= {
NullIntSource(num, ports, sources))
intnode
}
}