TWI844326B - Direct memory access (dma) circuit and operation method thereof - Google Patents
Direct memory access (dma) circuit and operation method thereof Download PDFInfo
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 31
- 239000000872 buffer Substances 0.000 claims abstract description 199
- 230000000875 corresponding effect Effects 0.000 description 29
- 101150059273 PTR1 gene Proteins 0.000 description 5
- 101100012902 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) FIG2 gene Proteins 0.000 description 4
- 238000011017 operating method Methods 0.000 description 3
- 101001121408 Homo sapiens L-amino-acid oxidase Proteins 0.000 description 2
- 101000827703 Homo sapiens Polyphosphoinositide phosphatase Proteins 0.000 description 2
- 102100026388 L-amino-acid oxidase Human genes 0.000 description 2
- 102100023591 Polyphosphoinositide phosphatase Human genes 0.000 description 2
- 101100233916 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) KAR5 gene Proteins 0.000 description 2
- 230000002596 correlated effect Effects 0.000 description 2
- 230000007812 deficiency Effects 0.000 description 2
- 230000003111 delayed effect Effects 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 230000004044 response Effects 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
Images
Abstract
Description
本發明是關於直接記憶體存取(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
圖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
當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
圖3是回應於讀取請求Req來配置緩衝電路150之一實施例的流程圖,包含以下步驟。
FIG3 is a flow chart of an embodiment of configuring the
步驟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:
舉例來說,讀取請求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
步驟S320:寫狀態判斷電路110仲裁(arbitrate)產生一目標讀取請求。寫狀態判斷電路110可以包含仲裁器(arbitrator)(圖未示),用來根據預先決定的仲裁規則(例如,循環制(round-robin))從讀取請求Req0與讀取請求Req1之間仲裁產生目標讀取請求。
Step S320: The write
步驟S330:寫狀態判斷電路110判斷緩衝電路150是否有足夠未被使用的空間(例如緩衝區塊)。更明確地說,寫狀態判斷電路110根據緩
衝段的寫狀態標誌位wr_flg、待處理的資料量(即,第一資料的資料長度Ln0或第二資料的資料長度Ln1)及粒度X從緩衝電路150找出個未被使用的緩衝段。在一些實施例中,粒度X可以是2的冪次方(即,X=1,2,4,8,...)。以圖2為例(X=4),假設Ln=6(即,需要個緩衝段buff_sec),因為至少有5個緩衝段buff_sec(緩衝段buff_sec0、緩衝段buff_sec1、緩衝段buff_sec2、緩衝段buff_sec3及緩衝段buff_sec31)的寫狀態標誌位wr_flg皆為第一數值(例如1,代表未被使用),所以步驟S330的判斷結果為是。
Step S330: The write
當步驟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
在一些實施例中,分配給一個讀取請求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
步驟S350:寫狀態判斷電路110判斷通道160的暫存器162是否已滿。如果是,則寫狀態判斷電路110回到步驟S320以仲裁產生另一個目標讀取請求;如果否,則寫狀態判斷電路110執行步驟S370及步驟S390。
Step S350: The write
步驟S360:寫狀態判斷電路110判斷通道170的暫存器172是
否已滿。如果是,則寫狀態判斷電路110回到步驟S320以仲裁產生另一目標讀取請求;如果否,則寫狀態判斷電路110執行步驟S380及步驟S390。
Step S360: The write
步驟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
步驟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
步驟S390:寫狀態判斷電路110設定目標讀取請求與通道(通道160或通道170)之通道編號(ID0或ID1)之間的關聯性(correspondence)(如寫狀態表220所示),以便於確認資料與通道之間的關聯性。更明確地說,如果步驟S350為否,則寫狀態判斷電路110將讀取請求Req0與Axi識別碼ID0設定為互相關聯。如果步驟S360為否,則寫狀態判斷電路110將讀取請求Req1與Axi識別碼ID1設定為互相關聯。
Step S390: The write
承上例,圖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
在一些實施例中,可以使用緩衝段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
請參閱圖5,圖5是寫地址生成電路120將資料Din寫入緩衝電路150的流程圖,包含以下步驟。
Please refer to FIG. 5, which is a flow chart of the write
步驟S510:寫地址生成電路120從目標裝置取得資料Din,即,根據讀取請求Req0或讀取請求Req1從目標裝置讀取相對應的第一資料或第二資料。
Step S510: The write
步驟S520:寫地址生成電路120判斷此次的寫入操作是否為第一次的叢發寫入(burst write),即,判斷是否第一次將對應於某個讀取請求
Req的資料寫入緩衝電路150。如果是,則執行步驟S530;如果否,則執行步驟S540。
Step S520: The write
步驟S530:寫地址生成電路120重置寫計數值wr_cnt(例如,將寫計數值wr_cnt設定為0)。更明確地說,寫地址生成電路120根據資料Din是屬於讀取請求Req0或讀取請求Req1來從寫狀態表220中取得相對應的寫計數值wr_cnt,並且重置該相對應的寫計數值wr_cnt。
Step S530: The write
步驟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
步驟S560:寫地址生成電路120更新寫計數值wr_cnt,即,將寫計數值wr_cnt0或寫計數值wr_cnt1加1。
Step S560: The write
請參閱圖6~圖8,圖6~圖8顯示緩衝電路150、緩衝段狀態表210、寫狀態表220及讀狀態表230根據圖5之流程的一個例子。
Please refer to Figures 6 to 8, which show an example of the
圖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
圖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
圖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
圖6~圖8顯示直接記憶體存取電路100可以以亂序的方式處理讀取請求Req0及讀取請求Req1,因為寫地址生成電路120並非處理完全部的第一資料後再處理第二資料。
FIG6 to FIG8 show that the direct
圖9是控制電路140從緩衝電路150讀取資料的流程圖,包含以下步驟。
FIG9 is a flow chart of the
步驟S910:讀地址生成電路130根據通道160的起始地址Sa0取得通道160的讀計數值rd_cnt0。
Step S910: The read
步驟S920:讀地址生成電路130根據起始地址Sa0及讀計數值rd_cnt0決定讀取地址,並且決定對應於該讀取地址的目標緩衝段。請參閱圖10(接續圖8),此時對應於通道160的讀取地址為Sa0+rd_cnt0=0+0=0(即,指標ptr0所指的地址),而對應於指標ptr0的目標緩衝段為(0為讀取
地址,4為前述的粒度X)。
Step S920: The read
步驟S930:讀地址生成電路130判斷目標緩衝段的讀狀態標誌位rd_flg是否大於0。如果是(代表目標緩衝段中有尚未被讀取的資料),則執行步驟S940;如果否,則重複步驟S910~步驟S930,直到目標緩衝段中有尚未被讀取的資料。在圖10的例子中,因為目標緩衝段(即,緩衝段buff_sec0)的讀狀態標誌位rd_flg為1,所以步驟S930的判斷結果為是。
Step S930: The read
步驟S940:讀地址生成電路130產生讀取命令rd_cmd0,以讀取目標緩衝段buff_sec0中的資料。
Step S940: The read
步驟S915~步驟S945是對應於第二通道的操作,且內容分別與步驟S910~步驟S940相似或相同。以圖10的例子來說,通道170的讀取地址為Sa1+rd_cnt1=8+0=8(即,指標ptr1所指的地址),而目標緩衝段為。因為目標緩衝段(即,緩衝段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
步驟S950:控制電路140根據預先決定的仲裁規則(例如,循環制)在讀取命令rd_cmd0與讀取命令rd_cmd1之間仲裁產生目標讀取命令rd_cmd。承上例,如果目標讀取命令rd_cmd是讀取命令rd_cmd0(rd_cmd1),則目標讀取地址rd_addr是指標ptr0(ptr1)所指的地址。
Step S950: The
步驟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
如圖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
圖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
需注意的是,於控制電路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
在第二資料被讀取完畢之後(圖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
如圖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
綜上所述,本發明可以提升直接記憶體存取電路的效能。更明 確地說,即使某一通道遭遇資料延時(例如圖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
步驟S1820:寫狀態判斷電路110根據第二通道(例如,通道170)之第二讀取請求(例如,讀取請求Req1),從緩衝電路150決定第二起始地址(例如,起始地址Sa1),第二讀取請求對應於第二資料。步驟S1810及步驟S1820的細節請參考圖2~圖4的說明。
Step S1820: The write
步驟S1830:讀地址生成電路130根據該第一起始地址及第一讀計數值(例如,讀計數值rd_cnt0)決定讀取地址。步驟S1830的細節請參考圖9。
Step S1830: The read
步驟S1840:控制電路140根據該讀取地址從緩衝電路150讀取該第一資料的該第一部分,並且更新該第一讀計數值。步驟S1840可以對應到圖10~圖11。
Step S1840: The
步驟S1850:控制電路140於讀取該第一資料的該第一部分之後,從緩衝電路150讀取該第二資料的至少一部分。步驟S1840可以對應到圖11~圖12或圖11~13。
Step S1850: After reading the first part of the first data, the
步驟S1860:於該第二資料的該至少一部分被讀取之後,讀地址生成電路130根據該第一起始地址及更新後的該第一讀計數值更新該讀取地址。步驟S1860的細節請參考圖9。
Step S1860: After at least a portion of the second data is read, the read
步驟S1870:控制電路140根據該更新後的該讀取地址從該緩衝電路讀取該第一資料的一第二部分。步驟S1870可以對應到圖16~圖17。
Step S1870: The
本發明直接記憶體存取電路的操作方法還可以包含圖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
需注意的是,步驟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
本技術領域具有通常知識者可以根據以上的討論以邏輯電路實作寫狀態判斷電路110、寫地址生成電路120、讀地址生成電路130及控制電路140。
A person with ordinary knowledge in this technical field can implement the write
前揭實施例雖以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
雖然本發明之實施例如上所述,然而該些實施例並非用來限定本發明,本技術領域具有通常知識者可根據本發明之明示或隱含之內容對本發明之技術特徵施以變化,凡此種種變化均可能屬於本發明所尋求之專利保護範疇,換言之,本發明之專利保護範圍須視本說明書之申請專利範圍所界定者為準。 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)
Publications (1)
Publication Number | Publication Date |
---|---|
TWI844326B true TWI844326B (en) | 2024-06-01 |
Family
ID=
Citations (1)
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)
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 |