介绍如何定义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. 第五章:深入Python的dict和set

    第五章:深入Python的dict和set 课程:Python3高级核心技术 5.1 dict的abc继承关系 class Mapping(Collection): __slots__ = () &q ...

  2. Cookie什么?Cookie和Session防御怎么做?

    Cookie什么?Cookie和Session防御怎么做? Cookie的概念 Cookie,复数形态Cookies,中文名称为小型文本文件.指某些网站为了辨别用户身份.进行session跟踪而储存在 ...

  3. Day_14【IO流】扩展案例3_对文本文件中的字符串内容进行反转

    分析以下需求,并用代码实现 项目根路径下有text.txt文件,内容如下 我爱黑马 123456 利用IO流的知识读取text.txt文件的内容反转后写入text.txt文件中 654321 马黑爱我 ...

  4. arangodb安装

    这里仅介绍windows环境下的安装,直接官网下载安装包安装即可.安装完后进入安装目录进行配置. cd ArangoDB\\etc\\arangodb3 打开arangod.conf配置文件,修改以下 ...

  5. Java--ArrayList的遍历

    三种遍历方式 一.for循环 二.for each 三.Iterator器遍历 Iterator it = list.iterator(); while(it.hasNext()){ syso(it. ...

  6. [Selenium] 自动侦测浏览器版本并下载对应的浏览器驱动

    昨天在群里聊天时,有同学说 Appium 官方支持自动下载兼容的浏览器驱动,想来Selenium也有类似的方法,于是在网上搜索一番.参考了Medium上一篇文章的方法,对步骤进行改进,增加了对多浏览器 ...

  7. Java—线程的生命周期及线程控制方法详解

    线程生命周期5种状态 介绍   线程的生命周期经过新建(New).就绪(Runnable).运行(Running).阻塞(Bolocked)和死亡(Dead) 状态转换图 新建(New)   程序使用 ...

  8. bash leetcode

    拓展:grep 193.  ref: https://blog.csdn.net/yanglingwell/article/details/82343407 Given a text file fil ...

  9. day04:购物车的练习(20170216)

    product_list = [ ('IPhone',5900), ('Mac pro',9800), ('Bike',800), ('Watch',16000), ('Coffee',35), (' ...

  10. Spring 中基于 AOP 的 XML架构

    Spring 中基于 AOP 的 XML架构 为了使用 aop 命名空间标签,你需要导入 spring-aop j架构,如下所述: <?xml version="1.0" e ...