介绍如何定义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. CC2530通用IO口的输入输出

    一.引脚概述 CC2530有40 个引脚.其中,有21个数字I/O端口,其中P0和P1是8 位端口,P2仅有5位可以使用.P2端口的5个引脚中,有2个需要用作仿真,有2个需要用作晶振.所以可供我们使用 ...

  2. 【Hadoop离线基础总结】oozie调度hive

    目录 1.拷贝hive的案例模板 2.编辑hive模板 3.上传工作文件到hdfs 4.执行oozie的调度 5.查看调度结果 1.拷贝hive的案例模板 cd /export/servers/ooz ...

  3. 【Hadoop离线基础总结】HDFS的API操作

    HDFS的API操作 创建maven工程并导入jar包 注意 由于cdh版本的所有的软件涉及版权的问题,所以并没有将所有的jar包托管到maven仓库当中去,而是托管在了CDH自己的服务器上面,所以我 ...

  4. HDU 2011 (水)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2011 题目大意:给你 m 个数,对于每个数,求前 n 项和,数列:1 - 1/2 + 1/3 - 1/ ...

  5. 暴力破解-HTTP Basic认证

    0x01 HTTP Basic认证介绍 基本认证 basic authentication ← HTTP1.0提出的认证方法 基本认证步骤: 1. 客户端访问一个受http基本认证保护的资源. 2. ...

  6. 你了解C#的协变和逆变吗

    从C# 4.0开始,泛型接口和泛型委托都支持协变和逆变,由于历史原因,数组也支持协变. 里氏替换原则:任何基类可以出现的地方,子类一定可以出现. 协变(out) 协变:即自然的变化,遵循里氏替换原则, ...

  7. java 版本比较

    public class version { public static int compareVersion(String version1, String version2) throws Exc ...

  8. delete old data in elasticsearch

    delete old data in elasticsearch 0.正文. 其实很简单,就是用他的rest api 发一个delete 请求到 localhost:9200/[indices] [i ...

  9. 05.django 搜索与过滤

    django-filter https://github.com/carltongibson/django-filter https://django-filter.readthedocs.io/en ...

  10. ol,li,ul,dl,dt,dd

    块级元素div尽量少用,其实和table一样,嵌套越少越好,它也是会影响速度的! ol 有序列表. <ol> <li>……</li> <li>……< ...