[go: up one dir, main page]

CN102004711B - A Single Interrupt Real-time Data Transmission Method Based on FPGA - Google Patents

A Single Interrupt Real-time Data Transmission Method Based on FPGA Download PDF

Info

Publication number
CN102004711B
CN102004711B CN201010547869XA CN201010547869A CN102004711B CN 102004711 B CN102004711 B CN 102004711B CN 201010547869X A CN201010547869X A CN 201010547869XA CN 201010547869 A CN201010547869 A CN 201010547869A CN 102004711 B CN102004711 B CN 102004711B
Authority
CN
China
Prior art keywords
data
buffer
interrupt
read
host computer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201010547869XA
Other languages
Chinese (zh)
Other versions
CN102004711A (en
Inventor
安建平
周荣花
孙磊
杨淼
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Institute of Technology BIT
Original Assignee
Beijing Institute of Technology BIT
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Institute of Technology BIT filed Critical Beijing Institute of Technology BIT
Priority to CN201010547869XA priority Critical patent/CN102004711B/en
Publication of CN102004711A publication Critical patent/CN102004711A/en
Application granted granted Critical
Publication of CN102004711B publication Critical patent/CN102004711B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Communication Control (AREA)

Abstract

The invention relates to a data transmission method, in particular to a real-time data transmission method in which the data of a plurality of asynchronous data sources is buffered through single-interrupt data transmission equipment based on an FPGA (Field Programmable Gate Array) and then sent to an upper computer, belonging to the technical field of real-time signal processing. The real-time data transmission method comprises the following steps of: firstly selecting an appropriate interrupt cycle according to a conditional inequality of data transmission without data loss; then establishing data buffers in the FPGA, and establishing writing state registers of the data buffers; and then generating a cyclic interrupt signal according to half full and full signals sent by the data buffers, wherein the upper computer triggers an interrupt service routine by responding to the cyclic interrupt signal so as to achieve the purpose of real-time continuous transmission. Compared with a multi-interrupt source trigger mode, the real-time data transmission method reduces the programming and debugging complexity of software and hardware and enhances the reliability of a system; in addition, the magnitude of data quantity generated by each interrupt is relatively stable, therefore the data is more convenient for intensive batch transmission and post processing.

Description

一种基于FPGA的单中断实时数据传输方法A Single Interrupt Real-time Data Transmission Method Based on FPGA

技术领域 technical field

本发明涉及一种数据传输方法,特别涉及将多个异步数据源的数据经过基于FPGA的单中断数据传输设备进行缓存,再发送到上位机的一种实时数据传输方法,属于实时信号处理技术领域。The invention relates to a data transmission method, in particular to a real-time data transmission method that caches data from multiple asynchronous data sources through an FPGA-based single-interruption data transmission device, and then sends them to a host computer, belonging to the technical field of real-time signal processing .

背景技术 Background technique

现代通信系统例如军事通信侦察系统中常需要对各种非合作信号进行迅速搜索、截获、测量、分析、识别、监视等操作,这对数字信号处理的时间要求非常苛刻,必须采用高速专用硬件系统来完成任务。FPGA+DSP/MCU/CPU等的高速实时数字信号处理架构在通信、雷达系统等需要高实时性的数字信号处理系统中很常见。因此,高速数据在FPGA和DSP/MCU/CPU等这两种模块之间的高效可靠传输就显得尤为重要。FPGA作为一种实现复杂数字算法逻辑的并行高速硬线逻辑器件,通常会作为一个高速数据源。而DSP/MCU/CPU等作为一个相对低速但使用灵活的数字信号分析处理设备常处于数据接收端(或称上位机)的位置。FPGA所产生的数据流的特点分以下几种情况:不间断连续数据流、非周期性突发数据流、周期性突发数据流等,并且各种数据流可能具有不同的数据速率。Modern communication systems such as military communication and reconnaissance systems often need to quickly search, intercept, measure, analyze, identify, monitor and other operations on various non-cooperative signals. mission accomplished. High-speed real-time digital signal processing architectures such as FPGA+DSP/MCU/CPU are very common in digital signal processing systems that require high real-time performance such as communications and radar systems. Therefore, the efficient and reliable transmission of high-speed data between FPGA and DSP/MCU/CPU and other modules is particularly important. As a parallel high-speed hard-wire logic device that implements complex digital algorithm logic, FPGA is usually used as a high-speed data source. As a relatively low-speed but flexible digital signal analysis and processing device, DSP/MCU/CPU is often at the data receiving end (or host computer). The characteristics of the data flow generated by the FPGA are divided into the following situations: uninterrupted continuous data flow, aperiodic burst data flow, periodic burst data flow, etc., and various data flows may have different data rates.

对于这些速率不同的异步数据源,要完成实时连续数据传输,传统的做法是针对不同的异步数据源产生多个不同的中断信号给上位机的方法来完成数据的实时连续传输。但是,基于多中断源的软硬件编程、调试等都比较复杂,并且容易导致系统崩溃等各种系统稳定性、可靠性问题。For these asynchronous data sources with different rates, to complete real-time continuous data transmission, the traditional method is to generate multiple different interrupt signals for different asynchronous data sources to the host computer to complete real-time continuous data transmission. However, the software and hardware programming and debugging based on multiple interrupt sources are relatively complicated, and it is easy to cause various system stability and reliability problems such as system crashes.

发明内容: Invention content:

本发明主要针对传统多中断源式实时数据传输方法的软硬件编程调试复杂、可靠性差的缺点,提出了一种基于FPGA的单中断实时连续数据传输方法,该方法不仅减少了产生中断的次数,而且使得中断间隔具有固定周期,提高了数据传输的效率,并且简化了设计的复杂度。The present invention mainly aims at the shortcomings of complex software and hardware programming and debugging and poor reliability of the traditional multi-interrupt source real-time data transmission method, and proposes a single-interrupt real-time continuous data transmission method based on FPGA. This method not only reduces the number of interruptions, Moreover, the interrupt interval has a fixed period, which improves the efficiency of data transmission and simplifies the complexity of design.

基于FPGA的单中断实时数据传输方法,是通过先在FPGA上构建n个与各种异步数据源相应的数据缓冲区(B1,B2,…,Bn),再通过采用合适的单中断源和n个数据缓冲区的写状态指针来协助完成实时连续数据传输。首先,要在n个异步数据源中选择一个数据源采用乒乓缓冲的方法建立数据缓冲区;其次,为剩余的n-1个异步数据源建立非乒乓方式的普通数据缓冲区,同时为n个数据缓冲区建立写状态指针寄存器,其中,非乒乓缓冲区的写状态指针为当前的写操作地址值,而乒乓缓冲区的状态指针可仅仅用0或1表示正进行写操作的上/下数据缓冲半区;然后,针对唯一的乒乓缓冲区建立具有周期性特征的单中断源数据传输触发机制;最后,完成上位机中断服务子程序编程,需要注意的是在上位机程序中也需要建立一个数据缓冲区的写状态指针存储变量以保存上一次中断时获得的数据缓冲区写状态指针。The FPGA-based single interrupt real-time data transmission method is to construct n data buffers (B1, B2, ..., Bn) corresponding to various asynchronous data sources on the FPGA first, and then adopt a suitable single interrupt source and n The write status pointer of each data buffer is used to assist in the completion of real-time continuous data transmission. First, one of the n asynchronous data sources should be selected to establish a data buffer using the method of ping-pong buffering; secondly, a non-ping-pong ordinary data buffer should be established for the remaining n-1 asynchronous data sources. The data buffer creates a write status pointer register, wherein the write status pointer of the non-ping-pong buffer is the current write operation address value, and the status pointer of the ping-pong buffer can only use 0 or 1 to represent the upper/lower data being written Buffer half area; then, establish a periodic single interrupt source data transmission trigger mechanism for the only ping-pong buffer; finally, complete the host computer interrupt service subroutine programming, it should be noted that in the host computer program also need to establish a The write status pointer of the data buffer stores the variable to save the data buffer write status pointer obtained at the time of the last interrupt.

不妨假设B1缓冲区被选中作为乒乓缓冲区,即B1缓冲区被分为上下两个具有相同存储深度的半区B1L和B1H,并利用其半满和全满信号来产生中断信号。假设B1数据缓冲区的写数据速率为W1字节/秒,并且B1乒乓缓冲区B1L或B1H的数据存储量为S0字节,则B1L或B1H缓冲区写满的所需的存储时间T1为:It may be assumed that the B1 buffer is selected as a ping-pong buffer, that is, the B1 buffer is divided into upper and lower half areas B1L and B1H with the same storage depth, and the half-full and full-full signals are used to generate interrupt signals. Assuming that the write data rate of the B1 data buffer is W1 byte/s, and the data storage capacity of the B1 ping-pong buffer B1L or B1H is S0 bytes, then the required storage time T1 for the B1L or B1H buffer to be full is:

T1=S1/W1T1=S1/W1

显然,T1也即中断源的中断周期。而上位机读取完B1L或B1H缓冲区数据所需时间为:Obviously, T1 is also the interrupt period of the interrupt source. The time required for the host computer to read the B1L or B1H buffer data is:

T1’=S1/RT1'=S1/R

其中R为上位机读数据速率,单位同样为字节/秒。Among them, R is the read data rate of the upper computer, and the unit is also byte/second.

如此,则B2缓冲区在T1时间内所存储的数据量为S2=W2×T1,W2为写数据速率;而上位机读取完该数据所需时间为:T2’=S2/R。同理,Bk数据缓冲区(k=1,2,…,n)在T1时间内所存储的数据量为Sk=Wk*T1,上位机读取完所有数据所需时间为Tk’=Sk/R,其中,k=1,2,…,n。需要注意的是各个数据缓冲区的大小必须要大于等于其在T1时间内数据存储量Sk(k=1,2,…,n)的2倍。In this way, the amount of data stored in the B2 buffer within the T1 time is S2=W2×T1, W2 is the write data rate; and the time required for the host computer to read the data is: T2'=S2/R. In the same way, the amount of data stored in the Bk data buffer (k=1, 2, ..., n) in the T1 time is Sk=Wk*T1, and the time required for the upper computer to read all the data is Tk'=Sk/ R, where k=1, 2, . . . , n. It should be noted that the size of each data buffer must be greater than or equal to twice its data storage capacity Sk (k=1, 2, . . . , n) within T1.

上位机要完全读取B1,B2,…,Bn缓冲区在T1时间内存储的所有数据需要的时间Ts为:The time Ts required for the host computer to completely read all the data stored in the B1, B2, ..., Bn buffers within the time T1 is:

Ts=T1’+T2’+...+Tn’Ts=T1'+T2'+...+Tn'

=S1/R+S2/R+...+Sn/R=S1/R+S2/R+...+Sn/R

=(W1+W2+...+Wn)×I1/R=(W1+W2+...+Wn)×I1/R

显然,要保证数据实时连续传输而不丢失数据,需要满足条件:Obviously, to ensure real-time continuous data transmission without data loss, the following conditions need to be met:

Ts<T1,Ts<T1,

也即,需要满足条件:That is, the conditions need to be met:

W1+W2+...+Wn<RW1+W2+...+Wn<R

一种基于FPGA的单中断实时连续数据传输方法,包括以下具体步骤:An FPGA-based single interrupt real-time continuous data transmission method, comprising the following specific steps:

步骤一:选择合适的中断周期Step 1: Choose an appropriate interrupt period

根据各异步数据源1,2,…,n的写数据速率Wk和上位机的读数据速率R,利用不丢失数据下实时连续数据传输条件不等式W1+W2+...+Wn<R,首先确认系统实现的可行性。在系统可实现的前提下,再依据FPGA硬件资源的大小及其他限制条件,选择合适的中断周期T1,因为各数据缓冲区的总字节数至少为(W1+W2+...+Wn)×T1×2。According to the write data rate Wk of each asynchronous data source 1, 2, ..., n and the read data rate R of the host computer, using the real-time continuous data transmission condition inequality W1+W2+...+Wn<R without data loss, first confirm system implementation feasibility. On the premise that the system can be realized, and then according to the size of the FPGA hardware resources and other constraints, select the appropriate interrupt period T1, because the total number of bytes of each data buffer is at least (W1+W2+...+Wn)× T1×2.

步骤二:创建数据缓冲区Step 2: Create a data buffer

根据各异步数据源1,2,…,n的写数据速率Wk和中断周期T1,确定各个异步数据源的缓冲区存储量大小为Wk×T1×2,为这n个异步数据源建立n个数据缓冲区,并确定其中的某一个数据缓冲区为乒乓缓冲区,不妨假设选B1为乒乓缓冲区,其缓冲区分成上下半区B1L和B1H,具有半满和全满指示信号,而其它数据缓冲区则为普通数据缓冲区即可。According to the write data rate Wk and the interrupt period T1 of each asynchronous data source 1, 2,..., n, determine the buffer storage size of each asynchronous data source as Wk×T1×2, and establish n for these n asynchronous data sources Data buffer, and determine that one of the data buffers is a ping-pong buffer. It may be assumed that B1 is selected as a ping-pong buffer. The buffer is an ordinary data buffer.

步骤三:创建各数据缓冲区的写状态指针寄存器Step 3: Create a write status pointer register for each data buffer

创建各数据缓冲区的写状态指针寄存器时,其中的乒乓缓冲区B1的写状态指针值为当前写操作地址最高位的值,其值可能为0或1,而其他数据缓冲区的写状态指针为当前写操作地址值。When creating the write status pointer registers of each data buffer, the write status pointer value of the ping-pong buffer B1 among them is the value of the highest bit of the current write operation address, which may be 0 or 1, while the write status pointers of other data buffers It is the address value of the current write operation.

步骤四:产生周期性中断信号Step 4: Generate a periodic interrupt signal

依据乒乓缓冲区B1的写操作产生的缓冲区半满和全满信号产生与上位机相对应的周期性中断信号,该中断信号发送至上位机即可触发中断服务子程序,从而完成读取FPGA中各数据缓冲区数据操作。According to the buffer half-full and full-full signals generated by the write operation of the ping-pong buffer B1, a periodic interrupt signal corresponding to the host computer is generated, and the interrupt signal is sent to the host computer to trigger the interrupt service subroutine, thereby completing the read FPGA Data operations in each data buffer.

步骤五:建立上位机和FPGA中各数据缓冲区(B1,B2,…,Bn)之间的总线接口。Step 5: Establish bus interfaces between the host computer and each data buffer (B1, B2, . . . , Bn) in the FPGA.

将上位机的读操作指令中包含的读时钟C、读操作地址A及读使能等信号转换为各数据缓冲区的读时钟C、读使能(E1,E2,…,En)和读地址(A1R,A2R,…,AnR)信号及各缓冲区的写状态指针寄存器的读地址信号AR等。以读取上述存储空间中的数据。Convert the read clock C, read operation address A and read enable signals contained in the read operation instruction of the host computer into the read clock C, read enable (E1, E2,..., En) and read address of each data buffer (A1R, A2R,..., AnR) signal and the read address signal AR of the write state pointer register of each buffer zone, etc. to read the data in the above storage space.

步骤六:创建上位机中断服务子程序Step 6: Create the host computer interrupt service subroutine

上位机中断服务子程序工作过程如下:上位机中断服务子程序接收到硬件中断信号后,先做是否要初始化的判断:如果系统是刚上电复位或其他形式重置之后,则将FPGA各缓冲区写地址和上位机的历史写指针寄存器值初始化为其相应的起始地址,否则跳过该初始化步骤。然后读取各数据缓冲区的当前写状态指针寄存器值,而上位机程序中保存有上一次中断时存储的各数据缓冲区的写状态指针寄存器值,不妨称为历史写状态指针寄存器值。中断服务子程序然后利用当前写状态指针和上位机保存的历史写状态指针的一个临时备份来完成读取FPGA中各数据缓冲区相应地址段的数据,并在历史写状态指针寄存器值备份之后和上位机读操作之前,把历史写状态指针寄存器值更新为当前写状态指针寄存器值,以保证下次中断时能够正确读取各缓冲区相应地址段的数据。上位机中断服务子程序执行读操作完毕后结束,进入等待下次中断状态。The working process of the interrupt service subroutine of the host computer is as follows: After the interrupt service subroutine of the host computer receives the hardware interrupt signal, it first makes a judgment whether to initialize: if the system has just been reset after power-on or other forms, then the FPGA buffer The area write address and the history write pointer register value of the upper computer are initialized to their corresponding start addresses, otherwise, this initialization step is skipped. Then read the current write state pointer register value of each data buffer, and the write state pointer register value of each data buffer stored during the last interruption is saved in the host computer program, which may be called the historical write state pointer register value. The interrupt service subroutine then uses a temporary backup of the current write status pointer and the historical write status pointer saved by the host computer to complete reading the data in the corresponding address segment of each data buffer in the FPGA, and after the backup of the historical write status pointer register value and Before the read operation of the upper computer, update the historical write status pointer register value to the current write status pointer register value to ensure that the data in the corresponding address segment of each buffer can be read correctly when the next interruption occurs. After the host computer interrupt service subroutine executes the read operation, it ends and enters the state of waiting for the next interrupt.

步骤七:上位机在周期性中断信号的触发下循环调用步骤六中所述中断服务子程序,即可达到实时连续数据传输目的。Step 7: Under the trigger of the periodic interrupt signal, the upper computer cyclically calls the interrupt service subroutine described in step 6, so as to achieve the purpose of real-time continuous data transmission.

有益效果Beneficial effect

本发明方法对比传统多中断源触发方式的数据传输方法,大大降低了软硬件编程调试的复杂度,由于中断单一从而使得系统的实时数据传输更加稳定、可靠,降低了系统不稳定的可能性,每次中断产生的数据量大小相对稳定,数据更便于集中进行批量传输和后处理。Compared with the traditional data transmission method triggered by multiple interrupt sources, the method of the present invention greatly reduces the complexity of software and hardware programming and debugging. Due to the single interrupt, the real-time data transmission of the system is more stable and reliable, and the possibility of system instability is reduced. The amount of data generated by each interrupt is relatively stable, and the data is more convenient for centralized batch transmission and post-processing.

附图说明: Description of drawings:

图1-单中断实时数据传输装置示意图;Figure 1 - Schematic diagram of a single-interrupt real-time data transmission device;

图2-上位机中断服务子程序流程图。Figure 2 - Flowchart of host computer interrupt service subroutine.

具体实施方式Detailed ways

下面结合附图和实施例对本发明做进一步说明。The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

假设有一个如图1所示的实时数据传输装置。异步数据源1,2,…,n在各自写时钟C1,C2,…,Cn作用下的写数据速率分别为W1,W2,…,Wn。我们不妨假设异步数据源的个数为3,即n=3,并且设定数据源1,2,3的写数据速率分别为50KB/s、100KB/s、150KB/s。同时,设定上位机处理器的读数据速率为1200KB/s。Suppose there is a real-time data transmission device as shown in Figure 1. The write data rates of the asynchronous data sources 1, 2, . . . , n under the action of respective write clocks C1, C2, . Let us assume that the number of asynchronous data sources is 3, that is, n=3, and set the write data rates of data sources 1, 2, and 3 to 50KB/s, 100KB/s, and 150KB/s, respectively. At the same time, set the read data rate of the host computer processor to 1200KB/s.

步骤一:判断是否满足不丢失数据的实时数据传输条件。显然,由于三个数据源的写数据速率之和W1+W2+W3等于300KB/s,远小于上位机读数据速率1200KB/s,因此,不丢失数据的连续实时数据传输可以实现。另外,我们假设FPGA资源足够充裕,选择中断周期为10ms,即0.01s。Step 1: Judging whether the real-time data transmission condition without data loss is satisfied. Obviously, since the sum W1+W2+W3 of the write data rates of the three data sources is equal to 300KB/s, which is far less than the host computer’s read data rate of 1200KB/s, continuous real-time data transmission without data loss can be realized. In addition, we assume that FPGA resources are sufficient, and choose the interrupt period to be 10ms, that is, 0.01s.

步骤二:确定各数据缓冲区大小,建立3个数据缓冲区。我们不妨选择数据源1的缓冲区作为乒乓缓冲区。显然数据源1的缓冲区B1的大小应为W1×T1×2,其中,T1即中断源周期为0.01s,W1=50KB/s,于是数据源1的乒乓缓冲区总大小为1KB。同理,数据源2的缓冲区大小为W2×T1×2=2KB,数据源3的缓冲区大小为W3×T1×2=3KB。由于数据源2和3的缓冲区为非乒乓缓冲区而不需要用于产生中断信号,故而其缓冲区大小选择可以略大于2KB和3KB以更好地保证数据的连续性,避免新数据在读取前被后续数据覆盖。Step 2: Determine the size of each data buffer, and establish three data buffers. We might as well choose the buffer of data source 1 as the ping-pong buffer. Obviously, the size of the buffer B1 of the data source 1 should be W1×T1×2, wherein, T1, that is, the period of the interrupt source is 0.01s, W1=50KB/s, so the total size of the ping-pong buffer of the data source 1 is 1KB. Similarly, the buffer size of data source 2 is W2×T1×2=2KB, and the buffer size of data source 3 is W3×T1×2=3KB. Since the buffers of data sources 2 and 3 are non-ping-pong buffers and do not need to be used to generate interrupt signals, the buffer size selection can be slightly larger than 2KB and 3KB to better ensure data continuity and avoid new data being read It is overwritten by subsequent data before fetching.

步骤三:创建各数据缓冲区B1,B2,B3的写状态指针存储寄存器。其中,数据缓冲区B1的写状态指针值等于当前写操作地址A1W的最高位的值,而数据缓冲区B2和B3的写状态指针值就等于其当前的写操作地址A2W和A3W。Step 3: Create the storage registers for the write status pointers of the data buffers B1, B2, and B3. Wherein, the write status pointer value of the data buffer B1 is equal to the value of the highest bit of the current write operation address A1W, and the write status pointer values of the data buffer B2 and B3 are equal to their current write operation addresses A2W and A3W.

步骤四:利用乒乓数据缓冲区B1的半满或全满信号产生中断信号。B1缓冲区的半满或全满信号显然与其写操作地址的值有关,假设B1缓冲区的数据宽度为1字节而存储深度为1KB,则B1缓冲区写操作地址A1W的地址范围为0至1023。显然,当写操作地址为511时B1缓冲区半满,而当写操作地址为1023时缓冲区全满。B1缓冲区半满或全满时都应该产生一个中断脉冲信号发给上位机。在图1中,由中断产生模块根据B1缓冲区的写操作地址A1W的大小是否等于511或1023来产生脉冲式的中断信号给上位机处理器。Step 4: Use the half-full or full-full signal of the ping-pong data buffer B1 to generate an interrupt signal. The half-full or full-full signal of the B1 buffer is obviously related to the value of its write operation address. Assuming that the data width of the B1 buffer is 1 byte and the storage depth is 1KB, the address range of the write operation address A1W of the B1 buffer is 0 to 1023. Obviously, the B1 buffer is half full when the address of the write operation is 511, and the buffer is full when the address of the write operation is 1023. When the B1 buffer is half full or full, an interrupt pulse signal should be generated and sent to the host computer. In Fig. 1, the interrupt generation module generates a pulse interrupt signal to the host computer processor according to whether the size of the write operation address A1W of the B1 buffer is equal to 511 or 1023.

步骤五:建立上位机与FPGA中各数据缓冲区B1,B2,B3间的总线接口模块,如图1中所示。总线接口模块用于将来自上位机的读操作指令中蕴含的读时钟C、读地址A和读使能E等信号转换为各个数据缓冲区及其写状态指针存储寄存器的读时钟C、读地址A1R、A2R、A3R、AR和读使能E1,E2,E3等信号以实现上位机对这些存储空间中可读数据的顺利读取。Step 5: Establish bus interface modules between the host computer and the data buffers B1, B2, and B3 in the FPGA, as shown in Figure 1. The bus interface module is used to convert the read clock C, read address A and read enable E contained in the read operation command from the host computer into the read clock C and read address of each data buffer and its write status pointer storage register. A1R, A2R, A3R, AR and read enable signals such as E1, E2, E3 to realize the smooth reading of readable data in these storage spaces by the host computer.

步骤六:创建上位机中断服务子程序,其流程图如图2所示。在中断到来的时刻,首先完成保护现场。其次,判断当前系统是否是刚执行了上电复位或其他形式的重置操作,若是,则执行历史写状态指针寄存器的初始化操作,否则跳过该初始化步骤。然后,系统先读取FPGA中的当前写状态指针存储寄存器值,再将中断服务子程序中保存的历史写状态指针寄存器值备份到临时变量中,以备后续上位机读操作使用。接着,系统更新历史写状态指针寄存器值,也即,将刚读取的FPGA当前写状态指针寄存器结果赋值给历史写状态指针寄存器以备下一次中断使用。接下来,上位机根据前面步骤中读取的当前写状态指针寄存器值和备份到临时变量中的历史写状态指针寄存器值计算产生本次中断的读操作地址A的范围,然后根据该地址范围执行读操作函数。数据读取完毕后,执行恢复现场操作,中断服务子程序结束退出,等待下一次中断的到来。Step 6: Create the host computer interrupt service subroutine, the flow chart of which is shown in Figure 2. At the moment of interruption, first complete the protection site. Secondly, it is judged whether the current system has just performed a power-on reset or other forms of reset operation, and if so, executes the initialization operation of the history writing state pointer register, otherwise skips the initialization step. Then, the system first reads the value of the current write status pointer storage register in the FPGA, and then backs up the historical write status pointer register value saved in the interrupt service subroutine to a temporary variable for subsequent host computer read operations. Then, the system updates the value of the historical write status pointer register, that is, assigns the result of the FPGA current write status pointer register just read to the historical write status pointer register for the next interrupt. Next, the host computer calculates the range of the read operation address A that generated this interrupt based on the current write status pointer register value read in the previous steps and the historical write status pointer register value backed up in the temporary variable, and then executes according to the address range Read operation function. After the data is read, execute the scene recovery operation, the interrupt service subroutine ends and exits, and waits for the arrival of the next interrupt.

步骤七:在周期性中断信号触发下,上位机反复执行步骤六中所述中断服务子程序即可完成多异步数据源的实时连续数据传输。Step 7: Triggered by periodic interrupt signals, the host computer repeatedly executes the interrupt service subroutine described in step 6 to complete real-time continuous data transmission of multiple asynchronous data sources.

Claims (1)

1.一种基于FPGA的单中断实时数据传输方法,其特征在于包括以下具体步骤:1. a single interruption real-time data transmission method based on FPGA, is characterized in that comprising following concrete steps: 步骤一:选择合适的中断周期Step 1: Choose an appropriate interrupt period 根据各异步数据源1,2,…,n的写数据速率Wk和上位机的读数据速率R,利用不丢失数据下实时连续数据传输条件不等式W1+W2+...+Wn<R,首先确认系统实现的可行性,在系统可实现的前提下,再依据FPGA硬件资源的大小及其他限制条件,选择合适的中断周期T1,因为各数据缓冲区的总字节数至少为(W1+W2+...+Wn)×T1×2;According to the write data rate Wk of each asynchronous data source 1, 2, ..., n and the read data rate R of the host computer, using the real-time continuous data transmission condition inequality W1+W2+...+Wn<R without data loss, first confirm Feasibility of system implementation, on the premise that the system can be realized, and then according to the size of FPGA hardware resources and other constraints, select the appropriate interrupt cycle T1, because the total number of bytes of each data buffer is at least (W1+W2+. ..+Wn)×T1×2; 步骤二:创建数据缓冲区Step 2: Create a data buffer 根据各异步数据源1,2,…,n的写数据速率Wk和中断周期T1,确定各个异步数据源的缓冲区存储量大小为Wk×T1×2,为这n个异步数据源建立n个数据缓冲区,并确定其中的某一个数据缓冲区为乒乓缓冲区,不妨假设选B1为乒乓缓冲区,其缓冲区分成上下半区B1L和B1H,具有半满和全满指示信号,而其它数据缓冲区则为普通数据缓冲区即可;According to the write data rate Wk and the interrupt period T1 of each asynchronous data source 1, 2,..., n, determine the buffer storage size of each asynchronous data source as Wk×T1×2, and establish n for these n asynchronous data sources data buffer, and determine that one of the data buffers is a ping-pong buffer. It may be assumed that B1 is selected as a ping-pong buffer. The buffer is an ordinary data buffer; 步骤三:创建各数据缓冲区的写状态指针寄存器Step 3: Create a write status pointer register for each data buffer 创建各数据缓冲区的写状态指针寄存器时,其中的乒乓缓冲区B1的写状态指针值为当前写操作地址最高位的值,其值可能为0或1,而其他数据缓冲区的写状态指针为当前写操作地址值;When creating the write status pointer registers of each data buffer, the write status pointer value of the ping-pong buffer B1 among them is the value of the highest bit of the current write operation address, which may be 0 or 1, while the write status pointers of other data buffers is the address value of the current write operation; 步骤四:产生周期性中断信号Step 4: Generate a periodic interrupt signal 依据乒乓缓冲区B1的写操作产生的缓冲区半满和全满信号产生与上位机相对应的周期性中断信号,该中断信号发送至上位机即可触发中断服务子程序,从而完成读取FPGA中各数据缓冲区数据操作;According to the buffer half-full and full-full signals generated by the write operation of the ping-pong buffer B1, a periodic interrupt signal corresponding to the host computer is generated, and the interrupt signal is sent to the host computer to trigger the interrupt service subroutine, thereby completing the read FPGA Data operation in each data buffer; 步骤五:建立上位机和FPGA中各数据缓冲区B1,B2,…,Bn之间的总线接口;Step five: establish the bus interface between the host computer and each data buffer B1, B2, ..., Bn in the FPGA; 将上位机的读操作指令中包含的读时钟C、读操作地址A及读使能信号转换为各数据缓冲区的读时钟C、读使能E1,E2,…,En和读地址A1R,A2R,…,AnR信号及各缓冲区的写状态指针寄存器的读地址信号AR,以读取上述存储空间中的数据;Convert the read clock C, read operation address A and read enable signal contained in the read operation instruction of the host computer to the read clock C, read enable E1, E2,..., En and read address A1R, A2R of each data buffer ,..., AnR signal and the read address signal AR of the write state pointer register of each buffer zone, to read the data in the above-mentioned storage space; 步骤六:创建上位机中断服务子程序Step 6: Create the host computer interrupt service subroutine 上位机中断服务子程序工作过程如下:上位机中断服务子程序接收到硬件中断信号后,先做是否要初始化的判断:如果系统是刚上电复位或其他形式重置之后,则将FPGA各缓冲区写地址和上位机的历史写指针寄存器值初始化为其相应的起始地址,否则跳过该初始化步骤,然后读取各数据缓冲区的当前写状态指针寄存器值,而上位机程序中保存有上一次中断时存储的各数据缓冲区的写状态指针寄存器值,不妨称为历史写状态指针寄存器值,中断服务子程序然后利用当前写状态指针和上位机保存的历史写状态指针的一个临时备份来完成读取FPGA中各数据缓冲区相应地址段的数据,并在历史写状态指针寄存器值备份之后和上位机读操作之前,把历史写状态指针寄存器值更新为当前写状态指针寄存器值,以保证下次中断时能够正确读取各缓冲区相应地址段的数据,上位机中断服务子程序执行读操作完毕后结束,进入等待下次中断状态;The working process of the interrupt service subroutine of the host computer is as follows: After the interrupt service subroutine of the host computer receives the hardware interrupt signal, it first makes a judgment whether to initialize: if the system has just been reset after power-on or other forms, then the FPGA buffer The area write address and the history write pointer register value of the host computer are initialized to their corresponding start addresses, otherwise the initialization step is skipped, and then the current write status pointer register value of each data buffer is read, and the host computer program saves the The write status pointer register value of each data buffer stored at the last interrupt may be called the historical write status pointer register value, and the interrupt service subroutine then uses the current write status pointer and a temporary backup of the historical write status pointer saved by the host computer To complete the reading of the data in the corresponding address segment of each data buffer in the FPGA, and after the historical write status pointer register value is backed up and before the upper computer read operation, the historical write status pointer register value is updated to the current write status pointer register value to Ensure that the data in the corresponding address segment of each buffer can be read correctly when the next interrupt is interrupted, and the interrupt service subroutine of the host computer ends after the read operation is completed, and enters the state of waiting for the next interrupt; 步骤七:上位机在周期性中断信号的触发下循环调用步骤六中所述中断服务子程序,即可达到实时连续数据传输目的。Step 7: Under the trigger of the periodic interrupt signal, the upper computer cyclically calls the interrupt service subroutine described in step 6, so as to achieve the purpose of real-time continuous data transmission.
CN201010547869XA 2010-11-17 2010-11-17 A Single Interrupt Real-time Data Transmission Method Based on FPGA Expired - Fee Related CN102004711B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201010547869XA CN102004711B (en) 2010-11-17 2010-11-17 A Single Interrupt Real-time Data Transmission Method Based on FPGA

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201010547869XA CN102004711B (en) 2010-11-17 2010-11-17 A Single Interrupt Real-time Data Transmission Method Based on FPGA

Publications (2)

Publication Number Publication Date
CN102004711A CN102004711A (en) 2011-04-06
CN102004711B true CN102004711B (en) 2012-02-29

Family

ID=43812083

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201010547869XA Expired - Fee Related CN102004711B (en) 2010-11-17 2010-11-17 A Single Interrupt Real-time Data Transmission Method Based on FPGA

Country Status (1)

Country Link
CN (1) CN102004711B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI460574B (en) * 2011-05-19 2014-11-11 Novatek Microelectronics Corp Method of calibrating signal skews in mipi and related transmission system
CN102426538B (en) * 2011-08-26 2014-05-28 深圳市迪威视讯股份有限公司 Interrupt response device and method thereof
CN103164361B (en) * 2011-12-08 2016-01-13 炬芯(珠海)科技有限公司 With the device of memory transfer data and the method transmitting data thereof
CN103049323A (en) * 2012-12-31 2013-04-17 西安奇维科技股份有限公司 Multi-interrupt balance management method implemented in FPGA (field programmable gate array)
CN103401807B (en) * 2013-06-27 2016-08-24 宇龙计算机通信科技(深圳)有限公司 USB data transmission method, device and mobile terminal
CN105912354B (en) * 2016-03-16 2019-06-21 昆山软龙格自动化技术有限公司 A kind of method for burn-recording of the quick I2C of CMOS chip
CN107368415A (en) * 2017-07-20 2017-11-21 成都雅骏新能源汽车科技股份有限公司 A kind of real-time stream debugging software component and its adjustment method
CN108268381B (en) * 2017-12-15 2021-12-24 中国航空工业集团公司西安飞行自动控制研究所 Method for safely realizing fast addressing of data
CN111026679A (en) * 2019-11-26 2020-04-17 中电科仪器仪表有限公司 Real-time downloading and playing device and method for massive random wave files
CN112559047B (en) * 2021-02-22 2021-05-14 南京沁恒微电子股份有限公司 A RISC-V based interrupt control system and method

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1289127A (en) * 2000-11-10 2001-03-28 清华大学 Digital reactor protecting system based on parallel hardware and software treatment
CN1466152A (en) * 2002-06-20 2004-01-07 深圳市中兴通讯股份有限公司 Method for effectively utilizing memory in site programmable gate array
CN1786932A (en) * 2004-12-12 2006-06-14 华为技术有限公司 Method for controlling operation of communicational interface

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8027749B2 (en) * 2007-06-19 2011-09-27 Omnicell, Inc. Handling of patient's own medicine systems, methods, and devices

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1289127A (en) * 2000-11-10 2001-03-28 清华大学 Digital reactor protecting system based on parallel hardware and software treatment
CN1466152A (en) * 2002-06-20 2004-01-07 深圳市中兴通讯股份有限公司 Method for effectively utilizing memory in site programmable gate array
CN1786932A (en) * 2004-12-12 2006-06-14 华为技术有限公司 Method for controlling operation of communicational interface

Also Published As

Publication number Publication date
CN102004711A (en) 2011-04-06

Similar Documents

Publication Publication Date Title
CN102004711B (en) A Single Interrupt Real-time Data Transmission Method Based on FPGA
CN101833424B (en) High-speed storage and transmission device based on FPGA
US7710969B2 (en) Rapid I/O traffic system
WO2021259041A1 (en) Ai computational graph sorting method and apparatus, device, and storage medium
WO2001093040A1 (en) Program counter trace system, program counter trace method, and semiconductor device
CN1983326A (en) Graphics processing unit pipeline multi-stage synchronous control processor and method thereof
US20080155353A1 (en) Data processing apparatus and method for reducing trace bandwidth
US12105655B2 (en) System and method for optimizing AHB bus data transmission performance and server
WO2015127796A1 (en) Data processing device and method for processing serial tasks
CN108170571B (en) Chip tracking debugging device and method
CN104765701B (en) Data access method and equipment
CN111831383A (en) Window splicing method, device, device and storage medium
JP7229305B2 (en) Apparatus, method, and processing apparatus for writing back instruction execution results
CN101625635A (en) Method, system and equipment for processing circular task
CN111625180B (en) Data writing method and device and storage medium
WO2008042584A2 (en) Apparatus and method for tracing instructions with simplified instruction state descriptors
US20060256877A1 (en) Rapid I/O Compliant Message Mapper
CN102411555A (en) A Scalable Dynamically Reconfigurable Array Configuration Information Method
US20060256878A1 (en) Out of Order Message Completion Management
US10416888B2 (en) Parallel processing device, method for controlling parallel processing device, and controller used in parallel processing device
CN106484640A (en) A kind of high speed serialization user interface circuit based on FPGA and DSP
US20060282719A1 (en) Unique Addressable Memory Data Path
US20230267169A1 (en) Sparse matrix dense vector multliplication circuitry
CN116366574A (en) Protocol conversion method based on double buffer areas
US20060268714A1 (en) Rapid I/O Compliant Congestion Control

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20120229

Termination date: 20131117