Chisel3 - Tutorial - Adder4
https://mp.weixin.qq.com/s/X5EStKor2DU0-vS_wIO-fg
import chisel3._
import chisel3.util._ //A 4-bit adder with carry in and carry out
class Adder4 extends Module {
val io = IO(new Bundle {
val A = Input(UInt(4.W))
val B = Input(UInt(4.W))
val Cin = Input(UInt(1.W))
val Sum = Output(UInt(4.W))
val Cout = Output(UInt(1.W))
})
//Adder for bit 0
val Adder0 = Module(new FullAdder())
Adder0.io.a := io.A(0)
Adder0.io.b := io.B(0)
Adder0.io.cin := io.Cin
// val s0 = Adder0.io.sum
//Adder for bit 1
val Adder1 = Module(new FullAdder())
Adder1.io.a := io.A(1)
Adder1.io.b := io.B(1)
Adder1.io.cin := Adder0.io.cout
// val s1 = Cat(Adder1.io.sum, s0)
//Adder for bit 2
val Adder2 = Module(new FullAdder())
Adder2.io.a := io.A(2)
Adder2.io.b := io.B(2)
Adder2.io.cin := Adder1.io.cout
// val s2 = Cat(Adder2.io.sum, s1)
//Adder for bit 3
val Adder3 = Module(new FullAdder())
Adder3.io.a := io.A(3)
Adder3.io.b := io.B(3)
Adder3.io.cin := Adder2.io.cout
// io.Sum := Cat(Adder3.io.sum, s2).asUInt
io.Sum := Cat(Adder3.io.sum, Adder2.io.sum, Adder1.io.sum, Adder0.io.sum)
io.Cout := Adder3.io.cout
} object Adder4Main {
def main(args: Array[String]): Unit = {
chisel3.Driver.execute(Array("--target-dir", "generated/Adder4"), () => new Adder4)
// chisel3.Driver.execute(args, () => new FullAdder)
}
}
Chisel3 - Tutorial - Adder4的更多相关文章
- Chisel3 - Tutorial - VendingMachine
https://mp.weixin.qq.com/s/tDpUe9yhwC-2c1VqisFzMw 演示如何使用状态机. 参考链接: https://github.com/ucb-bar/ch ...
- Chisel3 - Tutorial - VendingMachineSwitch
https://mp.weixin.qq.com/s/5lcMkenM2zTy-pYOXfRjyA 演示如何使用switch/is来实现状态机. 参考链接: https://github.co ...
- Chisel3 - Tutorial - Tbl
https://mp.weixin.qq.com/s/e8vJ8claauBtiuedxYYaJw 实现可以动态索引的表. 参考链接: https://github.com/ucb-bar/c ...
- Chisel3 - Tutorial - Stack
https://mp.weixin.qq.com/s/-AVJD1IfvNIJhmZM40DemA 实现后入先出(last in, first out)的栈. 参考链接: https://gi ...
- Chisel3 - Tutorial - Functionality
https://mp.weixin.qq.com/s/3hDzpJiANdwp07hO03psyA 演示使用函数进行代码复用的方法. 参考链接: https://github.com/ucb- ...
- Chisel3 - Tutorial - Parity
https://mp.weixin.qq.com/s/OtiQnE52PwdCpvmzJ6VFnA 奇偶发生器.统计输入中1的个数,如果为偶数则输出0,奇数则输出1. 参考链接: https: ...
- Chisel3 - Tutorial - ByteSelector
https://mp.weixin.qq.com/s/RQg2ca1rwfVHx_QG-IOV-w 字节选择器. 参考链接: https://github.com/ucb-bar/chisel ...
- Chisel3 - Tutorial - ShiftRegister
https://mp.weixin.qq.com/s/LKiXUgSnt3DzgFLa9zLCmQ 简单的寄存器在时钟的驱动下,逐个往下传值. 参考链接: https://github.com ...
- Chisel3 - Tutorial - Adder
https://mp.weixin.qq.com/s/SEcVjGRL1YloGlEPSoHr3A 位数为参数的加法器.通过FullAdder级联实现. 参考链接: https://githu ...
随机推荐
- Linux的vi和vim编辑器
Linux中分为:一般模式,插入模式和底行模式 一般模式(通过按iaoIAO键)-->插入模式 插入模式(按Esc键)--> 一般模式 一般模式(通过按:键)-->底行模式 底行模式 ...
- C# 判断文件格式的一些总结
前提概述: 项目中 经常会有上传图片的地方 有的时候需要对图片类型做一些要求 这个时候就需要一些判断 虽然前段上传的时候可以去做类型的限制 或者后台接受的时候从file的type 中获取图 ...
- 用Python快速实现一个垃圾分类APP|附带微信小程序
最近北京开始实行垃圾分类,导致大家对垃圾的研究热度突然涨高,垃圾们也纷纷表示从来没有获得过这么高的关注度.其实,上海市去年已经开始实行,网上已经有不少成熟的教程了,像什么<垃圾分类从入门到精通& ...
- ASP.NET Core on K8S学习之旅(12)Ingress
本篇已加入<.NET Core on K8S学习实践系列文章索引>,可以点击查看更多容器化技术相关系列文章. 一.关于Ingress Kubernetes对外暴露Service主要有三种方 ...
- Power Query:非常规工资条
常规工资条为标题.内容.空行,每三行一循环,横向排版.打印.空行填充颜色,方便切割.其中用到函数嵌套,先把table以row转换为list,然后用List.TransformMany生成Table.C ...
- 基于R语言的航空公司客户价值分析
分析航空公司现状 1.行业内竞争 民航的竞争除了三大航空公司之间的竞争之外,还将加入新崛起的各类小型航空公司.民营航空公司,甚至国外航空巨头.航空产品生产过剩,产品同质化特征愈加明显,于是航空公司从价 ...
- 在dynamics 365 中,看字段的描述需要到系统字段设置里面才能看到,这里提供一种sql直接看字段和实体名描述的方法
1.在crm对应的主数据库执行下面存储过程: -- ============================================= -- Author: <Author,,Name& ...
- 分布式锁-Redission-Lock锁的使用与原理
环境准备 添加 Maven 依赖 <dependency> <groupId>org.redisson</groupId> <artifactId>re ...
- 02JAVA基础-运算符及选择语句
一.运算符 1.算数运算符 算数运算符 备注 + 可以用作拼接 - * / 整数相除得整数,需要获得小数,需一方为浮点数 % 取余数 ++ 自增 -- 自减 扩展(1) 对于++和--的扩展(以++为 ...
- html中require.config 缓存问题
在html中,require的官方基本用法如下: <!DOCTYPE html> <html> <head> <title>My Sample Proj ...