FPGA-FIF0模型与应用场景(IP核)

什么是FIFO

FIFO (First In First Out) ,也就是先进先出。FPGA或者ASIC中使用到的FIFO一般指的是对数据的存储具有先进先出特性的一个缓存器,常被用于数据的缓存或者高速异步数据的交互。它与普通存储器的区别是没有外部读写地址线,这样使用起来相对简单,但缺点就是只能顺序写入数据,顺序的读出数据,其数据地址由内部读写指针自动加1完成,不能像普通存储器那样可以由地址线决定读取或写入某个指定的地址。

FIFO作用:对于存储的数据,先存入FIFO的先被读出,可以确保数据的连续性

1,特征:数据产生速率>数据消耗速率

FIFO写入侧位宽 > FIFO读出侧位宽

2,特征:数据产生速率<数据消耗速率

FIFO写入侧位宽 < FIFO读出侧位宽

标准读模式同步FIFO

利用以下例子来熟悉FIFO使用:

打开vivado 创建工程

点击ok FIFO配置完成

然后编写FIFO测试文件

代码如下

`timescale 1ns / 1ps
module bram_sync_fifo_tb;reg clk;                    // input wire clkreg srst;                  // input wire srstreg [7:0]din;                   // input wire [7 : 0] dinreg wr_en;               // input wire wr_enreg rd_en;               // input wire rd_enwire [7:0]dout;                  // output wire [7 : 0] doutwire full;               // output wire fullwire almost_full;    // output wire almost_fullwire wr_ack;            // output wire wr_ackwire overflow;        // output wire overflowwire empty;              // output wire emptywire almost_empty;  // output wire almost_emptywire valid;               // output wire validwire underflow;        // output wire underflowwire [7:0]data_count;     // output wire [7 : 0] data_count    bram_sync_fifo your_instance_name (.clk(clk),                    // input wire clk.srst(srst),                  // input wire srst.din(din),                    // input wire [7 : 0] din.wr_en(wr_en),                // input wire wr_en.rd_en(rd_en),                // input wire rd_en.dout(dout),                  // output wire [7 : 0] dout.full(full),                  // output wire full.almost_full(almost_full),    // output wire almost_full.wr_ack(wr_ack),              // output wire wr_ack.overflow(overflow),          // output wire overflow.empty(empty),                // output wire empty.almost_empty(almost_empty),  // output wire almost_empty.valid(valid),                // output wire valid.underflow(underflow),        // output wire underflow.data_count(data_count)      // output wire [7 : 0] data_count);initial clk = 1;always #10 clk = ~clk;initial beginsrst = 1'b1;wr_en = 1'b0;rd_en = 1'b0;din = 8'hff;#21;srst = 1'b0;//写操作 从0-255 共256数据while(full == 1'b0)begin@(posedge clk);#1;wr_en = 1'b1;din = din + 1'b1;end//再多写1个数据  观察overflow的变化din = 8'hf0;@(posedge clk);#1;wr_en = 1'b0;#2000;//读操作 读256次while(empty == 1'b0)begin@(posedge clk)#1;rd_en = 1'b1;end//再多给一个读使能  看underflow的变化@(posedge clk)#1;rd_en = 1'b0;//复位#200;srst = 1'b1;#21;srst = 1'b0;#2000;$stop;endendmodule

仿真波形

写入时的波形

写满时的波形

读出时的波形

读完时的波形

FWFT读模式异步FIFO

点击ok FIFO配置完成

然后编写FWFT读模式异步FIFO测试文件

代码如下

`timescale 1ns / 1ps
module bram_asynv_fifo_tb;reg rst;                     // input wire rstreg wr_clk;                // input wire wr_clkreg rd_clk;                // input wire rd_clkreg [7:0]din;                     // input wire [7 : 0] dinreg wr_en;                 // input wire wr_enreg rd_en;                // input wire rd_enwire [15:0]dout;                  // output wire [15 : 0] doutwire full;                   // output wire fullwire almost_full;     // output wire almost_fullwire wr_ack;               // output wire wr_ackwire overflow;           // output wire overflowwire empty;                // output wire emptywire almost_empty;   // output wire almost_emptywire valid;                // output wire validwire underflow;          // output wire underflowwire [7:0]rd_data_count; // output wire [7 : 0] rd_data_countwire [8:0]wr_data_count;  // output wire [8 : 0] wr_data_countwire wr_rst_busy;     // output wire wr_rst_busywire rd_rst_busy;      // output wire rd_rst_busybram_async_fifo your_instance_name (.rst(rst),                      // input wire rst.wr_clk(wr_clk),                // input wire wr_clk.rd_clk(rd_clk),                // input wire rd_clk.din(din),                      // input wire [7 : 0] din.wr_en(wr_en),                  // input wire wr_en.rd_en(rd_en),                  // input wire rd_en.dout(dout),                    // output wire [15 : 0] dout.full(full),                    // output wire full.almost_full(almost_full),      // output wire almost_full.wr_ack(wr_ack),                // output wire wr_ack.overflow(overflow),            // output wire overflow.empty(empty),                  // output wire empty.almost_empty(almost_empty),    // output wire almost_empty.valid(valid),                  // output wire valid.underflow(underflow),          // output wire underflow.rd_data_count(rd_data_count),  // output wire [7 : 0] rd_data_count.wr_data_count(wr_data_count),  // output wire [8 : 0] wr_data_count.wr_rst_busy(wr_rst_busy),      // output wire wr_rst_busy.rd_rst_busy(rd_rst_busy)      // output wire rd_rst_busy);initial wr_clk = 1;always #10 wr_clk = ~wr_clk;initial rd_clk = 1;always #5 rd_clk = ~rd_clk;reg [5:0]cnt;always@(posedge rd_clk or posedge rst)if(rst)#1 cnt <= 1'b0;else if(cnt >= 6'd31)#1 cnt <= 1'b0;else if(rd_en)#1 cnt <= cnt + 1'b1;always@(posedge rd_clk or posedge rst)if(rst)#1 rd_en <= 1'b0;else if(rd_data_count > 9'd31)#1 rd_en <= 1'b1;else if(cnt >= 6'd31)#1 rd_en <= 1'b0;initial beginrst = 1'b1;wr_en = 1'b0;din = 8'hff;#(20*3+1);rst = 1'b0;//写数据@(negedge wr_rst_busy);wait(rd_rst_busy == 1'b0);repeat(257)begin@(posedge wr_clk)#1;wr_en = 1'b1;din = din +1'b1;endwr_en = 1'b0;#1000;$stop;endendmodule

仿真波形

写入时的波形

wr_en拉高 开始写数据

问题1解答:

这一块是由于仿真器设置导致的,在设置中语言选择的是Verilog和VHDL混合模式,所以会导致这个现象,但不建议直接改为Verilog语言模式,因为在一些IP核的底层是由Verilog和VHDL写好的,如果在这里改过来,虽然这一块波形是好的,但有可能在其他地方出现问题。

问题2解答:

看手册可以得知 空FIFO下 wr_data_count的值和 写深度与读深度的比例有关

在前面FIFO设置中,写深度与读深度比例是(256:128)即2:1 

看手册可知 wr_data_count的值为4。

问题3解答:

查看手册:

可知:在设置more accurate data counts后,当FIFO为空或几乎空时,写计数会多计数两个读数据量。当empty取消断言后,在almost_empty取消断言后的几个写时钟周期内,写计数会存在一个过渡期,来让自己的值正确。

为此会出现下列情况:

1·虽然没有读操作,但是写计数会出现递减

2.由于写操作的持续,写计数的值并不会按照预期增加

读出时波形

rd_en拉高  开始读数据

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/708040.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

python脚本实现全景站点欧拉角转矩阵

效果 脚本 import numpy as np import math import csv import os from settings import *def euler_to_rotation_matrix(roll, pitch, yaw):# 计算旋转矩阵# Z-Y-X转换顺序Rz

随想录算法训练营第四十五天|322.零钱兑换、279.完全平方数

322.零钱兑换 public class Solution {public int CoinChange(int[] coins, int amount) {int[] dpnew int [amount1];int maxint.MaxValue;for(int i0;i<dp.Length;i){dp[i]max;}dp[0]0;for(int i0;i<coins.Length;i){for(int jcoins[i];j<amount;j){if(dp[j-coins[…

leetcode hot100-2

给你一个字符串数组&#xff0c;请你将 字母异位词 组合在一起。可以按任意顺序返回结果列表。 字母异位词 是由重新排列源单词的所有字母得到的一个新单词。我的解法&#xff0c;是错误解法&#xff0c;只能通过 56 / 126 的测试用例 这个题就是想求&#xff0c;用到的所有字…

java多线程编程(学习笔记)入门

一、多线程创建的三种方式 (1)通过继承Thread本身 (2)通过实现runnable接口 (3)通过 Callable 和 Future 创建线程 其中&#xff0c;前两种不能获取到编程的结果&#xff0c;第三种能获取到结果 二、常见的成员方法 方法名称说明String getName()返回此线程的名称void setNam…

[数据集][目标检测]鸟类检测数据集VOC+YOLO格式11758张200类别

数据集格式&#xff1a;Pascal VOC格式YOLO格式(不包含分割路径的txt文件&#xff0c;仅仅包含jpg图片以及对应的VOC格式xml文件和yolo格式txt文件) 图片数量(jpg文件个数)&#xff1a;11758 标注数量(xml文件个数)&#xff1a;11758 标注数量(txt文件个数)&#xff1a;11758 标…

Docker之数据卷自定义镜像

文章目录 前言一、数据卷二、自定义镜像 前言 Docker提供了一个持久化存储数据的机制&#xff0c;与容器生命周期分离&#xff0c;从而带来一系列好处&#xff1a; 总的来说Docker 数据卷提供了一种灵活、持久、可共享的存储机制&#xff0c;使得容器化应用在数据管理方面更加…

Git 指令深入浅出【3】—— 远程仓库

Git 指令深入浅出【3】—— 远程仓库 一、远程仓库&#xff08;一&#xff09;基本指令1. 配置 SSH 密钥2. 推送远程仓库其他分支推送远程仓库方法1方法2建立分支链接 方法3 3. 合并分支请求 &#xff08;二&#xff09;.gitignore 忽略文件&#xff08;三&#xff09;标签管理…

MVCC【重点】

参考链接 [1] https://www.bilibili.com/video/BV1YD4y1J7Qq/?spm_id_from333.1007.top_right_bar_window_history.content.click&vd_source0cb0c5881f5c7d76e7580fbd2f551074 [2]https://www.cnblogs.com/jelly12345/p/14889331.html [3]https://xiaolincoding.com/mysql…

基于频率增强的数据增广的视觉语言导航方法(VLN论文阅读)

基于频率增强的数据增广的视觉语言导航方法&#xff08;VLN论文阅读&#xff09; 本文提出的方法很简单&#xff0c;将原始图像增加其他随机图像的高频信息&#xff0c;得到增强的图像作为新的样本&#xff0c;与原始的样本交替训练。背后的动机是&#xff0c;vln模型对高频信息…

TV-SAM 新型零样本医学图像分割算法:GPT-4语言处理 + GLIP视觉理解 + SAM分割技术

TV-SAM 新型零样本医学图像分割算法&#xff1a;GPT-4语言处理 GLIP视觉理解 SAM分割技术 提出背景TV-SAM 方法论 提出背景 论文&#xff1a;https://arxiv.org/ftp/arxiv/papers/2402/2402.15759.pdf 代码&#xff1a;https://github.com/JZK00/TV-SAM 利用了GPT-4的强大语…

TCP/IP-常用网络协议自定义结构体

1、TCP/IP模型&#xff1a; 2、TCP/IP- 各层级网络协议&#xff08;从下往上&#xff09;&#xff1a; 1&#xff09;数据链路层&#xff1a; ARP: 地址解析协议&#xff0c;用IP地址获取MAC地址的协议&#xff0c;通过ip的地址获取mac地 …

SpringBoot使用jsoup爬取HTML

原文网址&#xff1a;SpringBoot使用jsoup爬取HTML_IT利刃出鞘的博客-CSDN博客 简介 本文介绍SpringBoot--使用jsoup(Java爬虫工具)的方法。 jsoup 是一款 Java 的 HTML 解析器&#xff0c;它提供了一套非常便利的 API&#xff0c;可通过 DOM、CSS 通过类似于 JQuery 的操作…

Java的基础数据类型有哪些?String是Java的基础数据类型吗?

目录 Java的基础数据类型有哪些&#xff1f; String是Java的基础数据类型吗&#xff1f; Java的基础数据类型有哪些&#xff1f; Java的基础数据类型是Java语言中预定义的几种基本的数据格式&#xff0c;它们在Java虚拟机&#xff08;JVM&#xff09;中有固定的内存占用和…

分享一个FreeSWITCH通道吊死的帖子

https://forum.signalwire.community/t/session-is-pending-when-shutdown-freeswitch/886/7 之前碰到过类似的情况&#xff0c;就是show channels能看到&#xff0c;但是uuid_kill <uuid>报错&#xff0c;说uuid不存在&#xff0c;或者叫僵尸通道 这人真正的问题是&am…

【最新】如何将idea上的项目推送到gitee

1.打开Gitee&#xff0c;在首页&#xff0c;点击“”&#xff0c;创建一个仓库 2.填写仓库基本信息 3.下拉&#xff0c;点击“创建”&#xff0c;出现下方页面&#xff0c;证明仓库创建成功。 4.打开idea&#xff0c;下载gitee的插件&#xff08;此处默认已经下载git&#xff0…

基于React, Redux实现的俄罗斯方块游戏及源码

分享一个俄罗斯方块游戏游戏框架使用的是 React Redux&#xff0c;其中再加入了 Immutable&#xff0c;用它的实例来做来Redux的state。&#xff08;有关React和Redux的介绍可以看 安装 npm install运行 npm start浏览自动打开 http://127.0.0.1:8080/ 打包编译 npm run …

T - SQL使用事务 及 在Winform使用事务

事务适用场景 1 事务使用在存储过程中&#xff0c;直接在数据库中进行编写 2 事务使用在Winfrom项目中 SQl&#xff1a;使用事务转账操作的实例 一般都会找一个变量记录错误的个数&#xff0c;error记录上一句sql的错误和错误编号 declare errornum int 0 -- 定义…

自动化搭建初期必要的需求分析

1. 项目目标理解 与项目团队沟通&#xff1a;与项目经理、开发团队、产品经理等关键角色进行深入沟通&#xff0c;了解项目的整体目标和预期成果。理解业务需求&#xff1a;详细阅读项目文档&#xff0c;包括需求规格说明书、设计文档等&#xff0c;确保对业务逻辑和流程有深入…

selenium-激活pycharm,以及在pycharm中使用selenium时标红报错问题处理

激活pycharm&#xff1a;http://idea.955code.com/ 01 pycharm中导入selenium报错 现象: pycharm中输入from selenium import webdriver, selenium标红 原因1: pycharm使用的虚拟环境中没有安装selenium&#xff1a; 解决方法: 在pycharm中通过设置或terminal面板重新安装s…

nosql的注入

一、SQL注入数据库分类 关系型数据库 mysql oracle sqlserver 非关系型数据库 key-value redis MongoDB&#xff08;not only sql&#xff09; 二、MongoDB环境搭建 自己官网下载 Download MongoDB Community Server | MongoDB 其中Mongod.exe是它的一个启动 加上数据库&…