TWI844326B - Direct memory access (dma) circuit and operation method thereof - Google Patents

Direct memory access (dma) circuit and operation method thereof Download PDF

Info

Publication number
TWI844326B
TWI844326B TW112112707A TW112112707A TWI844326B TW I844326 B TWI844326 B TW I844326B TW 112112707 A TW112112707 A TW 112112707A TW 112112707 A TW112112707 A TW 112112707A TW I844326 B TWI844326 B TW I844326B
Authority
TW
Taiwan
Prior art keywords
read
data
buffer
circuit
write
Prior art date
Application number
TW112112707A
Other languages
Chinese (zh)
Inventor
王建之
朱煒
賀丙杰
劉健
林博
孫明勇
Original Assignee
大陸商星宸科技股份有限公司
Filing date
Publication date
Application filed by 大陸商星宸科技股份有限公司 filed Critical 大陸商星宸科技股份有限公司
Application granted granted Critical
Publication of TWI844326B publication Critical patent/TWI844326B/en

Links

Images

Abstract

A direct memory access (DMA) circuit and an operation method thereof are provided. The DMA circuit includes a buffer circuit, a first channel, and a second channel. The operation method includes: determining first and second start addresses from the buffer circuit respectively according to first and second read requests of the first and second channels that correspond to a first data and a second data, respectively; determining a read address according to the first start address and a read count value; reading a first part of the first data from the buffer circuit according to the read address and updating the read count value; reading at least a part of the second data from the buffer circuit according to the second start address after reading the first part of the first data; updating the read address according to the first start address and the updated read count value; and reading a second part of the first data from the buffer circuit according to the updated read address.

Description

直接記憶體存取電路及其操作方法Direct memory access circuit and operation method thereof

本發明是關於直接記憶體存取(Direct Memory Access,DMA),尤其是關於直接記憶體存取電路及其操作方法。 The present invention relates to direct memory access (DMA), and more particularly to a direct memory access circuit and an operating method thereof.

直接記憶體存取電路的資料來源端(例如記憶體)或資料目的地端(例如處理電路)的延時通常不是固定的,而且資料來源端與資料目的地端的讀寫速度也不一定是匹配的。此外,當資料來源端的個數或資料目的地端的個數大於一個時,多路之間的資料傳送可能會因為上述的延時而阻塞,造成直接記憶體存取電路的效能降低。 The delay of the data source end (such as memory) or the data destination end (such as processing circuit) of the direct memory access circuit is usually not fixed, and the read and write speeds of the data source end and the data destination end are not necessarily matched. In addition, when the number of data source ends or the number of data destination ends is greater than one, the data transmission between multiple channels may be blocked due to the above delay, resulting in reduced performance of the direct memory access circuit.

鑑於先前技術之不足,本發明之一目的在於提供一種直接記憶體存取電路與直接記憶體存取電路的操作方法,以改善先前技術的不足。 In view of the deficiencies of the prior art, one purpose of the present invention is to provide a direct memory access circuit and a method for operating the direct memory access circuit to improve the deficiencies of the prior art.

本發明之一實施例提供一種直接記憶體存取電路的操作方法。該直接記憶體存取電路包含一緩衝電路、一第一通道及一第二通道。該方法包含:根據該第一通道之一第一讀取請求,從該緩衝電路決定一第一起始地址,該第一讀取請求對應於一第一資料;根據該第二通道之一第二讀取請求,從該 緩衝電路決定一第二起始地址,該第二讀取請求對應於一第二資料;根據該第一起始地址及一第一讀計數值決定一讀取地址;根據該讀取地址從該緩衝電路讀取該第一資料的一第一部分,並且更新該第一讀計數值;於讀取該第一資料的該第一部分之後,根據該第二起始地址從該緩衝電路讀取該第二資料的至少一部分;根據該第一起始地址及更新後的該第一讀計數值更新該讀取地址;以及,根據該更新後的該讀取地址從該緩衝電路讀取該第一資料的一第二部分。 An embodiment of the present invention provides an operation method of a direct memory access circuit. The direct memory access circuit includes a buffer circuit, a first channel and a second channel. The method includes: determining a first starting address from the buffer circuit according to a first read request of the first channel, the first read request corresponding to a first data; determining a second starting address from the buffer circuit according to a second read request of the second channel, the second read request corresponding to a second data; determining a read address according to the first starting address and a first read count value; and determining a read address from the buffer circuit according to the read address. The circuit reads a first portion of the first data and updates the first read count value; after reading the first portion of the first data, reads at least a portion of the second data from the buffer circuit according to the second starting address; updates the read address according to the first starting address and the updated first read count value; and reads a second portion of the first data from the buffer circuit according to the updated read address.

本發明之另一實施例提供一種直接記憶體存取電路,包含:一緩衝電路、一第一通道、一第二通道、一寫狀態判斷電路、一讀地址生成電路及一控制電路。第一通道用來產生一第一讀取請求。第二通道用來產生一第二讀取請求。寫狀態判斷電路用來根據該第一讀取請求從該緩衝電路決定一第一起始地址,以及根據該第二讀取請求從該緩衝電路決定一第二起始地址,該第一讀取請求對應於一第一資料,該第二讀取請求對應於一第二資料。讀地址生成電路用來根據該第一起始地址及一第一讀計數值決定一讀取地址。控制電路用來根據該讀取地址從該緩衝電路讀取該第一資料的一第一部分、控制該讀地址生成電路更新該第一讀計數值,並且於讀取該第一資料的該第一部分之後,根據該第二起始地址從該緩衝電路讀取該第二資料的至少一部分。該讀地址生成電路更根據該第一起始地址及更新後的該第一讀計數值更新該讀取地址,以及該控制電路更根據該更新後的該讀取地址從該緩衝電路讀取該第一資料的一第二部分。 Another embodiment of the present invention provides a direct memory access circuit, comprising: a buffer circuit, a first channel, a second channel, a write state determination circuit, a read address generation circuit and a control circuit. The first channel is used to generate a first read request. The second channel is used to generate a second read request. The write state determination circuit is used to determine a first starting address from the buffer circuit according to the first read request, and to determine a second starting address from the buffer circuit according to the second read request, the first read request corresponds to a first data, and the second read request corresponds to a second data. The read address generation circuit is used to determine a read address according to the first starting address and a first read count value. The control circuit is used to read a first part of the first data from the buffer circuit according to the read address, control the read address generation circuit to update the first read count value, and after reading the first part of the first data, read at least a part of the second data from the buffer circuit according to the second start address. The read address generation circuit further updates the read address according to the first start address and the updated first read count value, and the control circuit further reads a second part of the first data from the buffer circuit according to the updated read address.

本發明之實施例所體現的技術手段可以改善先前技術之缺點的至少其中之一,因此本發明相較於先前技術可以提高直接記憶體存取電路的效能。 The technical means embodied in the embodiments of the present invention can improve at least one of the shortcomings of the prior art, so the present invention can improve the performance of the direct memory access circuit compared to the prior art.

有關本發明的特徵、實作與功效,茲配合圖式作實施例詳細說明如下。 The features, implementation and effects of the present invention are described in detail below with reference to the accompanying drawings.

100:直接記憶體存取電路 100: Direct memory access circuit

110:寫狀態判斷電路 110: Write status judgment circuit

120:寫地址生成電路 120: Write address generation circuit

130:讀地址生成電路 130: Read address generation circuit

140:控制電路 140: Control circuit

150:緩衝電路 150: Buffer circuit

160,170:通道 160,170: Channel

162,172:暫存器 162,172: register

122,124:寫計數器 122,124: Write counter

132,134:讀計數器 132,134: Read counter

buff_sec0~buff_sec31:緩衝段 buff_sec0~buff_sec31: buffer segment

buff0~buff127:緩衝區塊 buff0~buff127: buffer block

210:緩衝段狀態表 210: Buffer status table

wr_flg:寫狀態標誌位 wr_flg: write status flag

rd_flg:讀狀態標誌位 rd_flg: read status flag

220:寫狀態表 220: Write status table

Req,Req0,Req1:讀取請求 Req, Req0, Req1: Read request

addr_start,Sa0,Sa1:起始地址 addr_start, Sa0, Sa1: starting address

wr_cnt,wr_cnt0,wr_cnt1:寫計數值 wr_cnt,wr_cnt0,wr_cnt1: write count value

230:讀狀態表 230: Read status table

Ln,Ln0,Ln1:資料長度 Ln, Ln0, Ln1: data length

rd_cnt,rd_cnt0,rd_cnt1:讀計數值 rd_cnt,rd_cnt0,rd_cnt1: read count value

Axi_ID,ID0,ID1:Axi識別碼 Axi_ID, ID0, ID1: Axi identification code

ptr0,ptr1:指標 ptr0,ptr1:pointer

Din:資料 Din: Data

wr_addr:寫入地址 wr_addr: write address

wr_data:待寫入資料 wr_data: data to be written

rd_cmd0,rd_cmd1:讀取命令 rd_cmd0,rd_cmd1: read command

rd_cmd:目標讀取命令 rd_cmd: target read command

rd_addr:目標讀取地址 rd_addr: target read address

310,S315,S320,S330,S340,S350,S360,S370,S380,S390,S510,S520,S530,S540,S550,S560,S910,S915,S920,S925,S930,S935,S940,S945,S950,S960,S1810,S1820,S1830,S1840,S1850,S1855,S1860,S1870:步驟 310,S315,S320,S330,S340,S350,S360,S370,S380,S390,S510,S520,S530,S540,S550,S560,S910,S915,S920,S925,S930,S935,S940,S945,S950,S960,S1810,S1820,S1830,S1840,S1850,S1855,S1860,S1870: Steps

圖1是本發明直接記憶體存取電路之一實施例的功能方塊圖;圖2、圖4、圖6~圖8、圖10~圖17及圖20顯示緩衝電路的內容以及直接記憶體存取電路的一些控制值;圖3是回應於讀取請求來配置緩衝電路之一實施例的流程圖;圖5是寫地址生成電路將資料寫入緩衝電路的流程圖;圖9是控制電路從緩衝電路讀取資料的流程圖;以及圖18~圖19是本發明直接記憶體存取電路的操作方法之一實施例的流程圖。 FIG1 is a functional block diagram of an embodiment of the direct memory access circuit of the present invention; FIG2, FIG4, FIG6~FIG8, FIG10~FIG17 and FIG20 show the contents of the buffer circuit and some control values of the direct memory access circuit; FIG3 is a flow chart of an embodiment of configuring the buffer circuit in response to a read request; FIG5 is a flow chart of a write address generation circuit writing data into the buffer circuit; FIG9 is a flow chart of a control circuit reading data from the buffer circuit; and FIG18~FIG19 are flow charts of an embodiment of an operation method of the direct memory access circuit of the present invention.

以下說明內容之技術用語係參照本技術領域之習慣用語,如本說明書對部分用語有加以說明或定義,該部分用語之解釋係以本說明書之說明或定義為準。 The technical terms used in the following descriptions refer to the customary terms in this technical field. If this manual explains or defines some of the terms, the interpretation of those terms shall be based on the explanation or definition in this manual.

本發明之揭露內容包含直接記憶體存取電路及其操作方法。由於本發明之直接記憶體存取電路所包含之部分元件單獨而言可能為已知元件,因此在不影響該裝置發明之充分揭露及可實施性的前提下,以下說明對於已知元件的細節將予以節略。此外,本發明之直接記憶體存取電路的操作方法的部分或全部流程可以是軟體及/或韌體之形式,並且可藉由本發明之直接記憶體存取電路或其等效裝置來執行,在不影響該方法發明之充分揭露及可實施性的前 提下,以下方法發明之說明將著重於步驟內容而非硬體。 The disclosure of the present invention includes a direct memory access circuit and an operating method thereof. Since some components included in the direct memory access circuit of the present invention may be known components individually, the following description will omit the details of the known components without affecting the full disclosure and feasibility of the device invention. In addition, part or all of the process of the operating method of the direct memory access circuit of the present invention may be in the form of software and/or firmware, and may be executed by the direct memory access circuit of the present invention or its equivalent device. Without affecting the full disclosure and feasibility of the method invention, the following description of the method invention will focus on the step content rather than the hardware.

圖1是本發明直接記憶體存取電路100之一實施例的功能方塊圖。直接記憶體存取電路100包含寫狀態判斷電路110、寫地址生成電路120、讀地址生成電路130、控制電路140及緩衝電路150。寫狀態判斷電路110包含多個通道(包含但不限於通道160及通道170)及多個對應於該些通道的暫存器(包含但不限於分別對應於通道160及通道170的暫存器162及暫存器172)。寫地址生成電路120包含多個寫計數器(包含但不限於寫計數器122及寫計數器124)。讀地址生成電路130包含多個讀計數器(包含但不限於讀計數器132及讀計數器134)。 FIG1 is a functional block diagram of an embodiment of a direct memory access circuit 100 of the present invention. The direct memory access circuit 100 includes a write state determination circuit 110, a write address generation circuit 120, a read address generation circuit 130, a control circuit 140, and a buffer circuit 150. The write state determination circuit 110 includes a plurality of channels (including but not limited to channels 160 and 170) and a plurality of registers corresponding to the channels (including but not limited to registers 162 and 172 corresponding to channels 160 and 170, respectively). The write address generation circuit 120 includes a plurality of write counters (including but not limited to write counter 122 and write counter 124). The read address generation circuit 130 includes a plurality of read counters (including but not limited to the read counter 132 and the read counter 134).

圖2顯示緩衝電路150的細節以及直接記憶體存取電路100的一些控制值。緩衝電路150包含N個緩衝段buff_sec(在圖2的例子中N=32(buff_sec0~buff_sec31)),一個緩衝段buff_sec包含X個緩衝區塊(在圖2的例子中X=4)(換言之,X為緩衝段buff_sec的粒度(granularity));因此,緩衝電路150總共有N*X個緩衝區塊(buff0~buff127)。 FIG2 shows the details of the buffer circuit 150 and some control values of the direct memory access circuit 100. The buffer circuit 150 includes N buffer segments buff_sec (in the example of FIG2, N=32 (buff_sec0~buff_sec31)), and one buffer segment buff_sec includes X buffer blocks (in the example of FIG2, X=4) (in other words, X is the granularity of the buffer segment buff_sec); therefore, the buffer circuit 150 has a total of N*X buffer blocks (buff0~buff127).

當X等於1時,一個緩衝段buff_sec等效於一個緩衝區塊buff。 When X is equal to 1, one buffer buff_sec is equivalent to one buffer chunk buff.

緩衝段狀態表210記錄每個緩衝段buff_sec的寫狀態標誌位wr_flg及讀狀態標誌位rd_flg。寫狀態表220記錄每個讀取請求Req的相對應的Axi識別碼Axi_ID、起始地址addr_start及寫計數值wr_cnt。Axi識別碼Axi_ID也可用作通道編號。讀狀態表230記錄每個通道的起始地址addr_start、資料長度Ln及讀計數值rd_cnt。寫狀態表220的起始地址Sa0及起始地址Sa1是由寫狀態判斷電路110決定,並且可以儲存在寫狀態判斷電路 110中(例如,分別儲存於暫存器162與暫存器172中)。寫狀態表220的寫計數值wr_cnt0及寫計數值wr_cnt1分別是寫計數器122及寫計數器124的計數值。讀狀態表230的讀計數值rd_cnt0及讀計數值rd_cnt1分別是讀計數器132及讀計數器134的計數值。資料長度Ln0及資料長度Ln1可以分別儲存在暫存器162與暫存器172中。 The buffer status table 210 records the write status flag wr_flg and the read status flag rd_flg of each buffer buff_sec. The write status table 220 records the corresponding Axi identification code Axi_ID, the start address addr_start and the write count value wr_cnt of each read request Req. The Axi identification code Axi_ID can also be used as a channel number. The read status table 230 records the start address addr_start, the data length Ln and the read count value rd_cnt of each channel. The start address Sa0 and the start address Sa1 of the write status table 220 are determined by the write status judgment circuit 110 and can be stored in the write status judgment circuit 110 (for example, stored in the register 162 and the register 172 respectively). The write count value wr_cnt0 and the write count value wr_cnt1 of the write status table 220 are the count values of the write counter 122 and the write counter 124 respectively. The read count value rd_cnt0 and the read count value rd_cnt1 of the read status table 230 are the count values of the read counter 132 and the read counter 134 respectively. The data length Ln0 and the data length Ln1 can be stored in the register 162 and the register 172 respectively.

圖3是回應於讀取請求Req來配置緩衝電路150之一實施例的流程圖,包含以下步驟。 FIG3 is a flow chart of an embodiment of configuring the buffer circuit 150 in response to a read request Req, including the following steps.

步驟S310:通道160發出讀取請求Req0(對應於資料長度為Ln0的第一資料)。 Step S310: Channel 160 issues a read request Req0 (corresponding to the first data with a data length of Ln0).

步驟S315:通道170發出讀取請求Req1(對應於資料長度為Ln1的第二資料)。 Step S315: Channel 170 issues a read request Req1 (corresponding to the second data with a data length of Ln1).

舉例來說,讀取請求Req0及讀取請求Req1可以是從一個目標裝置(例如,直接記憶體存取電路100所在之電子裝置(例如一個晶片)的外部記憶體(例如雙倍資料率(Double Data Rate,DDR)記憶體))讀取資料的讀取請求。在一些實施例中,讀取請求Req0及讀取請求Req1對應到不同的目標裝置。 For example, the read request Req0 and the read request Req1 may be read requests for reading data from a target device (e.g., an external memory (e.g., a double data rate (DDR) memory) of an electronic device (e.g., a chip) in which the direct memory access circuit 100 is located). In some embodiments, the read request Req0 and the read request Req1 correspond to different target devices.

步驟S320:寫狀態判斷電路110仲裁(arbitrate)產生一目標讀取請求。寫狀態判斷電路110可以包含仲裁器(arbitrator)(圖未示),用來根據預先決定的仲裁規則(例如,循環制(round-robin))從讀取請求Req0與讀取請求Req1之間仲裁產生目標讀取請求。 Step S320: The write state determination circuit 110 arbitrates to generate a target read request. The write state determination circuit 110 may include an arbitrator (not shown) for arbitrating between the read request Req0 and the read request Req1 to generate a target read request according to a predetermined arbitration rule (e.g., round-robin).

步驟S330:寫狀態判斷電路110判斷緩衝電路150是否有足夠未被使用的空間(例如緩衝區塊)。更明確地說,寫狀態判斷電路110根據緩 衝段的寫狀態標誌位wr_flg、待處理的資料量(即,第一資料的資料長度Ln0或第二資料的資料長度Ln1)及粒度X從緩衝電路150找出

Figure 112112707-A0305-02-0008-1
個未被使用的緩衝段。在一些實施例中,粒度X可以是2的冪次方(即,X=1,2,4,8,...)。以圖2為例(X=4),假設Ln=6(即,需要
Figure 112112707-A0305-02-0008-2
個緩衝段buff_sec),因為至少有5個緩衝段buff_sec(緩衝段buff_sec0、緩衝段buff_sec1、緩衝段buff_sec2、緩衝段buff_sec3及緩衝段buff_sec31)的寫狀態標誌位wr_flg皆為第一數值(例如1,代表未被使用),所以步驟S330的判斷結果為是。 Step S330: The write status determination circuit 110 determines whether the buffer circuit 150 has sufficient unused space (e.g., buffer block). More specifically, the write status determination circuit 110 finds out the buffer circuit 150 based on the write status flag wr_flg of the buffer segment, the amount of data to be processed (i.e., the data length Ln0 of the first data or the data length Ln1 of the second data) and the granularity X.
Figure 112112707-A0305-02-0008-1
unused buffers. In some embodiments, the granularity X may be a power of 2 (i.e., X=1, 2, 4, 8, ...). Taking FIG. 2 as an example (X=4), assuming Ln=6 (i.e.,
Figure 112112707-A0305-02-0008-2
Buffers buff_sec), because the write status flags wr_flg of at least five buffers buff_sec (buffer buff_sec0, buffer buff_sec1, buffer buff_sec2, buffer buff_sec3, and buffer buff_sec31) are all the first value (for example, 1, representing that they are not used), the determination result of step S330 is yes.

當步驟S330的判斷結果為是,寫狀態判斷電路110更從直接記憶體存取電路100的空閒的Axi識別碼Axi_ID中選取其中之一。在以下的討論中,假設寫狀態判斷電路110將Axi識別碼ID0指定給通道160(即,通道160的編號為ID0),以及將Axi識別碼ID1指定給通道170(即,通道170的編號為ID1)。 When the judgment result of step S330 is yes, the write status judgment circuit 110 further selects one of the idle Axi identification codes Axi_ID of the direct memory access circuit 100. In the following discussion, it is assumed that the write status judgment circuit 110 assigns the Axi identification code ID0 to the channel 160 (i.e., the channel 160 is numbered as ID0), and assigns the Axi identification code ID1 to the channel 170 (i.e., the channel 170 is numbered as ID1).

在一些實施例中,分配給一個讀取請求Req的多個緩衝段buff_sec或多個緩衝區塊必須是連續的。 In some embodiments, multiple buffer segments buff_sec or multiple buffer blocks allocated to a read request Req must be contiguous.

步驟S340:寫狀態判斷電路110判斷目標讀取請求是讀取請求Req0或讀取請求Req1。如果是判斷目標讀取請求是讀取請求Req0,則執行步驟S350。如果是判斷目標讀取請求是讀取請求Req1,則執行步驟S360。 Step S340: The write status judgment circuit 110 judges whether the target read request is a read request Req0 or a read request Req1. If the target read request is judged to be a read request Req0, step S350 is executed. If the target read request is judged to be a read request Req1, step S360 is executed.

步驟S350:寫狀態判斷電路110判斷通道160的暫存器162是否已滿。如果是,則寫狀態判斷電路110回到步驟S320以仲裁產生另一個目標讀取請求;如果否,則寫狀態判斷電路110執行步驟S370及步驟S390。 Step S350: The write status determination circuit 110 determines whether the register 162 of the channel 160 is full. If yes, the write status determination circuit 110 returns to step S320 to arbitrate and generate another target read request; if not, the write status determination circuit 110 executes steps S370 and S390.

步驟S360:寫狀態判斷電路110判斷通道170的暫存器172是 否已滿。如果是,則寫狀態判斷電路110回到步驟S320以仲裁產生另一目標讀取請求;如果否,則寫狀態判斷電路110執行步驟S380及步驟S390。 Step S360: The write status determination circuit 110 determines whether the register 172 of the channel 170 is full. If yes, the write status determination circuit 110 returns to step S320 to arbitrate and generate another target read request; if no, the write status determination circuit 110 executes steps S380 and S390.

步驟S370:寫狀態判斷電路110更新寫狀態標誌位wr_flg,並且將已決定之緩衝段buff_sec的起始地址addr_start及讀取請求Req0的資料長度Ln0寫入通道160的暫存器162。請參閱圖2,假設Ln=Ln0=6而且寫狀態判斷電路110將緩衝段buff_sec0及緩衝段buff_sec1指定給通道160,則寫狀態判斷電路110將緩衝段buff_sec0及緩衝段buff_sec1的寫狀態標誌位wr_flg更新為第二數值(例如0,代表已被使用),並且將資料長度Ln0及緩衝段buff_sec0的起始地址addr_start(以下稱為起始地址Sa0)寫入暫存器162。 Step S370: The write status determination circuit 110 updates the write status flag wr_flg, and writes the determined start address addr_start of the buffer segment buff_sec and the data length Ln0 of the read request Req0 into the register 162 of the channel 160. Please refer to FIG. 2. Assuming that Ln=Ln0=6 and the write status determination circuit 110 assigns the buffer segments buff_sec0 and buff_sec1 to the channel 160, the write status determination circuit 110 updates the write status flag wr_flg of the buffer segments buff_sec0 and buff_sec1 to a second value (e.g., 0, indicating that they have been used), and writes the data length Ln0 and the starting address addr_start of the buffer segment buff_sec0 (hereinafter referred to as the starting address Sa0) into the register 162.

步驟S380:寫狀態判斷電路110更新寫狀態標誌位wr_flg,並且將已決定之緩衝段buff_sec的起始地址addr_start及讀取請求Req1的資料長度Ln1寫入通道170的暫存器172。請參閱圖2,假設Ln=Ln1=5而且寫狀態判斷電路110將緩衝段buff_sec2及緩衝段buff_sec3指定給通道170,則寫狀態判斷電路110將緩衝段buff_sec2及緩衝段buff_sec3的寫狀態標誌位wr_flg更新為第二數值,並且將資料長度Ln1及緩衝段buff_sec2的起始地址addr_start(以下稱為起始地址Sa1)寫入暫存器172。 Step S380: The write status determination circuit 110 updates the write status flag wr_flg, and writes the determined start address addr_start of the buffer segment buff_sec and the data length Ln1 of the read request Req1 into the register 172 of the channel 170. Please refer to FIG. 2. Assuming that Ln=Ln1=5 and the write status determination circuit 110 assigns the buffer segments buff_sec2 and buff_sec3 to the channel 170, the write status determination circuit 110 updates the write status flag wr_flg of the buffer segments buff_sec2 and buff_sec3 to the second value, and writes the data length Ln1 and the starting address addr_start of the buffer segment buff_sec2 (hereinafter referred to as the starting address Sa1) into the register 172.

步驟S390:寫狀態判斷電路110設定目標讀取請求與通道(通道160或通道170)之通道編號(ID0或ID1)之間的關聯性(correspondence)(如寫狀態表220所示),以便於確認資料與通道之間的關聯性。更明確地說,如果步驟S350為否,則寫狀態判斷電路110將讀取請求Req0與Axi識別碼ID0設定為互相關聯。如果步驟S360為否,則寫狀態判斷電路110將讀取請求Req1與Axi識別碼ID1設定為互相關聯。 Step S390: The write status determination circuit 110 sets the correspondence between the target read request and the channel number (ID0 or ID1) of the channel (channel 160 or channel 170) (as shown in the write status table 220) to confirm the correlation between the data and the channel. More specifically, if step S350 is no, the write status determination circuit 110 sets the read request Req0 and the Axi identification code ID0 to be mutually correlated. If step S360 is no, the write status determination circuit 110 sets the read request Req1 and the Axi identification code ID1 to be mutually correlated.

承上例,圖3的流程結束後,緩衝電路150、緩衝段狀態表210、寫狀態表220及讀狀態表230的內容如圖4所示。因為尚未有資料被寫入及讀出緩衝電路150,所以寫計數值wr_cnt0、寫計數值wr_cnt1、讀計數值rd_cnt0、讀計數值rd_cnt1及讀狀態標誌位rd_flg的值皆為0。讀狀態標誌位rd_flg用來記錄相對應的緩衝段buff_sec中未被讀取的資料的筆數。以圖4為例,如果一個緩衝段buff_sec的4個緩衝區塊皆有資料但只有其中3個尚未被讀取,則對應於該緩衝段buff_sec的讀狀態標誌位rd_flg為3。在一些實施例中,讀狀態標誌位rd_flg位元數可以是log2 X+1。指標ptr0對應讀取請求Req0及通道160(ID0)。指標ptr1對應讀取請求Req1及通道170(ID1)。指標ptr0及指標ptr1用來指示讀取操作或寫入操作的地址,將於下方詳述。 Continuing with the above example, after the process of FIG. 3 is completed, the contents of the buffer circuit 150, the buffer segment status table 210, the write status table 220 and the read status table 230 are shown in FIG. 4. Because no data has been written into or read from the buffer circuit 150, the values of the write count value wr_cnt0, the write count value wr_cnt1, the read count value rd_cnt0, the read count value rd_cnt1 and the read status flag bit rd_flg are all 0. The read status flag bit rd_flg is used to record the number of unread data in the corresponding buffer segment buff_sec. Taking FIG. 4 as an example, if all four buffer blocks of a buffer segment buff_sec have data but only three of them have not been read, the read status flag bit rd_flg corresponding to the buffer segment buff_sec is 3. In some embodiments, the number of bits of the read status flag bit rd_flg can be log 2 X +1. Pointer ptr0 corresponds to the read request Req0 and channel 160 (ID0). Pointer ptr1 corresponds to the read request Req1 and channel 170 (ID1). Pointer ptr0 and pointer ptr1 are used to indicate the address of the read operation or the write operation, which will be described in detail below.

在一些實施例中,可以使用緩衝段buff_sec的編號作為起始地址(例如,Sa0=0,Sa1=2)。在後續的操作中,直接記憶體存取電路100藉由將起始地址Sa0及起始地址Sa1左移log2 X個位元來得到相對應的緩衝區塊編號(例如,Sa0=0對應到緩衝區塊buff0,Sa1=2對應到緩衝區塊buff8)。相較於儲存緩衝區塊的編號,儲存緩衝段buff_sec的編號可以節省記憶體。 In some embodiments, the number of the buffer segment buff_sec may be used as the starting address (e.g., Sa0=0, Sa1=2). In subsequent operations, the direct memory access circuit 100 obtains the corresponding buffer block number (e.g., Sa0=0 corresponds to buffer block buff0, Sa1=2 corresponds to buffer block buff8) by shifting the starting address Sa0 and the starting address Sa1 left by log 2 X bits. Compared to storing the number of the buffer block, storing the number of the buffer segment buff_sec can save memory.

請參閱圖5,圖5是寫地址生成電路120將資料Din寫入緩衝電路150的流程圖,包含以下步驟。 Please refer to FIG. 5, which is a flow chart of the write address generation circuit 120 writing the data Din into the buffer circuit 150, including the following steps.

步驟S510:寫地址生成電路120從目標裝置取得資料Din,即,根據讀取請求Req0或讀取請求Req1從目標裝置讀取相對應的第一資料或第二資料。 Step S510: The write address generation circuit 120 obtains data Din from the target device, that is, reads the corresponding first data or second data from the target device according to the read request Req0 or the read request Req1.

步驟S520:寫地址生成電路120判斷此次的寫入操作是否為第一次的叢發寫入(burst write),即,判斷是否第一次將對應於某個讀取請求 Req的資料寫入緩衝電路150。如果是,則執行步驟S530;如果否,則執行步驟S540。 Step S520: The write address generation circuit 120 determines whether the current write operation is the first burst write, that is, whether the data corresponding to a read request Req is written into the buffer circuit 150 for the first time. If yes, execute step S530; if not, execute step S540.

步驟S530:寫地址生成電路120重置寫計數值wr_cnt(例如,將寫計數值wr_cnt設定為0)。更明確地說,寫地址生成電路120根據資料Din是屬於讀取請求Req0或讀取請求Req1來從寫狀態表220中取得相對應的寫計數值wr_cnt,並且重置該相對應的寫計數值wr_cnt。 Step S530: The write address generation circuit 120 resets the write count value wr_cnt (for example, sets the write count value wr_cnt to 0). More specifically, the write address generation circuit 120 obtains the corresponding write count value wr_cnt from the write status table 220 according to whether the data Din belongs to the read request Req0 or the read request Req1, and resets the corresponding write count value wr_cnt.

步驟S540:根據起始地址addr_start及寫計數值wr_cnt決定寫入地址wr_addr。更明確地說,寫入地址wr_addr等於起始地址addr_start加上寫計數值wr_cnt。 Step S540: Determine the write address wr_addr according to the start address addr_start and the write count value wr_cnt. More specifically, the write address wr_addr is equal to the start address addr_start plus the write count value wr_cnt.

步驟S550:寫地址生成電路120把待寫入資料wr_data(即,資料Din或資料Din的一部分)寫入緩衝電路150的寫入地址wr_addr,並且控制讀地址生成電路130更新相對應的讀狀態標誌位rd_flg。更明確地說,讀地址生成電路130根據寫入地址wr_addr更新對應於該寫入地址wr_addr的讀狀態標誌位rd_flg。舉例來說,如果寫入地址wr_addr對應於緩衝段buff_sec1(即,寫入地址wr_addr為緩衝區塊buff4~緩衝區塊buff7的其中之一),則讀地址生成電路130將緩衝段buff_sec1的讀狀態標誌位rd_flg更新為1。 Step S550: The write address generation circuit 120 writes the data to be written wr_data (i.e., data Din or a part of data Din) into the write address wr_addr of the buffer circuit 150, and controls the read address generation circuit 130 to update the corresponding read status flag rd_flg. More specifically, the read address generation circuit 130 updates the read status flag rd_flg corresponding to the write address wr_addr according to the write address wr_addr. For example, if the write address wr_addr corresponds to the buffer segment buff_sec1 (i.e., the write address wr_addr is one of the buffer blocks buff4 to buff7), the read address generation circuit 130 updates the read status flag bit rd_flg of the buffer segment buff_sec1 to 1.

步驟S560:寫地址生成電路120更新寫計數值wr_cnt,即,將寫計數值wr_cnt0或寫計數值wr_cnt1加1。 Step S560: The write address generation circuit 120 updates the write count value wr_cnt, that is, adds 1 to the write count value wr_cnt0 or the write count value wr_cnt1.

請參閱圖6~圖8,圖6~圖8顯示緩衝電路150、緩衝段狀態表210、寫狀態表220及讀狀態表230根據圖5之流程的一個例子。 Please refer to Figures 6 to 8, which show an example of the buffer circuit 150, the buffer segment status table 210, the write status table 220 and the read status table 230 according to the process of Figure 5.

圖6(接續圖4)顯示寫地址生成電路120將對應於讀取請求Req0的第1筆資料寫入緩衝區塊buff0(相當於執行一次圖5之流程)。因為 此時緩衝段buff_sec0已寫入1筆資料,所以緩衝段buff_sec0的讀狀態標誌位rd_flg的值為1(步驟S550),而且寫計數值wr_cnt0為1(步驟S560)。 FIG6 (continued from FIG4) shows that the write address generation circuit 120 writes the first data corresponding to the read request Req0 into the buffer block buff0 (equivalent to executing the process of FIG5 once). Because at this time, the buffer segment buff_sec0 has written one data, so the value of the read status flag bit rd_flg of the buffer segment buff_sec0 is 1 (step S550), and the write count value wr_cnt0 is 1 (step S560).

圖7(接續圖6)是寫地址生成電路120將對應於讀取請求Req1的第1筆資料寫入緩衝區塊buff8。因為此時緩衝區塊buff8已寫入1筆資料,所以緩衝段buff_sec2的讀狀態標誌位rd_flg的值為1(步驟S550),而且寫計數值wr_cnt1為1(步驟S560)。 FIG7 (continued from FIG6) shows that the write address generation circuit 120 writes the first data corresponding to the read request Req1 into the buffer block buff8. Because one data has been written into the buffer block buff8 at this time, the value of the read status flag bit rd_flg of the buffer segment buff_sec2 is 1 (step S550), and the write count value wr_cnt1 is 1 (step S560).

圖8(接續圖7)是寫地址生成電路120將對應於讀取請求Req1的第2~5筆資料寫入緩衝區塊buff9至緩衝區塊buff12(相當於連續執行圖5之流程4次)。因為此時緩衝段buff_sec2已寫入4筆資料且緩衝區塊buff12已寫入1筆資料,所以緩衝段buff_sec2的讀狀態標誌位rd_flg的值為4、緩衝段buff_sec3的讀狀態標誌位rd_flg的值為1,而且寫計數值wr_cnt1為5。 FIG8 (following FIG7) shows that the write address generation circuit 120 writes the 2nd to 5th data corresponding to the read request Req1 into the buffer blocks buff9 to buff12 (equivalent to executing the process of FIG5 4 times in a row). Because at this time, 4 data have been written into the buffer segment buff_sec2 and 1 data has been written into the buffer segment buff12, the value of the read status flag bit rd_flg of the buffer segment buff_sec2 is 4, the value of the read status flag bit rd_flg of the buffer segment buff_sec3 is 1, and the write count value wr_cnt1 is 5.

圖6~圖8顯示直接記憶體存取電路100可以以亂序的方式處理讀取請求Req0及讀取請求Req1,因為寫地址生成電路120並非處理完全部的第一資料後再處理第二資料。 FIG6 to FIG8 show that the direct memory access circuit 100 can process the read request Req0 and the read request Req1 in a disordered manner, because the write address generation circuit 120 does not process all the first data before processing the second data.

圖9是控制電路140從緩衝電路150讀取資料的流程圖,包含以下步驟。 FIG9 is a flow chart of the control circuit 140 reading data from the buffer circuit 150, including the following steps.

步驟S910:讀地址生成電路130根據通道160的起始地址Sa0取得通道160的讀計數值rd_cnt0。 Step S910: The read address generation circuit 130 obtains the read count value rd_cnt0 of the channel 160 according to the starting address Sa0 of the channel 160.

步驟S920:讀地址生成電路130根據起始地址Sa0及讀計數值rd_cnt0決定讀取地址,並且決定對應於該讀取地址的目標緩衝段。請參閱圖10(接續圖8),此時對應於通道160的讀取地址為Sa0+rd_cnt0=0+0=0(即,指標ptr0所指的地址),而對應於指標ptr0的目標緩衝段為

Figure 112112707-A0305-02-0012-4
(0為讀取 地址,4為前述的粒度X)。 Step S920: The read address generation circuit 130 determines the read address according to the start address Sa0 and the read count value rd_cnt0, and determines the target buffer corresponding to the read address. Please refer to FIG. 10 (continued from FIG. 8), at this time, the read address corresponding to the channel 160 is Sa0+rd_cnt0=0+0=0 (i.e., the address pointed to by the pointer ptr0), and the target buffer corresponding to the pointer ptr0 is
Figure 112112707-A0305-02-0012-4
(0 is the read address, 4 is the aforementioned granularity X).

步驟S930:讀地址生成電路130判斷目標緩衝段的讀狀態標誌位rd_flg是否大於0。如果是(代表目標緩衝段中有尚未被讀取的資料),則執行步驟S940;如果否,則重複步驟S910~步驟S930,直到目標緩衝段中有尚未被讀取的資料。在圖10的例子中,因為目標緩衝段(即,緩衝段buff_sec0)的讀狀態標誌位rd_flg為1,所以步驟S930的判斷結果為是。 Step S930: The read address generation circuit 130 determines whether the read status flag bit rd_flg of the target buffer is greater than 0. If yes (indicating that there is unread data in the target buffer), step S940 is executed; if no, steps S910 to S930 are repeated until there is unread data in the target buffer. In the example of FIG10 , because the read status flag bit rd_flg of the target buffer (i.e., buffer buff_sec0) is 1, the judgment result of step S930 is yes.

步驟S940:讀地址生成電路130產生讀取命令rd_cmd0,以讀取目標緩衝段buff_sec0中的資料。 Step S940: The read address generation circuit 130 generates a read command rd_cmd0 to read the data in the target buffer buff_sec0.

步驟S915~步驟S945是對應於第二通道的操作,且內容分別與步驟S910~步驟S940相似或相同。以圖10的例子來說,通道170的讀取地址為Sa1+rd_cnt1=8+0=8(即,指標ptr1所指的地址),而目標緩衝段為

Figure 112112707-A0305-02-0013-5
。因為目標緩衝段(即,緩衝段buff_sec2)的讀狀態標誌位rd_flg為4,所以步驟S935的判斷結果為是,且讀地址生成電路130產生讀取命令rd_cmd1以讀取目標緩衝段buff_sec2中的資料(步驟S945)。 Steps S915 to S945 correspond to the operation of the second channel, and the contents are similar or identical to steps S910 to S940. For example, in FIG. 10 , the read address of channel 170 is Sa1+rd_cnt1=8+0=8 (i.e., the address pointed to by pointer ptr1), and the target buffer is
Figure 112112707-A0305-02-0013-5
Since the read status flag rd_flg of the target buffer (ie, buffer buff_sec2) is 4, the determination result of step S935 is yes, and the read address generation circuit 130 generates a read command rd_cmd1 to read the data in the target buffer buff_sec2 (step S945).

步驟S950:控制電路140根據預先決定的仲裁規則(例如,循環制)在讀取命令rd_cmd0與讀取命令rd_cmd1之間仲裁產生目標讀取命令rd_cmd。承上例,如果目標讀取命令rd_cmd是讀取命令rd_cmd0(rd_cmd1),則目標讀取地址rd_addr是指標ptr0(ptr1)所指的地址。 Step S950: The control circuit 140 arbitrates between the read command rd_cmd0 and the read command rd_cmd1 according to a predetermined arbitration rule (e.g., a round-robin system) to generate a target read command rd_cmd. Continuing with the above example, if the target read command rd_cmd is the read command rd_cmd0 (rd_cmd1), the target read address rd_addr is the address pointed to by the pointer ptr0 (ptr1).

步驟S960:控制電路140發出目標讀取命令rd_cmd以從緩衝電路150讀取資料,並且控制讀地址生成電路130更新相對應的讀計數值rd_cnt及讀狀態標誌位rd_flg(等效於讀地址生成電路130更新相對應的讀計數值rd_cnt及根據目標讀取地址rd_addr更新讀狀態標誌位rd_flg)。請參閱圖11 (接續圖10),假設目標讀取命令rd_cmd是讀取命令rd_cmd0,則控制電路140讀取緩衝區塊buff0的資料,並且讀地址生成電路130將讀計數值rd_cnt0加1(即,rd_cnt0由0變為1)以及將目標緩衝段buff_sec0的讀狀態標誌位rd_flg減1(即,rd_flg由1變為0)。 Step S960: The control circuit 140 issues a target read command rd_cmd to read data from the buffer circuit 150, and controls the read address generation circuit 130 to update the corresponding read count value rd_cnt and the read status flag bit rd_flg (equivalent to the read address generation circuit 130 updating the corresponding read count value rd_cnt and updating the read status flag bit rd_flg according to the target read address rd_addr). Please refer to Figure 11 (Continued from Figure 10), assuming that the target read command rd_cmd is the read command rd_cmd0, the control circuit 140 reads the data of the buffer block buff0, and the read address generation circuit 130 adds 1 to the read count value rd_cnt0 (i.e., rd_cnt0 changes from 0 to 1) and reduces 1 to the read status flag rd_flg of the target buffer segment buff_sec0 (i.e., rd_flg changes from 1 to 0).

如圖11所示,由於目前第一資料只有緩衝區塊buff0中的資料,而且已被讀取(即,緩衝段buff_sec0的讀狀態標誌位rd_flg=0),所以接下來步驟S930的判斷結果便一直為否,直到直接記憶體存取電路100從目標裝置收到更多第一資料。此時,由於通道160暫不產生讀取命令,所以控制電路140便持續以通道170所產生的讀取命令rd_cmd1作為目標讀取命令rd_cmd(步驟S950),直到通道160再次產生讀取命令rd_cmd0或第二資料已被讀取完畢。 As shown in FIG11 , since the first data currently only has data in the buffer block buff0 and has been read (i.e., the read status flag bit rd_flg of the buffer segment buff_sec0 is 0), the judgment result of the next step S930 is always negative until the direct memory access circuit 100 receives more first data from the target device. At this time, since the channel 160 does not generate a read command temporarily, the control circuit 140 continues to use the read command rd_cmd1 generated by the channel 170 as the target read command rd_cmd (step S950) until the channel 160 generates a read command rd_cmd0 again or the second data has been read.

圖12~圖13顯示控制電路140連續讀取第二資料。圖12(接續圖11)顯示緩衝段buff_sec2的4筆資料已被讀取完畢;因此,緩衝段buff_sec2的讀狀態標誌位rd_flg由4變為0,而讀計數值rd_cnt1由0變為4。圖13(接續圖12)顯示控制電路140進一步讀取緩衝段buff_sec3的1筆資料;因此,緩衝段buff_sec3的讀狀態標誌位rd_flg由1變為0,而讀計數值rd_cnt1由4變為5。此時,因為讀計數值rd_cnt1與資料長度Ln1都等於5,所以控制電路140得知第二資料已被讀取完畢。 FIG. 12 and FIG. 13 show that the control circuit 140 continuously reads the second data. FIG. 12 (continued from FIG. 11) shows that the four data of the buffer segment buff_sec2 have been read; therefore, the read status flag bit rd_flg of the buffer segment buff_sec2 changes from 4 to 0, and the read count value rd_cnt1 changes from 0 to 4. FIG. 13 (continued from FIG. 12) shows that the control circuit 140 further reads one data of the buffer segment buff_sec3; therefore, the read status flag bit rd_flg of the buffer segment buff_sec3 changes from 1 to 0, and the read count value rd_cnt1 changes from 4 to 5. At this time, because the read count value rd_cnt1 and the data length Ln1 are both equal to 5, the control circuit 140 knows that the second data has been read.

需注意的是,於控制電路140讀取完一個緩衝段buff_sec的最後一筆資料之後,控制電路140更新對應於該緩衝段buff_sec的寫狀態標誌位wr_flg(即,將該寫狀態標誌位wr_flg重置為1)。更明確地說,因為緩衝段buff_sec2有4筆待讀取的資料,所以當控制電路140讀取完畢緩衝區塊buff11 的資料之後,控制電路140才能將對應於緩衝段buff_sec2的寫狀態標誌位wr_flg重置為1(圖12)。接下來,因為緩衝段buff_sec3只有1筆待讀取的資料,所以當控制電路140讀取完畢緩衝區塊buff12的資料之後,控制電路140將對應於緩衝段buff_sec3的寫狀態標誌位wr_flg重置為1(圖13)。 It should be noted that after the control circuit 140 has read the last data of a buffer buff_sec, the control circuit 140 updates the write status flag wr_flg corresponding to the buffer buff_sec (i.e., resets the write status flag wr_flg to 1). More specifically, because the buffer buff_sec2 has 4 data to be read, the control circuit 140 can reset the write status flag wr_flg corresponding to the buffer buff_sec2 to 1 only after the control circuit 140 has read the data of the buffer block buff11 (Figure 12). Next, because there is only one piece of data to be read in the buffer segment buff_sec3, after the control circuit 140 finishes reading the data in the buffer block buff12, the control circuit 140 resets the write status flag wr_flg corresponding to the buffer segment buff_sec3 to 1 (Figure 13).

在第二資料被讀取完畢之後(圖13),寫地址生成電路120接收到對應於讀取請求Req0的第一資料,並將其寫入緩衝電路150,其過程如圖14~圖15所示(請參考圖5的流程)。圖14(接續圖13)顯示寫地址生成電路120在緩衝區塊buff1寫入第一資料的第2筆資料,因此緩衝段buff_sec0的讀狀態標誌位rd_flg由0變為1,而寫計數值wr_cnt0由1變為2。圖15(接續圖14)顯示寫地址生成電路120繼續在緩衝段buff_sec0寫入2筆資料,然後在緩衝段buff_sec1寫入另2筆資料,因此緩衝段buff_sec0的讀狀態標誌位rd_flg由1變為3、緩衝段buff_sec1的讀狀態標誌位rd_flg由0變為2,而寫計數值wr_cnt0由2變為6。 After the second data is read (FIG. 13), the write address generation circuit 120 receives the first data corresponding to the read request Req0 and writes it into the buffer circuit 150, as shown in FIG. 14 and FIG. 15 (please refer to the flow chart of FIG. 5). FIG. 14 (following FIG. 13) shows that the write address generation circuit 120 writes the second data of the first data into the buffer block buff1, so the read status flag bit rd_flg of the buffer segment buff_sec0 changes from 0 to 1, and the write count value wr_cnt0 changes from 1 to 2. FIG15 (continued from FIG14) shows that the write address generation circuit 120 continues to write 2 data in the buffer buff_sec0, and then writes another 2 data in the buffer buff_sec1, so the read status flag rd_flg of the buffer buff_sec0 changes from 1 to 3, the read status flag rd_flg of the buffer buff_sec1 changes from 0 to 2, and the write count value wr_cnt0 changes from 2 to 6.

如圖15所示,因為緩衝段buff_sec0的讀狀態標誌位rd_flg大於0(即,圖9之步驟S930的判斷結果為是),所以後續控制電路140將讀取第一資料。如圖16(接續圖15)所示,因為讀計數值rd_cnt0=1,所以控制電路140會從緩衝區塊buff1(即,Sa0+rd_cnt0=0+1=1)開始依序讀取資料(即,重複執行圖9的流程)。圖17(接續圖16)顯示第一資料被讀取完畢後的狀態,此時緩衝段buff_sec0及緩衝段buff_sec1的寫狀態標誌位wr_flg變為1,緩衝段buff_sec0及緩衝段buff_sec1的讀狀態標誌位rd_flg變為0,而讀計數值rd_cnt0變為6。 As shown in FIG15 , because the read status flag bit rd_flg of the buffer segment buff_sec0 is greater than 0 (i.e., the judgment result of step S930 in FIG9 is yes), the subsequent control circuit 140 will read the first data. As shown in FIG16 (following FIG15 ), because the read count value rd_cnt0=1, the control circuit 140 will start to read data in sequence from the buffer block buff1 (i.e., Sa0+rd_cnt0=0+1=1) (i.e., repeatedly execute the process of FIG9 ). Figure 17 (continued from Figure 16) shows the state after the first data is read. At this time, the write status flag wr_flg of buffer buff_sec0 and buffer buff_sec1 becomes 1, the read status flag rd_flg of buffer buff_sec0 and buffer buff_sec1 becomes 0, and the read count value rd_cnt0 becomes 6.

綜上所述,本發明可以提升直接記憶體存取電路的效能。更明 確地說,即使某一通道遭遇資料延時(例如圖6~圖8,第一資料發生延時),另一通道的資料的寫入及讀取不會受到影響(如圖11~圖13所示,在第一資料有延時的情況下,第二資料仍可被順利地寫入及讀取)。此外,第一資料的寫入可以被中斷(如上面的實施所示,第一資料的第一部分(例如,緩衝區塊buff0)及第二部分(例如,緩衝區塊buff1~緩衝區塊buff5)並非被連續寫入),第一資料的讀取也可以被中斷(如上面的實施所示,第一資料非被連續讀出)。 In summary, the present invention can improve the performance of direct memory access circuits. More specifically, even if a channel encounters data delay (for example, FIG. 6 to FIG. 8, the first data is delayed), the writing and reading of the data of the other channel will not be affected (as shown in FIG. 11 to FIG. 13, when the first data is delayed, the second data can still be smoothly written and read). In addition, the writing of the first data can be interrupted (as shown in the above implementation, the first part (for example, buffer block buff0) and the second part (for example, buffer block buff1 to buffer block buff5) of the first data are not continuously written), and the reading of the first data can also be interrupted (as shown in the above implementation, the first data is not continuously read out).

圖18顯示本發明直接記憶體存取電路的操作方法之一實施例的流程圖,包含以下步驟。 FIG18 is a flow chart showing an embodiment of the operation method of the direct memory access circuit of the present invention, which includes the following steps.

步驟S1810:寫狀態判斷電路110根據第一通道(例如,通道160)之第一讀取請求(例如,讀取請求Req0),從緩衝電路150決定第一起始地址(例如,起始地址Sa0),第一讀取請求對應於第一資料。 Step S1810: The write state determination circuit 110 determines the first starting address (e.g., starting address Sa0) from the buffer circuit 150 according to the first read request (e.g., read request Req0) of the first channel (e.g., channel 160), and the first read request corresponds to the first data.

步驟S1820:寫狀態判斷電路110根據第二通道(例如,通道170)之第二讀取請求(例如,讀取請求Req1),從緩衝電路150決定第二起始地址(例如,起始地址Sa1),第二讀取請求對應於第二資料。步驟S1810及步驟S1820的細節請參考圖2~圖4的說明。 Step S1820: The write state determination circuit 110 determines the second starting address (e.g., starting address Sa1) from the buffer circuit 150 according to the second read request (e.g., read request Req1) of the second channel (e.g., channel 170), and the second read request corresponds to the second data. For details of step S1810 and step S1820, please refer to the description of Figures 2 to 4.

步驟S1830:讀地址生成電路130根據該第一起始地址及第一讀計數值(例如,讀計數值rd_cnt0)決定讀取地址。步驟S1830的細節請參考圖9。 Step S1830: The read address generation circuit 130 determines the read address according to the first start address and the first read count value (e.g., read count value rd_cnt0). Please refer to FIG. 9 for details of step S1830.

步驟S1840:控制電路140根據該讀取地址從緩衝電路150讀取該第一資料的該第一部分,並且更新該第一讀計數值。步驟S1840可以對應到圖10~圖11。 Step S1840: The control circuit 140 reads the first part of the first data from the buffer circuit 150 according to the read address, and updates the first read count value. Step S1840 may correspond to FIG. 10 to FIG. 11.

步驟S1850:控制電路140於讀取該第一資料的該第一部分之後,從緩衝電路150讀取該第二資料的至少一部分。步驟S1840可以對應到圖11~圖12或圖11~13。 Step S1850: After reading the first part of the first data, the control circuit 140 reads at least a part of the second data from the buffer circuit 150. Step S1840 may correspond to FIG. 11 to FIG. 12 or FIG. 11 to FIG. 13.

步驟S1860:於該第二資料的該至少一部分被讀取之後,讀地址生成電路130根據該第一起始地址及更新後的該第一讀計數值更新該讀取地址。步驟S1860的細節請參考圖9。 Step S1860: After at least a portion of the second data is read, the read address generation circuit 130 updates the read address according to the first start address and the updated first read count value. Please refer to FIG. 9 for details of step S1860.

步驟S1870:控制電路140根據該更新後的該讀取地址從該緩衝電路讀取該第一資料的一第二部分。步驟S1870可以對應到圖16~圖17。 Step S1870: The control circuit 140 reads a second part of the first data from the buffer circuit according to the updated read address. Step S1870 may correspond to FIG. 16 to FIG. 17.

本發明直接記憶體存取電路的操作方法還可以包含圖19的步驟S1855:於該第二資料的該至少一部分被讀取(即,步驟S1850)之後,及該第一資料的該第二部分被讀取(即,步驟S1870)之前,寫地址生成電路120將該第一資料的該第二部分寫入該緩衝電路。步驟S1855可以對應到圖14~圖15。 The operation method of the direct memory access circuit of the present invention may also include step S1855 of FIG. 19: after the at least a portion of the second data is read (i.e., step S1850) and before the second portion of the first data is read (i.e., step S1870), the write address generation circuit 120 writes the second portion of the first data into the buffer circuit. Step S1855 may correspond to FIG. 14 to FIG. 15.

需注意的是,步驟S1855並非必須(即,第一資料的寫入不一定會被中斷)。更明確地說,在一些實施例中,即使第一資料全部被寫入緩衝電路150之後才開始被讀取,控制電路140對第一資料的讀取也可能因為圖9之步驟S950而中斷(即,對應到圖18的步驟S1840~步驟S1870)。舉例來說,假設第一資料及第二資料皆已被寫入緩衝電路150但都未被讀取(如圖20所示),則步驟S950所仲裁產生的目標讀取命令rd_cmd可能是以下的順序:讀取命令rd_cmd0(讀取緩衝段buff_sec0)→讀取命令rd_cmd1(讀取緩衝段buff_sec2)→讀取命令rd_cmd0(讀取緩衝段buff_sec1)→讀取命令rd_cmd1(讀取緩衝段buff_sec3);換言之,第一資料沒有被連續讀取。 It should be noted that step S1855 is not necessary (i.e., the writing of the first data may not be interrupted). More specifically, in some embodiments, even if the first data is read only after it is written into the buffer circuit 150, the reading of the first data by the control circuit 140 may be interrupted due to step S950 of FIG. 9 (i.e., corresponding to step S1840 to step S1870 of FIG. 18). For example, assuming that both the first data and the second data have been written into the buffer circuit 150 but have not been read (as shown in FIG. 20 ), the target read command rd_cmd generated by arbitration in step S950 may be in the following order: read command rd_cmd0 (read buffer segment buff_sec0) → read command rd_cmd1 (read buffer segment buff_sec2) → read command rd_cmd0 (read buffer segment buff_sec1) → read command rd_cmd1 (read buffer segment buff_sec3); in other words, the first data is not read continuously.

本技術領域具有通常知識者可以根據以上的討論以邏輯電路實作寫狀態判斷電路110、寫地址生成電路120、讀地址生成電路130及控制電路140。 A person with ordinary knowledge in this technical field can implement the write state determination circuit 110, the write address generation circuit 120, the read address generation circuit 130 and the control circuit 140 with a logic circuit according to the above discussion.

前揭實施例雖以2個通道為例,然此並非對本發明之限制,本技術領域人士可依本發明之揭露適當地將本發明應用於更多通道。 Although the above-mentioned embodiment uses two channels as an example, this is not a limitation of the present invention. People skilled in the art can appropriately apply the present invention to more channels based on the disclosure of the present invention.

此外,本技術領域具有通常知識者亦可以根據上述的討論,將本發明應用於單一通道的讀取操作及寫入操作的至少其一者為亂序的情況。也就是說,將通道160的寫入操作(或讀取操作)及通道170寫入操作(或讀取操作)視為同一通道之不同資料部分的寫入操作(或讀取操作)。 In addition, those with ordinary knowledge in the art can also apply the present invention to the case where at least one of the read operation and write operation of a single channel is out of order based on the above discussion. In other words, the write operation (or read operation) of channel 160 and the write operation (or read operation) of channel 170 are regarded as write operations (or read operations) of different data parts of the same channel.

雖然本發明之實施例如上所述,然而該些實施例並非用來限定本發明,本技術領域具有通常知識者可根據本發明之明示或隱含之內容對本發明之技術特徵施以變化,凡此種種變化均可能屬於本發明所尋求之專利保護範疇,換言之,本發明之專利保護範圍須視本說明書之申請專利範圍所界定者為準。 Although the embodiments of the present invention are described above, these embodiments are not intended to limit the present invention. Those with ordinary knowledge in the technical field may make changes to the technical features of the present invention based on the explicit or implicit content of the present invention. All these changes may fall within the scope of patent protection sought by the present invention. In other words, the scope of patent protection of the present invention shall be subject to the scope of the patent application defined in this specification.

S1810,S1820,S1830,S1840,S1850,S1860,S1870:步驟 S1810,S1820,S1830,S1840,S1850,S1860,S1870: Steps

Claims (18)

一種直接記憶體存取電路的操作方法,該直接記憶體存取電路包含一緩衝電路、一第一通道及一第二通道,該方法包含:根據該第一通道之一第一讀取請求,從該緩衝電路決定一第一起始地址,該第一讀取請求對應於一第一資料;根據該第二通道之一第二讀取請求,從該緩衝電路決定一第二起始地址,該第二讀取請求對應於一第二資料;根據該第一起始地址及一第一讀計數值決定一讀取地址;根據該讀取地址從該緩衝電路讀取該第一資料的一第一部分,並且更新該第一讀計數值;於讀取該第一資料的該第一部分之後,根據該第二起始地址從該緩衝電路讀取該第二資料的至少一部分;根據該第一起始地址及更新後的該第一讀計數值更新該讀取地址;以及根據該更新後的該讀取地址從該緩衝電路讀取該第一資料的一第二部分;其中,該直接記憶體存取電路更包含一第二讀計數值,該第二讀計數值對應於該第二起始地址,且該第二讀計數值不等於該第一讀計數值。 A method for operating a direct memory access circuit includes a buffer circuit, a first channel and a second channel. The method includes: determining a first starting address from the buffer circuit according to a first read request of the first channel, wherein the first read request corresponds to a first data; determining a second starting address from the buffer circuit according to a second read request of the second channel, wherein the second read request corresponds to a second data; determining a read address according to the first starting address and a first read count value; and reading the first data from the buffer circuit according to the read address. a first portion of the data and updates the first read count value; after reading the first portion of the first data, read at least a portion of the second data from the buffer circuit according to the second start address; update the read address according to the first start address and the updated first read count value; and read a second portion of the first data from the buffer circuit according to the updated read address; wherein the direct memory access circuit further includes a second read count value, the second read count value corresponds to the second start address, and the second read count value is not equal to the first read count value. 如請求項1之方法,更包含:於讀取該第二資料的該至少一部分之後,及於讀取該第一資料的該第二部分之前,將該第一資料的該第二部分寫入該緩衝電路。 The method of claim 1 further comprises: after reading the at least a portion of the second data and before reading the second portion of the first data, writing the second portion of the first data into the buffer circuit. 如請求項1之方法,其中,該緩衝電路包含複數個緩衝段,每一緩衝段對應於一寫狀態標誌位,該寫狀態標誌位用來指示對應於該寫狀態標誌位的該緩衝段是否未被使用,該方法更包含:根據該第一資料的一資料量及該些寫狀態標誌位,自該些緩衝段中決定一第一緩衝段;其中,該第一起始地址係該第一緩衝段之一起始地址,且該第一緩衝段係用來儲存該第一資料。 As in the method of claim 1, the buffer circuit includes a plurality of buffer segments, each buffer segment corresponds to a write status flag bit, and the write status flag bit is used to indicate whether the buffer segment corresponding to the write status flag bit is not used. The method further includes: determining a first buffer segment from the buffer segments according to a data amount of the first data and the write status flag bits; wherein the first starting address is a starting address of the first buffer segment, and the first buffer segment is used to store the first data. 如請求項3之方法,更包含:於決定該第一緩衝段之後,更新對應於該第一緩衝段之該寫狀態標誌位。 The method of claim 3 further includes: after determining the first buffer segment, updating the write status flag corresponding to the first buffer segment. 如請求項1之方法,其中,該緩衝電路包含用來儲存該第一資料的該第一部分的一第一緩衝段,該第一緩衝段具有一讀狀態標誌位,該讀狀態標誌位用來指示該第一緩衝段中是否有任何未讀取的資料,該方法更包含:於讀取該第一資料的該第一部分之前,根據該讀狀態標誌位決定是否從該第一緩衝段讀取該第一資料的該第一部分。 As in the method of claim 1, the buffer circuit includes a first buffer segment for storing the first part of the first data, the first buffer segment has a read status flag bit, and the read status flag bit is used to indicate whether there is any unread data in the first buffer segment. The method further includes: before reading the first part of the first data, determining whether to read the first part of the first data from the first buffer segment according to the read status flag bit. 如請求項5之方法,更包含:將該第一資料的該第一部分寫入該第一緩衝段;以及當該第一緩衝段被寫入資料時,更新該讀狀態標誌位。 The method of claim 5 further comprises: writing the first part of the first data into the first buffer; and updating the read status flag when the data is written into the first buffer. 如請求項5之方法,更包含:於讀取該第一資料的該第一部分之後,更新該讀狀態標誌位。 The method of claim 5 further includes: after reading the first part of the first data, updating the read status flag. 如請求項1之方法,更包含:於讀取該第一資料的該第一部分之後,更新該第一讀計數值。 The method of claim 1 further includes: after reading the first part of the first data, updating the first read count value. 如請求項1之方法,更包含:根據該第一起始地址及一寫計數值,將該第一資料的該第一部分寫入該緩衝電路;以及於寫入該第一資料的該第一部分之後,更新該寫計數值。 The method of claim 1 further comprises: writing the first part of the first data into the buffer circuit according to the first starting address and a write count value; and updating the write count value after writing the first part of the first data. 一種直接記憶體存取電路,包含:一緩衝電路;一第一通道,用來產生一第一讀取請求;一第二通道,用來產生一第二讀取請求;一寫狀態判斷電路,用來根據該第一讀取請求從該緩衝電路決定一第一起始地址,以及根據該第二讀取請求從該緩衝電路決定一第二起始地址,該第一讀取請求對應於一第一資料,該第二讀取請求對應於一第二資料;一讀地址生成電路,用來根據該第一起始地址及一第一讀計數值決定一讀取地址;一控制電路,用來根據該讀取地址從該緩衝電路讀取該第一資料的一第一部分、控制該讀地址生成電路更新該第一讀計數值,並且於讀取該第一資料的該第一部分之後,根據該第二起始地址從該緩衝電路讀取該第二資料的至少一部分; 其中,該讀地址生成電路更根據該第一起始地址及更新後的該第一讀計數值更新該讀取地址,以及該控制電路更根據該更新後的該讀取地址從該緩衝電路讀取該第一資料的一第二部分;其中,該讀地址生成電路更儲存一第二讀計數值,該第二讀計數值對應於該第二起始地址,且該第二讀計數值不等於該第一讀計數值。 A direct memory access circuit includes: a buffer circuit; a first channel for generating a first read request; a second channel for generating a second read request; a write state determination circuit for determining a first starting address from the buffer circuit according to the first read request, and a second starting address from the buffer circuit according to the second read request, wherein the first read request corresponds to a first data, and the second read request corresponds to a second data; a read address generation circuit for determining a read address according to the first starting address and a first read count value; and a control circuit for reading the first data from the buffer circuit according to the read address. a first part of the first data, controlling the read address generation circuit to update the first read count value, and after reading the first part of the first data, reading at least a part of the second data from the buffer circuit according to the second starting address; Wherein, the read address generation circuit further updates the read address according to the first starting address and the updated first read count value, and the control circuit further reads a second part of the first data from the buffer circuit according to the updated read address; wherein, the read address generation circuit further stores a second read count value, the second read count value corresponds to the second starting address, and the second read count value is not equal to the first read count value. 如請求項10之直接記憶體存取電路,更包含:一寫地址生成電路,用來於該第二資料的該至少一部分被讀取之後,及該第一資料的該第二部分被讀取之前,將該第一資料的該第二部分寫入該緩衝電路。 The direct memory access circuit of claim 10 further comprises: a write address generation circuit for writing the second portion of the first data into the buffer circuit after the at least a portion of the second data is read and before the second portion of the first data is read. 如請求項10之直接記憶體存取電路,其中,該緩衝電路包含複數個緩衝段,每一緩衝段對應於一寫狀態標誌位,該寫狀態標誌位用來指示對應於該寫狀態標誌位的該緩衝段是否未被使用,該寫狀態判斷電路更根據該第一資料的一資料量及該些寫狀態標誌位,自該些緩衝段中決定用來儲存該第一資料之一第一緩衝段,該第一起始地址係該第一緩衝段之一起始地址。 As in claim 10, the direct memory access circuit includes a plurality of buffer segments, each buffer segment corresponds to a write status flag bit, and the write status flag bit is used to indicate whether the buffer segment corresponding to the write status flag bit is not used. The write status determination circuit further determines a first buffer segment from the buffer segments for storing the first data according to a data amount of the first data and the write status flag bits, and the first starting address is a starting address of the first buffer segment. 如請求項12之直接記憶體存取電路,其中,該寫狀態判斷電路更於決定該第一緩衝段之後,更新對應於該第一緩衝段之該寫狀態標誌位。 A direct memory access circuit as claimed in claim 12, wherein the write status determination circuit further updates the write status flag corresponding to the first buffer segment after determining the first buffer segment. 如請求項10之直接記憶體存取電路,其中,該緩衝電路包含用來儲存該第一資料的該第一部分的一第一緩衝段,該第一緩衝段具有一讀狀態標誌位,該讀狀態標誌位用來指示該第一緩衝段中是否有任何未讀取的資料,該讀地址生成電路更於該控制電路讀取該第一資料的該第一部分之前, 根據該讀狀態標誌位決定是否從該第一緩衝段讀取該第一資料的該第一部分。 A direct memory access circuit as claimed in claim 10, wherein the buffer circuit includes a first buffer segment for storing the first part of the first data, the first buffer segment has a read status flag bit, the read status flag bit is used to indicate whether there is any unread data in the first buffer segment, and the read address generation circuit is before the control circuit reads the first part of the first data, and determines whether to read the first part of the first data from the first buffer segment according to the read status flag bit. 如請求項14之直接記憶體存取電路,其中,該直接記憶體存取電路更包含一寫地址生成電路,該寫地址生成電路用來將該第一資料的該第一部分寫入該第一緩衝段,並且該讀地址生成電路更於該第一緩衝段被寫入資料時,更新該讀狀態標誌位。 A direct memory access circuit as claimed in claim 14, wherein the direct memory access circuit further comprises a write address generation circuit, the write address generation circuit is used to write the first part of the first data into the first buffer, and the read address generation circuit further updates the read status flag bit when the data is written into the first buffer. 如請求項14之直接記憶體存取電路,其中,該讀地址生成電路更於該第一資料的該第一部分被讀取之後,更新該讀狀態標誌位。 A direct memory access circuit as claimed in claim 14, wherein the read address generation circuit further updates the read status flag after the first portion of the first data is read. 如請求項10之直接記憶體存取電路,其中,該讀地址生成電路更於該第一資料的該第一部分被讀取之後,更新該第一讀計數值。 A direct memory access circuit as claimed in claim 10, wherein the read address generation circuit further updates the first read count value after the first portion of the first data is read. 如請求項10之直接記憶體存取電路,更包含:一寫地址生成電路,用來根據該第一起始地址及一寫計數值,將該第一資料的該第一部分寫入該緩衝電路,並且更新該寫計數值。 The direct memory access circuit of claim 10 further comprises: a write address generation circuit for writing the first part of the first data into the buffer circuit according to the first starting address and a write count value, and updating the write count value.
TW112112707A 2023-03-31 Direct memory access (dma) circuit and operation method thereof TWI844326B (en)

Publications (1)

Publication Number Publication Date
TWI844326B true TWI844326B (en) 2024-06-01

Family

ID=

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115701597A (en) 2021-08-02 2023-02-10 辉达公司 Accelerating table lookups using a decoupled lookup table accelerator in a system on a chip

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115701597A (en) 2021-08-02 2023-02-10 辉达公司 Accelerating table lookups using a decoupled lookup table accelerator in a system on a chip

Similar Documents

Publication Publication Date Title
JP6123017B2 (en) Apparatus and method for variable latency memory operation
KR100337056B1 (en) Buffering data that flows between buses operating at different frequencies
CN109815172B (en) Device controller and storage device including the same
US11042300B2 (en) Command load balancing for NVME dual port operations
JP4820566B2 (en) Memory access control circuit
US8095744B2 (en) Device for controlling access from a plurality of masters to shared memory composed of a plurality of banks each having a plurality of pages
US7904626B2 (en) Arbiter and arbitration method of multiple data accesses
JPWO2004057481A1 (en) DMA control device, DMA control method, DMA control program
US10049035B1 (en) Stream memory management unit (SMMU)
TW201331826A (en) Memory controller and a method thereof
JP2006195714A (en) Resource management device
US6728797B2 (en) DMA controller
US10817183B2 (en) Information processing apparatus and information processing system
JP2024038365A (en) Memory controller and method implemented on memory controller
TWI844326B (en) Direct memory access (dma) circuit and operation method thereof
JP5056668B2 (en) Data transfer apparatus and data transfer method
US20100064071A1 (en) DMA device having plural buffers storing transfer request information and DMA transfer method
CN116204464A (en) Direct memory access circuit and operation method thereof
JP3824122B2 (en) DMA device
JP2007079715A (en) Data transfer method, program and device
JP4468885B2 (en) Bus arbitration method, apparatus and program
JP2007323473A (en) Information processor
US7200690B2 (en) Memory access system providing increased throughput rates when accessing large volumes of data by determining worse case throughput rate delays
US8473705B2 (en) Memory access apparatus
KR100359811B1 (en) Apparatus for controlling memory