https://mp.weixin.qq.com/s/KkkqvekWHG6yrqwHUECRIw
 
介绍如何定义Wire/Reg/Memory/Prim。
 
1. DefWire
 
Wire()表明内括的Data的容器为线,用法为:
 
Wire()定义如下:
a. 获取一个t的克隆x;
(sourceInfo, x)
(sourceInfo, x))
 
pushCommand()定义如下:
把命令c即DefWire,加入到forcedUserModule中。
 
 
2. DefReg
 
Reg()定义如下:
同样调用pushCommand()把定义寄存器的命令(DefReg),添加到forcedUserModule中。
 
 
3. DefMemory
 
Mem()定义如下:
调用pushCommand()把定义内存的命令(DefMemory),添加到forcedUserModule中。
 
4. DefPrim
 
以加法为例。
 
作为抽象方法,定义在Num中:
 
在子类UInt中实现,
 
 
 
5. 附录
 
Wire():
WireFactory {
= {
(compileOptions.declaredTypeMustBeUnbound) {
)
}
x = t.cloneTypeFull
 
// Bind each element of x to being a Wire
))
 
(sourceInfo, x))
(!compileOptions.explicitInvalidate) {
(sourceInfo, x.ref))
}
 
x
}
}
 
Reg():
Reg {
/** Creates a register without initialization (reset is ignored). Value does
* not change unless assigned to (using the := operator).
*
: data type for the register
*/
= {
(compileOptions.declaredTypeMustBeUnbound) {
)
}
reg = t.cloneTypeFull
)
 
))
(sourceInfo, reg, clock))
reg
}
}
 
Mem():
Mem {
@chiselRuntimeDeprecated
)
(size, t)(UnlocatableSourceInfo, compileOptions)
 
.
*
number of elements in the memory
data type of memory element
*/
]
] = {
(compileOptions.declaredTypeMustBeUnbound) {
)
}
mt = t.cloneTypeFull
Mem(mt, size)
(sourceInfo, mem, mt, size))
mem
}
}
 

相关文章:

  • 2022-12-23
  • 2021-10-30
  • 2021-06-16
  • 2022-12-23
  • 2021-09-21
  • 2022-12-23
  • 2021-06-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案