Chisel3 - Tutorial - Stack
https://mp.weixin.qq.com/s/-AVJD1IfvNIJhmZM40DemA
import chisel3._
import chisel3.util.log2Ceil class Stack(val depth: Int) extends Module {
val io = IO(new Bundle {
val push = Input(Bool())
val pop = Input(Bool())
val en = Input(Bool())
val dataIn = Input(UInt(32.W))
val dataOut = Output(UInt(32.W))
}) val stack_mem = Mem(depth, UInt(32.W))
val sp = RegInit(0.U(log2Ceil(depth+1).W))
val out = RegInit(0.U(32.W)) when (io.en) {
when(io.push && (sp < depth.asUInt)) {
stack_mem(sp) := io.dataIn
sp := sp + 1.U
} .elsewhen(io.pop && (sp > 0.U)) {
sp := sp - 1.U
}
when (sp > 0.U) {
out := stack_mem(sp - 1.U)
}
} io.dataOut := out
} object StackMain {
def main(args: Array[String]): Unit = {
chisel3.Driver.execute(Array("--target-dir", "generated/Stack"), () => new Stack(8))
}
}
Chisel3 - Tutorial - Stack的更多相关文章
- 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 - 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 ...
- Chisel3 - Tutorial - Adder4
https://mp.weixin.qq.com/s/X5EStKor2DU0-vS_wIO-fg 四位加法器.通过FullAdder级联实现. 参考链接: https://github.co ...
随机推荐
- K - Leapin' Lizards HDU - 2732 网络流
题目链接:https://vjudge.net/contest/299467#problem/K 这个题目从数据范围来看可以发现是网络流,怎么建图呢?这个其实不是特别难,主要是读题难. 这个建图就是把 ...
- react中this.setState的理解
this.setState作用? 在react中要修改this.state要使用this.setState,因为this.state只是一个对象,单纯的修改state并不会触发ui更新.所以我们需要用 ...
- 视频文件自动转rtsp流
最近碰到一个项目需要用到 rtsp 视频流做测试, 由于真实环境的 摄像头 并不能满足需求,故尝试了一下用本地视频文件转换成rtsp视频流做测试,记录一下~ 采用方案: Docker + EasyDa ...
- 【Scala】用实例弄清楚scala几种函数的定义和特点
文章目录 作为参数的函数 匿名函数 柯里化函数(currying) 闭包函数 作为参数的函数 scala> val a1 = Array(1,2,3,4) //这是一个数组 a1: Array[ ...
- 宽字节XSS跨站攻击
简介 宽字节跨站漏洞多发生在GB系统编码. 对于GBK编码,字符是由两个字节构成,在%df遇到%5c时,由于%df的ascii大于128,所以会自动拼接%5c,吃掉反斜线.而%27 %20小于asci ...
- md5函数
0x01 <?php error_reporting(0); $flag = 'flag{test}'; if (isset($_GET['username']) and isset($_GET ...
- 10大Web漏洞扫描工具
Web scan tool 推荐10大Web漏洞扫描程序 Nikto 这是一个开源的Web服务器扫描程序,它可以对Web服务器的多种项目(包括3500个潜在的危险文件/CGI,以及超过900个服务器版 ...
- SpringBoot + react app 项目,解决跨域问题的配置(跳坑含泪总结,亲测有效)
方法一: 对某一接口配置,可以在方法上添加 @CrossOrigin 注解 @CrossOrigin(origins = {"http://localhost:8110", &qu ...
- Postman学习之Postman简介
前言:对于测试人员来说,接口测试是必须掌握的一个技能:在工作中掌握了接口自动化测试无疑是如虎添翼,那么怎么开展接口测试呢?下面将介绍一款接口测试的神器——postman 1.postman背景介绍 p ...
- python datetime 转timestamp
import datetime import time d1=datetime.date.today() t1=time.mktime(d1.timetuple()) d2=datetime.date ...