Chisel3 - Tutorial - Adder
https://mp.weixin.qq.com/s/SEcVjGRL1YloGlEPSoHr3A
import chisel3._ //A n-bit adder with carry in and carry out
class Adder(val n:Int) extends Module {
val io = IO(new Bundle {
val A = Input(UInt(n.W))
val B = Input(UInt(n.W))
val Cin = Input(UInt(1.W))
val Sum = Output(UInt(n.W))
val Cout = Output(UInt(1.W))
})
//create an Array of FullAdders
// NOTE: Since we do all the wiring during elaboration and not at run-time,
// i.e., we don't need to dynamically index into the data structure at run-time,
// we use an Array instead of a Vec.
val FAs = Array.fill(n)(Module(new FullAdder()).io)
// val FAs = Array.fill(n)(Module(new FullAdder()))
val carry = Wire(Vec(n+1, UInt(1.W)))
val sum = Wire(Vec(n, Bool())) //first carry is the top level carry in
carry(0) := io.Cin //wire up the ports of the full adders
for (i <- 0 until n) {
FAs(i).a := io.A(i)
FAs(i).a := io.A(i)
FAs(i).b := io.B(i)
FAs(i).cin := carry(i)
carry(i+1) := FAs(i).cout
sum(i) := FAs(i).sum.toBool()
} // for (i <- 0 until n) {
// FAs(i).io.a := io.A(i)
// FAs(i).io.a := io.A(i)
// FAs(i).io.b := io.B(i)
// FAs(i).io.cin := carry(i)
// carry(i+1) := FAs(i).io.cout
// sum(i) := FAs(i).io.sum.toBool()
// } io.Sum := sum.asUInt
io.Cout := carry(n)
} object AdderMain {
def main(args: Array[String]): Unit = {
chisel3.Driver.execute(Array("--target-dir", "generated/Adder"), () => new Adder(4))
}
}
Chisel3 - Tutorial - Adder的更多相关文章
- Chisel3 - Tutorial - Adder4
https://mp.weixin.qq.com/s/X5EStKor2DU0-vS_wIO-fg 四位加法器.通过FullAdder级联实现. 参考链接: https://github.co ...
- 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 ...
随机推荐
- Dynamics 9.0 安装好后 公告出现 提示:出现错误。 请稍等片刻,然后重试。 如果问题仍然存在,请与管理员联系。
此问题为系统的Bug,示例图如下: 解决方案为修改存储过程 p_RetrievePosts,将startDate参数的默认值改成 1900-01-01,endDate参数的默认值改成 9999-12- ...
- 03_CSS入门和高级技巧(1)
上节课知识的复习 插入图片,页面中能够插入的图片类型:jpg.jpeg.bmp.png.gif:不能的psd.fw. 语法: <img src="路径" alt=" ...
- 3、Hive-sql优化,数据倾斜处理
一.Hive-sql优化 #增加reducer任务数量(拉取数量分流) ; #在同一个sql中的不同的job是否可以同时运行,默认为false set hive.exec.parallel=true; ...
- js对页面中的内容进行拼音搜索,只对后台已经传过来的页面数据进行索引
实现输入拼音(可以使用拼音首字母来查),来查询出已经存在于页面的数据 注意:这种写法只能适用于页面中已经存在的数据进行检索,大体意思是将本页内的数据拼接成一个字符串,然后通过该字符串去检索匹配的字符串 ...
- SpringMVC底层执行原理
一个简单的HelloSpringMVC程序 先在web,xml中注册一个前端控制器(DispatcherServlet) <?xml version="1.0" encodi ...
- js中的小案例(一)
效果图: html代码: <div id="date"> <p> <span id="prev">上一月</span& ...
- OGG FOR BigData(Hive) GoldenGate 性能测试
版本信息: Oracle GoldenGate Command Interpreter Version 12.2.0.1.160419 OGGCORE_12.2.0.1.0OGGBP_PLATFORM ...
- mysql小白系列_08 zabbix添加自定义监控项items和触发器
监控mysql存活 1.配置agent自定义参数 vi /usr/local/zabbix/etc/zabbix_agentd.conf Include=/usr/local/zabbix/etc/z ...
- mysql 一台服务器中装两个mysql
个人经验: 服务器中已有mysql5.0 现要安装mysql5.5 下载安装包,安装后,mysql5.5中没有my.ini文件,就在我自己的电脑上复制了mysql5.5的my.ini文件进去. 1.在 ...
- HTML中id与name的通俗区别
转自:https://blog.csdn.net/qq_35038153/article/details/70215356 https://zhidao.baidu.com/question/7582 ...