关于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

相关文章

Java中ArrayList和LinkedList有什么区别举例详解

《Java中ArrayList和LinkedList有什么区别举例详解》:本文主要介绍Java中ArrayList和LinkedList区别的相关资料,包括数据结构特性、核心操作性能、内存与GC影... 目录一、底层数据结构二、核心操作性能对比三、内存与 GC 影响四、扩容机制五、线程安全与并发方案六、工程

Ubuntu固定虚拟机ip地址的方法教程

《Ubuntu固定虚拟机ip地址的方法教程》本文详细介绍了如何在Ubuntu虚拟机中固定IP地址,包括检查和编辑`/etc/apt/sources.list`文件、更新网络配置文件以及使用Networ... 1、由于虚拟机网络是桥接,所以ip地址会不停地变化,接下来我们就讲述ip如何固定 2、如果apt安

Java数字转换工具类NumberUtil的使用

《Java数字转换工具类NumberUtil的使用》NumberUtil是一个功能强大的Java工具类,用于处理数字的各种操作,包括数值运算、格式化、随机数生成和数值判断,下面就来介绍一下Number... 目录一、NumberUtil类概述二、主要功能介绍1. 数值运算2. 格式化3. 数值判断4. 随机

C语言中自动与强制转换全解析

《C语言中自动与强制转换全解析》在编写C程序时,类型转换是确保数据正确性和一致性的关键环节,无论是隐式转换还是显式转换,都各有特点和应用场景,本文将详细探讨C语言中的类型转换机制,帮助您更好地理解并在... 目录类型转换的重要性自动类型转换(隐式转换)强制类型转换(显式转换)常见错误与注意事项总结与建议类型

查询SQL Server数据库服务器IP地址的多种有效方法

《查询SQLServer数据库服务器IP地址的多种有效方法》作为数据库管理员或开发人员,了解如何查询SQLServer数据库服务器的IP地址是一项重要技能,本文将介绍几种简单而有效的方法,帮助你轻松... 目录使用T-SQL查询方法1:使用系统函数方法2:使用系统视图使用SQL Server Configu

Python实现视频转换为音频的方法详解

《Python实现视频转换为音频的方法详解》这篇文章主要为大家详细Python如何将视频转换为音频并将音频文件保存到特定文件夹下,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1. python需求的任务2. Python代码的实现3. 代码修改的位置4. 运行结果5. 注意事项

使用Java实现获取客户端IP地址

《使用Java实现获取客户端IP地址》这篇文章主要为大家详细介绍了如何使用Java实现获取客户端IP地址,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 首先是获取 IP,直接上代码import org.springframework.web.context.request.Requ

java中不同版本JSONObject区别小结

《java中不同版本JSONObject区别小结》本文主要介绍了java中不同版本JSONObject区别小结,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们... 目录1. FastjsON2. Jackson3. Gson4. org.json6. 总结在Jav

使用Python实现图片和base64转换工具

《使用Python实现图片和base64转换工具》这篇文章主要为大家详细介绍了如何使用Python中的base64模块编写一个工具,可以实现图片和Base64编码之间的转换,感兴趣的小伙伴可以了解下... 简介使用python的base64模块来实现图片和Base64编码之间的转换。可以将图片转换为Bas

数据库使用之union、union all、各种join的用法区别解析

《数据库使用之union、unionall、各种join的用法区别解析》:本文主要介绍SQL中的Union和UnionAll的区别,包括去重与否以及使用时的注意事项,还详细解释了Join关键字,... 目录一、Union 和Union All1、区别:2、注意点:3、具体举例二、Join关键字的区别&php