TW202420073A - Instruction compression method, instruction decompression method and process compression method - Google Patents

Instruction compression method, instruction decompression method and process compression method Download PDF

Info

Publication number
TW202420073A
TW202420073A TW111141685A TW111141685A TW202420073A TW 202420073 A TW202420073 A TW 202420073A TW 111141685 A TW111141685 A TW 111141685A TW 111141685 A TW111141685 A TW 111141685A TW 202420073 A TW202420073 A TW 202420073A
Authority
TW
Taiwan
Prior art keywords
instruction
jump
block
group
parameters
Prior art date
Application number
TW111141685A
Other languages
Chinese (zh)
Other versions
TWI820994B (en
Inventor
鄧亞明
Original Assignee
大陸商星宸科技股份有限公司
Filing date
Publication date
Application filed by 大陸商星宸科技股份有限公司 filed Critical 大陸商星宸科技股份有限公司
Priority to TW111141685A priority Critical patent/TWI820994B/en
Priority claimed from TW111141685A external-priority patent/TWI820994B/en
Application granted granted Critical
Publication of TWI820994B publication Critical patent/TWI820994B/en
Publication of TW202420073A publication Critical patent/TW202420073A/en

Links

Images

Abstract

An instruction compression method, an instruction decompression method, and a process compression method are provided. The process compression method is used for compressing a process that includes a jump instruction. The process compression method includes the following steps: dividing the process into multiple blocks according to a position of the jump instruction in the process and a destination of the jump instruction; recording a jump relationship between these blocks; performing instruction compression on these blocks; updating a jump address of the jump instruction according to the jump relationship; determining multiple groups according to the sizes of the blocks and the jump relationship; and determining whether the jump instruction is a first type jump instruction or a second type jump instruction according to the relationship between the jump instruction and the groups.

Description

指令壓縮方法、指令解壓縮方法及流程壓縮方法Instruction compression method, instruction decompression method and process compression method

本發明是關於指令壓縮與指令解壓縮,尤其是關於與跳轉指令(jump instruction,或稱為分支指令(branch instruction))相關的指令壓縮與指令解壓縮。The present invention relates to instruction compression and instruction decompression, and in particular to instruction compression and instruction decompression related to jump instructions (also called branch instructions).

一般而言,一個流程(例如,影像處理流程、啟動流程等)通常包含至少一個跳轉指令。然而,現有的平台處理跳轉邏輯時無法同時開啟變長指令(variable-length instruction)壓縮,導致指令暫存器需要較大的空間、長跳轉(long jump)指令的個數變多,以及流程的執行效率下降。因此,需要一種指令壓縮方法、指令解壓縮方法及流程壓縮方法來減少指令暫存器所需的空間,以及減少長跳轉指令的個數。Generally speaking, a process (e.g., an image processing process, a startup process, etc.) usually includes at least one jump instruction. However, existing platforms cannot enable variable-length instruction compression at the same time when processing jump logic, resulting in a larger space required for the instruction register, an increase in the number of long jump instructions, and a decrease in the execution efficiency of the process. Therefore, an instruction compression method, an instruction decompression method, and a process compression method are needed to reduce the space required for the instruction register and reduce the number of long jump instructions.

鑑於先前技術之不足,本發明之一目的在於提供一種指令壓縮方法、指令解壓縮方法及流程壓縮方法,以改善先前技術的不足。In view of the deficiencies of the prior art, one object of the present invention is to provide an instruction compression method, an instruction decompression method and a process compression method to improve the deficiencies of the prior art.

本發明之一實施例提供一種指令解壓縮方法,應用於一硬體電路,該硬體電路解壓縮一指令並執行該指令,該指令包含一標頭,該標頭包含一參考值,該方法包含:當該指令的該參考值係一預設值時,讀取該指令的一第一參數以取得一相異參數個數;以及,以該指令的複數個第二參數設定該硬體電路之複數個相對應的參數,該些第二參數的個數等於該相異參數個數。An embodiment of the present invention provides an instruction decompression method, which is applied to a hardware circuit. The hardware circuit decompresses an instruction and executes the instruction. The instruction includes a header, and the header includes a reference value. The method includes: when the reference value of the instruction is a default value, reading a first parameter of the instruction to obtain a number of different parameters; and setting a plurality of corresponding parameters of the hardware circuit with a plurality of second parameters of the instruction, and the number of the second parameters is equal to the number of different parameters.

本發明之另一實施例提供一種指令壓縮方法,用來壓縮一指令以產生一壓縮後的指令,該指令包含一標頭及複數個參數,該標頭包含一參考值,該方法包含:比較該指令與一前一指令,以找出該指令中與該前一指令不同的複數個相異參數;將該壓縮後的指令的該參考值設為一預設值;將該壓縮後的指令的一目標參數設為該些相異參數的個數;以及,將該壓縮後的指令的其他參數設為該些相異參數。Another embodiment of the present invention provides an instruction compression method for compressing an instruction to generate a compressed instruction, wherein the instruction includes a header and a plurality of parameters, wherein the header includes a reference value, and the method includes: comparing the instruction with a previous instruction to find a plurality of different parameters in the instruction that are different from those in the previous instruction; setting the reference value of the compressed instruction to a default value; setting a target parameter of the compressed instruction to the number of the different parameters; and setting other parameters of the compressed instruction to the different parameters.

本發明之另一實施例提供一種流程壓縮方法,用來壓縮一流程,該流程包含一跳轉指令,該方法包含:根據該跳轉指令在該流程中的一位置及該跳轉指令的一目的地,將該流程劃分為複數個區塊;記錄該些區塊之間的一跳轉關係;對該些區塊進行指令壓縮;根據該跳轉關係重新計算該跳轉指令之一跳轉地址;根據該些區塊的大小及該跳轉關係決定複數個群組;以及,根據該跳轉指令與該些群組的關係決定該跳轉指令係一第一種類的跳轉指令或一第二種類的跳轉指令。Another embodiment of the present invention provides a process compression method for compressing a process, wherein the process includes a jump instruction, and the method includes: dividing the process into a plurality of blocks according to a position of the jump instruction in the process and a destination of the jump instruction; recording a jump relationship between the blocks; performing instruction compression on the blocks; recalculating a jump address of the jump instruction according to the jump relationship; determining a plurality of groups according to the sizes of the blocks and the jump relationship; and determining whether the jump instruction is a first type of jump instruction or a second type of jump instruction according to the relationship between the jump instruction and the groups.

本發明之實施例所體現的技術手段可以改善先前技術之缺點的至少其中之一,因此本發明相較於先前技術可以減少指令暫存器所需的空間及/或減少長跳轉指令的個數。The technical means embodied in the embodiments of the present invention can improve at least one of the shortcomings of the prior art. Therefore, compared with the prior art, the present invention can reduce the space required for the instruction register and/or reduce the number of long jump instructions.

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

以下說明內容之技術用語係參照本技術領域之習慣用語,如本說明書對部分用語有加以說明或定義,該部分用語之解釋係以本說明書之說明或定義為準。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 an instruction compression method, an instruction decompression method, and a process compression method. Since some of the components included in the intelligent processor of the present invention may be known components individually, the details of the known components will be omitted in the following description without affecting the full disclosure and feasibility of the device invention. In addition, part or all of the processes of the instruction compression method, instruction decompression method, and process compression method of the present invention may be in the form of software and/or firmware.

圖1是本發明智能處理器(Intelligent Processing Unit, IPU)之一實施例的功能方塊圖。智能處理器100包含解碼器110、直接記憶體存取120(direct memory access, DMA)、向量電路130及卷積電路140。直接記憶體存取120、向量電路130及卷積電路140各包含指令解壓縮電路122、132、142及計算電路124、134、144。指令解壓縮電路122、132及142用來解壓縮指令(解壓縮指令的細節將於後面配合圖13詳述),而計算電路124、134及144分別執行直接記憶體存取120、向量電路130及卷積電路140的主要功能。由於本技術領域具有通常知識者知悉直接記憶體存取120、向量電路130及卷積電路140的主要功能,故不再贅述。FIG1 is a functional block diagram of an embodiment of an intelligent processing unit (IPU) of the present invention. The intelligent processing unit 100 includes a decoder 110, a direct memory access (DMA) 120, a vector circuit 130, and a convolution circuit 140. The direct memory access 120, the vector circuit 130, and the convolution circuit 140 each include an instruction decompression circuit 122, 132, 142 and a calculation circuit 124, 134, 144. The instruction decompression circuits 122, 132 and 142 are used to decompress instructions (decompression instructions will be described in detail later with reference to FIG. 13), and the calculation circuits 124, 134 and 144 respectively perform the main functions of the direct memory access 120, the vector circuit 130 and the convolution circuit 140. Since the main functions of the direct memory access 120, the vector circuit 130 and the convolution circuit 140 are known to those skilled in the art, they will not be described in detail.

解碼器110包含記憶體112(例如,靜態隨機存取記憶體(Static Random Access Memory, SRAM))、指令預擷取(prefetch)電路114、指令分發(delivery)電路116及跳轉邏輯電路118。記憶體112可以儲存智能處理器100將要執行的指令。指令預擷取電路114用來從記憶體112中取得指令,然後指令分發電路116根據指令的旗標InstFlag(請參閱圖7)將該指令分發給對應的硬體電路(即,直接記憶體存取120、向量電路130或卷積電路140)。跳轉邏輯電路118則用來判斷該指令是否為跳轉指令及/或跳轉指令的種類(長跳轉指令或短跳轉(short jump)指令)。遇到跳轉指令時,跳轉邏輯電路118判斷跳轉指令的目的地,然後指令預擷取電路114再根據該目的地取得下一個指令。The decoder 110 includes a memory 112 (e.g., a static random access memory (SRAM)), an instruction prefetch circuit 114, an instruction delivery circuit 116, and a jump logic circuit 118. The memory 112 can store instructions to be executed by the intelligent processor 100. The instruction prefetch circuit 114 is used to obtain instructions from the memory 112, and then the instruction delivery circuit 116 delivers the instruction to the corresponding hardware circuit (i.e., direct memory access 120, vector circuit 130, or convolution circuit 140) according to the flag InstFlag of the instruction (see FIG. 7). The jump logic circuit 118 is used to determine whether the instruction is a jump instruction and/or the type of the jump instruction (long jump instruction or short jump instruction). When encountering a jump instruction, the jump logic circuit 118 determines the destination of the jump instruction, and then the instruction pre-fetch circuit 114 obtains the next instruction based on the destination.

在一些實施例中,如果一個跳轉指令的目的地(即,目標指令在記憶體112中的地址)與該跳轉指令本身在記憶體112中的地址的差小於門檻值(例如,記憶體112之指令暫存區的大小),則該跳轉指令是短跳轉指令;反之,該跳轉指令是長跳轉指令。也就是說,短跳轉指令的跳轉範圍(jump range)小於長跳轉指令的跳轉範圍。解碼器110處理長跳轉指令時,需要直接記憶體存取120從智能處理器100的外部記憶體(例如,動態隨機存取記憶體(Dynamic Random Access Memory, DRAM),圖未示)取得更多的指令,而短跳轉指令則不需要;因此長跳轉指令比短跳轉指令更耗時及耗費系統資源。In some embodiments, if the difference between the destination of a jump instruction (i.e., the address of the target instruction in the memory 112) and the address of the jump instruction itself in the memory 112 is less than a threshold value (e.g., the size of the instruction buffer of the memory 112), the jump instruction is a short jump instruction; otherwise, the jump instruction is a long jump instruction. In other words, the jump range of the short jump instruction is smaller than the jump range of the long jump instruction. When the decoder 110 processes the long jump instruction, direct memory access 120 is required to obtain more instructions from the external memory of the intelligent processor 100 (e.g., dynamic random access memory (DRAM), not shown), while short jump instructions do not require it; therefore, long jump instructions are more time-consuming and consume system resources than short jump instructions.

圖2是本發明流程壓縮方法之一實施例的流程圖。在一些實施例中,圖2的步驟是在智能處理器100的開發階段由開發工具(例如,通用電腦)執行。圖2的流程壓縮方法可以用來壓縮某一流程(例如,影像處理流程、啟動流程等),且該流程包含多個指令(例如圖3之流程310包含指令INST1~指令INST15等15個指令,該些指令是變長指令,且其中至少一個指令是跳轉指令,圖3將於下方詳述)。圖2包含以下步驟。FIG. 2 is a flow chart of an embodiment of the process compression method of the present invention. In some embodiments, the steps of FIG. 2 are executed by a development tool (e.g., a general purpose computer) during the development stage of the intelligent processor 100. The process compression method of FIG. 2 can be used to compress a certain process (e.g., an image processing process, a startup process, etc.), and the process includes multiple instructions (e.g., process 310 of FIG. 3 includes 15 instructions such as instructions INST1 to INST15, which are variable-length instructions, and at least one of which is a jump instruction, FIG. 3 will be described in detail below). FIG. 2 includes the following steps.

步驟S210:根據跳轉指令在一個流程中的位置(例如,跳轉指令在記憶體112中的地址)及跳轉指令的目的地(例如,目的地在記憶體112中的地址),將該流程劃分為多個區塊。更明確地說,步驟S210掃描一個流程中的指令並設置區塊邊界BB以將該流程劃分成多個區塊。步驟S210的細節將在下方配合圖5詳述。在圖3的例子中,流程310被劃分成4個區塊(區塊BLK1~區塊BLK4,分別包含指令INST1~指令INST5、指令INST6~指令INST8、指令INST9~指令INST11以及指令INST12~指令INST15,其中指令INST5及指令INST11是跳轉指令,其目的地分別是指令INST9與指令INST6)。Step S210: Divide the flow into a plurality of blocks according to the position of the jump instruction in a flow (e.g., the address of the jump instruction in the memory 112) and the destination of the jump instruction (e.g., the address of the destination in the memory 112). More specifically, step S210 scans the instructions in a flow and sets the block boundary BB to divide the flow into a plurality of blocks. The details of step S210 will be described in detail below with reference to FIG. 5. In the example of FIG. 3 , the process 310 is divided into four blocks (blocks BLK1 to BLK4, respectively including instructions INST1 to INST5, instructions INST6 to INST8, instructions INST9 to INST11, and instructions INST12 to INST15, where instructions INST5 and INST11 are jump instructions, and their destinations are instructions INST9 and INST6, respectively).

步驟S220:記錄區塊間的跳轉關係。請參閱圖3,步驟S210結束後可得到區塊間的跳轉關係320:區塊BLK1的目標區塊是區塊BLK3(因為區塊BLK3包含指令INST5的目的地(即,指令INST9));區塊BLK2的來源區塊是區塊BLK3(因為區塊BLK2包含指令INST11的目的地(即,指令INST6));以及區塊BLK3的來源區塊與目標區塊分別是區塊BLK1與區塊BLK2。請參閱圖4,圖4是區塊間的跳轉關係的示意圖,對應到圖3的區塊間的跳轉關係320;換言之,區塊間的跳轉關係亦可用圖形的方式表示或記錄。Step S220: Record the jump relationship between blocks. Please refer to FIG. 3. After step S210 is completed, the jump relationship 320 between blocks can be obtained: the target block of block BLK1 is block BLK3 (because block BLK3 contains the destination of instruction INST5 (i.e., instruction INST9)); the source block of block BLK2 is block BLK3 (because block BLK2 contains the destination of instruction INST11 (i.e., instruction INST6)); and the source block and target block of block BLK3 are block BLK1 and block BLK2 respectively. Please refer to FIG. 4 , which is a schematic diagram of the jump relationship between blocks, corresponding to the jump relationship 320 between blocks in FIG. 3 ; in other words, the jump relationship between blocks can also be represented or recorded in a graphical manner.

步驟S230:逐區塊對該些區塊進行指令壓縮,以得到多個壓縮後的區塊。此步驟將於下方配合圖6詳述。Step S230: perform command compression on the blocks one by one to obtain a plurality of compressed blocks. This step will be described in detail below with reference to FIG. 6 .

步驟S240:根據區塊之間的跳轉關係重新計算跳轉地址(jump address,即跳轉指令的目的地地址)。因為區塊在步驟S230中已被壓縮,所以壓縮後跳轉指令的目的地的地址已非原本的地址,所以必須重新計算或更新跳轉地址。舉例來說,請參閱圖3,由於壓縮後幾乎每個區塊都變小,所以指令INST9與指令INST6的位置改變,因此必須順應更新或調整指令INST5與指令INST11的目的地的地址。Step S240: Recalculate the jump address (i.e., the destination address of the jump instruction) according to the jump relationship between the blocks. Because the block has been compressed in step S230, the destination address of the jump instruction after compression is no longer the original address, so the jump address must be recalculated or updated. For example, please refer to Figure 3. Since almost every block becomes smaller after compression, the positions of instruction INST9 and instruction INST6 are changed, so the destination addresses of instruction INST5 and instruction INST11 must be updated or adjusted accordingly.

步驟S250:根據區塊大小及跳轉關係決定群組。此步驟的目的是將多個區塊劃分成多個群組。步驟S250的細節將在下方配合圖8~圖9說明。Step S250: Determine the group according to the block size and jump relationship. The purpose of this step is to divide multiple blocks into multiple groups. The details of step S250 will be explained below in conjunction with Figures 8 and 9.

步驟S260:根據跳轉指令與群組的關係決定跳轉指令是第一種類的跳轉指令(例如,短跳轉指令)或第二種類的跳轉指令(例如,長跳轉指令)。藉由將區塊劃分成多個群組,本發明可以更正確地劃分短跳轉指令與長跳轉指令,以避免執行流程的期間發生錯誤。步驟S260將於下方配合圖11說明。Step S260: Determine whether the jump instruction is a first type of jump instruction (e.g., a short jump instruction) or a second type of jump instruction (e.g., a long jump instruction) based on the relationship between the jump instruction and the group. By dividing the blocks into a plurality of groups, the present invention can more accurately divide the short jump instructions and the long jump instructions to avoid errors during the execution of the process. Step S260 will be described below in conjunction with FIG. 11.

圖5是步驟S210的細節,包含步驟S510~步驟S550。以下的說明請同時參閱圖3及圖4。FIG5 is a detailed diagram of step S210, including steps S510 to S550. Please refer to FIG3 and FIG4 for the following description.

步驟S510:讀取一條指令。Step S510: Read an instruction.

步驟S520:判斷該條指令是否為跳轉指令或跳轉指令的目的地。如果不是,則執行步驟S510以讀取下一條指令;如果是,則執行步驟S530。Step S520: Determine whether the instruction is a jump instruction or a destination of a jump instruction. If not, execute step S510 to read the next instruction; if yes, execute step S530.

步驟S530:設定區塊邊界BB以決定區塊。更明確地說,如果該指令是跳轉指令,則步驟S530在該指令之後設定區塊邊界BB(例如,圖3之指令INST5與指令INST6之間以及指令INST11與指令INST12之間);如果該指令是跳轉指令的目的地,則步驟S530在該指令之前設定區塊邊界BB(例如,圖3之指令INST5與指令INST6之間以及指令INST8與指令INST9之間)。Step S530: Set block boundary BB to determine the block. More specifically, if the instruction is a jump instruction, step S530 sets block boundary BB after the instruction (e.g., between instruction INST5 and instruction INST6 and between instruction INST11 and instruction INST12 in FIG. 3 ); if the instruction is the destination of a jump instruction, step S530 sets block boundary BB before the instruction (e.g., between instruction INST5 and instruction INST6 and between instruction INST8 and instruction INST9 in FIG. 3 ).

步驟S540:判斷流程中是否仍有待處理的指令。如果是,則執行步驟S510以讀取下一條指令;如果否,則執行步驟S550。Step S540: Determine whether there are still instructions to be processed in the process. If yes, execute step S510 to read the next instruction; if not, execute step S550.

步驟S550:設定區塊邊界BB然後結束。Step S550: Set block boundary BB and then end.

以圖3為例,圖5的方法會在指令INST5處將流程310劃分開(即,設置區塊邊界BB),以產生區塊BLK1。類似地,因為指令INST9及指令INST11分別是目的地與跳轉指令,所以指令INST9之前及指令INST11之後會被設置區塊邊界BB,因此分別產生區塊BLK2及區塊BLK3。流程310的結尾亦會被設置區塊邊界BB,以產生區塊BLK4。Taking FIG. 3 as an example, the method of FIG. 5 divides the process 310 at instruction INST5 (i.e., sets block boundary BB) to generate block BLK1. Similarly, since instruction INST9 and instruction INST11 are destination and jump instructions respectively, block boundary BB will be set before instruction INST9 and after instruction INST11, thereby generating blocks BLK2 and BLK3 respectively. Block boundary BB will also be set at the end of the process 310 to generate block BLK4.

圖6是本發明指令壓縮方法之一實施例的流程圖。圖7是壓縮前的指令結構及壓縮後的指令結構的示意圖。如圖7所示,指令INST_k-1與指令INST_k是未經壓縮的指令(兩者是連續的指令,且指令INST_k-1在指令INST_k之前)。指令INST_k-1、指令INST_k及壓縮後的指令INST_k'皆包含標頭HD及至少一個參數(例如,指令INST_k-1與指令INST_k各包含n個參數P1~Pn,而壓縮後的指令INST_k'包含1個參數P1')。在一些實施例中,標頭HD及每個參數的大小皆為一個字組(word)。標頭HD包含旗標InstFlag及參考值HDLen。旗標InstFlag記錄該指令所屬的硬體電路。對未經壓縮的指令而言,參考值HDLen記錄參數個數(例如,指令INST_k-1及指令INST_k的參考值HDLen為n);對壓縮後的指令INST_k'而言,參考值HDLen為預設值(例如0)。圖6的壓縮方法是以區塊為單位,包含以下步驟。FIG6 is a flow chart of an embodiment of the instruction compression method of the present invention. FIG7 is a schematic diagram of the instruction structure before compression and the instruction structure after compression. As shown in FIG7, instruction INST_k-1 and instruction INST_k are uncompressed instructions (the two are consecutive instructions, and instruction INST_k-1 is before instruction INST_k). Instruction INST_k-1, instruction INST_k, and the compressed instruction INST_k' all include a header HD and at least one parameter (for example, instruction INST_k-1 and instruction INST_k each include n parameters P1~Pn, and the compressed instruction INST_k' includes 1 parameter P1'). In some embodiments, the size of the header HD and each parameter is a word. The header HD includes a flag InstFlag and a reference value HDLen. The flag InstFlag records the hardware circuit to which the instruction belongs. For uncompressed instructions, the reference value HDLen records the number of parameters (for example, the reference value HDLen of instruction INST_k-1 and instruction INST_k is n); for compressed instruction INST_k', the reference value HDLen is a default value (for example, 0). The compression method of Figure 6 is based on blocks and includes the following steps.

步驟S610:讀取一區塊的一條指令。Step S610: Read an instruction of a block.

步驟S620:判斷該條指令是否為該區塊的第一條指令。如果是,則執行步驟S610以讀取該區塊的下一條指令;如果否,則執行步驟S630。一個區塊的第一條指令不進行壓縮(因為沒有先前的指令作為參考)。Step S620: Determine whether the instruction is the first instruction of the block. If yes, execute step S610 to read the next instruction of the block; if no, execute step S630. The first instruction of a block is not compressed (because there is no previous instruction as a reference).

步驟S630:比較該指令與前一指令,以找出該指令中不同於前一指令的相異參數。以圖7為例,因為指令INST_k-1的參數P2~參數Pn分別等於指令INST_k的參數P2~參數Pn,而只有參數P1不等於參數P1',所以步驟S630找到的相異參數為參數P1'。Step S630: Compare the instruction with the previous instruction to find out the different parameters in the instruction that are different from the previous instruction. Taking FIG. 7 as an example, since the parameters P2 to Pn of the instruction INST_k-1 are respectively equal to the parameters P2 to Pn of the instruction INST_k, and only the parameter P1 is not equal to the parameter P1', the different parameter found in step S630 is the parameter P1'.

步驟S640:將壓縮後的指令的標頭HD的參考值HDLen設為預設值,目的在於標記壓縮後的指令。Step S640: Setting the reference value HDLen of the header HD of the compressed command to a default value, in order to mark the compressed command.

步驟S650:將壓縮後的指令的第一參數設為相異參數個數Nd。以圖7為例,因為指令INST_k-1與指令INST_k之間的相異參數個數Nd為1,所以此步驟將壓縮後的指令INST_k'的第一參數設為1(即,「Len=1」)。Step S650: Set the first parameter of the compressed instruction to the number of different parameters Nd. Taking FIG. 7 as an example, since the number of different parameters Nd between instruction INST_k-1 and instruction INST_k is 1, this step sets the first parameter of the compressed instruction INST_k' to 1 (ie, "Len=1").

步驟S660:將壓縮後的指令的其他參數設為該或該些相異參數。此步驟將壓縮後的指令INST_k'的第2~第x個(x=1+Nd)參數設為步驟S630所得到的相異參數。以圖7為例,因為指令INST_k-1與指令INST_k之間的相異參數只有參數P1'(即,相異參數個數Nd為1),所以此步驟將壓縮後的指令INST_k'的第二參數設為參數P1'。步驟S660結束後便可得到壓縮後的指令INST_k'。Step S660: Set the other parameters of the compressed instruction to the one or more different parameters. In this step, the 2nd to xth (x=1+Nd) parameters of the compressed instruction INST_k' are set to the different parameters obtained in step S630. Taking Figure 7 as an example, since the only different parameter between instruction INST_k-1 and instruction INST_k is parameter P1' (i.e., the number of different parameters Nd is 1), this step sets the second parameter of the compressed instruction INST_k' to parameter P1'. After step S660 is completed, the compressed instruction INST_k' can be obtained.

步驟S670:判斷該區塊是否還有待處理的指令。如果是,則執行步驟S610以讀取該區塊的下一條指令;如果否,則結束圖6的方法(步驟S680)。Step S670: Determine whether there are instructions to be processed in the block. If yes, execute step S610 to read the next instruction in the block; if no, end the method of FIG. 6 (step S680).

圖8及圖9是圖2之步驟S250之一實施例的細節。步驟S250包含兩個主要步驟:先根據區塊大小決定群組(圖8),再根據跳轉關係調整群組(圖9)。以下的說明請一併參閱圖10A及圖10B,圖10A及圖10B是本發明將流程之多個區塊劃分成多個群組之一實施例的示意圖,對應到圖3之流程310。圖8包含以下步驟。FIG8 and FIG9 are details of an embodiment of step S250 of FIG2. Step S250 includes two main steps: first, determine the group according to the block size (FIG8), and then adjust the group according to the jump relationship (FIG9). Please refer to FIG10A and FIG10B for the following description. FIG10A and FIG10B are schematic diagrams of an embodiment of the present invention that divides multiple blocks of the process into multiple groups, corresponding to the process 310 of FIG3. FIG8 includes the following steps.

步驟S810:選取一區塊,並根據該區塊的大小更新當前群組的大小。群組的大小為其所包含的所有區塊的大小的總和。此步驟是將當前群組的大小加上該區塊的大小來更新當前群組的大小。以圖10A為例,假設當前群組只包含區塊BLK1,則選取的區塊為區塊BLK2,且更新後的當前群組的大小為區塊BLK1的大小與區塊BLK2的大小的總和。Step S810: Select a block and update the size of the current group according to the size of the block. The size of a group is the sum of the sizes of all the blocks it contains. This step is to update the size of the current group by adding the size of the block to the size of the current group. Taking Figure 10A as an example, assuming that the current group only contains block BLK1, the selected block is block BLK2, and the size of the current group after update is the sum of the size of block BLK1 and the size of block BLK2.

步驟S820:判斷當前群組的大小是否大於門檻值。在一些實施例中,門檻值可以是記憶體112之指令暫存區的大小。如果步驟S820的判斷結果為否,則執行步驟S830;否則,執行步驟S840及步驟S850。Step S820: Determine whether the size of the current group is greater than a threshold value. In some embodiments, the threshold value may be the size of the instruction buffer of the memory 112. If the determination result of step S820 is no, then execute step S830; otherwise, execute step S840 and step S850.

步驟S830:將該區塊設為當前群組的一部分。步驟S820的判斷結果為否代表將選取的區塊加入當前群組不會使當前群組過大(大於門檻值),所以步驟S830便將該區塊設為當前群組的一部分。承上例,假設區塊BLK1的大小與區塊BLK2的大小的總和沒有超過門檻值SR,則在此步驟中區塊BLK2被設為與區塊BLK1同一群組。Step S830: Set the block as part of the current group. If the judgment result of step S820 is no, it means that adding the selected block to the current group will not make the current group too large (greater than the threshold value), so step S830 sets the block as part of the current group. Continuing with the above example, assuming that the sum of the size of block BLK1 and the size of block BLK2 does not exceed the threshold value SR, then in this step, block BLK2 is set to the same group as block BLK1.

步驟S840:將該區塊設為新的群組的一部分。步驟S820的判斷結果為是代表將選取的區塊加入當前群組會使當前群組過大(大於門檻值),所以步驟S840便確定當前群組(即,設定群組邊界GB),然後將選取的區塊設為新的群組的一部分(此時新的群組只包含該區塊)。以圖10A為例,當選取的區塊是區塊BLK3時,在步驟S840中會先設定群組邊界GB(即,確定群組GRP1),然後建立群組GRP2(此時群組GRP2僅包含區塊BLK3且尚未確定)。Step S840: Set the block as part of the new group. The judgment result of step S820 is that adding the selected block to the current group will make the current group too large (greater than the threshold value), so step S840 determines the current group (i.e., sets the group boundary GB), and then sets the selected block as part of the new group (at this time, the new group only includes the block). Taking Figure 10A as an example, when the selected block is block BLK3, in step S840, the group boundary GB will be set first (i.e., group GRP1 will be determined), and then group GRP2 will be established (at this time, group GRP2 only includes block BLK3 and has not yet been determined).

步驟S850:將新的群組的大小設為該區塊的大小。承上例,因為此時群組GRP2只包含區塊BLK3所以新的群組的大小等於區塊BLK3的大小。需注意的是,新的組群在下一回合(即,再次執行步驟S810時)成為該回合的當前群組。Step S850: Set the size of the new group to the size of the block. In the above example, since group GRP2 only contains block BLK3, the size of the new group is equal to the size of block BLK3. It should be noted that the new group becomes the current group in the next round (i.e., when step S810 is executed again).

步驟S860:判斷是否仍有待處理的區塊。如果是,則執行步驟S810以選取下一個區塊;如果否,則執行步驟S870。Step S860: Determine whether there are still blocks to be processed. If yes, execute step S810 to select the next block; if no, execute step S870.

步驟S870:設定群組邊界,然後結束。以圖10A為例,當選取的區塊是區塊BLK4時,步驟S860的判斷為否,然後步驟S870在區塊BLK4之後設定群組邊界GB以確定群組GRP2。Step S870: Set the group boundary, and then end. Taking FIG. 10A as an example, when the selected block is block BLK4, the judgment of step S860 is no, and then step S870 sets the group boundary GB after block BLK4 to determine group GRP2.

請參考圖10A,圖8的方法結束後,圖4的4個區塊被劃分成2個群組。然而,因為群組GRP1的中間(即,一個群組的第一個區塊與最後一個區塊之間)有跳轉指令的目的地(即,指令INST11的目的地是區塊BLK2),這會造成流程於執行時發生跳轉錯誤,所以必須進一步根據圖9的方法調整群組。圖9包含以下步驟。Please refer to FIG10A. After the method of FIG8 is completed, the four blocks of FIG4 are divided into two groups. However, because there is a destination of a jump instruction in the middle of group GRP1 (i.e., between the first block and the last block of a group) (i.e., the destination of instruction INST11 is block BLK2), this will cause a jump error during execution of the process, so the group must be further adjusted according to the method of FIG9. FIG9 includes the following steps.

步驟S910:選取一群組。Step S910: Select a group.

步驟S920:選取該群組的一區塊。Step S920: Select a block of the group.

步驟S930:判斷以下的條件是否成立:該區塊非該群組的第一個區塊,且該區塊是其他群組的跳轉指令的目的地。以圖10A為例,如果步驟S910及步驟S920分別選取群組GRP1及區塊BLK1,則步驟S830的判斷結果為否(因為區塊BLK1是群組GRP1的第一個區塊);如果步驟S910及步驟S920分別選取群組GRP1及區塊BLK2,則步驟S830的判斷結果為是(因為區塊BLK2不是群組GRP1的第一個區塊,而且是指令INST11的目的地)。Step S930: Determine whether the following conditions are met: the block is not the first block of the group, and the block is the destination of the jump instruction of other groups. Taking Figure 10A as an example, if step S910 and step S920 select group GRP1 and block BLK1 respectively, the judgment result of step S830 is no (because block BLK1 is the first block of group GRP1); if step S910 and step S920 select group GRP1 and block BLK2 respectively, the judgment result of step S830 is yes (because block BLK2 is not the first block of group GRP1 and is the destination of instruction INST11).

步驟S940:判斷該群組是否仍有待處理的區塊。如果是,則執行步驟S920以選取該群組的下一個區塊;否則,執行步驟S960。Step S940: Determine whether the group still has blocks to be processed. If yes, execute step S920 to select the next block of the group; otherwise, execute step S960.

步驟S950:設定群組邊界GB,即,將當前群組劃分為2個群組。以圖10A及圖10B為例,步驟S950在區塊BLK2之前(即,指令INST11的目的地)設定群組邊界GB,使得原本的群組GRP1變成群組GRP1及群組GRP3。Step S950: Set the group boundary GB, that is, divide the current group into two groups. Taking Figures 10A and 10B as an example, step S950 sets the group boundary GB before block BLK2 (that is, the destination of instruction INST11), so that the original group GRP1 becomes group GRP1 and group GRP3.

步驟S960:判斷是否仍有待處理的群組。如果是,則執行步驟S910以選取下一個群組;如果否,則結束圖9的方法(步驟S970)。Step S960: Determine whether there are still groups to be processed. If yes, execute step S910 to select the next group; if no, end the method of FIG. 9 (step S970).

圖11是圖2之步驟S260之一實施例的細節,包含以下步驟。FIG. 11 is a detailed diagram of an implementation example of step S260 of FIG. 2 , including the following steps.

步驟S1110:選取一跳轉指令。以圖10B為例,此步驟會選取指令INST5或指令INST11。Step S1110: Select a jump instruction. Taking FIG. 10B as an example, this step will select instruction INST5 or instruction INST11.

步驟S1120:判斷該跳轉指令之目的地是否位於該跳轉指令所屬之群組內。以圖10B為例,對指令INST5而言,因為其目的地(區塊BLK3)不是在指令INST5所屬之群組(即,群組GRP1)內,所以步驟S1120的判斷結果為否。同理,對指令INST11而言步驟S1120的判斷結果亦為否。Step S1120: Determine whether the destination of the jump instruction is in the group to which the jump instruction belongs. Taking FIG. 10B as an example, for instruction INST5, since its destination (block BLK3) is not in the group to which instruction INST5 belongs (i.e., group GRP1), the determination result of step S1120 is no. Similarly, for instruction INST11, the determination result of step S1120 is also no.

步驟S1130:將該跳轉指令設為長跳轉指令。Step S1130: Set the jump instruction as a long jump instruction.

步驟S1140:將該跳轉指令設為短跳轉指令。Step S1140: Set the jump instruction as a short jump instruction.

步驟S1150:判斷是否仍有跳轉指令。如果是,則執行步驟S1110以選取下一個跳轉指令;如果否,則結束圖11的方法(步驟S1160)。Step S1150: Determine whether there are still jump instructions. If yes, execute step S1110 to select the next jump instruction; if no, end the method of FIG. 11 (step S1160).

在圖10B的例子中,指令INST5及指令INST11都是群組間跳轉指令(長跳轉指令)。請參閱圖12,圖12是本發明劃分群組之另一實施例的示意圖。如圖12所示,群組GRP1包含區塊BLK1、區塊BLK2及區塊BLK3,而群組GRP2只包含區塊BLK4。由於跳轉指令INST_n在群組GRP1中而且其目的地(區塊BLK3)也在群組GRP1中,所以跳轉指令INST_n是一個群組內跳轉指令;因此,跳轉指令INST_n會在圖11的方法中被判斷為短跳轉指令(即,步驟S1120判斷為是)。In the example of FIG. 10B , instruction INST5 and instruction INST11 are both inter-group jump instructions (long jump instructions). Please refer to FIG. 12 , which is a schematic diagram of another embodiment of the present invention for dividing groups. As shown in FIG. 12 , group GRP1 includes block BLK1, block BLK2, and block BLK3, while group GRP2 only includes block BLK4. Since the jump instruction INST_n is in group GRP1 and its destination (block BLK3) is also in group GRP1, the jump instruction INST_n is an intra-group jump instruction; therefore, the jump instruction INST_n will be judged as a short jump instruction in the method of FIG. 11 (i.e., step S1120 is judged as yes).

圖13是本發明指令解壓縮方法之一實施例的流程圖。圖13由圖1之硬體電路(即,直接記憶體存取120、向量電路130或卷積電路140)的指令解壓縮電路(即,指令解壓縮電路122、指令解壓縮電路132或指令解壓縮電路142)執行,圖13包含以下步驟。FIG13 is a flow chart of an embodiment of the instruction decompression method of the present invention. FIG13 is executed by the instruction decompression circuit (i.e., the instruction decompression circuit 122, the instruction decompression circuit 132, or the instruction decompression circuit 142) of the hardware circuit (i.e., the direct memory access 120, the vector circuit 130, or the convolution circuit 140) of FIG1, and FIG13 includes the following steps.

步驟S1310:讀取或接收一條指令,例如,從記憶體讀取一條指令,或是接收指令分發電路116所分發的指令。Step S1310: Read or receive an instruction, for example, read an instruction from the memory, or receive an instruction distributed by the instruction distribution circuit 116.

步驟S1320:判斷該指令的標頭HD的參考值HDLen是否為預設值。如果否(代表該指令不是壓縮後的指令),則執行步驟S1330;如果是(代表該指令是壓縮後的指令),則執行步驟S1340及步驟S1350。Step S1320: Determine whether the reference value HDLen of the header HD of the instruction is a default value. If not (indicating that the instruction is not a compressed instruction), execute step S1330; if yes (indicating that the instruction is a compressed instruction), execute steps S1340 and S1350.

步驟S1330:以該指令的所有參數設定硬體電路的相對應的參數(例如,設定暫存器的暫存值)。請參閱圖14,圖14是本發明的硬體電路執行未經壓縮的指令的示意圖。假設執行未經壓縮的指令INST_y(包含P1'、P2'、P3'、P4'及P5'等5個參數)之前,硬體電路的暫存器群組REGP儲存P1、P2、P3、P4及P5等5個參數(分別為暫存器REG1、暫存器REG2、暫存器REG3、暫存器REG4及暫存器REG5的暫存值),則於硬體電路執行指令INST_y之後,暫存器群組REGP儲存指令INST_y的該5個參數(如圖14右邊的暫存器群組REGP所示)。也就是說,步驟S1330的目的在於以指令INST_y的參數設定硬體電路的參數,硬體電路的參數設定完成後,硬體電路(更明確地說,硬體電路的計算電路)即可執行該指令(步驟S1360)。Step S1330: Set the corresponding parameters of the hardware circuit with all the parameters of the instruction (for example, set the temporary value of the register). Please refer to Figure 14, which is a schematic diagram of the hardware circuit of the present invention executing an uncompressed instruction. Assume that before executing the uncompressed instruction INST_y (including five parameters P1', P2', P3', P4' and P5'), the register group REGP of the hardware circuit stores five parameters P1, P2, P3, P4 and P5 (respectively the register values of register REG1, register REG2, register REG3, register REG4 and register REG5), then after the hardware circuit executes the instruction INST_y, the register group REGP stores the five parameters of the instruction INST_y (as shown in the register group REGP on the right side of Figure 14). That is, the purpose of step S1330 is to set the parameters of the hardware circuit with the parameters of instruction INST_y. After the parameters of the hardware circuit are set, the hardware circuit (more specifically, the computing circuit of the hardware circuit) can execute the instruction (step S1360).

步驟S1340:讀取該指令的第一參數以取得相異參數個數Nd。請參閱圖15,圖15是本發明的硬體電路執行壓縮指令的示意圖。圖15中的指令INST_z是壓縮後的指令,其相異參數個數Nd為2(即,「Len=2」)。Step S1340: Read the first parameter of the instruction to obtain the number of different parameters Nd. Please refer to Figure 15, which is a schematic diagram of the hardware circuit of the present invention executing the compression instruction. The instruction INST_z in Figure 15 is a compressed instruction, and its number of different parameters Nd is 2 (ie, "Len=2").

步驟S1350:以該指令的第2至第Nd+1個參數設定硬體電路的相對應的參數(例如,設定暫存器的暫存值)。在圖15的例子中,指令解壓縮電路根據相異參數個數Nd取得壓縮後的指令INST_z的參數P1'及參數P2',然後以參數P1'及參數P2'分別設定暫存器REG1及暫存器REG2。步驟S1350的目的在於以壓縮後的指令INST_z的參數設定硬體電路的參數,硬體電路的參數設定完成後,硬體電路即可執行該指令(步驟S1360)。Step S1350: Set the corresponding parameters of the hardware circuit with the 2nd to Nd+1th parameters of the instruction (for example, set the temporary value of the register). In the example of FIG. 15 , the instruction decompression circuit obtains the parameters P1' and P2' of the compressed instruction INST_z according to the number of different parameters Nd, and then sets the register REG1 and the register REG2 with the parameters P1' and P2' respectively. The purpose of step S1350 is to set the parameters of the hardware circuit with the parameters of the compressed instruction INST_z. After the parameters of the hardware circuit are set, the hardware circuit can execute the instruction (step S1360).

綜上所述,本發明藉由對指令進行壓縮來減少指令暫存器所需的空間(即,減少記憶體112的大小),以節省成本。此外,因為對指令進行壓縮,所以本發明還可以減少長跳轉指令的個數,以提升流程的執行效率。In summary, the present invention reduces the space required for the instruction register (i.e., reduces the size of the memory 112) by compressing the instructions to save costs. In addition, because the instructions are compressed, the present invention can also reduce the number of long jump instructions to improve the execution efficiency of the process.

前揭實施例雖以變長指令及智能處理器為例,然此並非對本發明之限制,本技術領域人士可依本發明之揭露適當地將本發明應用於其它類型的指令及控制電路。Although the above-mentioned embodiments are based on variable-length instructions and intelligent processors, this is not a limitation of the present invention. Those skilled in the art can appropriately apply the present invention to other types of instructions and control circuits based on the disclosure of the present invention.

雖然本發明之實施例如上所述,然而該些實施例並非用來限定本發明,本技術領域具有通常知識者可依據本發明之明示或隱含之內容對本發明之技術特徵施以變化,凡此種種變化均可能屬於本發明所尋求之專利保護範疇,換言之,本發明之專利保護範圍須視本說明書之申請專利範圍所界定者為準。Although the embodiments of the present invention are described above, these embodiments are not intended to limit the present invention. A person having ordinary knowledge in the technical field may modify the technical features of the present invention according to the explicit or implicit contents of the present invention. All such modifications 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.

100:智能處理器 110:解碼器 112:記憶體 114:指令預擷取電路 116:指令分發電路 118:跳轉邏輯電路 120:直接記憶體存取(DMA) 130:向量電路 140:卷積電路 122,132,142:指令解壓縮電路 124,134,144:計算電路 310:流程 INST1~INST15,INST_k-1,INST_k,INST_y:指令 320:區塊間的跳轉關係 BB:區塊邊界 BLK1,BLK2,BLK3,BLK4:區塊 INST_k',INST_z:壓縮後的指令 HD:標頭 InstFlag:旗標 HDLen:參考值 P1,P2,P3,P4,P5,Pn,P1',P2',P3',P4',P5':參數 Nd:相異參數個數 SR:門檻值 GB:群組邊界 GRP1,GRP2,GRP3:群組 INST_n:跳轉指令 REGP:暫存器群組 REG1,REG2,REG3,REG4,REG5:暫存器 S210,S220,S230,S240,S250,S260,S510,S520,S530,S540,S550,S610,S620,S630,S640,S650,S660,S670,S680,S810,S820,S830,S840,S850,S860,S870,S910,S920,S930,S940,S950,S960,S970,S1110,S1120,S1130,S1140,S1150,S1160,S1310,S1320,S1330,S1340,S1350,S1360:步驟 100: Intelligent processor 110: Decoder 112: Memory 114: Instruction pre-fetch circuit 116: Instruction dispatch circuit 118: Jump logic circuit 120: Direct memory access (DMA) 130: Vector circuit 140: Convolution circuit 122,132,142: Instruction decompression circuit 124,134,144: Calculation circuit 310: Process INST1~INST15,INST_k-1,INST_k,INST_y: Instruction 320: Jump relationship between blocks BB: Block boundary BLK1,BLK2,BLK3,BLK4: Block INST_k',INST_z:Compressed instruction HD:Header InstFlag:Flag HDLen:Reference value P1,P2,P3,P4,P5,Pn,P1',P2',P3',P4',P5':Parameter Nd:Number of different parameters SR:Threshold value GB:Group boundary GRP1,GRP2,GRP3:Group INST_n:Jump instruction REGP:Register group REG1,REG2,REG3,REG4,REG5:Register S210,S220,S230,S240,S250,S260,S510,S520,S530,S540,S550,S610,S620,S630,S640,S650,S660,S670,S680,S810,S820,S830,S840,S850,S860,S870,S910,S920,S930,S940,S950,S960,S970,S1110,S1120,S1130,S1140,S1150,S1160,S1310,S1320,S1330,S1340,S1350,S1360: Steps

圖1是本發明智能處理器之一實施例的功能方塊圖; 圖2是本發明流程壓縮方法之一實施例的流程圖; 圖3顯示一個包含多個指令的流程,以及該流程的區塊間的跳轉關係; 圖4是區塊間的跳轉關係的示意圖; 圖5是圖2之步驟S210之一實施例的細節; 圖6是本發明指令壓縮方法之一實施例的流程圖; 圖7是壓縮前的指令結構及壓縮後的指令結構的示意圖; 圖8及圖9是圖2之步驟S250之一實施例的細節; 圖10A及圖10B是本發明將流程之多個區塊劃分成多個群組之一實施例的示意圖; 圖11是圖2之步驟S260之一實施例的細節; 圖12是本發明劃分群組之另一實施例的示意圖; 圖13是本發明指令解壓縮方法之一實施例的流程圖; 圖14是本發明的硬體電路執行未經壓縮的指令的示意圖;以及 圖15是本發明的硬體電路執行壓縮指令的示意圖。 FIG1 is a functional block diagram of an embodiment of the intelligent processor of the present invention; FIG2 is a flow chart of an embodiment of the process compression method of the present invention; FIG3 shows a process including multiple instructions and the jump relationship between blocks of the process; FIG4 is a schematic diagram of the jump relationship between blocks; FIG5 is a detail of an embodiment of step S210 of FIG2; FIG6 is a flow chart of an embodiment of the instruction compression method of the present invention; FIG7 is a schematic diagram of the instruction structure before compression and the instruction structure after compression; FIG8 and FIG9 are details of an embodiment of step S250 of FIG2; FIG10A and FIG10B are schematic diagrams of an embodiment of the present invention in which multiple blocks of a process are divided into multiple groups; FIG. 11 is a detail of an embodiment of step S260 of FIG. 2; FIG. 12 is a schematic diagram of another embodiment of the present invention for dividing groups; FIG. 13 is a flow chart of an embodiment of the instruction decompression method of the present invention; FIG. 14 is a schematic diagram of the hardware circuit of the present invention executing an uncompressed instruction; and FIG. 15 is a schematic diagram of the hardware circuit of the present invention executing a compressed instruction.

S210,S220,S230,S240,S250,S260:步驟 S210, S220, S230, S240, S250, S260: Steps

Claims (18)

一種指令解壓縮方法,應用於一硬體電路,該硬體電路解壓縮一指令並執行該指令,該指令包含一標頭,該標頭包含一參考值,該方法包含: 當該指令的該參考值係一預設值時,讀取該指令的一第一參數以取得一相異參數個數;以及 以該指令的複數個第二參數設定該硬體電路之複數個相對應的參數,該些第二參數的個數等於該相異參數個數。 A method for decompressing an instruction is applied to a hardware circuit, the hardware circuit decompresses an instruction and executes the instruction, the instruction includes a header, the header includes a reference value, the method includes: when the reference value of the instruction is a default value, reading a first parameter of the instruction to obtain a number of different parameters; and setting a plurality of corresponding parameters of the hardware circuit with a plurality of second parameters of the instruction, the number of the second parameters being equal to the number of different parameters. 如請求項1之方法,更包含: 當該指令的該參考值非該預設值時,以該指令的所有參數設定該硬體電路之該些相對應的參數。The method of claim 1 further includes: when the reference value of the instruction is not the default value, setting the corresponding parameters of the hardware circuit with all the parameters of the instruction. 如請求項1之方法,其中,該硬體電路包含複數個暫存器,該些相對應的參數係該些暫存器的暫存值。As in the method of claim 1, wherein the hardware circuit comprises a plurality of registers, and the corresponding parameters are the stored values of the registers. 如請求項1之方法,其中,當該相異參數個數係N時,該些第二參數係該指令之第二個參數至第N+1個參數。The method of claim 1, wherein, when the number of different parameters is N, the second parameters are the second to N+1th parameters of the instruction. 如請求項1之方法,其中,該指令係一變長指令。A method as claimed in claim 1, wherein the instruction is a variable length instruction. 一種指令壓縮方法,用來壓縮一指令以產生一壓縮後的指令,該指令包含一標頭及複數個參數,該標頭包含一參考值,該方法包含: 比較該指令與一前一指令,以找出該指令中與該前一指令不同的複數個相異參數; 將該壓縮後的指令的該參考值設為一預設值; 將該壓縮後的指令的一目標參數設為該些相異參數的個數;以及 將該壓縮後的指令的其他參數設為該些相異參數。 A method for compressing an instruction is provided for compressing an instruction to generate a compressed instruction, the instruction comprising a header and a plurality of parameters, the header comprising a reference value, the method comprising: comparing the instruction with a previous instruction to find a plurality of different parameters in the instruction that are different from the previous instruction; setting the reference value of the compressed instruction to a default value; setting a target parameter of the compressed instruction to the number of the different parameters; and setting other parameters of the compressed instruction to the different parameters. 如請求項6之方法,其中,該方法係應用於一硬體電路,該硬體電路執行一流程,該指令與該前一指令係該流程的連續指令,且該指令晚於該前一指令。A method as claimed in claim 6, wherein the method is applied to a hardware circuit, the hardware circuit executes a process, the instruction and the previous instruction are consecutive instructions of the process, and the instruction is later than the previous instruction. 如請求項7之方法,其中,該流程包含複數個區塊,每一區塊包含複數個指令,該指令與該前一指令屬於該些區塊中的同一目標區塊,且該指令非該目標區塊的第一個指令。A method as claimed in claim 7, wherein the process comprises a plurality of blocks, each block comprises a plurality of instructions, the instruction and the previous instruction belong to the same target block among the blocks, and the instruction is not the first instruction of the target block. 如請求項6之方法,其中,該目標參數係該壓縮後的指令的第一個參數。The method of claim 6, wherein the target parameter is the first parameter of the compressed instruction. 如請求項6之方法,其中,該指令係一變長指令。A method as claimed in claim 6, wherein the instruction is a variable length instruction. 一種流程壓縮方法,用來壓縮一流程,該流程包含一跳轉指令,該方法包含: (A)根據該跳轉指令在該流程中的一位置及該跳轉指令的一目的地,將該流程劃分為複數個區塊; (B)記錄該些區塊之間的一跳轉關係; (C)對該些區塊進行指令壓縮; (D)根據該跳轉關係重新計算該跳轉指令之一跳轉地址; (E)根據該些區塊的大小及該跳轉關係決定複數個群組;以及 (F)根據該跳轉指令與該些群組的關係決定該跳轉指令係一第一種類的跳轉指令或一第二種類的跳轉指令。 A flow compression method is used to compress a flow, wherein the flow includes a jump instruction, and the method includes: (A) dividing the flow into a plurality of blocks according to a position of the jump instruction in the flow and a destination of the jump instruction; (B) recording a jump relationship between the blocks; (C) performing instruction compression on the blocks; (D) recalculating a jump address of the jump instruction according to the jump relationship; (E) determining a plurality of groups according to the sizes of the blocks and the jump relationship; and (F) determining whether the jump instruction is a first type of jump instruction or a second type of jump instruction according to the relationship between the jump instruction and the groups. 如請求項11之方法,其中,該流程更包含複數個指令,該步驟(A)包含: 讀取該些指令的其中之一;以及 當該讀取的指令係該跳轉指令或該跳轉指令的該目的地時,設定一區塊邊界。 The method of claim 11, wherein the process further comprises a plurality of instructions, and the step (A) comprises: reading one of the instructions; and when the read instruction is the jump instruction or the destination of the jump instruction, setting a block boundary. 如請求項12之方法,其中,該些指令係複數個變長指令。A method as claimed in claim 12, wherein the instructions are a plurality of variable-length instructions. 如請求項11之方法,其中,該步驟(E)包含: 選取一區塊; 根據該區塊的大小更新一當前群組的大小; 當該當前群組的大小大於一門檻值時,將該區塊設為一新的群組的一部分;以及 當該當前群組的大小不大於該門檻值時,將該區塊設為該當前群組的一部分。 The method of claim 11, wherein step (E) comprises: selecting a block; updating the size of a current group according to the size of the block; setting the block as part of a new group when the size of the current group is greater than a threshold; and setting the block as part of the current group when the size of the current group is not greater than the threshold. 如請求項14之方法,其中,該步驟(E)更包含: 當該當前群組的大小大於該門檻值時,將該新的群組的大小設為該區塊的大小。The method of claim 14, wherein the step (E) further comprises: when the size of the current group is greater than the threshold value, setting the size of the new group to the size of the block. 如請求項14之方法,其中,該跳轉指令係一第一跳轉指令,該目的地係一第一目的地,該步驟(E)更包含: 選取一第一群組; 選取該第一群組的一目標區塊;以及 當該目標區塊非該第一群組的第一個區塊,且該目標區塊是一第二群組的一第二跳轉指令的一第二目的地時,設定一群組邊界。 The method of claim 14, wherein the jump instruction is a first jump instruction, the destination is a first destination, and the step (E) further comprises: selecting a first group; selecting a target block of the first group; and setting a group boundary when the target block is not the first block of the first group and the target block is a second destination of a second jump instruction of a second group. 如請求項11之方法,其中,該步驟(F)包含: 選取該跳轉指令; 當該跳轉指令之該目的地係位於該跳轉指令所屬之一目標群組內時,將該跳轉指令設為一短跳轉指令。 The method of claim 11, wherein the step (F) comprises: selecting the jump instruction; When the destination of the jump instruction is located in a target group to which the jump instruction belongs, setting the jump instruction to a short jump instruction. 如請求項17之方法,其中,該步驟(F)更包含: 當該跳轉指令之該目的地係不位於該目標群組內時,將該跳轉指令設為一長跳轉指令; 其中,該短跳轉指令之跳轉範圍係小於該長跳轉指令之跳轉範圍。 The method of claim 17, wherein the step (F) further comprises: when the destination of the jump instruction is not within the target group, setting the jump instruction to a long jump instruction; wherein the jump range of the short jump instruction is smaller than the jump range of the long jump instruction.
TW111141685A 2022-11-01 2022-11-01 Instruction compression method, instruction decompression method and process compression method TWI820994B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW111141685A TWI820994B (en) 2022-11-01 2022-11-01 Instruction compression method, instruction decompression method and process compression method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW111141685A TWI820994B (en) 2022-11-01 2022-11-01 Instruction compression method, instruction decompression method and process compression method

Publications (2)

Publication Number Publication Date
TWI820994B TWI820994B (en) 2023-11-01
TW202420073A true TW202420073A (en) 2024-05-16

Family

ID=89722406

Family Applications (1)

Application Number Title Priority Date Filing Date
TW111141685A TWI820994B (en) 2022-11-01 2022-11-01 Instruction compression method, instruction decompression method and process compression method

Country Status (1)

Country Link
TW (1) TWI820994B (en)

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8645337B2 (en) * 2009-04-30 2014-02-04 Oracle International Corporation Storing compression units in relational tables
US8949513B2 (en) * 2011-05-10 2015-02-03 Marvell World Trade Ltd. Data compression and compacting for memory devices
EP2949047B1 (en) * 2013-01-22 2021-03-31 Altera Corporation Data compression and decompression using simd instructions
US9672041B2 (en) * 2013-08-01 2017-06-06 Andes Technology Corporation Method for compressing variable-length instructions including PC-relative instructions and processor for executing compressed instructions using an instruction table
US9990304B2 (en) * 2015-11-13 2018-06-05 Samsung Electronics Co., Ltd Multimode storage management system
US10630312B1 (en) * 2019-01-31 2020-04-21 International Business Machines Corporation General-purpose processor instruction to perform compression/decompression operations
CN114282141A (en) * 2021-12-20 2022-04-05 瑞数信息技术(上海)有限公司 Processing method and device for compression format data, electronic equipment and readable storage medium

Similar Documents

Publication Publication Date Title
US5892979A (en) Queue control apparatus including memory to save data received when capacity of queue is less than a predetermined threshold
JP6253514B2 (en) Processor
WO2010058790A1 (en) Content distribution device, content distribution control method, content distribution control program, and cache control device
US10884744B2 (en) System and method of loop vectorization by compressing indices and data elements from iterations based on a control mask
CN111079917B (en) Tensor data block access method and device
US11574188B2 (en) Data processing apparatus, data processing method, medium, and trained model
US7877428B2 (en) Processor system including processor and coprocessor
JP2008117368A5 (en)
JP4279317B2 (en) Data processing method and data processing apparatus
TWI820994B (en) Instruction compression method, instruction decompression method and process compression method
TW202420073A (en) Instruction compression method, instruction decompression method and process compression method
US20100146242A1 (en) Data processing apparatus and method of controlling the data processing apparatus
WO2023083213A1 (en) Data decoding method and apparatus, electronic device and readable storage medium
JPH07200262A (en) Modulo reduction method making use of precomputing table
CN115599441A (en) Instruction compression method, instruction decompression method and process compression method
US20240231828A9 (en) Instruction compression method, instruction decompression method and process compression method
CN115049531A (en) Image rendering method and device, graphic processing equipment and storage medium
CN113705795A (en) Convolution processing method and device, convolution neural network accelerator and storage medium
US20190026247A1 (en) Information processing apparatus and information processing method
JP4184034B2 (en) How to execute processing functions
WO2024125340A1 (en) Clock tree gate delay optimization method and system, and device and computer storage medium
JPH1066200A (en) Data buffering device and its control method
US11431349B2 (en) Method, electronic device and computer program product for processing data
US20220156074A1 (en) Electronic device and multiplexing method of spatial
JP2006314054A (en) Turbo decoder