关于FIFO Generator IP和XPM_FIFO在涉及位宽转换上的区别

2024-05-16 05:12

本文主要是介绍关于FIFO Generator IP和XPM_FIFO在涉及位宽转换上的区别,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

在Xilinx FPGA中,要实现FIFO的功能时,大部分时候会使用两种方法:

  • FIFO Generator IP核
  • XPM_FIFO原语

FIFO Generator IP核的优点是有图形化界面,配置参数非常直观;缺点是参数一旦固定,想要更改的化就只能重新generate IP核。

XPM_FIFO原语的优点就是参数配置方便。

对于两者,还有一个非常重要的区别。!!!大小端不一样!!!

当din的位宽和dout的位宽非对称时。举个栗子:当din的位宽为8bit,dout的位宽为32bit时。

FIFO Generator IP核按大端输出,即先写进去的数据放在高8bit

XPM_FIFO原语按小端输出,即先写进去的数据放在低8bit

下面为RTL设计文件和测试结果。

//-----------------------------------------------------------------------------
//  
//  Copyright (c) JoeJoe.
//
//  Project  : fifo_test
//  Module   : fifo_test.v
//  Parent   : None
//  Children : None
//
//  Description: 
//     
//     
//     
//
//  Parameters:
//    
//    
//    
//
//  Local Parameters:
//
//  Notes       : 
//
//  Multicycle and False Paths
//    Some exist, embedded within the submodules. See the submodule
//    descriptions.
//`timescale 1ns/1psmodule fifo_test (input sclk,input srst_n
);//***************************************************************************
// Parameter definitions
//***************************************************************************//***************************************************************************
// Reg declarations
//***************************************************************************reg [2:0] wait_cnt;reg wr_en;reg [7:0] din;wire rd_en;wire prog_full;wire full;wire empty;wire [31:0] dout;reg xpm_wr_en;reg [7:0] xpm_din;wire xpm_rd_en;wire xpm_prog_full;wire xpm_full;wire xpm_empty;wire [31:0] xpm_dout;//***************************************************************************
// Wire declarations
//***************************************************************************//***************************************************************************
// Code
//***************************************************************************// 等待XPM FIFO not busyalways @(posedge sclk) beginif (srst_n == 1'b0) beginwait_cnt <= 'd0;endelse beginif (wait_cnt == 'd7) beginwait_cnt <= wait_cnt;endelse beginwait_cnt <= wait_cnt + 'd1;endendend// 非满就写always @(posedge sclk) beginif (srst_n == 1'b0) beginwr_en <= 1'b0;din <= 'd0;endelse beginif (prog_full == 1'b1) beginwr_en <= 1'b0;din <= 'd0;endelse if (wait_cnt == 'd7) beginwr_en <= 1'b1;din <= din + 'd1;endelse beginwr_en <= 1'b0;din <= 'd0;endendend// 非空就读assign rd_en = ~empty;// 非满就写always @(posedge sclk) beginif (srst_n == 1'b0) beginxpm_wr_en <= 1'b0;xpm_din <= 'd0;endelse beginif (xpm_prog_full == 1'b1) beginxpm_wr_en <= 1'b0;xpm_din <= 'd0;endelse if (wait_cnt == 'd7) beginxpm_wr_en <= 1'b1;xpm_din <= din + 'd1;endelse beginxpm_wr_en <= 1'b0;xpm_din <= 'd0;endendend// 非空就读assign xpm_rd_en = ~xpm_empty;fifo_generator_0 U_FIFO_GENERATOR_0 (.clk              ( sclk           ) // input wire clk,.srst             ( ~srst_n        ) // 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 [31 : 0] dout,.full             ( full           ) // output wire full,.empty            ( empty          ) // output wire empty,.prog_full        ( prog_full      ) // output wire prog_full);xpm_fifo_sync #(.DOUT_RESET_VALUE   ( "0"      ), // String.ECC_MODE           ( "no_ecc" ), // String.FIFO_MEMORY_TYPE   ( "block"  ), // String.FIFO_READ_LATENCY  ( 0        ), // DECIMAL.FIFO_WRITE_DEPTH   ( 1024     ), // DECIMAL.FULL_RESET_VALUE   ( 0        ), // DECIMAL.PROG_EMPTY_THRESH  ( 10       ), // DECIMAL.PROG_FULL_THRESH   ( 500      ), // DECIMAL.RD_DATA_COUNT_WIDTH( 1        ), // DECIMAL.READ_DATA_WIDTH    ( 32       ), // DECIMAL.READ_MODE          ( "fwft"   ), // String.SIM_ASSERT_CHK     ( 0        ), // DECIMAL; 0=disable simulation messages, 1=enable simulation messages.USE_ADV_FEATURES   ( "0707"   ), // String.WAKEUP_TIME        ( 0        ), // DECIMAL.WRITE_DATA_WIDTH   ( 8        ), // DECIMAL.WR_DATA_COUNT_WIDTH( 1        )  // DECIMAL)U_XPM_FIFO_SYNC (.almost_empty   (             ), // 1-bit output: Almost Empty : When asserted, this signal indicates that// only one more read can be performed before the FIFO goes to empty..almost_full    (             ), // 1-bit output: Almost Full: When asserted, this signal indicates that// only one more write can be performed before the FIFO is full..data_valid     (             ), // 1-bit output: Read Data Valid: When asserted, this signal indicates// that valid data is available on the output bus (dout         )..dbiterr        (             ), // 1-bit output: Double Bit Error: Indicates that the ECC decoder detected// a double-bit error and data in the FIFO core is corrupted..dout           (xpm_dout     ), // READ_DATA_WIDTH-bit output: Read Data: The output data bus is driven// when reading the FIFO..empty          (xpm_empty    ), // 1-bit output: Empty Flag: When asserted, this signal indicates that the// FIFO is empty. Read requests are ignored when the FIFO is empty,// initiating a read while empty is not destructive to the FIFO..full           (xpm_full     ), // 1-bit output: Full Flag: When asserted, this signal indicates that the// FIFO is full. Write requests are ignored when the FIFO is full,// initiating a write when the FIFO is full is not destructive to the// contents of the FIFO..overflow       (             ), // 1-bit output: Overflow: This signal indicates that a write request// (wren) during the prior clock cycle was rejected, because the FIFO is// full. Overflowing the FIFO is not destructive to the contents of the// FIFO..prog_empty     (             ), // 1-bit output: Programmable Empty: This signal is asserted when the// number of words in the FIFO is less than or equal to the programmable// empty threshold value. It is de-asserted when the number of words in// the FIFO exceeds the programmable empty threshold value..prog_full      (xpm_prog_full), // 1-bit output: Programmable Full: This signal is asserted when the// number of words in the FIFO is greater than or equal to the// programmable full threshold value. It is de-asserted when the number of// words in the FIFO is less than the programmable full threshold value..rd_data_count  (             ), // RD_DATA_COUNT_WIDTH-bit output: Read Data Count: This bus indicates the// number of words read from the FIFO..rd_rst_busy    (             ), // 1-bit output: Read Reset Busy: Active-High indicator that the FIFO read// domain is currently in a reset state..sbiterr        (             ), // 1-bit output: Single Bit Error: Indicates that the ECC decoder detected// and fixed a single-bit error..underflow      (             ), // 1-bit output: Underflow: Indicates that the read request (rd_en) during// the previous clock cycle was rejected because the FIFO is empty. Under// flowing the FIFO is not destructive to the FIFO..wr_ack         (             ), // 1-bit output: Write Acknowledge: This signal indicates that a write// request(wr_en) during the prior clock cycle is succeeded..wr_data_count  (             ), // WR_DATA_COUNT_WIDTH-bit output: Write Data Count: This bus indicates// the number of words written into the FIFO..wr_rst_busy    (             ), // 1-bit output: Write Reset Busy: Active-High indicator that the FIFO// write domain is currently in a reset state..din            (xpm_din      ), // WRITE_DATA_WIDTH-bit input: Write Data: The input data bus used when// writing the FIFO..injectdbiterr  (1'b0         ), // 1-bit input: Double Bit Error Injection: Injects a double bit error if// the ECC feature is used on block RAMs or UltraRAM macros..injectsbiterr  (1'b0         ), // 1-bit input: Single Bit Error Injection: Injects a single bit error if// the ECC feature is used on block RAMs or UltraRAM macros..rd_en          (xpm_rd_en    ), // 1-bit input: Read Enable: If the FIFO is not empty, asserting this// signal causes data(on dout) to be read from the FIFO. Must be held// active-low when rd_rst_busy is active high..rst            (~srst_n      ), // 1-bit input: Reset: Must be synchronous to wr_clk. The clock(s) can be// unstable at the time of applying reset, but reset must be released only// after the clock(s) is/are stable..sleep          (1'b0         ), // 1-bit input: Dynamic power saving- If sleep is High, the memory/fifo// block is in power saving mode..wr_clk         (sclk         ), // 1-bit input: Write clock: Used for write operation. wr_clk must be a// free running clock..wr_en          (xpm_wr_en    )  // 1-bit input: Write Enable: If the FIFO is not full, asserting this// signal causes data(on din) to be written to the FIFO Must be held// active-low when rst or wr_rst_busy or rd_rst_busy is active high);      endmodule

32bit写,8bit读
当din的位宽和dout的位宽非对称时。举个栗子:当din的位宽为32bit,dout的位宽为8bit时。

FIFO Generator IP核 高8bit先输出,低8bit最后输出

XPM_FIFO原语 低8bit先输出,高8bit最后输出

下面为RTL设计文件和测试结果。

//-----------------------------------------------------------------------------
//  
//  Copyright (c) JoeJoe.
//
//  Project  : fifo_test
//  Module   : fifo_test.v
//  Parent   : None
//  Children : None
//
//  Description: 
//     
//     
//     
//
//  Parameters:
//    
//    
//    
//
//  Local Parameters:
//
//  Notes       : 
//
//  Multicycle and False Paths
//    Some exist, embedded within the submodules. See the submodule
//    descriptions.
//`timescale 1ns/1psmodule fifo_test (input sclk,input srst_n
);//***************************************************************************
// Parameter definitions
//***************************************************************************//***************************************************************************
// Reg declarations
//***************************************************************************reg [2:0] wait_cnt;reg wr_en;reg [31:0] din;wire rd_en;wire prog_full;wire full;wire empty;wire [7:0] dout;reg xpm_wr_en;reg [31:0] xpm_din;wire xpm_rd_en;wire xpm_prog_full;wire xpm_full;wire xpm_empty;wire [7:0] xpm_dout;//***************************************************************************
// Wire declarations
//***************************************************************************//***************************************************************************
// Code
//***************************************************************************// 等待XPM FIFO not busyalways @(posedge sclk) beginif (srst_n == 1'b0) beginwait_cnt <= 'd0;endelse beginif (wait_cnt == 'd7) beginwait_cnt <= wait_cnt;endelse beginwait_cnt <= wait_cnt + 'd1;endendend// 非满就写always @(posedge sclk) beginif (srst_n == 1'b0) beginwr_en <= 1'b0;din <= 'd0;endelse beginif (prog_full == 1'b1) beginwr_en <= 1'b0;din <= din;endelse if (wait_cnt == 'd7) beginwr_en <= 1'b1;din <= din + 'd1;endelse beginwr_en <= 1'b0;din <= 'd0;endendend// 非空就读assign rd_en = ~empty;// 非满就写always @(posedge sclk) beginif (srst_n == 1'b0) beginxpm_wr_en <= 1'b0;xpm_din <= 'd0;endelse beginif (xpm_prog_full == 1'b1) beginxpm_wr_en <= 1'b0;xpm_din <= xpm_din;endelse if (wait_cnt == 'd7) beginxpm_wr_en <= 1'b1;xpm_din <= xpm_din + 'd1;endelse beginxpm_wr_en <= 1'b0;xpm_din <= 'd0;endendend// 非空就读assign xpm_rd_en = ~xpm_empty;// fifo_generator_0 U_FIFO_GENERATOR_0 (//      .clk              ( sclk           ) // input wire clk//     ,.srst             ( ~srst_n        ) // 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 [31 : 0] dout//     ,.full             ( full           ) // output wire full//     ,.empty            ( empty          ) // output wire empty//     ,.prog_full        ( prog_full      ) // output wire prog_full// );fifo_generator_1 U_FIFO_GENERATOR_1 (.clk              ( sclk           ) // input wire clk,.srst             ( ~srst_n        ) // input wire srst,.din              ( din            ) // input wire [31 : 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,.empty            ( empty          ) // output wire empty,.prog_full        ( prog_full      ) // output wire prog_full);xpm_fifo_sync #(.DOUT_RESET_VALUE   ( "0"      ), // String.ECC_MODE           ( "no_ecc" ), // String.FIFO_MEMORY_TYPE   ( "block"  ), // String.FIFO_READ_LATENCY  ( 0        ), // DECIMAL.FIFO_WRITE_DEPTH   ( 256      ), // DECIMAL.FULL_RESET_VALUE   ( 0        ), // DECIMAL.PROG_EMPTY_THRESH  ( 10       ), // DECIMAL.PROG_FULL_THRESH   ( 125      ), // DECIMAL.RD_DATA_COUNT_WIDTH( 1        ), // DECIMAL.READ_DATA_WIDTH    ( 8        ), // DECIMAL.READ_MODE          ( "fwft"   ), // String.SIM_ASSERT_CHK     ( 0        ), // DECIMAL; 0=disable simulation messages, 1=enable simulation messages.USE_ADV_FEATURES   ( "0707"   ), // String.WAKEUP_TIME        ( 0        ), // DECIMAL.WRITE_DATA_WIDTH   ( 32       ), // DECIMAL.WR_DATA_COUNT_WIDTH( 1        )  // DECIMAL)U_XPM_FIFO_SYNC (.almost_empty   (             ), // 1-bit output: Almost Empty : When asserted, this signal indicates that// only one more read can be performed before the FIFO goes to empty..almost_full    (             ), // 1-bit output: Almost Full: When asserted, this signal indicates that// only one more write can be performed before the FIFO is full..data_valid     (             ), // 1-bit output: Read Data Valid: When asserted, this signal indicates// that valid data is available on the output bus (dout         )..dbiterr        (             ), // 1-bit output: Double Bit Error: Indicates that the ECC decoder detected// a double-bit error and data in the FIFO core is corrupted..dout           (xpm_dout     ), // READ_DATA_WIDTH-bit output: Read Data: The output data bus is driven// when reading the FIFO..empty          (xpm_empty    ), // 1-bit output: Empty Flag: When asserted, this signal indicates that the// FIFO is empty. Read requests are ignored when the FIFO is empty,// initiating a read while empty is not destructive to the FIFO..full           (xpm_full     ), // 1-bit output: Full Flag: When asserted, this signal indicates that the// FIFO is full. Write requests are ignored when the FIFO is full,// initiating a write when the FIFO is full is not destructive to the// contents of the FIFO..overflow       (             ), // 1-bit output: Overflow: This signal indicates that a write request// (wren) during the prior clock cycle was rejected, because the FIFO is// full. Overflowing the FIFO is not destructive to the contents of the// FIFO..prog_empty     (             ), // 1-bit output: Programmable Empty: This signal is asserted when the// number of words in the FIFO is less than or equal to the programmable// empty threshold value. It is de-asserted when the number of words in// the FIFO exceeds the programmable empty threshold value..prog_full      (xpm_prog_full), // 1-bit output: Programmable Full: This signal is asserted when the// number of words in the FIFO is greater than or equal to the// programmable full threshold value. It is de-asserted when the number of// words in the FIFO is less than the programmable full threshold value..rd_data_count  (             ), // RD_DATA_COUNT_WIDTH-bit output: Read Data Count: This bus indicates the// number of words read from the FIFO..rd_rst_busy    (             ), // 1-bit output: Read Reset Busy: Active-High indicator that the FIFO read// domain is currently in a reset state..sbiterr        (             ), // 1-bit output: Single Bit Error: Indicates that the ECC decoder detected// and fixed a single-bit error..underflow      (             ), // 1-bit output: Underflow: Indicates that the read request (rd_en) during// the previous clock cycle was rejected because the FIFO is empty. Under// flowing the FIFO is not destructive to the FIFO..wr_ack         (             ), // 1-bit output: Write Acknowledge: This signal indicates that a write// request(wr_en) during the prior clock cycle is succeeded..wr_data_count  (             ), // WR_DATA_COUNT_WIDTH-bit output: Write Data Count: This bus indicates// the number of words written into the FIFO..wr_rst_busy    (             ), // 1-bit output: Write Reset Busy: Active-High indicator that the FIFO// write domain is currently in a reset state..din            (xpm_din      ), // WRITE_DATA_WIDTH-bit input: Write Data: The input data bus used when// writing the FIFO..injectdbiterr  (1'b0         ), // 1-bit input: Double Bit Error Injection: Injects a double bit error if// the ECC feature is used on block RAMs or UltraRAM macros..injectsbiterr  (1'b0         ), // 1-bit input: Single Bit Error Injection: Injects a single bit error if// the ECC feature is used on block RAMs or UltraRAM macros..rd_en          (xpm_rd_en    ), // 1-bit input: Read Enable: If the FIFO is not empty, asserting this// signal causes data(on dout) to be read from the FIFO. Must be held// active-low when rd_rst_busy is active high..rst            (~srst_n      ), // 1-bit input: Reset: Must be synchronous to wr_clk. The clock(s) can be// unstable at the time of applying reset, but reset must be released only// after the clock(s) is/are stable..sleep          (1'b0         ), // 1-bit input: Dynamic power saving- If sleep is High, the memory/fifo// block is in power saving mode..wr_clk         (sclk         ), // 1-bit input: Write clock: Used for write operation. wr_clk must be a// free running clock..wr_en          (xpm_wr_en    )  // 1-bit input: Write Enable: If the FIFO is not full, asserting this// signal causes data(on din) to be written to the FIFO Must be held// active-low when rst or wr_rst_busy or rd_rst_busy is active high);      endmodule

8bit写,32bit读
参考文档如下:《FIFO Generator v13.2 Product Guide》(PG057)
FIFO Generator IP
支持的非对称比

FIFO Generator IP,小位宽写,大位宽读,大端。
大转小
大转小时序图
FIFO Generator IP,大位宽写,小位宽读。
小转大
小转大时序图
疑问:XPM_FIFO为什么不可以设置大小端,以及为什么不和FIFO Generator IP统一???

这篇关于关于FIFO Generator IP和XPM_FIFO在涉及位宽转换上的区别的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/993968

相关文章

native和static native区别

本文基于Hello JNI  如有疑惑,请看之前几篇文章。 native 与 static native java中 public native String helloJni();public native static String helloJniStatic();1212 JNI中 JNIEXPORT jstring JNICALL Java_com_test_g

LabVIEW FIFO详解

在LabVIEW的FPGA开发中,FIFO(先入先出队列)是常用的数据传输机制。通过配置FIFO的属性,工程师可以在FPGA和主机之间,或不同FPGA VIs之间进行高效的数据传输。根据具体需求,FIFO有多种类型与实现方式,包括目标范围内FIFO(Target-Scoped)、DMA FIFO以及点对点流(Peer-to-Peer)。 FIFO类型 **目标范围FIFO(Target-Sc

Android fill_parent、match_parent、wrap_content三者的作用及区别

这三个属性都是用来适应视图的水平或者垂直大小,以视图的内容或尺寸为基础的布局,比精确的指定视图的范围更加方便。 1、fill_parent 设置一个视图的布局为fill_parent将强制性的使视图扩展至它父元素的大小 2、match_parent 和fill_parent一样,从字面上的意思match_parent更贴切一些,于是从2.2开始,两个属性都可以使用,但2.3版本以后的建议使

Collection List Set Map的区别和联系

Collection List Set Map的区别和联系 这些都代表了Java中的集合,这里主要从其元素是否有序,是否可重复来进行区别记忆,以便恰当地使用,当然还存在同步方面的差异,见上一篇相关文章。 有序否 允许元素重复否 Collection 否 是 List 是 是 Set AbstractSet 否

javascript中break与continue的区别

在javascript中,break是结束整个循环,break下面的语句不再执行了 for(let i=1;i<=5;i++){if(i===3){break}document.write(i) } 上面的代码中,当i=1时,执行打印输出语句,当i=2时,执行打印输出语句,当i=3时,遇到break了,整个循环就结束了。 执行结果是12 continue语句是停止当前循环,返回从头开始。

maven发布项目到私服-snapshot快照库和release发布库的区别和作用及maven常用命令

maven发布项目到私服-snapshot快照库和release发布库的区别和作用及maven常用命令 在日常的工作中由于各种原因,会出现这样一种情况,某些项目并没有打包至mvnrepository。如果采用原始直接打包放到lib目录的方式进行处理,便对项目的管理带来一些不必要的麻烦。例如版本升级后需要重新打包并,替换原有jar包等等一些额外的工作量和麻烦。为了避免这些不必要的麻烦,通常我们

ActiveMQ—Queue与Topic区别

Queue与Topic区别 转自:http://blog.csdn.net/qq_21033663/article/details/52458305 队列(Queue)和主题(Topic)是JMS支持的两种消息传递模型:         1、点对点(point-to-point,简称PTP)Queue消息传递模型:         通过该消息传递模型,一个应用程序(即消息生产者)可以

2024.9.8 TCP/IP协议学习笔记

1.所谓的层就是数据交换的深度,电脑点对点就是单层,物理层,加上集线器还是物理层,加上交换机就变成链路层了,有地址表,路由器就到了第三层网络层,每个端口都有一个mac地址 2.A 给 C 发数据包,怎么知道是否要通过路由器转发呢?答案:子网 3.将源 IP 与目的 IP 分别同这个子网掩码进行与运算****,相等则是在一个子网,不相等就是在不同子网 4.A 如何知道,哪个设备是路由器?答案:在 A

PDF 软件如何帮助您编辑、转换和保护文件。

如何找到最好的 PDF 编辑器。 无论您是在为您的企业寻找更高效的 PDF 解决方案,还是尝试组织和编辑主文档,PDF 编辑器都可以在一个地方提供您需要的所有工具。市面上有很多 PDF 编辑器 — 在决定哪个最适合您时,请考虑这些因素。 1. 确定您的 PDF 文档软件需求。 不同的 PDF 文档软件程序可以具有不同的功能,因此在决定哪个是最适合您的 PDF 软件之前,请花点时间评估您的

STL经典案例(四)——实验室预约综合管理系统(项目涉及知识点很全面,内容有点多,耐心看完会有收获的!)

项目干货满满,内容有点过多,看起来可能会有点卡。系统提示读完超过俩小时,建议分多篇发布,我觉得分篇就不完整了,失去了这个项目的灵魂 一、需求分析 高校实验室预约管理系统包括三种不同身份:管理员、实验室教师、学生 管理员:给学生和实验室教师创建账号并分发 实验室教师:审核学生的预约申请 学生:申请使用实验室 高校实验室包括:超景深实验室(可容纳10人)、大数据实验室(可容纳20人)、物联网实验