TWI820994B - 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
TWI820994B
TWI820994B TW111141685A TW111141685A TWI820994B TW I820994 B TWI820994 B TW I820994B TW 111141685 A TW111141685 A TW 111141685A TW 111141685 A TW111141685 A TW 111141685A TW I820994 B TWI820994 B TW I820994B
Authority
TW
Taiwan
Prior art keywords
instruction
jump
block
group
parameters
Prior art date
Application number
TW111141685A
Other languages
Chinese (zh)
Other versions
TW202420073A (en
Inventor
鄧亞明
Original Assignee
大陸商星宸科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 大陸商星宸科技股份有限公司 filed Critical 大陸商星宸科技股份有限公司
Priority to TW111141685A priority Critical patent/TWI820994B/en
Application granted granted Critical
Publication of TWI820994B publication Critical patent/TWI820994B/en
Publication of TW202420073A publication Critical patent/TW202420073A/en

Links

Landscapes

  • Compression, Expansion, Code Conversion, And Decoders (AREA)
  • Electrotherapy Devices (AREA)

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 known as branch instructions).

一般而言,一個流程(例如,影像處理流程、啟動流程等)通常包含至少一個跳轉指令。然而,現有的平台處理跳轉邏輯時無法同時開啟變長指令(variable-length instruction)壓縮,導致指令暫存器需要較大的空間、長跳轉(long jump)指令的個數變多,以及流程的執行效率下降。因此,需要一種指令壓縮方法、指令解壓縮方法及流程壓縮方法來減少指令暫存器所需的空間,以及減少長跳轉指令的個數。 Generally speaking, a process (eg, image processing process, startup process, etc.) usually contains at least one jump instruction. However, the existing platform cannot turn on variable-length instruction compression at the same time when processing jump logic, resulting in the instruction register requiring larger space, the number of long jump instructions increasing, and the flow of processes increasing. Execution efficiency decreases. 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 purpose 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, using a plurality of second parameters of the instruction. The parameters set a plurality of corresponding parameters of the hardware circuit, and the number of the second parameters is equal to the number of the different parameters.

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

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

100:智能處理器 100:Intelligent processor

110:解碼器 110:Decoder

112:記憶體 112:Memory

114:指令預擷取電路 114: Instruction prefetch circuit

116:指令分發電路 116: Instruction distribution circuit

118:跳轉邏輯電路 118:Jump logic circuit

120:直接記憶體存取(DMA) 120: Direct memory access (DMA)

130:向量電路 130:Vector circuit

140:卷積電路 140:Convolution circuit

122,132,142:指令解壓縮電路 122,132,142: Instruction decompression circuit

124,134,144:計算電路 124,134,144: Calculation circuit

310:流程 310:Process

INST1~INST15,INST_k-1,INST_k,INST_y:指令 INST1~INST15,INST_k-1,INST_k,INST_y: instructions

320:區塊間的跳轉關係 320: Jump relationship between blocks

BB:區塊邊界 BB: block boundary

BLK1,BLK2,BLK3,BLK4:區塊 BLK1, BLK2, BLK3, BLK4: blocks

INST_k',INST_z:壓縮後的指令 INST_k',INST_z: compressed instructions

HD:標頭 HD: header

InstFlag:旗標 InstFlag: flag

HDLen:參考值 HDLen: reference value

P1,P2,P3,P4,P5,Pn,P1',P2',P3',P4',P5':參數 P1,P2,P3,P4,P5,Pn,P1',P2',P3',P4',P5': parameters

Nd:相異參數個數 Nd: number of different parameters

SR:門檻值 SR: threshold

GB:群組邊界 GB: group boundary

GRP1,GRP2,GRP3:群組 GRP1, GRP2, GRP3: group

INST_n:跳轉指令 INST_n: jump instruction

REGP:暫存器群組 REGP: register group

REG1,REG2,REG3,REG4,REG5:暫存器 REG1, REG2, REG3, REG4, REG5: temporary register

210,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:步驟 210,S220,S230,S240,S250,S260,S510,S520,S530,S540,S550,S610,S620,S630,S640,S650,S660,S670,S680,S810,S820,S830,S840,S850,S8 60, step

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

以下說明內容之技術用語係參照本技術領域之習慣用語,如本說明書對部分用語有加以說明或定義,該部分用語之解釋係以本說明書之說明或定義為準。 The technical terms used in the following description refer to the idioms in the technical field. If some terms are explained or defined in this specification, the explanation or definition of these terms shall prevail.

本發明之揭露內容包含指令壓縮方法、指令解壓縮方法及流程壓縮方法。由於本發明之智能處理器所包含之部分元件單獨而言可能為已知元件,因此在不影響該裝置發明之充分揭露及可實施性的前提下,以下說明對於已知元件的細節將予以節略。此外,本發明之指令壓縮方法、指令解壓縮方法及流程壓縮方法的部分或全部流程可以是軟體及/或韌體之形式。 The disclosure of the present invention includes an instruction compression method, an instruction decompression method and a process compression method. Since some components included in the smart 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 implementability of the device invention. . In addition, part or all of the processes of the command compression method, command 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的主要功能,故不再贅述。 Figure 1 is a functional block diagram of an embodiment of an intelligent processor (Intelligent Processing Unit, IPU) of the present invention. The intelligent processor 100 includes a decoder 110, a direct memory access (DMA) 120, a vector circuit 130 and a convolution circuit 140. Direct memory access 120, vector circuit 130 and convolution circuit 140 each include instruction decompression circuits 122, 132, 142 and calculation circuits 124, 134, 144. Instruction decompression circuits 122, 132 and 142 are used to decompress instructions (the details of the decompression instructions will be described later in conjunction with Figure 13), and calculation circuits 124, 134 and 144 execute direct memory access 120 and vector circuit 130 respectively. and the main functions of the convolution circuit 140. Since those skilled in the art know the main functions of the direct memory access 120, the vector circuit 130 and the convolution circuit 140, 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 (eg, 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 the instruction from the memory 112, and then the instruction distribution circuit 116 distributes the instruction to the corresponding hardware circuit (ie, direct memory storage) according to the instruction's flag InstFlag (please refer to FIG. 7). Take 120, vector circuit 130 or convolution circuit 140). The jump logic circuit 118 is used to determine whether the instruction is a jump instruction and/or the type of jump instruction (long jump instruction or short jump instruction). When a jump instruction is encountered, jump The logic circuit 118 determines the destination of the jump instruction, and then the instruction prefetch 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 (e.g., the address of the target instruction in the memory 112 The size of the instruction temporary storage area), then the jump instruction is a short jump instruction; otherwise, the jump instruction is a long jump instruction. In other words, the jump range of a short jump instruction is smaller than the jump range of a long jump instruction. When the decoder 110 processes the long jump instruction, the direct memory access 120 is required to obtain more information from the external memory of the intelligent processor 100 (for example, dynamic random access memory (DRAM), not shown). instructions, while short jump instructions do not; 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包含以下步驟。 Figure 2 is a flow chart of one embodiment of the process compression method of the present invention. In some embodiments, the steps of FIG. 2 are performed by a development tool (eg, a general-purpose computer) during the development phase of the intelligent processor 100 . The process compression method in Figure 2 can be used to compress a certain process (for example, image processing process, startup process, etc.), and the process contains multiple instructions (for example, the process 310 in Figure 3 includes 15 instructions including instructions INST1 ~ instructions INST15. These instructions are variable-length instructions, and at least one of them is a jump instruction, as shown in Figure 3 below). Figure 2 contains 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: According to the position of the jump instruction in a process (for example, the address of the jump instruction in the memory 112) and the destination of the jump instruction (for example, the address of the destination in the memory 112), the process is divided into Multiple blocks. More specifically, step S210 scans instructions in a process and sets block boundaries BB to divide the process into multiple blocks. The details of step S210 will be described in detail below with reference to FIG. 5 . In the example of Figure 3, the process 310 is divided into 4 blocks (blocks BLK1~Block BLK4 respectively include instructions INST1~Instruction INST5, instructions INST6~Instructions INST8, instructions INST9~Instructions INST11 and instructions INST12~Instructions INST15. Instructions INST5 and INST11 are jump instructions, and their destinations are INST9 and INST11 respectively. Instruction INST6).

步驟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 Figure 3. After step S210, 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 (ie, instruction INST9)); area 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 and target blocks of block BLK3 are block BLK1 and block BLK2 respectively. . Please refer to Figure 4. Figure 4 is a schematic diagram of the jump relationship between blocks, which corresponds to the jump relationship 320 between blocks in Figure 3; in other words, the jump relationship between blocks can also be represented or recorded graphically.

步驟S230:逐區塊對該些區塊進行指令壓縮,以得到多個壓縮後的區塊。此步驟將於下方配合圖6詳述。 Step S230: Perform instruction compression on these blocks block by block to obtain multiple compressed blocks. This step will be detailed below in conjunction with Figure 6.

步驟S240:根據區塊之間的跳轉關係重新計算跳轉地址(jump address,即跳轉指令的目的地地址)。因為區塊在步驟S230中已被壓縮,所以壓縮後跳轉指令的目的地的地址已非原本的地址,所以必須重新計算或更新跳轉地址。舉例來說,請參閱圖3,由於壓縮後幾乎每個區塊都變小,所以指令INST9與指令INST6的位置改變,因此必須順應更新或調整指令INST5與指令INST11的目的地的地址。 Step S240: Recalculate the jump address (jump address, that is, the destination address of the jump instruction) according to the jump relationship between 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 instructions INST9 and INST6 change, so the addresses of the destinations of instructions INST5 and 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 with reference to Figures 8 to 9 .

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

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

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

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

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

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

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

以圖3為例,圖5的方法會在指令INST5處將流程310劃分開(即,設置區塊邊界BB),以產生區塊BLK1。類似地,因為指令INST9及 指令INST11分別是目的地與跳轉指令,所以指令INST9之前及指令INST11之後會被設置區塊邊界BB,因此分別產生區塊BLK2及區塊BLK3。流程310的結尾亦會被設置區塊邊界BB,以產生區塊BLK4。 Taking Figure 3 as an example, the method of Figure 5 will divide the process 310 at the instruction INST5 (ie, set the block boundary BB) to generate the block BLK1. Similarly, since instructions INST9 and Instruction INST11 is the destination and jump instruction respectively, so the block boundary BB will be set before instruction INST9 and after instruction INST11, so block BLK2 and block BLK3 are generated respectively. At the end of the process 310, the block boundary BB will also be set 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(或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的壓縮方法是以區塊為單位,包含以下步驟。 Figure 6 is a flow chart of an embodiment of the instruction compression method of the present invention. FIG. 7 is a schematic diagram of the instruction structure before compression and the instruction structure after compression. As shown in Figure 7, instructions INST_k-1 and instructions INST_k are uncompressed instructions (both are consecutive instructions, and instruction INST_k-1 precedes instruction INST_k). Instructions INST_k-1, instructions INST_k and compressed instructions INST_k' all include header HD and at least one parameter (for example, instructions INST_k-1 and instructions INST_k each include n parameters P1 (or P1') ~ Pn, and after compression The instruction INST_k' contains 1 parameter P1'). In some embodiments, the size of the header HD and each parameter is one word. The header HD contains the flag InstFlag and the 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 instructions INST_k-1 and INST_k is n); for the compressed instruction INST_k', the reference value HDLen is the default value (e.g. 0). The compression method in 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, step S610 is executed to read the next instruction of the block; if not, step S630 is executed. The first instruction of a block is not compressed (because there are no previous instructions to refer to).

步驟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 Figure 7 as an example, because the parameters P2~parameters Pn of the instruction INST_k-1 are respectively equal to the parameters P2~parameters Pn of the instruction INST_k, and only the parameter P1 is not equal to the parameter P1', so the step The dissimilar parameter found in step S630 is parameter P1'.

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

步驟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 Figure 7 as an example, because the number Nd of different parameters between instructions INST_k-1 and INST_k is 1, this step sets the first parameter of the compressed instruction INST_k' to 1 (that is, "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 other parameters of the compressed instruction to the different parameters. In this step, the second 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, because the only different parameter between instruction INST_k-1 and instruction INST_k is parameter P1' (that is, the number of different parameters Nd is 1), so this step will compress the second parameter of instruction INST_k'. The parameter is set 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 any instructions to be processed in the block. If yes, step S610 is executed to read the next instruction of the block; if not, the method of FIG. 6 ends (step S680).

圖8及圖9是圖2之步驟S250之一實施例的細節。步驟S250包含兩個主要步驟:先根據區塊大小決定群組(圖8),再根據跳轉關係調整群組(圖9)。以下的說明請一併參閱圖10A及圖10B,圖10A及圖10B是本發明將流程之多個區塊劃分成多個群組之一實施例的示意圖,對應到圖3之流程310。圖8包含以下步驟。 FIG. 8 and FIG. 9 are details of an embodiment of step S250 in FIG. 2 . Step S250 includes two main steps: first determine the group according to the block size (Fig. 8), and then adjust the group according to the jump relationship (Fig. 9). Please refer to FIG. 10A and FIG. 10B together for the following description. FIG. 10A and FIG. 10B are schematic diagrams of an embodiment of dividing multiple blocks of the process into multiple groups according to the present invention, corresponding to the process 310 of FIG. 3 . Figure 8 contains 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. size. The size of a group is the sum of the sizes of all the blocks it contains. This step updates the current group size by adding the current group size to the block size. Taking FIG. 10A as an example, assuming that the current group only contains block BLK1, the selected block is block BLK2, and the updated size of the current group 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 the threshold. In some embodiments, the threshold may be the size of the instruction buffer area of the memory 112 . If the determination result in step S820 is no, step S830 is executed; otherwise, step S840 and step S850 are executed.

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

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

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

步驟S860:判斷是否仍有待處理的區塊。如果是,則執行步驟S810以選取下一個區塊;如果否,則執行步驟S870。 Step S860: Determine whether there are still blocks to be processed. If yes, perform step S810 to select the next block; if not, perform 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 determination in 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 Figure 10A. After the method in Figure 8 is completed, the four blocks in Figure 4 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 occurred during execution of the process, so the group must be further adjusted according to the method in Figure 9. Figure 9 contains 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 true: the block is not the first block of the group, and the block is the destination of jump instructions of other groups. Taking FIG. 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 respectively select group GRP1 and block BLK2, then 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, perform step S920 to select the next block of the group; otherwise, perform 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 group. Taking FIG. 10A and FIG. 10B as an example, step S950 sets the group boundary GB before the block BLK2 (ie, the destination of the instruction INST11), so that the original group GRP1 becomes the group GRP1 and the group GRP3.

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

圖11是圖2之步驟S260之一實施例的細節,包含以下步驟。 Figure 11 is the details of an embodiment of step S260 in Figure 2, including the following steps.

步驟S1110:選取一跳轉指令。以圖10B為例,此步驟會選取指令INST5或指令INST11。 Step S1110: Select a jump instruction. Taking Figure 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 within the group to which the jump instruction belongs. Taking FIG. 10B as an example, for instruction INST5, because its destination (block BLK3) is not in the group to which instruction INST5 belongs (ie, group GRP1), the judgment result in step S1120 is no. Similarly, for the instruction INST11, the judgment 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, step S1110 is executed to select the next jump instruction; if not, the method of FIG. 11 is ended (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 , instructions INST5 and INST11 are both inter-group jump instructions (long jump instructions). Please refer to FIG. 12 , which is a schematic diagram of another embodiment of dividing groups according to the present invention. As shown in Figure 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 used in the method of Figure 11 Judged as short jump Transfer command (ie, step S1120 determines yes).

圖13是本發明指令解壓縮方法之一實施例的流程圖。圖13由圖1之硬體電路(即,直接記憶體存取120、向量電路130或卷積電路140)的指令解壓縮電路(即,指令解壓縮電路122、指令解壓縮電路132或指令解壓縮電路142)執行,圖13包含以下步驟。 Figure 13 is a flow chart of one embodiment of the instruction decompression method of the present invention. FIG. 13 illustrates the instruction decompression circuit (ie, instruction decompression circuit 122, instruction decompression circuit 132, or instruction decompression circuit) of the hardware circuit (ie, direct memory access 120, vector circuit 130, or convolution circuit 140) of FIG. 1 Compression circuit 142) is executed, and Figure 13 contains 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 (representing that the instruction is not a compressed instruction), then step S1330 is executed; if yes (representing that the instruction is a compressed instruction), then step S1340 and step S1350 are executed.

步驟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: Use all parameters of the instruction to set corresponding parameters of the hardware circuit (for example, set the temporary value of the register). Please refer to FIG. 14 , which is a schematic diagram of the hardware circuit of the present invention executing uncompressed instructions. Assume that before executing the uncompressed instruction INST_y (including 5 parameters P1', P2', P3', P4' and P5'), the register group REGP of the hardware circuit stores P1, P2, P3, P4 and The five parameters including P5 (the temporary values of register REG1, register REG2, register REG3, register REG4 and register REG5 respectively) are temporarily stored 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 to say, the purpose of step S1330 is to set the parameters of the hardware circuit with the parameters of the instruction INST_y. After the parameter setting of the hardware circuit is completed, the hardware circuit (more specifically, the calculation 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 FIG. 15 , which is a schematic diagram of the hardware circuit of the present invention executing compression instructions. The fingers in Figure 15 Let INST_z be a compressed instruction, and its number of distinct 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: Use the second to Nd+1th parameters of the instruction to set the corresponding parameters of the hardware circuit (for example, set the temporary value of the register). In the example of Figure 15, the instruction decompression circuit obtains the parameters P1' and parameter P2' of the compressed instruction INST_z according to the number of different parameters Nd, and then sets the register REG1 and the temporary register respectively with the parameter P1' and the parameter P2'. Register REG2. The purpose of step S1350 is to set the parameters of the hardware circuit using the parameters of the compressed instruction INST_z. After the parameter setting of the hardware circuit is completed, the hardware circuit can execute the instruction (step S1360).

綜上所述,本發明藉由對指令進行壓縮來減少指令暫存器所需的空間(即,減少記憶體112的大小),以節省成本。此外,因為對指令進行壓縮,所以本發明還可以減少長跳轉指令的個數,以提升流程的執行效率。 In summary, the present invention reduces the space required for the instruction register (ie, reduces the size of the memory 112) by compressing 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 foregoing embodiments take variable-length instructions and intelligent processors as examples, this is not a limitation of the present invention. Those skilled in the art can appropriately apply the present invention to other types of command 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. Those skilled in the art may make changes to the technical features of the present invention based on the explicit or implicit contents of the present invention. All these changes may fall within the scope of patent protection sought by the present invention. In other words, the patent protection scope of the present invention must be determined by the patent application scope of this specification.

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

Claims (18)

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

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100281004A1 (en) * 2009-04-30 2010-11-04 Oracle International Corporation Storing compression units in relational tables
US20120290798A1 (en) * 2011-05-10 2012-11-15 Huang Chengkuo Data Compression and Compacting for Memory Devices
TW201506781A (en) * 2013-08-01 2015-02-16 Andes Technology Corp Method for compressing instruction and processor for executing compressed instruction
CN105264779A (en) * 2013-01-22 2016-01-20 阿尔特拉公司 Data compression and decompression using simd instructions
TW201723816A (en) * 2015-11-13 2017-07-01 三星電子股份有限公司 Storage system, method and system for managing storage media
TW202034161A (en) * 2019-01-31 2020-09-16 美商萬國商業機器公司 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

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100281004A1 (en) * 2009-04-30 2010-11-04 Oracle International Corporation Storing compression units in relational tables
US20120290798A1 (en) * 2011-05-10 2012-11-15 Huang Chengkuo Data Compression and Compacting for Memory Devices
CN105264779A (en) * 2013-01-22 2016-01-20 阿尔特拉公司 Data compression and decompression using simd instructions
TW201506781A (en) * 2013-08-01 2015-02-16 Andes Technology Corp Method for compressing instruction and processor for executing compressed instruction
TW201723816A (en) * 2015-11-13 2017-07-01 三星電子股份有限公司 Storage system, method and system for managing storage media
TW202034161A (en) * 2019-01-31 2020-09-16 美商萬國商業機器公司 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
CN111079917B (en) Tensor data block access method and device
US9740493B2 (en) System and method of loop vectorization by compressing indexes and data elements from iterations based on a control mask
WO2021052169A1 (en) Equalization processing method and device for distributed data, computing terminal and storage medium
EP3432157A1 (en) Data table joining mode processing method and apparatus
US7877428B2 (en) Processor system including processor and coprocessor
US20120011166A1 (en) Skip list generation
TWI820994B (en) Instruction compression method, instruction decompression method and process compression method
US7668894B2 (en) Computation of power functions using polynomial approximations
JP2008186345A (en) Data processing method and data processing apparatus
WO2020062252A1 (en) Operational accelerator and compression method
US20210336632A1 (en) Lossy Compression Techniques
WO2023083213A1 (en) Data decoding method and apparatus, electronic device and readable storage medium
JP2002358288A (en) Semiconductor integrated circuit and computer readable recording medium
CN115599441A (en) Instruction compression method, instruction decompression method and process compression method
US20240134649A1 (en) Instruction compression method, instruction decompression method and process compression method
JP2002108958A (en) System and method for designing circuit and computer readable recording medium stored with circuit design program
CN115830273A (en) Optimization method and device of lightweight grid before three-dimensional scene rendering
US11907855B2 (en) Data transfers in neural processing
CN111435309A (en) Register allocation optimization implementation method
CN107341113B (en) Cache compression method and device
CN115049531A (en) Image rendering method and device, graphic processing equipment and storage medium
US10754817B2 (en) Information processing apparatus and information processing method for process order in reconfigurable circuit
JP2018132899A (en) Storage method, storage device and storage program
US7509640B2 (en) Task distribution in computing architectures