Asynchronous FIFO memory read-write control method, device and equipment

文档序号:1937189 发布日期:2021-12-07 浏览:22次 中文

阅读说明:本技术 一种异步fifo存储器读写控制方法、装置及设备 (Asynchronous FIFO memory read-write control method, device and equipment ) 是由 孙旭 周玉龙 李维杰 于 2021-08-30 设计创作,主要内容包括:本发明公开了一种异步FIFO存储器读写控制方法、装置、设备及存储介质,该方法包括:获取异步FIFO存储器当前的读地址及写地址,将读地址及写地址分别同步至相同时钟域内,得到同步后读地址及同步后写地址;基于异步FIFO存储器的总容量、读地址、写地址、同步后读地址及同步后写地址,确定异步FIFO存储器的读信用积分及写信用积分;将读信用积分及写信用积分输出至读写端,以供读写端基于读信用积分及写信用积分实现对异步FIFO存储器的读写操作;读信用积分表示当前能基于异步FIFO存储器读取的数据量,写信用积分表示当前能基于异步FIFO存储器写入的数据量。可见,本申请能够有效提高异步FIFO存储器的使用效率。(The invention discloses a method, a device, equipment and a storage medium for controlling the read and write of an asynchronous FIFO memory, wherein the method comprises the following steps: acquiring a current read address and a current write address of an asynchronous FIFO memory, and synchronizing the read address and the write address into the same clock domain respectively to obtain a synchronous read address and a synchronous write address; determining a read credit integral and a write integral of the asynchronous FIFO memory based on the total capacity, the read address, the write address, the read address after synchronization and the write address after synchronization of the asynchronous FIFO memory; outputting the credit integral and the credit integral for writing to a read-write end so that the read-write end can realize the read-write operation of the asynchronous FIFO memory based on the credit integral and the credit integral for writing; the read credit integral represents the amount of data that can currently be read based on the asynchronous FIFO memory, and the write credit integral represents the amount of data that can currently be written based on the asynchronous FIFO memory. Therefore, the method and the device can effectively improve the service efficiency of the asynchronous FIFO memory.)

1. A method for controlling the read and write of an asynchronous FIFO memory is characterized by comprising the following steps:

acquiring a current read address and a current write address of an asynchronous FIFO memory, and synchronizing the read address and the write address into the same clock domain respectively to obtain a synchronous read address corresponding to the read address and a synchronous write address corresponding to the write address;

determining a read credit integral and a write integral of the asynchronous FIFO memory based on the total capacity of the asynchronous FIFO memory, the read address, the write address, the read address after synchronization and the write address after synchronization; wherein the read credit integral represents an amount of data currently readable based on the asynchronous FIFO memory, and the write credit integral represents an amount of data currently writable based on the asynchronous FIFO memory;

and outputting the read credit integral and the write integral to a corresponding read-write end so that the read-write end realizes the read-write operation of the asynchronous FIFO memory based on the read credit integral and the write integral.

2. The method of claim 1, further comprising:

receiving a read request sent by the read-write end, determining a current read-only-hot-code address, converting the current read-only-hot-code address into a corresponding read binary code address, realizing read operation corresponding to the read request in the asynchronous FIFO memory based on the read binary code address, and shifting the current read-only-code address by 1 bit to the left to serve as a new current read-only-hot-code address after the read operation is completed;

receiving a write request sent by the write-write end, determining a current write-one-hot-code address, converting the current write-one-hot-code address into a corresponding write binary code address, realizing write operation corresponding to the write request in the asynchronous FIFO memory based on the write binary code address, and after the write operation is finished, shifting the current write-one-hot-code address by 1 bit to the left to serve as a new current write-one-hot-code address;

correspondingly, acquiring the current read address and write address of the asynchronous FIFO memory comprises the following steps:

and acquiring the current read one-hot code address and write one-hot code address of the asynchronous FIFO memory.

3. The method of claim 2, wherein determining a read credit integral and a write credit integral for the asynchronous FIFO memory comprises:

if Wr _ addr _ hot > rd _ addr _ hot _ wp, the integral for writing of a single byte is calculated according to the following formula:

wr_credit_1=fifo_capa-log2Wr_addr_hot+log2rd_addr_hot_wp;

if Wr _ addr _ hot < rd _ addr _ hot _ wp, the integral for writing a single byte is calculated according to the following formula:

wr_credit_1=log2rd_addr_hot_wp-log2Wr_addr_hot;

if Wr _ addr _ hot _ rp > rd _ addr _ hot, the read credit integral of a single byte is calculated according to the following formula:

rd_credit_1=Wr_addr_hot_rp-rd_addr_hot;

if Wr _ addr _ hot _ rp < rd _ addr _ hot, the write/read credit integral of a single byte is calculated according to the following formula:

rd_credit_1=fifo_capa+Wr_addr_hot_rp-rd_addr_hot;

the writing of single bytes is represented by an integral Wr _ credit _1, the number of single bytes which can be written based on the asynchronous FIFO memory currently is represented by a read credit integral rd _ credit _1 of single bytes, the number of single bytes which can be read based on the asynchronous FIFO memory currently is represented by FIFO _ capa, the total capacity of the asynchronous FIFO memory is represented by FIFO _ capa, Wr _ addr _ hot is represented by the writing address, rd _ addr _ hot is represented by the reading address, Wr _ addr _ hot _ rp is represented by the synchronous writing address, and rd _ addr _ hot _ wp is represented by the synchronous reading address.

4. The method of claim 3, wherein after calculating the integral for writing a single byte, further comprising:

calculating a write score for a data set according to the following formula, and rounding down the write score to obtain a write integral for the data set:

wr_credit_user=wr_credit_1/wr_credit_user_define;

calculating the read credit score of the data set according to the following formula, and rounding the read credit score down to obtain the read credit score of the data set:

rd_credit_user=rd_credit_1/rd_credit_user;

the integration wr _ credit _ user for writing the data group represents the number of data groups which can be written based on the asynchronous FIFO memory currently, the read credit integration rd _ credit _ user for the data group represents the number of data groups which can be read based on the asynchronous FIFO memory currently, and the wr _ credit _ user _ define and rd _ credit _ user _ define are respectively a read conversion unit and a write conversion unit between the data group and a single byte.

5. The method of claim 4, further comprising:

acquiring a current read address zone bit and a current write address zone bit of the asynchronous FIFO memory, and synchronizing the read address zone bit and the write address zone bit into a clock domain which is the same as the read address and the write address to acquire a synchronized read address zone bit corresponding to the read address zone bit and a written synchronized address zone bit corresponding to the write address zone bit; the read address flag bit and the write address flag bit respectively take a value opposite to a current value when the read address and the write address jump from a last address to a first address;

determining an empty signal and a full signal of the asynchronous FIFO memory based on the read address, the write address, the read-after-synchronization address, the write-after-synchronization address, the read address flag bit, the write address flag bit, the read-after-synchronization address flag bit and the write-after-synchronization address flag bit of the asynchronous FIFO memory; wherein the full signal indicates whether the storage space of the asynchronous FIFO memory is full, and the empty signal indicates whether the asynchronous FIFO memory is empty;

and outputting the empty signal and the full signal to corresponding read-write ends so that the read-write ends can realize read-write operation on the asynchronous FIFO memory based on the empty signal and the full signal.

6. The method of claim 5, wherein determining the empty and full signals for the asynchronous FIFO memory comprises:

if Wr _ addr _ hot _ rp is Rd _ addr _ hot and Wr _ mark _ rp is Rd _ mark, the null signal is 1, if Wr _ addr _ hot _ rp is Rd _ addr _ hot and Wr _ mark _ rp |, the null signal is 1. Rd _ mark, the null signal is 0, and Wr _ addr _ hot _ rp! If Rd _ addr _ hot, the null signal is 0;

if rd _ addr _ hot _ wp and rd _ mark _ wp are wr _ mark, then the full signal is 0, if rd _ addr _ hot _ wp and rd _ mark _ wp are wr _ addr _ hot and rd _ mark _ wp | (w is a fast signal), and if rd _ addr _ hot is not equal to wr _ addr _ hot and rd _ mark _ wp is not enough! The full signal is 1 if wr _ mark, and rd _ addr _ hot _ wp! When wr _ addr _ hot, the full signal is 0.

7. The method of claim 6, wherein synchronizing the read address, the write address, the read address flag bit, and the write address flag bit into a same clock domain comprises:

and synchronizing the read address, the write address, the read address flag bit and the write address flag bit to the same clock domain through two stages of flip-flops respectively.

8. An asynchronous FIFO memory read-write control apparatus, comprising:

an acquisition module to: acquiring a current read address and a current write address of an asynchronous FIFO memory, and synchronizing the read address and the write address into the same clock domain respectively to obtain a synchronous read address corresponding to the read address and a synchronous write address corresponding to the write address;

a determination module to: determining a read credit integral and a write integral of the asynchronous FIFO memory based on the total capacity of the asynchronous FIFO memory, the read address, the write address, the read address after synchronization and the write address after synchronization; wherein the read credit integral represents an amount of data currently readable based on the asynchronous FIFO memory, and the write credit integral represents an amount of data currently writable based on the asynchronous FIFO memory;

an output module to: and outputting the read credit integral and the write integral to a corresponding read-write end so that the read-write end realizes the read-write operation of the asynchronous FIFO memory based on the read credit integral and the write integral.

9. An asynchronous FIFO memory read-write control device, comprising:

a memory for storing a computer program;

processor for implementing the steps of the asynchronous FIFO memory read-write control method according to any one of claims 1 to 7 when executing said computer program.

10. A computer-readable storage medium, having stored thereon a computer program which, when executed by a processor, performs the steps of the asynchronous FIFO memory read-write control method according to any one of claims 1 to 7.

Technical Field

The present invention relates to the field of data processing technologies, and in particular, to a method, an apparatus, a device, and a storage medium for controlling read and write operations of an asynchronous FIFO memory.

Background

With the development of integrated circuit technology, the situation of multiple clock domains needs to be considered more and more; in the electronic system with multiple clock domains, the data of the interface part between each module can not be directly transmitted, otherwise, the data transmission error can be generated by the metastable state. The problem can be conveniently solved by adopting an asynchronous FIFO (First Input First Output) memory, and the problem of data transmission between two different clock domains can be solved in a system with integral asynchronous-local synchronous clocks, so that the asynchronous FIFO memory is often used for storing and buffering data transmission between two asynchronous modules and is used as a reliable interface between the two asynchronous modules, and the asynchronous FIFO memory is widely applied to the fields of radar, signal processing, multimedia technology and the like.

The current asynchronous FIFO memory generally only provides an empty full indication signal and an almost empty almost full indication signal on the basis of normal reading and writing functions, which limits the use range of the asynchronous FIFO memory to a certain extent. For example, when an asynchronous FIFO memory (the asynchronous FIFO memory depth is 128, and the data bit width is 8 bits) is used to buffer the data packet of the DDR controller or PCIe at the preceding stage, since the preceding stage data is continuously transmitted, that is, when the data starts to be transmitted, the data must be continuously transmitted from the preceding stage to the following stage regardless of whether the FIFO at the following stage has space to store the data; when the previous-stage data packet only sends a part of data, if the subsequent-stage FIFO is already in a full state at this time, the latter-half data cannot be buffered in the FIFO or the data in the previous FIFO is overwritten, resulting in data loss.

The current general method for solving the problem is to judge the empty state of the asynchronous FIFO, and when the FIFO is empty, data is written in, because the data space which can be written in is the capacity of the FIFO; when the asynchronous FIFO memory is called, the data space is ensured to be not smaller than the data size of the previous stage of continuous writing. However, this method has a great waste of efficiency, and is also an example of the asynchronous FIFO memory in the above example, when 64 data bits with 8Bit width are cached in the current asynchronous FIFO memory, the empty and full signals are all 0 at this time, and the preceding stage wants to send a group of 32 8Bit data, and can only wait for the FIFO to be read empty, that is, the empty state signal is 1, and can only read, because it cannot be determined how much data has been stored in the FIFO by the empty and full indication signal; this reduces the efficiency of the asynchronous FIFO memory.

Disclosure of Invention

The invention aims to provide a read-write control method, a device, equipment and a storage medium for an asynchronous FIFO memory, which can improve the use efficiency of the asynchronous FIFO memory.

In order to achieve the above purpose, the invention provides the following technical scheme:

a method for controlling the reading and writing of an asynchronous FIFO memory comprises the following steps:

acquiring a current read address and a current write address of an asynchronous FIFO memory, and synchronizing the read address and the write address into the same clock domain respectively to obtain a synchronous read address corresponding to the read address and a synchronous write address corresponding to the write address;

determining a read credit integral and a write integral of the asynchronous FIFO memory based on the total capacity of the asynchronous FIFO memory, the read address, the write address, the read address after synchronization and the write address after synchronization; wherein the read credit integral represents an amount of data currently readable based on the asynchronous FIFO memory, and the write credit integral represents an amount of data currently writable based on the asynchronous FIFO memory;

and outputting the read credit integral and the write integral to a corresponding read-write end so that the read-write end realizes the read-write operation of the asynchronous FIFO memory based on the read credit integral and the write integral.

Preferably, the method further comprises the following steps:

receiving a read request sent by the read-write end, determining a current read-only-hot-code address, converting the current read-only-hot-code address into a corresponding read binary code address, realizing read operation corresponding to the read request in the asynchronous FIFO memory based on the read binary code address, and shifting the current read-only-code address by 1 bit to the left to serve as a new current read-only-hot-code address after the read operation is completed;

receiving a write request sent by the write-write end, determining a current write-one-hot-code address, converting the current write-one-hot-code address into a corresponding write binary code address, realizing write operation corresponding to the write request in the asynchronous FIFO memory based on the write binary code address, and after the write operation is finished, shifting the current write-one-hot-code address by 1 bit to the left to serve as a new current write-one-hot-code address;

correspondingly, acquiring the current read address and write address of the asynchronous FIFO memory comprises the following steps:

and acquiring the current read one-hot code address and write one-hot code address of the asynchronous FIFO memory.

Preferably, the determining the integration for read credit and the integration for write of the asynchronous FIFO memory comprises:

if Wr _ addr _ hot > rd _ addr _ hot _ wp, the integral for writing of a single byte is calculated according to the following formula:

wr_credit_1=fifo_capa-log2Wr_addr_hot+log2rd_addr_hot_wp;

if Wr _ addr _ hot < rd _ addr _ hot _ wp, the integral for writing a single byte is calculated according to the following formula:

wr_credit_1=log2rd_addr_hot_wp-log2Wr_addr_hot;

if Wr _ addr _ hot _ rp > rd _ addr _ hot, the read credit integral of a single byte is calculated according to the following formula:

rd_credit_1=Wr_addr_hot_rp-rd_addr_hot;

if Wr _ addr _ hot _ rp < rd _ addr _ hot, the write/read credit integral of a single byte is calculated according to the following formula:

rd_credit_1=fifo_capa+Wr_addr_hot_rp-rd_addr_hot;

the writing of single bytes is represented by an integral Wr _ credit _1, the number of single bytes which can be written based on the asynchronous FIFO memory currently is represented by a read credit integral rd _ credit _1 of single bytes, the number of single bytes which can be read based on the asynchronous FIFO memory currently is represented by FIFO _ capa, the total capacity of the asynchronous FIFO memory is represented by FIFO _ capa, Wr _ addr _ hot is represented by the writing address, rd _ addr _ hot is represented by the reading address, Wr _ addr _ hot _ rp is represented by the synchronous writing address, and rd _ addr _ hot _ wp is represented by the synchronous reading address.

Preferably, after calculating the integral for writing a single byte, the method further includes:

calculating a write score for a data set according to the following formula, and rounding down the write score to obtain a write integral for the data set:

wr_credit_user=wr_credit_1/wr_credit_user_define;

calculating the read credit score of the data set according to the following formula, and rounding the read credit score down to obtain the read credit score of the data set:

rd_credit_user=rd_credit_1/rd_credit_user_define;

the integration wr _ credit _ user for writing the data group represents the number of data groups which can be written based on the asynchronous FIFO memory currently, the read credit integration rd _ credit _ user for the data group represents the number of data groups which can be read based on the asynchronous FIFO memory currently, and the wr _ credit _ user _ define and rd _ credit _ user _ define are respectively a read conversion unit and a write conversion unit between the data group and a single byte.

Preferably, the method further comprises the following steps:

acquiring a current read address zone bit and a current write address zone bit of the asynchronous FIFO memory, and synchronizing the read address zone bit and the write address zone bit into a clock domain which is the same as the read address and the write address to acquire a synchronized read address zone bit corresponding to the read address zone bit and a written synchronized address zone bit corresponding to the write address zone bit; the read address flag bit and the write address flag bit respectively take a value opposite to a current value when the read address and the write address jump from a last address to a first address;

determining an empty signal and a full signal of the asynchronous FIFO memory based on the read address, the write address, the read-after-synchronization address, the write-after-synchronization address, the read address flag bit, the write address flag bit, the read-after-synchronization address flag bit and the write-after-synchronization address flag bit of the asynchronous FIFO memory; wherein the full signal indicates whether the storage space of the asynchronous FIFO memory is full, and the empty signal indicates whether the asynchronous FIFO memory is empty;

and outputting the empty signal and the full signal to corresponding read-write ends so that the read-write ends can realize read-write operation on the asynchronous FIFO memory based on the empty signal and the full signal.

Preferably, the determining the empty signal and the full signal of the asynchronous FIFO memory comprises:

if Wr _ addr _ hot _ rp is Rd _ addr _ hot and Wr _ mark _ rp is Rd _ mark, the null signal is 1, if Wr _ addr _ hot _ rp is Rd _ addr _ hot and Wr _ mark _ rp |, the null signal is 1. Rd _ mark, the null signal is 0, and Wr _ addr _ hot _ rp! If Rd _ addr _ hot, the null signal is 0;

if rd _ addr _ hot _ wp and rd _ mark _ wp are wr _ mark, then the full signal is 0, if rd _ addr _ hot _ wp and rd _ mark _ wp are wr _ addr _ hot and rd _ mark _ wp | (w is a fast signal), and if rd _ addr _ hot is not equal to wr _ addr _ hot and rd _ mark _ wp is not enough! The full signal is 1 if wr _ mark, and rd _ addr _ hot _ wp! When wr _ addr _ hot, the full signal is 0.

Preferably, synchronizing the read address, the write address, the read address flag bit and the write address flag bit into the same clock domain includes:

and synchronizing the read address, the write address, the read address flag bit and the write address flag bit to the same clock domain through two stages of flip-flops respectively.

An asynchronous FIFO memory read-write control apparatus comprising:

an acquisition module to: acquiring a current read address and a current write address of an asynchronous FIFO memory, and synchronizing the read address and the write address into the same clock domain respectively to obtain a synchronous read address corresponding to the read address and a synchronous write address corresponding to the write address;

a determination module to: determining a read credit integral and a write integral of the asynchronous FIFO memory based on the total capacity of the asynchronous FIFO memory, the read address, the write address, the read address after synchronization and the write address after synchronization; wherein the read credit integral represents an amount of data currently readable based on the asynchronous FIFO memory, and the write credit integral represents an amount of data currently writable based on the asynchronous FIFO memory;

an output module to: and outputting the read credit integral and the write integral to a corresponding read-write end so that the read-write end realizes the read-write operation of the asynchronous FIFO memory based on the read credit integral and the write integral.

An asynchronous FIFO memory read-write control device comprising:

a memory for storing a computer program;

a processor for implementing the steps of the asynchronous FIFO memory read-write control method as described in any of the above when executing the computer program.

A computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the asynchronous FIFO memory read-write control method of any preceding claim.

The invention provides a method, a device, equipment and a storage medium for controlling the read and write of an asynchronous FIFO memory, wherein the method comprises the following steps: acquiring a current read address and a current write address of an asynchronous FIFO memory, and synchronizing the read address and the write address into the same clock domain respectively to obtain a synchronous read address corresponding to the read address and a synchronous write address corresponding to the write address; determining a read credit integral and a write integral of the asynchronous FIFO memory based on the total capacity of the asynchronous FIFO memory, the read address, the write address, the read address after synchronization and the write address after synchronization; outputting the read credit integral and the write integral to a corresponding read-write end so that the read-write end realizes the read-write operation of the asynchronous FIFO memory based on the read credit integral and the write integral; wherein the read credit integral represents an amount of data currently readable based on the asynchronous FIFO memory and the write credit integral represents an amount of data currently writable based on the asynchronous FIFO memory. After the current read address and write address of the asynchronous FIFO memory are obtained, the read address and the write address are synchronized to the same clock domain, then the read credit integral and the write integral are determined based on the read address before synchronization, the read address after synchronization and the size of the asynchronous FIFO memory, and the read credit integral and the write integral are sent to the read-write end, so that the read-write end can obtain the data volume which can be currently read from the asynchronous FIFO memory based on the read credit integral to realize corresponding data reading, and the data volume which can be currently written into the asynchronous FIFO memory is obtained based on the write integral to realize corresponding data writing. Therefore, the read-write control of the asynchronous FIFO memory is realized through credit integration, namely the flow control of the system is realized, and the use efficiency of the asynchronous FIFO memory is further effectively improved.

Drawings

In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.

FIG. 1 is a system architecture diagram of an asynchronous FIFO memory read-write control scheme according to an embodiment of the present invention;

FIG. 2 is a flowchart of a method for controlling reading and writing of an asynchronous FIFO memory according to an embodiment of the present invention;

fig. 3 is a structural diagram of a read/write control device for an asynchronous FIFO memory according to an embodiment of the present invention.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

The embodiment of the invention discloses a method, a device, equipment and a medium for controlling the read-write of an asynchronous FIFO memory, which can improve the use efficiency of the asynchronous FIFO memory. For easy understanding, a system architecture applicable to the technical solution of the present application is described below, and refer to fig. 1, which is a schematic structural diagram of a system architecture used in the technical solution of the present application (the system architecture used in the technical solution of the present application is an asynchronous FIFO memory). As can be seen from fig. 1, the asynchronous FIFO memory, when implemented in hardware, may comprise the following modules: the device comprises a write one-hot code address generating module Wr _ addr _ one _ hot, a write binary coding address generating module Wr _ addr _ binary, a read one-hot code address generating module Rd _ addr _ one _ hot, a read binary coding address generating module Rd _ addr _ binary, a Memory module Memory, a synchronizing module Sync, a Credit integral generating module Credit, a FIFO empty signal generating module Cr _ empty through Credit integral and a FIFO full signal generating module Cr _ full through Credit integral. The description of the interface signal of the asynchronous FIFO memory may be specifically as shown in table 1.

TABLE 1 asynchronous FIFO memory interface signal table

The following description of the modules in fig. 1 is made in conjunction with table 1:

1. the write one hot code address generating module Wr _ addr _ one _ hot: the module generates a write one-hot address for writing the Memory module according to an input write enable wr _ en signal; and generates a write address flag bit wr _ mark.

2. The write binary coding address generating module Wr _ addr _ bank: the module generates a corresponding write binary code address according to the input write one-hot code address.

3. The read unique hot code address generating module Rd _ addr _ one _ hot: the module generates a read unique hot code address of the Memory module according to an input read enable rd _ en signal; and generates a read address flag bit rd _ mark.

4. The read binary coding address generating module Rd _ addr _ bank: the module generates corresponding read binary code address signals according to the input read one-hot code address.

5. Memory module Memory: the memory module is a dual-port static random access memory which calls or generates a synchronization.

6. The synchronization module Sync: the synchronization of the one-hot code address and the address flag bit is realized.

7. Credit integral generation module Credit: write credit score wr _ credit and read credit score rd _ credit are generated.

8. Generating an FIFO empty signal module Cr _ empty through the one-hot code address: the value of the null signal is determined.

9. The FIFO full signal module Cr _ full is generated by the one-hot address: the value of the full signal is determined.

Referring to fig. 2, a flowchart of a method for controlling reading and writing of an asynchronous FIFO memory according to an embodiment of the present invention is shown, where the method includes:

s11: and acquiring the current read address and write address of the asynchronous FIFO memory, and synchronizing the read address and the write address into the same clock domain respectively to obtain a synchronized read address corresponding to the read address and a synchronized write address corresponding to the write address.

The current reading address of the asynchronous FIFO memory is the address which is read if the asynchronous FIFO memory is read currently, and the current writing address of the asynchronous FIFO memory is the address which is written if the asynchronous FIFO memory is written currently; because the read address and the write address are generated in two different clock domains, the addresses need to be transferred to the clock domain of the other party 'safely', and therefore a synchronizer is needed for processing, namely, the application uses the synchronization module Sync to synchronize the read address and the write address into the same clock domain, so as to realize corresponding credit integral determination based on the synchronized read address and write address.

S12: determining a read credit integral and a write integral of the asynchronous FIFO memory based on the total capacity, the read address, the write address, the read address after synchronization and the write address after synchronization of the asynchronous FIFO memory; wherein the read credit integral represents the amount of data that can currently be read based on the asynchronous FIFO memory and the write credit integral represents the amount of data that can currently be written based on the asynchronous FIFO memory.

The credit mechanism is a method for controlling data flow, and the number of data which can be received or sent by the credit mechanism is fed back to the upper stage by the rear stage in real time or in a timing manner, so that the flow control of the whole system is realized, and the data is ensured not to overflow and not to be blocked; in the embodiment of the present application, the credit score represents the number of data groups that can be received or transmitted. Wherein, the receiving is reading, the sending is writing, the total capacity of the asynchronous FIFO memory is the size of the asynchronous FIFO memory, and the unit can be byte; the method and the device can calculate the credit reading integral and the credit writing integral of the asynchronous FIFO memory based on the total capacity, the reading address, the writing address, the reading address after synchronization and the writing address after synchronization of the asynchronous FIFO memory; the read credit integral represents the amount of data currently able to be read in the asynchronous FIFO memory, while the write credit integral represents the amount of data currently able to be written in the asynchronous FIFO memory. The credit integration for reading and the integration for writing are sent to the reading and writing end, the reading and writing end can acquire the data volume which can be read in the asynchronous FIFO memory currently based on the credit integration for reading, and acquire the data volume which can be written in the asynchronous FIFO memory currently based on the integration for writing, so that the reading and writing end can conveniently realize corresponding data reading and writing.

S13: and outputting the read credit integral and the write integral to corresponding read-write ends so that the read-write ends realize the read-write operation of the asynchronous FIFO memory based on the read credit integral and the write integral.

After the current read address and write address of the asynchronous FIFO memory are obtained, the read address and the write address are synchronized to the same clock domain, then the read credit integral and the write integral are determined based on the read address before synchronization, the read address after synchronization and the size of the asynchronous FIFO memory, and the read credit integral and the write integral are sent to the read-write end, so that the read-write end can obtain the data volume which can be currently read from the asynchronous FIFO memory based on the read credit integral to realize corresponding data reading, and the data volume which can be currently written into the asynchronous FIFO memory is obtained based on the write integral to realize corresponding data writing. Therefore, the read-write control of the asynchronous FIFO memory is realized through credit integration, namely the flow control of the system is realized, and the use efficiency of the asynchronous FIFO memory is further effectively improved.

The method for controlling read and write of the asynchronous FIFO memory provided by the embodiment of the invention can also comprise the following steps:

receiving a read request sent by a read-write end, determining a current read-only-hot code address, converting the current read-only-hot code address into a corresponding read binary code address, realizing read operation corresponding to the read request in an asynchronous FIFO memory based on the read binary code address, and shifting the current read-only-hot code address by 1 bit to the left to serve as a new current read-only-hot code address after the read operation is completed;

receiving a write request sent by a write end, determining a current write one-hot code address, converting the current write one-hot code address into a corresponding write binary code address, realizing write operation corresponding to the write request in an asynchronous FIFO memory based on the write binary code address, and shifting the current write one-hot code address by 1 bit to the left to serve as a new current write one-hot code address after the write operation is completed;

correspondingly, obtaining the current read address and write address of the asynchronous FIFO memory may include:

and acquiring the current read one-hot code address and write one-hot code address of the asynchronous FIFO memory.

In the embodiment of the application, the write one-hot code address generating module Wr _ addr _ one _ hot generates a write one-hot code address of the Memory storage module according to an input write enable Wr _ en signal; the one-hot code is used in the embodiment of the present application because the combinational logic is the least, the flip-flops are the most, and the operating clock frequency can be the highest. Specifically, after the asynchronous FIFO memory is reset, the address of the one-hot code is written to be 1; when wr _ en is high, data is written into the current write one-hot address, while the current write one-hot address is "cyclically shifted left by one bit" as the data address for the next write. For data with a data bit width of N, "rotate left by one bit" means: a1[ N-1:0] < { a1[ N-2:1], a [ N-1] }; where < > -represents a non-blocking assignment in verilog syntax. The write binary code address generating module Wr _ addr _ binary generates a write binary code address according to an input write one-hot code address, the process is realized by combinational logic, namely the write one-hot code address and the write binary code address are in the same clock cycle, and the conversion formula is as follows: wr _ addr _ bin ═ log2(Wr _ addr _ hot); wherein, Wr _ addr _ bin represents a write binary coding address, and Wr _ addr _ hot represents a write one-hot address.

Similarly, the read unique hot code address generating module Rd _ addr _ one _ hot generates a read unique hot code address of the Memory reading module Memory according to the input read enable Rd _ en signal. Specifically, after the asynchronous FIFO memory is reset, reading the address of the one-hot code to be 1; when rd _ en is high, the current read one-hot code address is given to the read address of the rear-stage memory module, and the current read one-hot code address is circularly shifted left by one bit to be used as the data address for next reading. The read binary code address generating module Rd _ addr _ binary generates a read binary code (binary) address according to an input read unique code address, and the process is realized by combinational logic, namely the read unique code address and the read binary code address are in the same clock cycle, and the conversion formula is as follows: rd _ addr _ bin log2(rd _ addr _ hot); wherein rd _ addr _ bin represents reading binary coding address, and rd _ addr _ hot represents reading one-hot code address.

The obtaining of the read address and the write address of the current asynchronous FIFO in the present application is to obtain the current read one-hot address and the current write one-hot address from the read one-hot address generating module Rd _ addr _ one _ hot and the write one-hot address generating module Wr _ addr _ one _ hot, respectively.

The method for controlling the read-write of the asynchronous FIFO memory provided by the embodiment of the invention determines the credit integral of the read and the credit integral of the write of the asynchronous FIFO memory, and comprises the following steps:

if Wr _ addr _ hot > rd _ addr _ hot _ wp, the integral for writing of a single byte is calculated according to the following formula:

wr_credit_1=fifo_capa-log2Wr_addr_hot+log2rd_addr_hot_wp;

if Wr _ addr _ hot < rd _ addr _ hot _ wp, the integral for writing a single byte is calculated according to the following formula:

wr_credit_1=log2rd_addr_hot_wp-log2Wr_addr_hot;

if Wr _ addr _ hot _ rp > rd _ addr _ hot, the read credit integral of a single byte is calculated according to the following formula:

rd_credit_1=Wr_addr_hot_rp-rd_addr_hot;

if Wr _ addr _ hot _ rp < rd _ addr _ hot, the write/read credit integral of a single byte is calculated according to the following formula:

rd_credit_1=fifo_capa+Wr_addr_hot_rp-rd_addr_hot;

the writing of single bytes is represented by an integral Wr _ credit _1, the number of single bytes which can be currently written based on the asynchronous FIFO memory is represented by a read credit integral rd _ credit _1 of single bytes, the number of single bytes which can be currently read based on the asynchronous FIFO memory is represented by FIFO _ capa, the total capacity of the asynchronous FIFO memory is represented by Wr _ addr _ hot, the writing address is represented by rd _ addr _ hot, the writing address is represented by Wr _ addr _ hot _ rp after synchronization, and the reading address is represented by rd _ addr _ hot _ wp after synchronization.

After calculating the integral for writing a single byte, the method may further include:

calculating a write score for the data set according to the following formula, and rounding the write score down to obtain a write integral for the data set:

wr_credit_user=wr_credit_1/wr_credit_user_define;

calculating the read credit score of the data set according to the following formula, and rounding the read credit score down to obtain the read credit score of the data set:

rd_credit_user=rd_credit_1/rd_credit_user_define;

the integration wr _ credit _ user for writing the data group represents the number of data groups which can be written based on the asynchronous FIFO memory currently, the read credit integration rd _ credit _ user for the data group represents the number of data groups which can be read based on the asynchronous FIFO memory currently, and the wr _ credit _ user _ definition and rd _ credit _ user _ definition are respectively a read conversion unit and a write conversion unit between the data groups and a single byte.

Credit integral generation module Credit

Write credit integration wr _ credit

The credit writing integration can be divided into the integration for writing of a single byte and the integration for writing of a data group, the integration for writing of the single byte represents the number of the single byte which can be currently written into the asynchronous FIFO memory, and the integration for writing of the data group represents the number of the data group which can be currently written into the asynchronous FIFO memory; similarly, the read credit points can be divided into a single-byte read credit point and a data group read credit point, the single-byte read credit point represents the number of single bytes currently readable to the asynchronous FIFO memory, and the data group read credit point represents the number of data groups currently readable to the asynchronous FIFO memory. Specifically, before using the asynchronous FIFO memory, the size of the asynchronous FIFO memory is generally defined, and is denoted as FIFO _ capa, and the unit is byte; when the wr _ credit is calculated, calculation is needed according to the current read-write one-hot code address, and the calculation process is as follows:

1. calculating a write single byte credit integral wr _ credit _ 1:

firstly, comparing the address sizes of Wr _ addr _ hot and rd _ addr _ hot _ wp, and if Wr _ addr _ hot > rd _ addr _ hot _ wp:

wr_credit_1=fifo_capa-log2Wr_addr_hot+log2rd_addr_hot_wp

if Wr _ addr _ hot < rd _ addr _ hot _ wp:

wr_credit_1=log2rd_addr_hot_wp-log2Wr_addr_hot;

2. calculate user-defined write credit integration (integration for writing of data set):

wr _ credit _ user ═ wr _ credit _1/wr _ credit _ user _ define _ define, rounded down.

The read credit integral represents the number of data groups that can be read out normally in the asynchronous FIFO memory. When rd _ credit is calculated, calculation is needed according to the current read-write unique hot code address, and the calculation process is as follows:

1. calculating a read single byte credit integral rd _ credit _ 1:

firstly, comparing the address sizes of rd _ addr _ hot and Wr _ addr _ hot _ rp, and if Wr _ addr _ hot _ rp is larger than rd _ addr _ hot:

rd_credit_1=Wr_addr_hot_rp-rd_addr_hot

if Wr _ addr _ hot _ rp < rd _ addr _ hot:

rd_credit_1=fifo_capa+Wr_addr_hot_rp-rd_addr_hot;

2. calculating the user-defined reading credit points (of the data set):

rd _ credit _ user, rd _ credit _1/rd _ credit _ user _ define, rounded down.

According to the embodiment of the application, effective and accurate determination of credit integration can be achieved according to the method, and because the reading and writing end and the unit of data in the asynchronous FIFO memory are different, conversion between different units is achieved by using the method in the embodiment of the application, direct processing of the reading and writing end on the data is facilitated, and the efficiency of the reading and writing end in achieving data reading and writing is improved.

The method for controlling read and write of the asynchronous FIFO memory provided by the embodiment of the invention can also comprise the following steps:

acquiring a current read address zone bit and a current write address zone bit of an asynchronous FIFO memory, synchronizing the read address zone bit and the write address zone bit into a clock domain which is the same as a read address and a write address, and acquiring a synchronous read address zone bit corresponding to the read address zone bit and a synchronous write address zone bit corresponding to the write address zone bit; the reading address flag bit and the writing address flag bit respectively take a value opposite to a current value when the reading address and the writing address jump from a last address to a first address;

determining an empty signal and a full signal of the asynchronous FIFO memory based on a read address, a write address, a read address after synchronization, a write address after synchronization, a read address zone bit, a write address zone bit, a read address zone bit after synchronization and a write address zone bit after synchronization of the asynchronous FIFO memory; the full signal indicates whether the storage space of the asynchronous FIFO memory is full, and the empty signal indicates whether the asynchronous FIFO memory is empty;

and outputting the empty signal and the full signal to corresponding read-write ends so that the read-write ends can realize read-write operation on the asynchronous FIFO memory based on the empty signal and the full signal.

Determining the empty signal and the full signal of the asynchronous FIFO memory may include:

if Wr _ addr _ hot _ rp is Rd _ addr _ hot and Wr _ mark _ rp is Rd _ mark, the null signal is 1, if Wr _ addr _ hot _ rp is Rd _ addr _ hot and Wr _ mark _ rp |, the null signal is 1. Rd _ mark, the null signal is 0, and Wr _ addr _ hot _ rp! If Rd _ addr _ hot, the null signal is 0;

if rd _ addr _ hot _ wp and rd _ mark _ wp are wr _ mark, then the full signal is 0, if rd _ addr _ hot _ wp and rd _ mark _ wp are wr _ addr _ hot and rd _ mark _ wp | (w is a fast signal), and if rd _ addr _ hot is not equal to wr _ addr _ hot and rd _ mark _ wp is not enough! The full signal is 1 if wr _ mark, and rd _ addr _ hot _ wp! When wr _ addr _ hot, the full signal is 0.

In the embodiment of the application, the write one-hot code address generating module Wr _ addr _ hot generates a write address mark Wr _ mark while generating the write one-hot code address; after the asynchronous FIFO memory is reset, the default value of the write address mark bit Wr _ mark is 0, and when the highest bit (Wr _ addr _ hot [ N-1]) of Wr _ addr _ hot is 1 and the write enable Wr _ en signal is valid, the Wr _ mark signal is inverted. The read unique hot code address generating module Rd _ addr _ hot generates a read address mark Rd _ mark while generating a read unique hot code address, the read address mark Rd _ mark default value is 0 after the asynchronous FIFO memory is reset, and the Rd _ mark signal is inverted when the highest bit (Rd _ addr _ hot [ N-1]) of the Rd _ addr _ hot is 1 and the write enable Rd _ en signal is valid.

The writing address is converted into a synchronized writing address Wr _ addr _ hot _ rp in a reading clock domain through a synchronization module, so that the synchronized writing address Wr _ addr _ hot _ rp and Rd _ addr _ hot are compared to be operated, namely, the writing address is processed in the same clock domain; specifically, when Wr _ addr _ hot _ rp is Rd _ addr _ hot, the following determination is made:

if wr _ mark _ rp is rd _ mark, the empty signal (null signal) is 1;

if wr _ mark _ rp! Rd _ mark, when empty signal is 0;

when Wr _ addr _ hot _ rp! Rd _ addr _ hot, the empty signal is 0 (| means not equal).

The read address is converted into a synchronized read address rd _ addr _ hot _ wp in a write clock domain through a synchronization module, so that the synchronized read address rd _ addr _ hot _ wp and the synchronized read address wr _ addr _ hot _ wp are compared and operated, and the processing in the same clock domain is realized; specifically, when rd _ addr _ hot _ wp is wr _ addr _ hot, the following determination is made:

if rd _ mark _ wp is wr _ mark, the full signal is 0;

if rd _ mark _ wp! Wr _ mark, when full signal is 1;

when rd _ addr _ hot _ wp! When wr _ addr _ hot, the full signal is 0.

In addition, synchronizing the read address, the write address, the read address flag bit and the write address flag bit into the same clock domain may include: and synchronizing the read address, the write address, the read address flag bit and the write address flag bit to the same clock domain through two stages of flip-flops respectively. Specifically, the embodiment of the application, which adopts the one-hot code address to synchronize to another clock domain, can ensure that only two bits change each time and do not change with the increase of the address bit width; the signal synchronization is completed by using a two-stage trigger mode, and the triggers can be selected according to actual needs, such as a D trigger, a T trigger and the like; after synchronization is achieved, the following information:

wr _ addr _ hot _ rp is a writing address synchronized by using two stages of triggers;

rd _ addr _ hot _ wp is a read address synchronized by using two stages of triggers;

wr _ mark _ rp is a writing address mark bit after synchronization by using a two-stage trigger;

rd _ mark _ wp is a read address flag bit synchronized by using two stages of flip-flops.

According to the method, the one-hot code is used for completing the crossing of an asynchronous clock domain, and credit integrals independent of a read-write end and empty and full signals of an asynchronous FIFO memory are generated; the asynchronous FIFO memory applying the scheme of the invention can simplify the calculation process of external interface signals, and is directly connected with systems supporting credit mechanisms such as PCIe and the like, thereby improving the reusability and reliability of the asynchronous FIFO memory, further improving the development efficiency of the whole SOC and further improving the product competitiveness.

An embodiment of the present invention further provides a read-write control device for an asynchronous FIFO memory, as shown in fig. 3, which may specifically include:

an obtaining module 11, configured to: acquiring a current read address and a current write address of an asynchronous FIFO memory, and synchronizing the read address and the write address into the same clock domain respectively to obtain a synchronous read address corresponding to the read address and a synchronous write address corresponding to the write address;

a determining module 12 for: determining a read credit integral and a write integral of the asynchronous FIFO memory based on the total capacity, the read address, the write address, the read address after synchronization and the write address after synchronization of the asynchronous FIFO memory; the credit integral of reading represents the data volume which can be read based on the asynchronous FIFO memory currently, and the integral of writing represents the data volume which can be written based on the asynchronous FIFO memory currently;

an output module 13 for: and outputting the read credit integral and the write integral to corresponding read-write ends so that the read-write ends realize the read-write operation of the asynchronous FIFO memory based on the read credit integral and the write integral.

An embodiment of the present invention further provides an asynchronous FIFO memory read-write control device, which may include:

a memory for storing a computer program;

and the processor is used for realizing the steps of the asynchronous FIFO memory read-write control method when executing the computer program.

The embodiment of the invention also provides a computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and when being executed by a processor, the computer program realizes the steps of any one of the above asynchronous FIFO memory read-write control methods.

It should be noted that for the description of the relevant parts in the asynchronous FIFO memory read-write control device, the apparatus, and the storage medium provided in the embodiments of the present invention, reference is made to the detailed description of the corresponding parts in the asynchronous FIFO memory read-write control method provided in the embodiments of the present invention, and details are not repeated here. In addition, parts of the technical solutions provided in the embodiments of the present invention that are consistent with the implementation principles of the corresponding technical solutions in the prior art are not described in detail, so as to avoid redundant description.

The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

17页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种基于HBM缓存的SSD固态盘

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!