介绍如何定义Wire/Reg/Memory/Prim。
 
1. DefWire
 
Wire()表明内括的Data的容器为线,用法为:
 
Wire()定义如下:
a. 获取一个t的克隆x;
b. 定义一个Definition, 即为DefWire:DefWire(sourceInfo, x)
c. DefWire同时也是一个Command,将其存下:pushCommand(DefWire(sourceInfo, x))
 
pushCommand()定义如下:
把命令c即DefWire,加入到forcedUserModule中。
 
 
2. DefReg
 
Reg()定义如下:
同样调用pushCommand()把定义寄存器的命令(DefReg),添加到forcedUserModule中。
 
 
3. DefMemory
 
Mem()定义如下:
调用pushCommand()把定义内存的命令(DefMemory),添加到forcedUserModule中。
 
4. DefPrim
 
以加法为例。
 
作为抽象方法,定义在Num中:
 
在子类UInt中实现,
 
 
 
5. 附录
 
Wire():
trait WireFactory {
def apply[T <: Data](t: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = {
if (compileOptions.declaredTypeMustBeUnbound) {
requireIsChiselType(t, "wire type")
}
val x = t.cloneTypeFull
 
// Bind each element of x to being a Wire
x.bind(WireBinding(Builder.forcedUserModule))
 
pushCommand(DefWire(sourceInfo, x))
if (!compileOptions.explicitInvalidate) {
pushCommand(DefInvalid(sourceInfo, x.ref))
}
 
x
}
}
 
Reg():
object Reg {
/** Creates a register without initialization (reset is ignored). Value does
* not change unless assigned to (using the := operator).
*
* @param t: data type for the register
*/
def apply[T <: Data](t: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = {
if (compileOptions.declaredTypeMustBeUnbound) {
requireIsChiselType(t, "reg type")
}
val reg = t.cloneTypeFull
val clock = Node(Builder.forcedClock)
 
reg.bind(RegBinding(Builder.forcedUserModule))
pushCommand(DefReg(sourceInfo, reg, clock))
reg
}
}
 
Mem():
object Mem {
@chiselRuntimeDeprecated
@deprecated("Mem argument order should be size, t; this will be removed by the official release", "chisel3")
def apply[T <: Data](t: T, size: Int)(implicit compileOptions: CompileOptions): Mem[T] = do_apply(size, t)(UnlocatableSourceInfo, compileOptions)
 
/** Creates a combinational/asynchronous-read, sequential/synchronous-write [[Mem]].
*
* @param size number of elements in the memory
* @param t data type of memory element
*/
def apply[T <: Data](size: Int, t: T): Mem[T] = macro MemTransform.apply[T]
def do_apply[T <: Data](size: Int, t: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Mem[T] = {
if (compileOptions.declaredTypeMustBeUnbound) {
requireIsChiselType(t, "memory type")
}
val mt = t.cloneTypeFull
val mem = new Mem(mt, size)
pushCommand(DefMemory(sourceInfo, mem, mt, size))
mem
}
}
 

Chisel3 - model - DefWire, Reg, Memory, Prim的更多相关文章

  1. Chisel3 - model - Builder

    https://mp.weixin.qq.com/s/THqyhoLbbuXXAtdQXRQDdA   介绍构建硬件模型的Builder.   1. DynamicContext   ​​ 动态上下文 ...

  2. Chisel3 - model - Hardware Model

    https://mp.weixin.qq.com/s/x6j7LZg7i7i_KcNEA8YCQw   Chisel作为领域专用语言(DSL),用于构建硬件模型.待硬件模型建立后,再基于模型进行仿真. ...

  3. Chisel3 - bind - Wire, Reg, MemPort

    https://mp.weixin.qq.com/s/AxYlRtAXjd55eoGX5l1W-A   模块(Module)从输入端口(input ports)接收输入,经过内部实现的转换逻辑,从输出 ...

  4. Chisel3 - model - 子模块,顶层模块

    https://mp.weixin.qq.com/s/3uUIHW8DmisYARYmNzUZeg   介绍如何构建由模块组成的硬件模型.   1. 子模块   一个模块可以有一个或多个子模块,创建子 ...

  5. Chisel3 - model - IO ports

    https://mp.weixin.qq.com/s/fgCvIFt0RdEajhJVSy125w   介绍模块的输入输出端口的定义与管理.     1. _ports   1) 模块的输入输出端口, ...

  6. Chisel3 - model - when

    https://mp.weixin.qq.com/s/YGTXky4wff7LXUphUxISQg   介绍创建模块判断逻辑的when命令.   1. when/elsewhen/otherwise ...

  7. linux abstract model of virtual memory

  8. Chisel3 - model - connect

    https://mp.weixin.qq.com/s/w8NqM3GVlF0NydpsB65KPg   介绍创建模块顺序逻辑的connect命令.     0. 这里先简单对 "=" ...

  9. Chisel3 - model - UserModule commands

    https://mp.weixin.qq.com/s/0ECca6XyFyEri0B4ckOZ4A   介绍UserModule类中,如何管理构建硬件模型所需的命令.   ​​   1. _comma ...

随机推荐

  1. Codeforces Round #575 (Div. 3) 昨天的div3 补题

    Codeforces Round #575 (Div. 3) 这个div3打的太差了,心态都崩了. B. Odd Sum Segments B 题我就想了很久,这个题目我是找的奇数的个数,因为奇数想分 ...

  2. IDEA的窗口布局设置

    修改idea的窗口布局 idea默认的窗口模式是如: 可以通过File->Appearance->Window Options->勾选 Widescreen tool window ...

  3. JS理论:编码习惯

    1.声明变量,你只会var吗?那你真的是JS小鲜肉 如果要声明3个变量,你要var 三下吗? 不用: let [a,b,c] = ['name',18,'ddd'] console.log(a,b,c ...

  4. throttle和debounce

    遇到的问题 在开发过程中会遇到频率很高的事件或者连续的事件,如果不进行性能的优化,就可能会出现页面卡顿的现象,比如: 鼠标事件:mousemove(拖曳)/mouseover(划过)/mouseWhe ...

  5. call(),apply(),bind() 区别和用法

    call call 方法第一个参数是要绑定给this的值,后面传入的是一个参数列表.当第一个参数为null.undefined的时候,默认指向window. var arr = [1, 2, 3, 8 ...

  6. 黑马程序员_毕向东_Java基础视频教程——进制转换之负数二进制(随笔)

    进制转换之负数二进制 负数的二进制表现形式 6 = 110 -6 : 其实就是 6 的二进制取反再 + 1 一个整数在内存中是占 4 个字节 **取反:将二进制里的 1 变成 0,0 变成 1. 以6 ...

  7. .Net Core3.0 WebApi 项目框架搭建 四:JWT权限验证

    .Net Core3.0 WebApi 项目框架搭建:目录 什么是JWT 根据维基百科定义,JWT(读作 [/dʒɒt/]),即JSON Web Tokens,是一种基于JSON的.用于在网络上声明某 ...

  8. vue+express上传头像到数据库中img的路径

    项目结构 express中间件指定静态资源目录 app.use("/static",express.static(path.join(__dirname,"/public ...

  9. js 前端实现文件流下载的几种方式

    后端是用Java写的一个下载的接口,返回的是文件流,需求:点击,请求,下载 利用iframe实现文件流下载 //把上一次创建的iframe删掉,不然随着下载次数的增多页面上会一堆的iframe var ...

  10. 聚类算法——DBSCAN算法原理及公式

    聚类的定义 聚类就是对大量未知标注的数据集,按数据的内在相似性将数据集划分为多个类别,使类别内的数据相似度较大而类别间的数据相似度较小.聚类算法是无监督的算法. 常见的相似度计算方法 闵可夫斯基距离M ...