https://mp.weixin.qq.com/s/L5eAwv--WzZdr-CfW2-XNA

 
Chisel提供的Valid接口。如果valid为置1,则表明输出的bits有效;反之,则输出无效。
 
参考链接:
 
​​
 
1. Valid是一组用户自定义的输入输出接口
 
类的声明如下:
class Valid[+T <: Data](gen: T) extends Bundle
 
类Valid是一个泛型类(generic class),参数类型为T。
 
首先,T <: Data 表明T在类型结构树(hierarchy)中为Data的子类,就是说传入的T需要是Data类的子类。
其次,+T 在Scala中成为协变(covariance), 意思是,Valid[ChildClassOfT]是Valid[T]的子类,即是Valid[T]的子类型关系,与参数类型T的子类型关系是一致的,所以叫协变。反过来就叫逆变(contravariance),还有个不变(invariance)。有兴趣可以了解一下,没兴趣略过即可。
 
Valid类继承自Bundle,表明自己是一个用户自定义的复合数据类型。
 
包含两个数据成员:
val valid = Output(Bool())
val bits = Output(gen)
 
很好理解,当valid置1时,bits输出有效;当valid置0时,bits输出无效。
 
2. object Valid提供一个创建Valid接口的工厂方法
 
Companion object Valid起到的作用是一个工厂方法,可以省略new的使用,直接创建一个valid对象:
val enq = Input(Valid(gen))
 
3. 附录
 
Valid.scala:

/** Wrappers for valid interfaces and associated circuit generators using them.
*/ package chisel3.util import chisel3._
import chisel3.core.CompileOptions
import chisel3.experimental.DataMirror
import chisel3.internal.naming.chiselName // can't use chisel3_ version because of compile order /** An Bundle containing data and a signal determining if it is valid */
class Valid[+T <: Data](gen: T) extends Bundle
{
val valid = Output(Bool())
val bits = Output(gen)
def fire(dummy: Int = 0): Bool = valid
override def cloneType: this.type = Valid(gen).asInstanceOf[this.type]
} /** Adds a valid protocol to any interface */
object Valid {
def apply[T <: Data](gen: T): Valid[T] = new Valid(gen)
}
 

Chisel3 - util - Valid的更多相关文章

  1. Chisel3 - util - Pipe

    https://mp.weixin.qq.com/s/WeFesE8k0ORxlaNfLvDzgg   流水线,用于添加延迟.   参考链接: https://github.com/freechips ...

  2. Chisel3 - util - LockingArbiter

    https://mp.weixin.qq.com/s/5oAwH3scumARzPidRBfG2w     带锁多入单出仲裁器,输出会被锁定指定的时钟周期.   参考链接: https://githu ...

  3. Chisel3 - util - RRArbiter

    https://mp.weixin.qq.com/s/GcNIFkHfa0gW0HKkKvHZEQ     循环优先级(Round Robin)仲裁器.   参考链接: https://github. ...

  4. Chisel3 - util - Arbiter

    https://mp.weixin.qq.com/s/7Y23gV6yPvtmvKHTo2I8mw   基于ReadyValid接口实现的多入单出仲裁器.   参考链接: https://github ...

  5. Chisel3 - util - Queue

    https://mp.weixin.qq.com/s/vlyOIsQxR6bCqDDMtRQLLg   实现队列模块,先入先出(FIFO).   参考链接: https://github.com/fr ...

  6. Chisel3 - util - ReadyValid

    https://mp.weixin.qq.com/s/g7Q9ChxHbAQGkbMmOymh-g   ReadyValid通信接口.通信的双方为数据的生产者(Producer)和消费者(Consum ...

  7. Chisel3 - util - OneHot

    https://mp.weixin.qq.com/s/Jsy8P3m9W2EYKwneGVekiw   独热码相关的电路生成器.   参考链接: https://github.com/freechip ...

  8. Chisel3 - util - MixedVec

    https://mp.weixin.qq.com/s/mO648yx4_ZRedXSWX4Gj2g   可以容纳不同类型的变量的向量.   参考链接: https://github.com/freec ...

  9. Chisel3 - util - Mux

    https://mp.weixin.qq.com/s/TK1mHqvDpG9fbLJyNxJp-Q   Mux相关电路生成器.   参考链接: https://github.com/freechips ...

随机推荐

  1. Java 8 CompletableFuture思考

    Java 8 CompletableFuture思考 最近一直在用响应式编程写Java代码,用的框架大概上有WebFlux(Spring).R2dbc.Akka...一些响应式的框架. 全都是Java ...

  2. Spring Cloud学习 之 Spring Cloud Hystrix(基础知识铺垫)

    Spring Boot版本:2.1.4.RELEASE Spring Cloud版本:Greenwich.SR1 文章目录 前述: 快速入门: 命令模式: RxJava: 前述: ​ 在微服务架构中, ...

  3. Programmatically add an application to Windows Firewall

    Programmatically add an application to Windows Firewall 回答1   Not sure if this is the best way, but ...

  4. VL01N发货过账无法冲销

    1业务场景 SD和EWM在使用BAPI:BAPI_OUTB_DELIVERY_CONFIRM_DEC发货过账后,发现外向交货单无法被冲销,后来发现是在发货过账后,有一个字段VLSTK声明仓库被维护上了 ...

  5. python语法学习第五天--函数(2)

    命名空间: 命名空间(Namespace)是从名称到对象的映射,大部分的命名空间都是通过 Python 字典来实现的. 命名空间提供了在项目中避免名字冲突的一种方法.各个命名空间是独立的,没有任何关系 ...

  6. python语法学习第一天--变量、运算符、数据类型

    变量:计算机中的一块内存,给变量赋值意味着将值存入内存中 python中变量不用类型声明(根据赋的值决定类型),但使用时(创建时)必须赋值(=赋值). 多个变量的赋值: ①a=b=c=1; ②a,b, ...

  7. 设计模式GOF23之工厂模式01

    简单工厂模式和工厂方法模式 工厂模式核心:分工 简单工厂模式不符合OCP(Open-Closed Princinple)原则,扩展时需要更改原代码 工厂方法模式增加了类复杂度代码复杂度等,所以一般使用 ...

  8. Spring全家桶之springMVC(四)

      路径变量PathVariable PathVariable   Controller除了可以接收表单提交的数据之外,还可以获取url中携带的变量,即路径变量,此时需要使用@PathVariable ...

  9. 微信小程序通信录

    第一步:phone.wxml中 <view bindlongtap="clickPhone">{{phoneNum}}</view> 第二步:phone.j ...

  10. P4015 运输问题 最大/最小费用最大流

    P4015 运输问题 #include <bits/stdc++.h> using namespace std; , inf = 0x3f3f3f3f; struct Edge { int ...