TW201419140A - Reconfigurable instruction encoding, execution method and electronic apparatus - Google Patents

Reconfigurable instruction encoding, execution method and electronic apparatus Download PDF

Info

Publication number
TW201419140A
TW201419140A TW101141138A TW101141138A TW201419140A TW 201419140 A TW201419140 A TW 201419140A TW 101141138 A TW101141138 A TW 101141138A TW 101141138 A TW101141138 A TW 101141138A TW 201419140 A TW201419140 A TW 201419140A
Authority
TW
Taiwan
Prior art keywords
instruction
code
encoding
execution
module
Prior art date
Application number
TW101141138A
Other languages
Chinese (zh)
Inventor
Huang-Lun Lin
Shui-An Wen
Chi Wu
Tzu-Fang Lee
Original Assignee
Ind Tech Res Inst
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 Ind Tech Res Inst filed Critical Ind Tech Res Inst
Priority to TW101141138A priority Critical patent/TW201419140A/en
Priority to CN201210491698.2A priority patent/CN103809933A/en
Priority to US13/901,640 priority patent/US20130275721A1/en
Publication of TW201419140A publication Critical patent/TW201419140A/en

Links

Landscapes

  • Executing Machine-Instructions (AREA)

Abstract

Reconfigurable instruction encoding, execution method and electronic apparatus are provided. The instruction encoding method, in an embodiment, generates an instruction encoding table and an instruction mapping table by performing encoding on pairs of adjacent instructions of an application in terms of the pairs' respective usage times and then further performing repetitive encoding, and generates executable code of the application according to the instruction encoding table. The reconfigurable instruction execution method includes the following. An instruction code remapping table is loaded into a processing unit of an electronic apparatus, wherein the processing unit includes an instruction remapping module, an instruction decoding module, and an execution module. A first instruction signal of an application program is fetched by the processing unit. According to the instruction remapping table, the first instruction signal is converted to a target instruction signal by the instruction remapping module. The target instruction signal is decoded by the instruction decoding module and the decoded target instruction signal is executed by the execution module.

Description

可重新配置的指令編碼方法、執行方法及電子裝置 Reconfigurable instruction coding method, execution method and electronic device

本揭露是有關於一種可重新配置的指令編碼方法、執行方法及處理器架構。 The disclosure relates to a reconfigurable instruction encoding method, an execution method, and a processor architecture.

針對某一種處理器進行程式編譯時,編譯器(compiler)會依據一對應於此種處理器指令集架構之一固定的指令表(instruction table)將應用程式的原始碼轉換為機器碼(machine code)以供此種處理器執行相對應的運算動作。 When compiling a program for a certain processor, the compiler converts the source code of the application into machine code according to a fixed instruction table corresponding to one of the processor instruction set architectures. ) for such a processor to perform a corresponding arithmetic action.

另外,在一運算裝置中執行應用程式時,運算裝置之記憶體中所儲存的應用程式之機器碼,傳輸於匯流排而到達運算裝置之處理器時,可能會導致連續的執行指令間,在指令匯流排上的訊號相位產生劇烈的變化,進而使得電路輸入端會發生訊號邏輯位準的頻繁轉換,並伴隨著嚴重的功率消耗。 In addition, when the application program is executed in an arithmetic device, the machine code of the application stored in the memory of the computing device is transmitted to the bus bar and reaches the processor of the computing device, which may result in continuous execution of the command. The phase of the signal on the command bus changes drastically, which causes frequent conversion of the signal logic level at the input of the circuit, accompanied by severe power consumption.

本揭露是有關於一種可重新配置的指令編碼方法、執行方法及處理器架構。 The disclosure relates to a reconfigurable instruction encoding method, an execution method, and a processor architecture.

根據一實施例,提出一種可重新配置的指令執行方法。此方法執行於一電子裝置,包括以下步驟。載入一指令碼映對表至一電子裝置之一處理單元,其中此處理單元包括一指令映對模組、一指令解碼模組及一執行模組。藉由此處理單元,擷取一應用程式之一第一指令信號。藉由 此指令映對模組,依據此指令碼映對表,將第一指令信號轉換為一目標指令信號。藉由此指令解碼模組,對目標指令信號解碼,並藉由此執行模組,執行此解碼後之目標指令信號。 According to an embodiment, a reconfigurable instruction execution method is presented. The method is performed on an electronic device and includes the following steps. Loading a command code mapping table to a processing unit of an electronic device, wherein the processing unit comprises a command mapping module, an instruction decoding module and an execution module. By means of the processing unit, one of the first instruction signals of an application is retrieved. By The instruction maps the module, and according to the instruction code, the first command signal is converted into a target command signal. The target decoding signal is decoded by the instruction decoding module, and the decoded target instruction signal is executed by executing the module.

根據另一實施例,提供一種電子裝置。電子裝置,包括一處理單元,此處理單元用以依據一指令碼映對表以進行指令之執行。處理單元包括一指令映對模組、一指令解碼模組和一執行模組。指令映對模組,依據此指令碼映對表,將此處理單元擷取之一第一指令信號轉換為一目標指令信號。指令解碼模組,係對此目標指令信號解碼。執行模組,係執行此解碼後之目標指令信號。 According to another embodiment, an electronic device is provided. The electronic device includes a processing unit for mapping the table according to an instruction code for executing the instruction. The processing unit includes a command mapping module, an instruction decoding module and an execution module. The instruction mapping module, according to the instruction code mapping table, converts one of the first instruction signals from the processing unit into a target instruction signal. The instruction decoding module decodes the target command signal. The execution module executes the decoded target command signal.

根據另一實施例,提供一種可重新配置的指令編碼方法。此方法包括以下步驟。統計一應用程式之相鄰指令的配對分佈,並據以找出一指令配對集,此指令配對集包括此應用程式之具較高使用率的複數個指令配對。對此指令配對集中較高使用率的此些指令配對進行編碼以賦予各指令配對相近的指令編碼,從而產生一指令編碼表,其中此指令編碼表與一原始指令編碼表具有相同數量之指令,且至少有複數個指令於此指令編碼表與此原始指令編碼表中對應到不同的指令編碼。產生一指令碼映對表,其中此指令碼映對表儲存將此指令編碼表映對到此原始指令編碼表之映對關係。 According to another embodiment, a reconfigurable instruction encoding method is provided. This method includes the following steps. The pairing distribution of adjacent instructions of an application is counted, and an instruction pairing set is found. The command pairing set includes a plurality of instruction pairs of the application with higher usage rate. The instruction pairing of the instruction pairing the higher usage rate is encoded to give each instruction a similar instruction encoding, thereby generating an instruction encoding table, wherein the instruction encoding table has the same number of instructions as an original instruction encoding table. And at least a plurality of instructions corresponding to different instruction codes in the instruction code table and the original instruction code table. An instruction code mapping table is generated, wherein the instruction code mapping table stores the mapping relationship of the instruction encoding table pair to the original instruction encoding table.

根據另一實施例,提供一種運算裝置可讀式資訊儲存媒體,其上儲存有程式碼,此程式碼之執行能實現上述之可重新配置的指令編碼方法。 According to another embodiment, an information storage medium readable by an arithmetic device is provided, on which a program code is stored, and the execution of the code can implement the reconfigurable instruction encoding method described above.

為了對本揭露之上述及其他方面有更佳的瞭解,下文特舉多個實施例,並配合所附圖式,作詳細說明如下: In order to better understand the above and other aspects of the present disclosure, various embodiments are described below, and in conjunction with the drawings, the detailed description is as follows:

以下提供有關於可重新配置的指令編碼方法、執行方法及處理器架構之實施例。一些實施例提出具有一指令映對模組之一處理器架構,使處理器能執行基於一重新配置的指令集的應用程式。一些實施例提出產生一重新配置的指令集的應用程式之編譯方法。一些實施例更提出可減少相鄰指令間漢明距離的可重新配置的指令編碼方法。 Embodiments of the reconfigurable instruction encoding method, execution method, and processor architecture are provided below. Some embodiments propose a processor architecture having a processor mapping module that enables the processor to execute an application based on a reconfigured instruction set. Some embodiments propose a method of compiling an application that produces a reconfigured instruction set. Some embodiments further propose a reconfigurable instruction encoding method that reduces the Hamming distance between adjacent instructions.

第1圖為可重新配置的指令編碼之硬體架構1之一實施例的方塊圖。此硬體架構1包括一處理單元10和一記憶單元20。以下舉處理單元10包括一指令映對模組110、一指令解碼模組120和一執行模組130為例說明。但是,處理單元10並不受限於此,處理單元10亦可實施為單或多核心的處理器,又或處理器以管線(pipeline)架構之電路或超長指令字(Very long instruction word,VLIW)或其他的架構之電路實現。又例如,處理單元10之指令映對模組110可包含於一指令擷取模組100中,或耦接於一指令擷取模組與指令解碼模組120之間。 Figure 1 is a block diagram of one embodiment of a hardware architecture 1 of reconfigurable instruction encoding. The hardware architecture 1 includes a processing unit 10 and a memory unit 20. The following processing unit 10 includes a command mapping module 110, an instruction decoding module 120, and an execution module 130 as an example. However, the processing unit 10 is not limited thereto, and the processing unit 10 may also be implemented as a single or multi-core processor, or the processor may be a pipeline architecture circuit or a very long instruction word (Very long instruction word, VLIW) or other architectural circuit implementation. For example, the command mapping module 110 of the processing unit 10 can be included in an instruction capture module 100 or coupled between an instruction capture module and the instruction decoding module 120.

在第1圖中,處理單元10,用以依據一指令碼映對表210以進行指令之執行動作,例如執行一應用程式之執行碼220。指令映對模組110,依據指令碼映對表210,將處理單元10擷取之一第一指令信號S1轉換為一目標指令信號S2。指令解碼模組120,係對目標指令信號S2解 碼。執行模組130,係執行此解碼後之目標指令信號。記憶單元20,透過一匯流排30與處理單元10耦接,例如用以儲存指令碼映對表210及一應用程式220之複數個執行碼,記憶單元20可實施為相同或不同的記憶體模組或裝置。又,應用程式之執行碼220執行的過程中,處理單元10從記憶單元20可能擷取至少一或多個指令,執行碼220之至少一個或多個指令,可以為並行或串列的資料訊號,皆可以此第一指令信號S1代表。 In FIG. 1 , the processing unit 10 is configured to perform an action on the table 210 according to an instruction code, for example, executing an execution code 220 of an application. The instruction mapping module 110 converts the first instruction signal S1 from the processing unit 10 into a target instruction signal S2 according to the instruction code mapping table 210. The instruction decoding module 120 is configured to solve the target command signal S2 code. The execution module 130 executes the decoded target command signal. The memory unit 20 is coupled to the processing unit 10 via a bus 30, for example, to store a plurality of execution codes of the instruction code mapping table 210 and an application 220. The memory unit 20 can be implemented as the same or different memory modules. Group or device. In addition, during execution of the application execution code 220, the processing unit 10 may retrieve at least one or more instructions from the memory unit 20, and execute at least one or more instructions of the code 220, which may be parallel or serial data signals. , can be represented by the first command signal S1.

在第1圖中,處理單元10具有本身之一指令集(instruction set)架構,例如是基於精簡指令集(RISC)的處理器架構,如基於無內部互鎖管線階層微處理器(Microprocessor without Interlocked Pipeline Stage,MIPS)架構。而藉由具有指令映對模組110之架構,使處理單元10能執行基於一重新配置的指令集而產生(或編譯)的應用程式。指令映對模組110依據指令碼映對表210所輸出的目標指令信號S2所代表的指令編碼係符合處理單元10本身之指令集。故此,指令解碼模組120得以依據處理單元10本身之指令集進行解碼及由執行模組130執行。由此,處理單元10可視為可動態調整指令集的處理單元。 In Figure 1, processing unit 10 has its own instruction set architecture, such as a Reduced Instruction Set (RISC) based processor architecture, such as a microprocessor based interprocessor-free interleaved microprocessor (Microprocessor without Interlocked) Pipeline Stage, MIPS) architecture. By having the architecture of the instruction mapping module 110, the processing unit 10 can execute an application that is generated (or compiled) based on a reconfigured instruction set. The instruction mapping code represented by the instruction mapping module 110 according to the target command signal S2 outputted by the instruction code mapping table 210 conforms to the instruction set of the processing unit 10 itself. Therefore, the instruction decoding module 120 can be decoded according to the instruction set of the processing unit 10 itself and executed by the execution module 130. Thus, processing unit 10 can be considered a processing unit that can dynamically adjust the set of instructions.

請參照第2圖,其為可重新配置的指令執行方法之一實施例的流程圖。以下舉第1圖之硬體架構1為例說明,然而第2圖之方法並不受限於此。 Please refer to FIG. 2, which is a flowchart of one embodiment of a reconfigurable instruction execution method. The hardware architecture 1 of FIG. 1 is exemplified below, but the method of FIG. 2 is not limited thereto.

在步驟S110中,載入一指令碼映對表至一電子裝置之一處理單元10。電子裝置可視為此處理單元10,或亦 可視為基於此處理單元10的系統單晶片(system on chip),又可視為基於處理單元10之各種運算裝置,例如智慧型手機、平板電腦、筆記型電腦、個人電腦、或各種行動裝置或嵌入式系統如多媒體播放器等。步驟S110可實現為於處理單元10依據指令碼映對表執行一應用程式以前,處理單元10令指令映對模組110載入對應的指令碼映對表。又步驟S110可實現為於處理單元10中預先儲存一個或多個指令碼映對表,如此可供執行一應用程式執行時使用,其中更可實現依執行之應用程式選用對應的指令碼映對表。 In step S110, an instruction code is loaded into the processing unit 10 of one of the electronic devices. The electronic device can be regarded as the processing unit 10, or It can be regarded as a system on chip based on the processing unit 10, and can be regarded as various computing devices based on the processing unit 10, such as a smart phone, a tablet, a notebook, a personal computer, or various mobile devices or embedded. System such as multimedia player. Step S110 can be implemented. Before the processing unit 10 executes an application according to the instruction code mapping table, the processing unit 10 causes the instruction mapping module 110 to load the corresponding instruction code mapping table. Step S110 can be implemented to pre-store one or more instruction code mapping tables in the processing unit 10, so that it can be used when executing an application execution, and the corresponding instruction code mapping corresponding to the executed application can be implemented. table.

在步驟S120中,藉由處理單元10,擷取一應用程式之一第一指令信號S1。步驟S120可實施為由處理單元10之一指令擷取模組或指令映對模組110來完成。又例如處理單元10從電子裝置之記憶單元20取得指令碼映對表及擷取第一指令信號S1,第一指令信號S1代表此應用程式之複數個執行碼之至少一者。 In step S120, the processing unit 10 retrieves one of the first command signals S1 of an application. Step S120 can be implemented by one of the processing unit 10 to capture the module or the instruction mapping module 110. For another example, the processing unit 10 obtains the instruction code mapping table from the memory unit 20 of the electronic device and retrieves the first command signal S1, and the first command signal S1 represents at least one of the plurality of execution codes of the application.

在步驟S130中,藉由指令映對模組110,依據此載入之指令碼映對表,將第一指令信號S1轉換為一目標指令信號S2。 In step S130, the first mapping signal S1 is converted into a target command signal S2 by the instruction mapping module 110 according to the loaded instruction code mapping table.

在步驟S140中,藉由指令解碼模組120,對目標指令信號S2解碼,並藉由執行模組130,執行解碼後之目標指令信號。 In step S140, the target decoding signal S2 is decoded by the instruction decoding module 120, and the decoded target instruction signal is executed by the execution module 130.

於轉換步驟S130中,例如第一指令信號S1包括一編碼之指令編碼(例如是1001代表一指令ADD),目標指令信號S2包括一原始指令編碼(例如是1110代表指令 ADD),指令碼映對表儲存將此編碼之指令編碼映對為此原始指令編碼之一對一的映對關係。依據此指令碼映對表之映對關係,藉由指令映對模組110將第一指令信號S1轉換為目標指令信號S2。在另一例子中,指令碼映對表亦可儲存將複數個不同之編碼之指令編碼(例如1001、1101皆代表同一指令ADD)映對為此原始指令編碼之多對一的映對關係。 In the converting step S130, for example, the first command signal S1 includes an encoded instruction code (for example, 1001 represents an instruction ADD), and the target command signal S2 includes an original instruction code (for example, 1110 represents an instruction). ADD), the instruction code mapping table stores the mapping of the encoded code to the mapping of one of the original instructions to one. According to the mapping relationship of the instruction code, the first mapping signal S1 is converted into the target instruction signal S2 by the instruction mapping module 110. In another example, the instruction code mapping table may also store a multi-to-one mapping relationship that encodes a plurality of different encoded instruction codes (eg, 1001, 1101 representing the same instruction ADD).

在一實施例中,步驟S110-S140執行於一電子裝置。 In an embodiment, steps S110-S140 are performed on an electronic device.

從另一方面來說,指令碼映對表儲存將複數個編碼之指令編碼映對到複數個原始指令編碼之的函數關係(1對1或/及多對1之映對),而應用程式之執行碼係基於這些編碼之指令編碼表產生,又這些原始指令編碼表之指令包括於處理單元本身之一指令集中。 On the other hand, the instruction code mapping table stores a function relationship (one-to-one or/and many-to-one mapping) that maps a plurality of encoded instruction codes to a plurality of original instruction codes, and the application program The execution code is generated based on the coded instruction code tables, and the instructions of the original instruction code table are included in one of the processing units themselves.

由上述之實施例,處理單元10可視為可動態調整指令集編碼的處理單元。因為處理單元10可以執行基於不同指令集編碼的應用程式,如此,可帶來在實現處理單元10及執行應用程式時相當大的彈性以及產生不同的應用。在一實施例中,對於其他處理器指令集的程式,可以設計或產生指令碼映對表,與指令映對模組配合,藉由指令映對模組的轉換動作令基於其他處理器指令集的程式也能於處理單元10中執行。在一些實施例中,可設計或產生指令碼映對表,令應用程式之執行碼中兩相鄰之執行碼之漢明距離整體上(亦即在指令配對的分佈上)小於經此指令映對模組依據此指令碼映對表之轉換後之兩鄰之執行碼之漢明距離。有關於產生指令碼映對表及重新配置的 指令編碼方法,將舉例說明於後。 From the embodiments described above, processing unit 10 can be considered a processing unit that can dynamically adjust the instruction set encoding. Because the processing unit 10 can execute applications based on different instruction set encodings, it can bring considerable flexibility in implementing the processing unit 10 and executing the application and generate different applications. In an embodiment, for other processor instruction set programs, the instruction code mapping table may be designed or generated, and cooperated with the instruction mapping module, and the conversion operation of the instruction mapping module is based on other processor instruction sets. The program can also be executed in the processing unit 10. In some embodiments, the instruction code mapping table can be designed or generated such that the Hamming distance of two adjacent execution codes in the execution code of the application is less than the entire distribution (ie, the distribution of the instruction pair). The Hamming distance of the execution code of the two neighbors converted by the module according to the instruction code. Related to generating instruction code mapping and reconfiguration The instruction encoding method will be illustrated later.

請參考第3圖,其為第1圖之指令映對模組之一實施例的電路方塊圖。在第3圖中,指令映對模組300包括:一記憶體310(例如是暫存器或其他記憶體)及一控制電路320(例如是邏輯電路或其他電路之組合)。控制電路320,用以載入指令碼映對表於記憶體310中,並用以依據指令碼映對表,將第一指令信號S1轉換為目標指令信號S2。 Please refer to FIG. 3, which is a circuit block diagram of an embodiment of the command mapping module of FIG. 1. In FIG. 3, the command mapping module 300 includes a memory 310 (such as a temporary memory or other memory) and a control circuit 320 (for example, a combination of logic circuits or other circuits). The control circuit 320 is configured to load the instruction code mapping table in the memory 310, and to convert the first instruction signal S1 into the target instruction signal S2 according to the instruction code mapping table.

第4圖為可重新配置的指令編碼之處理器架構之另一實施例的方塊圖。相較於第1圖之處理單元10,第4圖之架構包括一指令擷取模組400和一多工器420。指令擷取模組400用以擷取第一指令信號S1。多工器420之複數個輸入端耦接一指令映對模組410及指令擷取模組400,多工器420之輸出端耦接指令解碼模組120。處理單元40依據一指示訊號(例如來自電子裝置之作業系統或電子裝置之系統電路),控制多工器420選擇指令映對模組410及指令擷取模組400之一者的輸出作為多工器420之輸出。在一實施例中,處理單元40可以具有一映對模式及一原始模式。在原始模式中,處理單元40可以執行以原始指令編碼編譯成的程式的執行碼(例如系統程式或作業系統的指令,也可以是一般應用程式)而不用經過指令映對模組410的處理,故利用多工器420,將指令擷取模組400之輸出傳送指令解碼模組120處理。在映對模式中,藉由指令映對模組410的處理,處理單元40可以執行以編碼之指令集而編譯成的程式的執行碼(例如是應用 程式,如以下第5圖所舉例所產生之應用程式),故利用多工器420,將指令映對模組410的輸出傳送到指令解碼模組120處理。此外,在另一實施例中,在原始模式中,又可令指令映對模組410進入省電狀態。如此,可重新配置的指令編碼之處理器架構之實施例可作具有多種實施方式,並不受限於此。 Figure 4 is a block diagram of another embodiment of a processor architecture for reconfigurable instruction encoding. The architecture of FIG. 4 includes an instruction capture module 400 and a multiplexer 420 as compared to the processing unit 10 of FIG. The instruction capture module 400 is configured to capture the first command signal S1. The plurality of inputs of the multiplexer 420 are coupled to a command mapping module 410 and the instruction capture module 400. The output of the multiplexer 420 is coupled to the instruction decoding module 120. The processing unit 40 controls the multiplexer 420 to select the output of the command mapping module 410 and the command capture module 400 as a multiplex according to an indication signal (for example, a system circuit from an operating system or an electronic device of the electronic device). The output of the 420. In an embodiment, processing unit 40 may have a mapping mode and a raw mode. In the original mode, the processing unit 40 can execute the execution code of the program compiled by the original instruction encoding (for example, the system program or the operating system command, or the general application) without the processing of the command mapping module 410. Therefore, the multiplexer 420 is used to process the output transfer instruction decoding module 120 of the instruction capture module 400. In the mapping mode, by the processing of the mapping module 410, the processing unit 40 can execute the execution code of the program compiled with the encoded instruction set (eg, an application). The program, as shown in the example shown in FIG. 5 below, uses the multiplexer 420 to transfer the output of the command mapping module 410 to the instruction decoding module 120 for processing. In addition, in another embodiment, in the original mode, the command mapping module 410 can be brought into a power saving state. As such, embodiments of the processor architecture of the reconfigurable instruction code can be implemented in a variety of ways, and are not limited thereto.

第5圖為可重新配置的指令編碼方法之一實施例的流程圖。此實施例可利用具有處理器及記憶體之一運算裝置中執行。步驟S10代表應用程式的原始碼(source code)被編譯為基於某一種指令集的目標碼之過程,例如可由編譯器(compiler)實現。目標碼如機器碼(machine code)或執行碼(executable code)或二進位碼(binary code)。在步驟S10產生目標碼的過程中,原始碼會被編譯為以組合語言(assembly)或虛擬語言(pseudo code)表示的程式碼,最後再基於某一指令集編碼而轉換為目標碼,能被基於此指令集所建構的處理器之指令解碼模組及執行模組處理。 Figure 5 is a flow diagram of one embodiment of a reconfigurable instruction encoding method. This embodiment can be implemented in an arithmetic device having a processor and a memory. Step S10 represents a process in which the source code of the application is compiled into an object code based on a certain instruction set, for example, by a compiler. The object code is such as a machine code or an executable code or a binary code. In the process of generating the target code in step S10, the original code is compiled into a code represented by a combination language or a pseudo code, and finally converted into a target code based on a certain instruction set encoding, which can be The instruction decoding module and the execution module processing of the processor constructed based on the instruction set.

在步驟S20中,執行程式碼概況分析(profiling),藉由統計程式碼(如以組合語言表示)中指令配對分佈,產生一指令編碼表及一指令碼映對表。步驟S20例如可實作於一編譯器中或者是實作為編譯器所使用的一個或多個軟體模組。指令編碼表給步驟S10之編譯過程使用,步驟S10基於此指令編碼表,代替原始的指令集編碼,將組合語言表示的程式碼轉換為目標碼。指令編碼表中的指令與指令編碼(即機器碼)的對應關係,是有別於原始的指令集編碼,故可視為重新配置之指令集編碼。故此,指令碼映 對表用以於目標碼藉由基於原始指令集編碼所建構的處理單元執行時使用。如第1至第4圖之實施例所示,處理單元藉由使用指令映對模組依據指令碼映對表,令應用程式得以執行。指令碼映對表儲存將此指令編碼表映對到一原始指令編碼表之映對關係。指令碼映對表及目標碼可皆包含於一應用程式之檔案中,亦可分開作為不同之檔案或軟體模組。 In step S20, program profiling is performed, and an instruction encoding table and an instruction code mapping table are generated by using the instruction pairing distribution in the statistical code (eg, in a combined language). Step S20 can be implemented, for example, in a compiler or as one or more software modules used by the compiler. The instruction encoding table is used by the compiling process of step S10, and step S10 converts the code represented by the combined language into the target code based on the instruction encoding table instead of the original instruction set encoding. The correspondence between the instructions in the instruction code table and the instruction code (ie, machine code) is different from the original instruction set code, so it can be regarded as the reconfigured instruction set code. Therefore, the instruction code map The table is used when the object code is executed by a processing unit constructed based on the original instruction set encoding. As shown in the first to fourth embodiments, the processing unit enables the application to execute by using the instruction mapping module to map the table according to the instruction code. The instruction code mapping table stores the mapping relationship of this instruction encoding table to an original instruction encoding table. The command code mapping table and the target code can all be included in an application file, or can be separated into different files or software modules.

第6圖為第5圖之程式碼概況分析步驟之一實施例的流程圖,用以實現可重新配置的指令編碼方法。 Figure 6 is a flow diagram of an embodiment of the code profiling step of Figure 5 for implementing a reconfigurable instruction encoding method.

如步驟S210所示,統計一應用程式之相鄰指令的配對分佈,並據以找出一指令配對集(例如至少含有原始指令編碼表中的部分指令),此指令配對集包括此應用程式之具較高使用率(例如出現次數較多)的複數個指令配對。 As shown in step S210, the pairing distribution of the adjacent instructions of an application is counted, and an instruction pairing set (for example, at least some instructions in the original instruction encoding table) is found, and the instruction pairing set includes the application. Multiple instruction pairs with higher usage rates (such as more occurrences).

在步驟S220中,對此指令配對集中較高使用率的複數個指令配對(一些或全部)進行編碼以賦予各指令配對相近的指令編碼,從而產生一第一指令編碼表。此第一指令編碼表與一原始指令編碼表具有相同數量之指令,且至少有複數個指令於此第一指令編碼表與此原始指令編碼表中對應到不同的指令編碼。 In step S220, a plurality of instruction pairs (some or all) of the higher usage rate are encoded in the instruction pairing pair to give each instruction a similar instruction encoding, thereby generating a first instruction encoding table. The first instruction encoding table has the same number of instructions as a raw instruction encoding table, and at least a plurality of instructions correspond to different instruction encodings in the first instruction encoding table and the original instruction encoding table.

在步驟S230中,依據此第一指令編碼表,找出此指令配對集內配對指令的漢明距離,並依據此指令配對集之此些配對指令的漢明距離和出現次數,從此指令配對集中找出複數個指令。 In step S230, according to the first instruction encoding table, finding the Hamming distance of the pairing instruction in the instruction pairing set, and according to the instruction, the Hamming distance and the number of occurrences of the pairing instructions of the pairing set, from the instruction pairing set Find out the multiple instructions.

在步驟S240中,對這些找出之指令進行重複編碼,以得到一第二指令編碼表。重複編碼賦予各個找出之指令 至少一額外的指令編碼。此第二指令編碼表係基於前述的第一指令編碼表延伸且包含此些額外的指令編碼。 In step S240, the found instructions are repeatedly encoded to obtain a second instruction encoding table. Repeat coding gives each found command At least one additional instruction code. This second instruction encoding table is extended based on the aforementioned first instruction encoding table and includes such additional instruction encoding.

在步驟S250中,產生一指令碼映對表,其中此指令碼映對表儲存將此第二指令編碼表映對到前述的原始指令編碼表之映對關係。 In step S250, an instruction code mapping table is generated, wherein the instruction code mapping table stores the mapping relationship of the second instruction encoding table to the original instruction encoding table.

如此,利用一編譯器依據此第二指令編碼表及此應用程式之指令,能產生此應用程式之執行碼。 Thus, a compiler can generate an execution code of the application according to the second instruction encoding table and the instructions of the application.

在一些實施例中,可在編譯器或組譯器內實施一編碼方式選擇模組或步驟,當一個指令對應到多個編碼之指令編碼時,使編譯器、組譯器產生連續指令間指令匯流排上訊號相位變化最少的機器碼。此編譯器之編碼方式選擇模組或步驟,依據指令編碼表選擇一個最佳的編碼方式,使其與前後指令漢明距離較短。例如在處理兩相鄰之指令,如對於指令IN1-IN2,IN1對應到(1001,0101),IN2對應到(0100),選擇能使指令IN1及IN2之漢明距離較小的指令編碼,即IN1:0101,IN2:0100。 In some embodiments, an encoding mode selection module or step may be implemented in the compiler or the interpreter to cause the compiler and the interpreter to generate consecutive inter-instruction instructions when an instruction corresponds to a plurality of encoded instruction encodings. The machine code with the least change in signal phase on the bus. The coding mode of the compiler selects a module or a step, and selects an optimal coding mode according to the instruction coding table, so that the distance between the front and rear instructions is shorter. For example, in processing two adjacent instructions, such as for instructions IN1-IN2, IN1 corresponds to (1001, 0101), and IN2 corresponds to (0100), and the instruction code that enables the commanding distances of IN1 and IN2 to be small is selected, that is, IN1:0101, IN2:0100.

此外,於一實施列中,產生指令編碼表之步驟S220可包括以下。對指令配對集的複數個指令配對,依據使用率高低依序從使用率最高的一指令配對開始對此些指令配對進行編碼以賦予各個這些指令配對相近的指令編碼。基於此些指令配對進行編碼,產生此指令編碼表。 Further, in an implementation, the step S220 of generating the instruction code table may include the following. A plurality of instruction pairs for the instruction pairing set are coded according to the usage level in order from the highest usage of the instruction pair to give each of the instructions a similar instruction code. The encoding of the instruction is generated based on the pairing of the instructions.

又於一些實施列中,步驟S230依據漢明距離和出現次數之各種關係來決定此些找出之指令。例如基於漢明距離和出現次數之乘積之大小來決定;換言之,此例子中此些找出之指令為指令配對集中漢明距離和出現次數之乘 積較大的配對指令,例如選出2、4或10個乘積較大的配對指令。 In some implementations, step S230 determines the instructions for finding out based on various relationships between the Hamming distance and the number of occurrences. For example, it is determined based on the product of the Hamming distance and the number of occurrences; in other words, the instructions found in this example are the multiplication of the Hamming distance and the number of occurrences in the instruction pairing set. A larger pairing instruction, such as selecting 2, 4 or 10 multiplied pairing instructions.

以下舉例說明程式碼概況分析步驟之實施例。茲舉台灣工業技術研究院(ITRI)的「平行架構核心」(Parallel Architecture Core,PAC)計畫所研發出的其中之一處理器PAC-Lite為例。PAC-Lite採用32-位元之固定位元長度指令集,指令的格式大致可表示為:oooo ccc fff dddddd sssssttttt aaaaaa,其中與指令的操作碼(opcode)相關的是o代表操作碼的型態(type)共4位元,f代表操作碼的功能(function)共3位元。而一操作碼是由型態碼及功能碼,即oooo fff所組成。PAC-Lite的原始的指令集可示意如表一。 The following is an example of an example of a code profiling step. Take the example of PAC-Lite, one of the processors developed by the Taiwan Industrial Technology Research Institute (ITRI)'s Parallel Architecture Core (PAC) program. PAC-Lite uses a 32-bit fixed bit length instruction set. The format of the instruction can be roughly expressed as: oooo ccc fff dddddd sssssttttt aaaaaa, where the opcode associated with the instruction is o representing the type of the opcode. (type) A total of 4 bits, f represents the function of the opcode (a total of 3 bits). An opcode consists of a type code and a function code, namely oooo fff. The original instruction set of PAC-Lite can be illustrated as Table 1.

為簡潔表述,在表一中以易記碼代表的指令,只有列出類型碼,而同一類型的指令,可以依照表一中指令排列 的順序加以定義指令相對應的功能碼,例如以二進位碼、格雷碼或其他方式編碼。例如,指令NOP及TRAP的操作碼可分別定義為0000 000及0000 0001。 For the sake of brevity, the instructions represented by the easy-to-remember code in Table 1 only list the type code, and the instructions of the same type can be arranged according to the instructions in Table 1. The order is defined by the function code corresponding to the instruction, for example, by binary code, Gray code or other means. For example, the opcodes for the NOP and TRAP commands can be defined as 0000 000 and 0000 0001, respectively.

在以下的舉例說明中,假設第1圖之處理單元10基於上述之PAC-Lite的指令集架構而成。為了減少應用程式在執行時,由於應用程式之指令傳輸於匯流排30產生頻繁的匯流排訊號切換動作導致的功率消耗,故利用如第5及6圖之方法以產生指令編碼表和指令映對表以及此應用程式的目標碼。 In the following description, it is assumed that the processing unit 10 of FIG. 1 is constructed based on the above-described instruction set of the PAC-Lite. In order to reduce the power consumption caused by frequent bus signal switching actions when the application program is transmitted to the bus 30, the method as shown in FIGS. 5 and 6 is used to generate the instruction code table and the command mapping. Table and object code for this application.

以下依據第6圖之方法,舉例說明產生指令編碼表和指令映對表的產生過程。 In the following, according to the method of FIG. 6, an example of generating a command code table and a command map table will be described.

依據步驟S210,統計一應用程式之相鄰指令的配對分佈(如表二所示),並據以找出一指令配對集。表二之「指令對」(instruction pairs)欄位表示一應用程式(例如以組合語言表示)之兩相鄰指令,例如MOVI.H-MOVI.L、ADD-SRLI、ADD-SLLI;欄位N代表指令對的出現次數,其中可統計應用程式碼中所有的或是某一出現次數以上的相鄰指令。指令配對集IP0,例如是至少含有原始指令編碼表OIT(如表一)中的部分指令,此指令配對集包括此應用程式之具較高使用率的複數個指令配對。例如將指令對的統計分佈按高低排序,如表二所示,可將出現次數較多(即使用率較高)的指令對排列在前,出現次數較少(即使用率較低)的指令對排列在後。 According to step S210, the pairing distribution of adjacent instructions of an application is counted (as shown in Table 2), and an instruction pairing set is found accordingly. The "instruction pairs" field in Table 2 indicates two adjacent instructions of an application (for example, in a combined language), such as MOVI.H-MOVI.L, ADD-SRLI, ADD-SLLI; field N Represents the number of occurrences of an instruction pair, where all or some of the adjacent instructions in the application code are counted. The instruction pairing set IP0, for example, contains at least some of the instructions in the original instruction encoding table OIT (as shown in Table 1). The instruction pairing set includes a plurality of instruction pairs of the application with higher usage rate. For example, the statistical distribution of the instruction pairs is sorted according to the level. As shown in Table 2, the instruction pairs with more occurrences (that is, the higher usage rate) can be arranged first, and the instructions with fewer occurrences (that is, the usage rate is lower) can be arranged. Paired in the back.

依據步驟S220中,對指令配對集IP0中較高使用率的複數個指令配對進行編碼以賦予各指令配對相近的指令編碼,從而產生一第一指令編碼表IET0(如表三所示)。例如對表二中使用率較高的前5對、10對、或對使用率超過一門檻值的指令對(如出現次數在1000以上),或對表二所有的指令對,以進行編碼。例如從指令配對集IP0中使用率最高的指令對開始編碼,接著按照使用率高低對指令對進行編碼。此處的編碼動作意味著重新定義此指令對中兩個指令的操作碼,例如本例之操作碼的型態代碼或功能代碼或兩者,令此兩指令具有相近(即漢明距離較小)的指令編碼。例如表一中的指令例如MOVI.H、MOVI.L、ADD、SW、SH的類型碼在表三中已分別改變為0111、0111、0011、0010、0010。基於此類型碼,更可以配置指令的 功能碼,令兩相鄰指令具有相近的指令編碼。例如表二的欄位T指出經過編碼動作後,例如指令對ADD-SRLI的漢明距離或轉換數(toggle count)從原來的5(即括號中的數字)改為2,指令對ADD-SLLI的漢明距離從4改為3。此外,如表三所示的第一指令編碼表與如表一所示的原始指令編碼表OIT具有相同數量之指令,且至少有複數個指令(例如MOVI.H、MOVI.L、ADD、SW、SH)於第一指令編碼表與原始指令編碼表中對應到不同的指令編碼。 According to step S220, a plurality of instruction pairs of the higher usage rate in the instruction pairing set IP0 are encoded to give the instruction codes of the respective instructions to be matched, thereby generating a first instruction encoding table IET0 (as shown in Table 3). For example, the first 5 pairs, 10 pairs, or the pair of instructions whose usage rate exceeds one threshold in Table 2 (if the number of occurrences is more than 1000), or all the pairs of instructions in Table 2 are encoded. For example, encoding is started from the instruction pair with the highest usage rate in the instruction pairing set IP0, and then the instruction pair is encoded according to the usage rate. The encoding action here means redefining the opcode of the two instructions in the pair of instructions, such as the type code or function code of the opcode of this example or both, so that the two instructions have similar (ie, the Hamming distance is small) The instruction code. For example, the type codes of the instructions in Table 1, such as MOVI.H, MOVI.L, ADD, SW, SH, have been changed to 0111, 0111, 0011, 0010, and 0010 in Table 3, respectively. Based on this type of code, it is more configurable Function code, so that two adjacent instructions have similar instruction codes. For example, the field T of Table 2 indicates that after the encoding action, for example, the Hamming distance or the toggle count of the instruction to ADD-SRLI is changed from the original 5 (ie, the number in parentheses) to 2, and the instruction is ADD-SLLI. The Hamming distance was changed from 4 to 3. In addition, the first instruction encoding table as shown in Table 3 has the same number of instructions as the original instruction encoding table OIT shown in Table 1, and at least a plurality of instructions (for example, MOVI.H, MOVI.L, ADD, SW) And SH) corresponding to different instruction codes in the first instruction encoding table and the original instruction encoding table.

此外,依據表二,此應用程式的指令對的總轉換數(total toggle count),即所有指令對的出現次數與轉換數的乘積的總和,經過編碼之後,從原有的168968減少為117420,即減少了30.50%。 In addition, according to Table 2, the total toggle count of the instruction pair of the application, that is, the sum of the number of occurrences of all instruction pairs and the number of conversions, is reduced from the original 168968 to 117420 after encoding. That is, it is reduced by 30.50%.

接著,依據步驟S230,依據第一指令編碼表,找出 此指令配對集IP0內所有配對指令的漢明距離(如表二的欄位T中的經編碼後的指令對的轉換數),並依據此指令配對集之這些配對指令的漢明距離和出現次數(例如其乘積),從指令配對集IP0中找出複數個指令IP1。如表四所示,依據配對指令的漢明距離和出現次數的乘積(P),從大至小排序,從而找出此乘積較高的複數個配對指令(即指令對)IP1,例如取乘積較高的前5對、10對、或取其乘積超過一門檻值(如1000或7000以上)的指令對,來進行下一步驟中的重複編碼。為便於說明,在此例中選出表四中乘積數排行前四對的指令(加註*號)。 Then, according to step S230, according to the first instruction coding table, find out This instruction pairs the Hamming distances of all paired instructions in IP0 (such as the number of converted instruction pairs in column T of Table 2), and according to the instruction, the Hamming distance and appearance of these pairing instructions The number of times (for example, its product) finds a plurality of instructions IP1 from the instruction pair set IP0. As shown in Table 4, according to the product (P) of the Hamming distance and the number of occurrences of the pairing instruction, the order is sorted from large to small, thereby finding a plurality of pairing instructions (ie, instruction pairs) IP1 having a higher product, for example, taking a product. A higher first 5 pairs, 10 pairs, or a pair of instructions whose product exceeds a threshold (eg, 1000 or more) to perform the repetitive encoding in the next step. For convenience of explanation, in this example, the first four pairs of the number of products in Table 4 are selected (the * is added).

依據步驟S240中,對這些找出之指令IP1進行重複編碼,以得到一第二指令編碼表IET1。例如表五所示,重複編碼步驟賦予各個這些找出之指令IP1(如SLLI、ADD、 SRLI、SH)至少一額外的指令編碼。在決定如何賦予額外的指令編碼時,設定這些找出之指令彼此間之一拓撲關係(topology),例如令SLLI-ADD、ADD-SRLI、SRLI-SH兩兩指令之間具有漢明距離為1的指令編碼。此外,此例之第二指令編碼表IET1係基於如表三所示之第一指令編碼表IET0延伸且包含如表五所示的這些額外的指令編碼。如此,第二指令編碼表中這些經重複編碼動作的指令具有兩個不同的指令編碼,如加法運算ADD具有兩個指令編碼:0011 000及0110 011。 According to step S240, the found commands IP1 are repeatedly encoded to obtain a second command encoding table IET1. For example, as shown in Table 5, the repetitive encoding step gives each of these found instructions IP1 (such as SLLI, ADD, SRLI, SH) at least one additional instruction code. When deciding how to assign additional instruction encoding, set a topological relationship between these found instructions, for example, let the Hamming distance between the SLLI-ADD, ADD-SRLI, and SRLI-SH instructions be 1 Instruction code. In addition, the second instruction encoding table IET1 of this example is extended based on the first instruction encoding table IET0 as shown in Table 3 and includes these additional instruction encodings as shown in Table 5. Thus, the instructions of the repetitive encoding action in the second instruction encoding table have two different instruction encodings, such as the addition operation ADD having two instruction encodings: 0011 000 and 0110 011.

然而,重複編碼賦予額外的指令編碼的方式並不受限於此。例如,可利用如表三所示的第一指令編碼表IET0中保留區段或保留位元(reserved bits)(如某些型態中未被使用的可能編碼),上述這些被找出之指令集IP1亦可依據一拓撲關係而分別決定要填入的保留區段,進而產生對應的重新配置編碼的額外的指令編碼。此外,重複編碼亦可同時利用保留區段及延伸區段(即新增型態如表五所示)來賦予額外的指令編碼。又對於前述找出的指令進行重複編碼時,各個指令可以被賦予不同或相同數目的額外指令編 碼。這些額外的指令編碼可以具有相同或不同的型態碼,而這些指令之間的拓撲關係及亦可對應到不同或相同的漢明距離。 However, the manner in which the repetition coding gives an additional instruction code is not limited to this. For example, the reserved segments or reserved bits in the first instruction encoding table IET0 as shown in Table 3 (such as possible encodings that are not used in some types) may be utilized, and the above-mentioned instructions are found. The set IP1 can also determine the reserved sections to be filled according to a topological relationship, thereby generating an additional instruction code corresponding to the reconfiguration code. In addition, the repetitive coding can also use the reserved section and the extended section (ie, the new type is shown in Table 5) to give additional instruction coding. In addition, when the above-mentioned found instructions are repeatedly coded, each instruction may be given a different or the same number of additional instructions. code. These additional instruction codes may have the same or different type codes, and the topological relationship between these instructions may also correspond to different or the same Hamming distance.

依據步驟S250中,產生一指令碼映對表,其中此指令碼映對表儲存將第二指令編碼表IET1映對到原始指令編碼表OIT(如表一)之映對關係。舉例而言,如表六所示,指令碼映對表儲存著將代表同一指令的多個指令編碼映對至一原始指令編碼的映對關係,例如加法運算指令ADD來說,在第二指令編碼表IET1中具有兩個不同的編碼。此外,如表六所示,指令碼映對表亦儲存著一重新配置編碼的指令碼映對到一原始指令編碼的映對關係,例如將32位元的字組儲存到資料記憶體的指令SW。 According to step S250, an instruction code mapping table is generated, wherein the instruction code mapping table stores the mapping relationship between the second instruction encoding table IET1 and the original instruction encoding table OIT (as shown in Table 1). For example, as shown in Table 6, the instruction code mapping table stores a mapping relationship that maps a plurality of instruction codes representing the same instruction to an original instruction code, such as the addition instruction ADD, in the second instruction. There are two different encodings in the coding table IET1. In addition, as shown in Table 6, the instruction code mapping table also stores a mapping relationship of a reconfigured coded code pair to an original instruction code, such as an instruction to store a 32-bit block into a data memory. SW.

依據上述例子的第二指令編碼表IET1,此應用程式的指令對的總轉換數,再經過重複編碼之後,從原有的168968降為73740,亦即減少了56.36%。 According to the second instruction encoding table IET1 of the above example, the total number of conversions of the instruction pair of the application is further reduced from the original 168968 to 73740 after the repeated encoding, that is, the reduction is 56.36%.

故此,基於處理器PAC-Lite之原始指令編碼表之所實現的處理單元10,藉由指令映對模組110依據前述例子所產生的指令碼映對表,可以執行依據本例之第二指令編碼表IET1所產生的應用程式的目標碼。又因此應用程 式之執行碼中兩相鄰之執行碼之漢明距離整體上係小於經此指令映對模組110依據此指令碼映對表之轉換後之兩鄰之執行碼之漢明距離,執行碼在匯流排30上傳輸時將會產生較低的切換損耗,從而有助減少處理單元10之電子裝置在執行應用程式時的電源消耗。 Therefore, the processing unit 10 implemented by the original instruction encoding table of the processor PAC-Lite can execute the second instruction according to the example by the instruction mapping module 110 according to the instruction code mapping table generated by the foregoing example. The object code of the application generated by the encoding table IET1. Application therefore The Hamming distance of the two adjacent execution codes in the execution code of the formula is less than the Hamming distance of the execution code of the two neighbors converted by the module 110 according to the instruction code mapping table, and the execution code A lower switching loss will occur when transmitting on the bus 30, thereby helping to reduce the power consumption of the electronic device of the processing unit 10 when executing the application.

除了上述採用PAC-Lite處理器的指令集為例的說明外,上述如第5及6圖所示的方法的實施例可應用其他合適的指令集架構,例如以MIPS處理器為例的32位元固定長度編碼的指令集,例如其指令格式可表示為:ooooooss sssttttt dddddaaa aaffffff,與指令相關的是o:opcode(6位元)與f:function(6位元)。又例如ARM之32位元之指令集架構或其他如32或64位元的指令集架構。吾人當可以相似於上述例子的方式來實施例之方法及電子裝置於其他處理器之指令集架構。 In addition to the above description of the instruction set using the PAC-Lite processor, the above embodiments of the method shown in Figures 5 and 6 can be applied to other suitable instruction set architectures, such as 32-bit MIPS processors. The instruction set of the fixed-length code, for example, its instruction format can be expressed as: ooooooss sssttttt dddddaaa aaffffff, related to the instruction are o:opcode (6-bit) and f:function (6-bit). Another example is ARM's 32-bit instruction set architecture or other instruction set architecture such as 32 or 64 bits. We can use the method of the embodiment and the instruction set architecture of the electronic device on other processors in a manner similar to the above examples.

上述程式碼概況分析步驟S20之實施例以產生第二指令編碼表為例,然而,實現方式並不受限於此。如在一些實施例中,程式碼概況分析步驟S20可實施為基於步驟S210及S220產生第一指令編碼表(IET0),且基於第一指令編碼表產生一指令碼映對表,其中第一指令編碼表(IET0)用以供編譯器產生此應用程式之執行碼之用,此指令碼映對表儲存將此第一指令編碼表(IET0)映對到此原始指令編碼表(OIT)之映對關係。此外,在一些實施例中,程式碼概況分析步驟S20可實施為其他方式,例如基於步驟S210、S230至S250以實施,其中原步驟S230中所依據之第一指令編碼表可以用原始指令編碼表代替。又上述 這些與第6圖不同的實施例亦可更進一步加上其他最佳化或處理以產生新的指令編碼表,進而透過步驟S250產生一指令碼映對表。 The embodiment of the above code profiling step S20 is exemplified by the second instruction encoding table. However, the implementation is not limited thereto. As in some embodiments, the code profiling step S20 may be implemented to generate a first instruction encoding table (IET0) based on steps S210 and S220, and generate an instruction code mapping table based on the first instruction encoding table, where the first instruction The code table (IET0) is used by the compiler to generate the execution code of the application. The code map maps the first instruction code table (IET0) to the original instruction code table (OIT). The relationship. In addition, in some embodiments, the code profiling step S20 may be implemented in other manners, for example, based on steps S210, S230 to S250, wherein the first instruction encoding table according to the original step S230 may use the original instruction encoding table. instead. Again The embodiments different from FIG. 6 can be further optimized or processed to generate a new instruction code table, and an instruction code mapping table is generated through step S250.

再者,其他實施例更揭露一種電腦或運算裝置可讀式資訊儲存媒體,其上儲存有程式碼或一個或多個程式模組,此程式碼之執行能實現上述實施例如第5圖之可重新配置的指令編碼方法,其中程式碼概況分析步驟可依據第6圖或其他實施例而實現。這些實施例的可讀式資訊儲存媒體比如但不受限於:光學式資訊儲存媒體,磁式資訊儲存媒體或記憶體,如記憶卡、靭體或ROM或RAM或可程式化之微控制器之內建記憶體。另外,上述之方法可以實施為一個或多個應用程式界面的程式庫。依據前述實施例,資訊儲存媒體儲存之程式碼或一個或多個程式模組例如可實作為一編譯器或者是實作為一編譯器所使用的一個或多個軟體模組。 Furthermore, other embodiments further disclose a computer or computing device readable information storage medium having a code or one or more program modules stored thereon, and the execution of the code can implement the above implementation, for example, FIG. A reconfigured instruction encoding method, wherein the code profiling step can be implemented in accordance with FIG. 6 or other embodiments. The readable information storage media of these embodiments are, for example but not limited to: optical information storage media, magnetic information storage media or memory such as a memory card, firmware or ROM or RAM or a programmable microcontroller Built-in memory. Additionally, the methods described above can be implemented as a library of one or more application interfaces. According to the foregoing embodiment, the code stored in the information storage medium or the one or more program modules can be implemented as a compiler or as one or more software modules used by a compiler.

綜上所述,雖然以實施例揭露如上,然其並非用以限定本案之實施方式。本揭露所屬技術領域中具有通常知識者,在不脫離本揭露之精神和範圍內,當可作各種之更動與潤飾。因此,本案之保護範圍當視後附之申請專利範圍所界定者為準。 In summary, although the above is disclosed in the embodiments, it is not intended to limit the embodiments of the present invention. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the disclosure. Therefore, the scope of protection of this case is subject to the definition of the scope of the patent application attached.

1‧‧‧硬體架構 1‧‧‧ hardware architecture

10‧‧‧處理單元 10‧‧‧Processing unit

20‧‧‧記憶單元 20‧‧‧ memory unit

30‧‧‧匯流排 30‧‧‧ Busbars

100‧‧‧指令擷取模組 100‧‧‧Command capture module

110、300、410‧‧‧指令映對模組 110, 300, 410‧‧‧ instruction mapping module

120‧‧‧指令解碼模組 120‧‧‧Instruction Decoding Module

130‧‧‧執行模組 130‧‧‧Execution module

210‧‧‧指令碼映對表 210‧‧‧ instruction code mapping

220‧‧‧應用程式之執行碼 220‧‧‧Application execution code

310‧‧‧記憶體 310‧‧‧ memory

320‧‧‧控制電路 320‧‧‧Control circuit

400‧‧‧指令擷取模組 400‧‧‧Command capture module

420‧‧‧多工器 420‧‧‧Multiplexer

S10、S20、S110-S140、S210-S250‧‧‧步驟 S10, S20, S110-S140, S210-S250‧‧‧ steps

第1圖為可重新配置的指令編碼之硬體架構之一實施例的方塊圖。 Figure 1 is a block diagram of one embodiment of a hardware architecture for reconfigurable instruction encoding.

第2圖為可重新配置的指令執行方法之一實施例的 流程圖。 Figure 2 is an embodiment of a reconfigurable instruction execution method flow chart.

第3圖為第1圖之指令映對模組之一實施例的電路方塊圖。 Figure 3 is a circuit block diagram of an embodiment of the command mapping module of Figure 1.

第4圖為可重新配置的指令編碼之處理器架構之另一實施例的方塊圖。 Figure 4 is a block diagram of another embodiment of a processor architecture for reconfigurable instruction encoding.

第5圖為可重新配置的指令編碼方法之一實施例的流程圖。 Figure 5 is a flow diagram of one embodiment of a reconfigurable instruction encoding method.

第6圖為第5圖之程式碼概況分析步驟之一實施例的流程圖。 Figure 6 is a flow chart showing an embodiment of the code profile analysis step of Figure 5.

1‧‧‧硬體架構 1‧‧‧ hardware architecture

10‧‧‧處理單元 10‧‧‧Processing unit

20‧‧‧記憶單元 20‧‧‧ memory unit

30‧‧‧匯流排 30‧‧‧ Busbars

100‧‧‧指令擷取模組 100‧‧‧Command capture module

110‧‧‧指令映對模組 110‧‧‧Command mapping module

120‧‧‧指令解碼模組 120‧‧‧Instruction Decoding Module

130‧‧‧執行模組 130‧‧‧Execution module

210‧‧‧指令碼映對表 210‧‧‧ instruction code mapping

220‧‧‧應用程式之執行碼 220‧‧‧Application execution code

Claims (22)

一種可重新配置的指令執行方法,執行於一電子裝置,包括:載入一指令碼映對表至該電子裝置之一處理單元,其中該處理單元包括一指令映對模組、一指令解碼模組及一執行模組;藉由該處理單元,擷取一應用程式之一第一指令信號;藉由該指令映對模組,依據該指令碼映對表,將該第一指令信號轉換為一目標指令信號;以及藉由該指令解碼模組,對該目標指令信號解碼,並藉由該執行模組,執行該解碼後之目標指令信號。 A reconfigurable instruction execution method, implemented in an electronic device, comprising: loading a command code mapping table to a processing unit of the electronic device, wherein the processing unit comprises a command mapping module and an instruction decoding module And an execution module; the processing unit captures a first instruction signal of an application; and the module reflects the module, and the first instruction signal is converted into a table according to the instruction code a target instruction signal; and the target instruction signal is decoded by the instruction decoding module, and the decoded target instruction signal is executed by the execution module. 如申請專利範圍第1項所述之可重新配置的指令執行方法,其中該處理單元從該電子裝置之一記憶單元取得該指令碼映對表及擷取該第一指令信號,該第一指令信號代表該應用程式之複數個執行碼之至少一者。 The reconfigurable instruction execution method of claim 1, wherein the processing unit obtains the instruction code mapping table from a memory unit of the electronic device and retrieves the first instruction signal, the first instruction The signal represents at least one of a plurality of execution codes of the application. 如申請專利範圍第1項所述之可重新配置的指令執行方法,其中於該轉換步驟中,該第一指令信號包括一編碼之指令編碼,該目標指令信號包括一原始指令編碼,該指令碼映對表儲存將該編碼之指令編碼映對為該原始指令編碼之一對一的映對關係;依據該指令碼映對表之該映對關係,藉由該指令映對模組將該第一指令信號轉換為該目標指令信號。 The reconfigurable instruction execution method of claim 1, wherein in the converting step, the first instruction signal comprises an encoded instruction code, the target instruction signal comprising an original instruction code, the instruction code The mapping table stores the coded instruction code paired as a mapping relationship of the original instruction code; and according to the instruction code, the pair mapping of the table is performed by the instruction mapping module A command signal is converted to the target command signal. 如申請專利範圍第1項所述之可重新配置的指令執行方法,其中於該轉換步驟中,該第一指令信號包括一 編碼之指令編碼,該目標指令信號包括一原始指令編碼,該指令碼映對表儲存將複數個不同之編碼之指令編碼映對為該原始指令編碼之多對一的映對關係;依據該指令碼映對表之該映對關係,藉由該指令映對模組將該第一指令信號轉換為該目標指令信號。 The reconfigurable instruction execution method of claim 1, wherein in the converting step, the first instruction signal comprises a The encoded instruction code, the target instruction signal includes an original instruction code, and the instruction code mapping table stores a plurality of different coded instruction code pairs as a multi-to-one mapping relationship of the original instruction code; The mapping of the mapping of the pair of pixels to the table is performed by the instruction mapping module to convert the first instruction signal into the target instruction signal. 如申請專利範圍第2項所述之可重新配置的指令執行方法,其中該指令碼映對表儲存將複數個編碼之指令編碼映對到複數個原始指令編碼之的函數關係,該應用程式之該些執行碼係基於該些編碼之指令編碼,該些原始指令編碼之指令包括於該處理單元之一指令集中。 The reconfigurable instruction execution method of claim 2, wherein the instruction code mapping table stores a function relationship of a plurality of coded instruction codes to a plurality of original instruction codes, and the application program The execution codes are based on the coded instruction codes, and the instructions of the original instruction code are included in one of the processing units. 如申請專利範圍第5項所述之可重新配置的指令執行方法,其中該些編碼之指令編碼中具有一第一複數個編碼之指令編碼對應到該些原始指令編碼之多對一的映對關係。 The reconfigurable instruction execution method of claim 5, wherein the coded instruction code has a first plurality of coded instruction codes corresponding to the many-to-one mapping of the original instruction codes. relationship. 如申請專利範圍第6項所述之可重新配置的指令執行方法,其中該處理器擷取之該應用程式之該些執行碼中兩相鄰之執行碼之漢明距離整體上係小於經該指令映對模組依據該指令碼映對表之轉換後之兩鄰之執行碼之漢明距離。 The reconfigurable instruction execution method of claim 6, wherein the Hamming distance of two adjacent execution codes of the execution codes of the application captured by the processor is less than The command mapping module according to the instruction code maps the Hamming distance of the two adjacent execution codes of the converted table. 一種電子裝置,包括:一處理單元,用以依據一指令碼映對表以進行指令之執行,其中該處理單元包括:一指令映對模組,依據該指令碼映對表,將該處理單元擷取之一第一指令信號轉換為一目標指令信號;一指令解碼模組,係對該目標指令信號解碼; 以及一執行模組,係執行該解碼後之目標指令信號。 An electronic device, comprising: a processing unit, configured to perform an instruction execution according to an instruction code, wherein the processing unit comprises: a command mapping module, according to the instruction code mapping table, the processing unit Extracting one of the first command signals into a target command signal; and an instruction decoding module decoding the target command signal; And an execution module, which executes the decoded target command signal. 如申請專利範圍第8項所述之電子裝置,更包括:一記憶單元,用以儲存該指令碼映對表及一應用程式之複數個執行碼;其中該第一指令信號代表該些執行碼之至少一者。 The electronic device of claim 8, further comprising: a memory unit for storing the instruction code mapping table and a plurality of execution codes of an application; wherein the first instruction signal represents the execution code At least one of them. 如申請專利範圍第9項所述之電子裝置,其中該處理單元依據該指令碼映對表執行該應用程式以前,令該指令映對模組載入該指令碼映對表。 The electronic device of claim 9, wherein the processing unit loads the instruction code mapping table before executing the application according to the instruction code mapping table. 如申請專利範圍第8項所述之電子裝置,其中該指令映對模組包括:一記憶體;以及一控制電路,用以載入該指令碼映對表於該記憶體中,並用以依據該指令碼映對表,將該第一指令信號轉換為該目標指令信號。 The electronic device of claim 8, wherein the command mapping module comprises: a memory; and a control circuit for loading the instruction code in the memory and for The instruction code maps the table and converts the first command signal into the target command signal. 如申請專利範圍第8項所述之電子裝置,更包括:一指令擷取模組,用以擷取該第一指令信號;以及一多工器,該多工器之複數個輸入端耦接該指令映對模組及該指令擷取模組,該多工器之複數個輸出端耦接該指令解碼模組;其中該處理單元依據一指示訊號,控制該多工器選擇該指令映對模組及該指令擷取模組之一者的輸出作為該多工器之輸出。 The electronic device of claim 8, further comprising: an instruction capture module for capturing the first command signal; and a multiplexer, the plurality of inputs of the multiplexer being coupled The command is directed to the module and the command capture module, and the plurality of outputs of the multiplexer are coupled to the command decode module; wherein the processing unit controls the multiplexer to select the command map according to an indication signal The output of the module and one of the instruction capture modules is used as the output of the multiplexer. 如申請專利範圍第8項所述之電子裝置,其中該 指令碼映對表儲存將複數個編碼之指令碼映對到複數個原始指令編碼之的函數關係,該應用程式之該些執行碼係基於該些編碼之指令編碼,該些原始指令編碼之指令包括於該處理單元之一指令集中。 An electronic device as claimed in claim 8, wherein the electronic device The instruction code mapping table stores a function relationship of a plurality of coded instruction codes to a plurality of original instruction codes, and the execution code of the application is based on the coded instruction codes, and the original instruction code instructions are Included in one of the processing units of the processing unit. 如申請專利範圍第13項所述之電子裝置,其中該處理器擷取之該應用程式之該些執行碼中兩相鄰之執行碼之漢明距離整體上係小於經該指令映對模組依據該指令碼映對表之轉換後之兩鄰之執行碼之漢明距離。 The electronic device of claim 13, wherein the Hamming distance of two adjacent execution codes of the execution codes of the application captured by the processor is less than the module corresponding to the instruction. According to the instruction code, the Hamming distance of the execution code of the two neighbors after the conversion of the table is mapped. 一種可重新配置的指令編碼方法,包括:統計一應用程式之相鄰指令的配對分佈,並據以找出一指令配對集,該指令配對集包括該應用程式之具較高使用率的複數個指令配對;對該指令配對集中較高使用率的該些指令配對進行編碼以賦予各指令配對相近的指令編碼,從而產生一指令編碼表,其中該指令編碼表與一原始指令編碼表具有相同數量之指令,且至少有複數個指令於該指令編碼表與該原始指令編碼表中對應到不同的指令編碼;以及產生一指令碼映對表,其中該指令碼映對表儲存將該指令編碼表映對到該原始指令編碼表之映對關係。 A reconfigurable instruction encoding method includes: counting a pairing distribution of adjacent instructions of an application, and finding an instruction pairing set, wherein the instruction pairing set includes a plurality of applications having a higher usage rate Instruction pairing; encoding the pair of instructions for the higher usage rate of the instruction pairing pair to give each instruction a similar instruction encoding, thereby generating an instruction encoding table, wherein the instruction encoding table has the same number as an original instruction encoding table And the at least one of the plurality of instructions corresponding to the instruction encoding table and the original instruction encoding table corresponding to different instruction encoding; and generating an instruction code mapping table, wherein the instruction code mapping table stores the instruction encoding table Reflects the mapping relationship of the original instruction encoding table. 如申請專利範圍第15項所述之可重新配置的指令編碼方法,其中產生該指令編碼表之步驟包括:對該指令配對集的該些指令配對,依據使用率高低依序從使用率最高的一指令配對開始對該些指令配對進行編碼以賦予各該些指令配對相近的指令編碼;以及基於該些指令配對進行編碼後之指令編碼,產生該指 令編碼表。 The reconfigurable instruction encoding method of claim 15, wherein the step of generating the instruction encoding table comprises: pairing the instructions of the instruction pairing set according to the usage rate according to the highest usage rate. An instruction pairing begins to encode the pair of instructions to give each of the instructions a similar instruction encoding; and encoding the encoded instruction based on the pairing of the instructions to generate the instruction Order the code list. 如申請專利範圍第15項所述之可重新配置的指令編碼方法,更包括:依據該指令編碼表及該應用程式之指令進行編譯產生該應用程式之執行碼。 The reconfigurable instruction encoding method as described in claim 15 further includes: compiling and generating an execution code of the application according to the instruction encoding table and the instruction of the application. 如申請專利範圍第17項所述之可重新配置的指令編碼方法,其中在對該指令配對集進行編碼以賦予各指令配對相近的指令編碼,從而產生該指令編碼表之步驟中,該指令編碼表係作為一第一指令編碼表,該方法更包括:(b1)依據該第一指令編碼表,找出該指令配對集之配對指令的漢明距離,並依據該指令配對集之該些配對指令的漢明距離和出現次數,從該指令配對集中找出複數個指令;以及(b2)對該些找出之指令進行重複編碼,以得到一第二指令編碼表,其中重複編碼賦予各該些找出之指令至少一額外的指令編碼,該第二指令編碼表係基於該第一指令編碼表延伸且包含該些額外的指令編碼;其中在產生該指令碼映對表之步驟和在產生該應用程式之執行碼之步驟中,以該第二指令編碼表代替該指令編碼表以執行該些步驟。 The reconfigurable instruction encoding method of claim 17, wherein the instruction encoding is performed by encoding the instruction pairing set to give each instruction a similar instruction encoding, thereby generating the instruction encoding table. The method is a first instruction encoding table, and the method further comprises: (b1) finding a Hamming distance of the pairing instruction of the instruction pairing set according to the first instruction encoding table, and matching the pairing according to the instruction pairing set a Hamming distance and an occurrence number of the instruction, finding a plurality of instructions from the instruction pairing set; and (b2) repeatedly encoding the found instructions to obtain a second instruction encoding table, wherein the repeated encoding is assigned to each Identifying at least one additional instruction code, the second instruction coding table extending based on the first instruction code table and including the additional instruction code; wherein the step of generating the instruction code pair table and generating In the step of executing the code of the application, the instruction encoding table is replaced by the second instruction encoding table to perform the steps. 如申請專利範圍第18項所述之可重新配置的指令編碼方法,其中在該步驟(b1)中,該些找出之指令為該指令配對集中漢明距離和出現次數之乘積較大的配對指令。 The reconfigurable instruction encoding method according to claim 18, wherein in the step (b1), the found instructions are pairs with a larger product of the Hamming distance and the number of occurrences in the pairing of the instruction pair. instruction. 如申請專利範圍第18項所述之可重新配置的指令編碼方法,其中在產生該應用程式之執行碼之步驟中,依據該第二指令編碼表,對該應用程式之兩相鄰指令產生漢明距離較小的執行碼。 The reconfigurable instruction encoding method according to claim 18, wherein in the step of generating an execution code of the application, according to the second instruction encoding table, generating two adjacent instructions of the application Execution code with a small distance. 如申請專利範圍第17項所述之可重新配置的指令編碼方法,其中該應用程式之執行碼執行於基於該原始指令編碼表之一電子裝置時,該電子裝置依據指令碼映對表將該應用程式之執行碼轉換後執行。 The reconfigurable instruction encoding method according to claim 17, wherein when the execution code of the application is executed on an electronic device based on the original instruction encoding table, the electronic device according to the instruction code mapping table Execute after the execution code of the application is converted. 一種運算裝置可讀式資訊儲存媒體,其上儲存有程式碼,此程式碼之執行能實現申請專利範圍第15至20項之任一項所述之可重新配置的指令編碼方法之步驟。 An arithmetic-readable information storage medium having stored thereon a program code for performing the steps of the reconfigurable instruction encoding method of any one of claims 15 to 20.
TW101141138A 2012-04-17 2012-11-06 Reconfigurable instruction encoding, execution method and electronic apparatus TW201419140A (en)

Priority Applications (3)

Application Number Priority Date Filing Date Title
TW101141138A TW201419140A (en) 2012-11-06 2012-11-06 Reconfigurable instruction encoding, execution method and electronic apparatus
CN201210491698.2A CN103809933A (en) 2012-11-06 2012-11-27 Reconfigurable instruction encoding method, execution method and electronic device
US13/901,640 US20130275721A1 (en) 2012-04-17 2013-05-24 Reconfigurable instruction encoding method, execution method, and electronic apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW101141138A TW201419140A (en) 2012-11-06 2012-11-06 Reconfigurable instruction encoding, execution method and electronic apparatus

Publications (1)

Publication Number Publication Date
TW201419140A true TW201419140A (en) 2014-05-16

Family

ID=50706773

Family Applications (1)

Application Number Title Priority Date Filing Date
TW101141138A TW201419140A (en) 2012-04-17 2012-11-06 Reconfigurable instruction encoding, execution method and electronic apparatus

Country Status (2)

Country Link
CN (1) CN103809933A (en)
TW (1) TW201419140A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20220382550A1 (en) * 2019-06-25 2022-12-01 Advanced Micro Devices, Inc. Method and apparatus for efficient programmable instructions in computer systems

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111542037B (en) * 2020-05-11 2023-07-21 深圳康盈半导体科技有限公司 Instruction transmission method, apparatus and storage medium
CN112822468B (en) * 2020-12-31 2023-02-17 成都极米科技股份有限公司 Projection control method and device, projection equipment and laser controller

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3896087B2 (en) * 2003-01-28 2007-03-22 松下電器産業株式会社 Compiler device and compiling method
US8281109B2 (en) * 2007-12-27 2012-10-02 Intel Corporation Compressed instruction format
US20120159444A1 (en) * 2010-12-17 2012-06-21 Microsoft Corporation Fusing debug information from different compiler stages
CN102270111B (en) * 2011-08-11 2014-01-01 中国科学院声学研究所 Command decoding method and command set simulation device
CN102426534B (en) * 2011-11-02 2014-06-04 大唐联仪科技有限公司 Method and system for converting test script language into executable instruction

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20220382550A1 (en) * 2019-06-25 2022-12-01 Advanced Micro Devices, Inc. Method and apparatus for efficient programmable instructions in computer systems
US12008371B2 (en) * 2019-06-25 2024-06-11 Advanced Micro Devices, Inc. Method and apparatus for efficient programmable instructions in computer systems

Also Published As

Publication number Publication date
CN103809933A (en) 2014-05-21

Similar Documents

Publication Publication Date Title
CN108292222B (en) Hardware apparatus and method for data decompression
KR20120084180A (en) Data compression device, operation method using the same, and data processing apparatus having the same
TW202321999A (en) Computing device and method
WO2014014709A1 (en) Methods and systems for handling data received by a state machine engine
CN1933334A (en) System and method for converting from scaled binary coded decimal into decimal floating point
TWI582692B (en) Three-dimensional morton coordinate conversion processors, methods, systems and instructions
US8892615B2 (en) Arithmetic operation circuit and method of converting binary number
TW201419140A (en) Reconfigurable instruction encoding, execution method and electronic apparatus
US8977663B2 (en) Converting binary values into binary-coded-centimal values
US20130275721A1 (en) Reconfigurable instruction encoding method, execution method, and electronic apparatus
US7523294B2 (en) Maintaining original per-block number of instructions by inserting NOPs among compressed instructions in compressed block of length compressed by predetermined ratio
US8150903B2 (en) Reconfigurable arithmetic unit and high-efficiency processor having the same
CN102662635A (en) Very long instruction word variable long instruction realization method and processor for realizing same
US20120017067A1 (en) On-demand predicate registers
CN103997648A (en) System and method for achieving decompression of JPEG2000 standard images rapidly based on DSPs
EP4310700A1 (en) Matrix multiplier, matrix computing method, and related device
US10678505B2 (en) Subset encoding method: increasing pattern density for finite automata
CN111787325A (en) Entropy encoder and encoding method thereof
US20160079996A1 (en) Compression ratio for a compression engine
JP2016045721A (en) Data storing method, ternary inner product calculation circuit, semiconductor device equipped with the same, and ternary inner product calculation processing program
TWI442317B (en) Reconfigurable instruction encoding method and processor architecture
US20210157485A1 (en) Pattern-based cache block compression
CN101246435A (en) Processor instruction set supporting part statement function of higher order language
CN111090465B (en) Decoding system and decoding method for RV32IC instruction set
CN103597828A (en) Image quantization parameter encoding method and image quantization parameter decoding method