https://mp.weixin.qq.com/s/AxYlRtAXjd55eoGX5l1W-A
 
模块(Module)从输入端口(input ports)接收输入,经过内部实现的转换逻辑,从输出端口(output ports)输出。
 
在Chisel3中,模块的输入输出端口,通过IO(new Bundle{...})的形式定义,其中定义了各种类型的数据变量。在实现模块内部转换逻辑的时候,也需要使用到各种类型的数据变量。这些变量如何加入到hardware graph中呢?就是通过WireBinding和RegBinding等。
 
 
1. WireBinding
 
定义如下:
ConstrainedBinding
 
a. Wire()
 
通过Wire()对一个变量进行Wire绑定,实例如下:
 
 
Wire继承自WireFactory:
WireFactory
 
b. WireFactory
 
 
a. 生成一个t的克隆x;
))
)
d. Builder.forcedUserModule可以理解为当前模块;
 
2. RegBinding
 
定义如下:
ConstrainedBinding
 
a. Reg()
 
通过Reg()对变量进行寄存器绑定,实例如下:
 
 
a. 生成一个t的可能reg;
))
)
d. Builder.forcedUserModule可以理解为当前模块;
 
3. MemPortBinding
 
Mem中的每一个元素,在使用时都会使用MemPortBinding进行绑定。
 
a. 使用实例如下:
b. 创建Mem()时并不会绑定
 
 
Mem()调用实现如下:
 
Mem类继承自MemBase:
 
MemBase在创建时并不会进行绑定;
 
c. 使用时进行绑定
 
中,stack_mem(sp)会调用方法:
 
进而调用makePort进行绑定:
 
 
 
 

相关文章:

  • 2021-08-28
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
  • 2021-07-13
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2021-08-15
相关资源
相似解决方案