A method, device, and storage medium for processing instruction data

By storing the same type of fields to the specified encoding location and generating opcodes in the instruction set design of the network processor, the problems of high complexity and high power consumption in traditional design are solved, and more efficient instruction decoding and resources are achieved use.

CN111240682BActive Publication Date: 2024-11-08SANECHIPS TECH CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN201811436260.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-11-28
Publication Date
2024-11-08
Estimated Expiration
2038-11-28

AI Technical Summary

Technical Problem

The instruction set design of existing network processors is complex, resulting in high logic design complexity and high power consumption. In addition, the traditional fixed-length instruction encoding method requires additional judgment of the instruction type during decoding, increasing chip memory resources and logic complexity.

Method used

By storing fields of the same type at the specified encoding position at compile time, generating an opcode, and directly obtaining fields and operands of the corresponding type from the encoding position during decoding, the judgment steps and complexity are reduced.

Benefits of technology

It reduces the complexity and power consumption of instruction set design, reduces chip resource usage, and improves instruction decoding efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111240682B_ABST
    Figure CN111240682B_ABST
Patent Text Reader

Abstract

The embodiments of the present application disclose a method and apparatus, device, and storage medium for processing instruction data, wherein the method includes: if it is determined that there are fields of the same type between instructions before compilation, during compilation, storing the fields of the same type in a specified encoding position; generating a corresponding operation code based on the type of each instruction before compilation and the attribute information of the fields of the same type; storing the operation code in the compiled instruction; and outputting the compiled instruction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to a computer system, and relate to but are not limited to a method and apparatus, device, and storage medium for processing instruction data. Background Art

[0002] A network processor is a processor specifically used for network data processing. It is mainly used in network products such as switches and routers, and is mostly used to process messages in the network. It has the advantages of high processing performance, programmability, flexible expansion, and short development cycle. It is precisely because the processing of network business data is different from that of ordinary system programs and its characteristic requirements that the instruction set design of the network processor must have the characteristics of high instruction execution efficiency, strong instruction scalability, and rich instruction set.

[0003] At the same time, on the basis of satisfying forwarding performance, it is necessary to reduce the complexity of logic design, reduce chip resources and reduce power consumption. These feature requirements require not only individual consideration of each process in instruction set design, but also overall consideration of all processes. Therefore, the instruction set design and processing of network processors is very complex. Summary of the invention

[0004] In view of this, embodiments of the present application provide a method and apparatus, device, and storage medium for processing instruction data to solve at least one problem existing in the prior art.

[0005] The technical solution of the embodiment of the present application is implemented as follows:

[0006] In a first aspect, an embodiment of the present application provides a method for processing instruction data, the method comprising: if it is determined that there are fields of the same type between instructions before compilation, during compilation, storing the fields of the same type to a specified encoding position; generating a corresponding opcode based on the type of each instruction before compilation and the attribute information of the fields of the same type; storing the opcode in the compiled instruction; and outputting the compiled instruction.

[0007] In a second aspect, an embodiment of the present application provides a method for processing instruction data, the method comprising: determining an opcode in a compiled instruction; determining the type of the instruction and attribute information of a field in the instruction based on the opcode; determining a field of a corresponding type from a specified encoding position in the instruction based on the attribute information of the field; obtaining a corresponding operand based on the field of the corresponding type, and outputting the operand.

[0008] In a third aspect, an embodiment of the present application provides an instruction data processing device, the device comprising: a first storage unit, configured to store the fields of the same type to a designated encoding position during compilation if it is determined that there are fields of the same type between instructions before compilation; a generation unit, configured to generate a corresponding operation code based on the type of each instruction before compilation and the attribute information of the fields of the same type; a second storage unit, configured to store the operation code in the compiled instruction; and a first output unit, configured to output the compiled instruction.

[0009] In a fourth aspect, an embodiment of the present application provides a device for processing instruction data, the device comprising: a first determination unit, configured to determine an opcode in a compiled instruction; a second determination unit, configured to determine the type of the instruction and attribute information of a field in the instruction based on the opcode; a third determination unit, configured to determine a field of a corresponding type from a specified encoding position in the instruction based on the attribute information of the field; and a second output unit, configured to obtain a corresponding operand based on the field of the corresponding type and output the operand.

[0010] In a fifth aspect, an embodiment of the present application provides a computer device, which comprises at least: a processor and a storage medium configured to store executable instructions, wherein: the processor is configured to execute the stored executable instructions, and the executable instructions are configured to execute the instruction data processing method provided in the above embodiment.

[0011] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and the computer-executable instructions are configured to execute the steps in the instruction data processing method provided in the above embodiment.

[0012] The embodiment of the present application provides a method and apparatus, device, and storage medium for processing instruction data, wherein the method includes: if it is determined that there are fields of the same type between instructions before compilation, during compilation, the fields of the same type are stored in a specified encoding position; according to the type of each instruction before compilation and the attribute information of the fields of the same type, a corresponding operation code is generated; the operation code is stored in the compiled instruction; and the compiled instruction is output. In this way, the operation code is directly associated with the type of instruction and the number and type of instruction source operands, so that the classified acquisition of instruction source operands is completed according to the instruction operation code. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 Schematic diagram of the processing method of instruction data provided in the embodiment of the present application Figure 1 ;

[0014] Figure 2 Schematic diagram of the processing method of instruction data provided in the embodiment of the present application Figure 2 ;

[0015] Figure 3 A flowchart of an instruction source operand processing method for a network processor provided in an embodiment of the present application;

[0016] Figure 4 A schematic diagram of the composition structure of a network processor instruction source operand processing device provided in an embodiment of the present application;

[0017] Figure 5 Schematic diagram of the composition structure of the instruction data processing device provided in the embodiment of the present application Figure 1 ;

[0018] Figure 6 Schematic diagram of the composition structure of the instruction data processing device provided in the embodiment of the present application Figure 2 ;

[0019] Figure 7 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0020] In the related technology, when designing the instruction set of a network processor, it is necessary to consider several key technologies such as instruction encoding, storage, acquisition, and decoding. Among them, instruction encoding and decoding is the basis of instruction set design and directly determines the complexity of instruction set processing. At the same time, in order to be able to process various business data in the network, it is necessary to design instructions with multiple different functions and a large-capacity instruction space. Therefore, if there is no corresponding good design solution for instruction encoding and decoding, it often leads to a high complexity of logic design, and it will occupy a large amount of chip memory and consume high power.

[0021] The instruction set design of traditional network processors uses an instruction pipeline decoding technology similar to that of Reduced Instruction Set Computer (RISC), and the instruction encoding is encoded in a fixed-length manner. Since the opcode field of the instruction is encoded only according to the functional operation of each instruction, when obtaining the source operand in the decoding stage, it is necessary to first determine the type of each instruction, and then obtain the source operand number and address field information according to the position of the source operand recorded by each instruction in the instruction encoding.

[0022] There are a large number of instructions based on network processors. Obtaining source operands in this way not only requires additional chip memory resources to store the source operand information of each instruction, but also greatly increases the logical complexity of the chip core.

[0023] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the specific technical solution of the invention will be further described in detail below in conjunction with the drawings in the embodiments of the present application. The following embodiments are used to illustrate the present application, but are not used to limit the scope of the present application.

[0024] An embodiment of the present application provides a method for processing instruction data, which is applied to a computer device. The function implemented by the method can be implemented by calling a program code through a processor in the computer device. Of course, the program code can be stored in a computer storage medium. It can be seen that the computer device at least includes a processor and a storage medium.

[0025] Figure 1 Schematic diagram of the processing method of instruction data provided in the embodiment of the present application Figure 1 ,like Figure 1 As shown, the method includes:

[0026] Step S11: If it is determined that there are fields of the same type between the instructions before compilation, the fields of the same type are stored in a designated encoding position during compilation.

[0027] Here, at least one instruction is obtained from a preset instruction set. Since the function and effect of each instruction are preset, the same type of fields between the instructions before compilation can be determined based on the obtained instructions. When compiling through the compilation unit, each instruction can be divided into several segments according to the corresponding rules, and each segment occupies a preset position and a corresponding byte length, and the preset position and the corresponding byte length are set to the corresponding encoding position. When compiling, the same type of fields between the instructions can be stored in the specified encoding position, and the formulated encoding position can be preset as needed. For example, there are instructions A and instruction B in the instruction set, instruction A has fields A1, A2, A3, and instruction B has fields B1, B2, B3. If A3 and B3 are fields of the same type, the compilation unit will put the A3 field of instruction A and the B3 field of instruction B in the same bit position of their respective encodings.

[0028] Step S12: Generate a corresponding operation code according to the type of each instruction before compilation and the attribute information of the field of the same type.

[0029] Here, the opcode is used to indicate the operation to be performed by the instruction, and the length of the opcode can be fixed or variable. In an embodiment of the present application, the type of instruction before compilation and the attribute information of the same type of field can be obtained, and the type of instruction before compilation and the attribute information of the same type of field are marked respectively, and the corresponding opcode is generated according to the generated marking information. Here, the type of instruction can be: logical calculation instructions, data upload / download instructions, jump instructions, and some special instructions, etc., which can be preset as needed. The same type of field can be different source operands, destination operands, or other fields, etc.

[0030] Step S13, storing the operation code into the compiled instruction.

[0031] Here, the compilation unit may store the opcode generated according to the above steps to a corresponding encoding position in the compiled instruction.

[0032] Step S14, outputting the compiled instructions.

[0033] In the embodiment of the present application, if it is determined that there are fields of the same type between the pre-compiled instructions, during compilation, the fields of the same type are stored in the designated encoding position, and the corresponding opcode is generated according to the type of each pre-compiled instruction and the attribute information of the fields of the same type, and the opcode is stored in the compiled instruction, and the compiled instruction is output. The opcode can be directly associated with the type of instruction and the attribute information of the field, so as to achieve the classification acquisition of the operands corresponding to the field according to the instruction opcode.

[0034] The present application also provides another method for processing instruction data, the method comprising:

[0035] Step S101: If it is determined that there are fields of the same type between instructions before compilation, the fields of the same type are stored in a designated encoding position during compilation.

[0036] Step S102: If it is determined that the fields of the same type include source operand fields, the number and type of the source operand fields are determined.

[0037] Here, the instruction may include one or more source operand fields. In the embodiment of the present application, if it is determined that the fields of the same type include source operand fields, the number and type of the source operand fields are determined.

[0038] Step S103, generating a corresponding operation code according to the type of each pre-compiled instruction and the number and type of the source operand fields.

[0039] Here, the type of instruction before compilation and the number and type of source operand fields can be obtained, and the type of instruction before compilation and the number and type of source operand fields can be marked respectively, and the corresponding operation code can be generated according to the identification code generated by the mark. The number and type of source operand fields are marked respectively, including: determining the number and type of source operands, and generating a mark according to the number and type of source operands. For example: the mark that does not require source operands or immediate numbers is 000; the mark that only needs to operate a conditional register is 001, etc.

[0040] The above-mentioned steps S102 to S103 provide a method for implementing the step of "generating a corresponding operation code according to the type of each instruction before compilation and the attribute information of the same type field". In this method, if it is determined that the same type of field includes a source operand field, the number and type of the source operand field are determined, and the corresponding operation code is generated according to the type of each instruction before compilation, the number and type of the source operand field. The operation code can be directly associated with the type of instruction and the number and type of the source operand field, so as to achieve the classification acquisition of the instruction source operand according to the instruction operation code.

[0041] Step S104, storing the operation code into the compiled instruction.

[0042] Step S105, outputting the compiled instructions.

[0043] The present application also provides another method for processing instruction data, the method comprising:

[0044] Step S201, classifying the pre-compiled instructions according to the function to be executed by each pre-compiled instruction to obtain a classification result.

[0045] Here, the pre-compiled instructions may be classified into at least one category according to the functions to be executed by the instructions, wherein the classification results may include: logic calculation instructions, data upload / download instructions, jump instructions, and some special instructions.

[0046] Step S202: If it is determined that there are fields of the same type between the instructions before compilation, the fields of the same type are stored in a designated encoding position during compilation.

[0047] Step S203: If it is determined that the fields of the same type include source operand fields, the number and type of the source operand fields are determined according to the classification result.

[0048] Here, it can be determined whether the instruction needs a source operand according to the function to be executed by the instruction before compilation. If a source operand is needed, the number and type of the required source operands can be determined. Take the division of instructions into logic calculation instructions, data upload / download instructions, and jump instructions as an example. Among them, logic calculation instructions usually have fields such as destination register, common register source operand one, common register source operand two or immediate source operand two, etc.; data upload / download instructions usually have fields such as destination register, conditional register source operand two, memory source operand one or memory source operand two, immediate source operand two, etc.; jump instructions usually have labels, conditional register source operand two, etc.; special instructions usually complete network service table lookup, co-processing and other processing, and do not require source operands. Among them, source operand one refers to the source operand in the first position when there is one operand, or when there are two operands; source operand two refers to the source operand in the second position when there are two operands.

[0049] Step S204: Generate a corresponding operation code according to the type of each pre-compiled instruction and the number and type of the source operand fields.

[0050] Step S205: store the operation code into the compiled instruction.

[0051] Step S206, outputting the compiled instructions.

[0052] The present application also provides another method for processing instruction data, the method comprising:

[0053] Step S301, classifying the pre-compiled instructions according to the functions to be executed by each pre-compiled instruction to obtain classification results.

[0054] Step S302: If it is determined that there are fields of the same type between the instructions before compilation, the fields of the same type are stored in a designated encoding position during compilation.

[0055] Step S303: If it is determined that the fields of the same type include source operand fields, the number and type of the source operand fields are determined according to the classification result.

[0056] Step S304: Mark the type of each pre-compiled instruction and generate a first identification code corresponding to each pre-compiled instruction.

[0057] Here, marking the type of instruction means that the compilation unit generates a corresponding identification code according to the type of instruction. For example, instructions can be divided into four types: logic calculation instructions, data upload / download instructions, jump instructions, and special instructions. Then, four corresponding tags are generated according to the four types, namely, the first identification code 10 for logic calculation instructions, the first identification code 201 for data upload / download instructions, the first identification code 310 for jump instructions, and the first identification code 411 for special instructions. The above identification code is used as the first part of the opcode field encoding of the corresponding instruction.

[0058] Step S305: Generate a corresponding second identification code according to the number and type of the source operand fields.

[0059] Here, taking the example of dividing instructions into eight types according to the number and type of source operands, namely, logic calculation instructions, data upload / download instructions, jump instructions and special instructions, the types formed are: instructions that do not require source operands or source operands in the form of immediate numbers are type one; instructions that only need to operate a source operand in the form of a conditional register are type two; instructions that only need to operate a source operand in the form of an ordinary register are type three; instructions that only need to operate a source operand in the form of a memory are type four; instructions that need to operate a source operand in the form of an ordinary register and a source operand in the form of a memory are type five; instructions that need to operate a source operand in the form of an ordinary register and a source operand in the form of a conditional register are type six; instructions that need to operate two source operands in the form of ordinary registers are type seven; instructions that need to operate a source operand in the form of a memory and a source operand in the form of a conditional register are type eight.

[0060] The compilation unit classifies the instructions according to the number and type of source operands, obtains the classification results, and obtains corresponding identification codes for the classification results. Taking the above eight types as an example, type one corresponds to the second identification code one 000, type two corresponds to the second identification code two 001, type three corresponds to the second identification code three 010, type four corresponds to the second identification code four 011, type five corresponds to the second identification code five 100, type six corresponds to the second identification code six 101, type seven corresponds to the second identification code seven 110, and type eight corresponds to the second identification code eight 111. The above identification codes are used as the second part of the opcode field encoding of the corresponding instruction.

[0061] Step S306: combine the first identification code and the second identification code to generate a corresponding operation code.

[0062] Here, the first part of the operation code field code generated through the above steps and the second part of the operation code field code may be combined to generate a corresponding operation code.

[0063] The above steps S304 to S306 provide a method for implementing the step of "generating a corresponding operation code according to the type of each instruction before compilation, the number and type of the source operand fields". In this method, the operation code can be directly associated with the type of instruction and the number and type of the source operand fields, so as to achieve the classification acquisition of the instruction source operand according to the instruction operation code.

[0064] Step S307, storing the operation code into the compiled instruction.

[0065] Step S308: output the compiled instructions.

[0066] Figure 2 Schematic diagram of the processing method of instruction data provided in the embodiment of the present application Figure 2 ,like Figure 2 As shown, the method includes:

[0067] Step S21, determining the operation code in the compiled instruction.

[0068] Here, after receiving the compiled instruction, the decoding unit may determine the corresponding operation code from the compiled instruction.

[0069] Step S22: Determine the type of the instruction and attribute information of the fields in the instruction according to the operation code.

[0070] Here, the decoding unit obtains the compiled instruction, can parse the corresponding operation code from the instruction, and determine the type of instruction and the attribute information of the field in the instruction according to the operation code.

[0071] Step S23, determining a field of a corresponding type from a designated encoding position in the instruction according to the attribute information of the field.

[0072] Here, the field is a designated encoding position stored in the compiled instruction, and the decoding unit can directly determine the corresponding type of field from the designated encoding position according to the attribute information of the field.

[0073] Step S24, obtaining corresponding operands according to the fields of the corresponding types, and outputting the operands.

[0074] Here, after the fields of corresponding types are determined based on the above steps, corresponding operands can be directly obtained from corresponding registers, and the obtained operands can be processed accordingly.

[0075] In the embodiment of the present application, the opcode in the compiled instruction is determined, and the type of instruction and the attribute information of the field in the instruction are determined according to the opcode, and the field of the corresponding type is determined from the specified encoding position in the instruction according to the attribute information of the field, and the corresponding operand is obtained according to the field of the corresponding type, and the operand is output. The decoding unit can directly intercept the corresponding operand from the compiled instruction without determining the type of instruction and then determining the corresponding operand according to the type of instruction, which can reduce the judgment steps and reduce the complexity of operand processing.

[0076] The present application also provides another method for processing instruction data, the method comprising:

[0077] Step S401, determining the operation code in the compiled instruction.

[0078] Step S402: If it is detected that the instruction needs to obtain a source operand field, the opcode corresponding to the instruction that needs to obtain a source operand field is parsed to obtain a parsing result.

[0079] Here, the decoding unit determines whether it is necessary to obtain the source operand according to the operation code. When the source operand needs to be obtained, the operation code corresponding to the instruction for which the source operand field needs to be obtained is parsed to obtain the parsing result.

[0080] Step S403: Determine the type of the instruction and the attribute information of the source operand field according to the parsing result.

[0081] Here, since the operation code includes the first identification code and the second identification code, the type of instruction can be determined according to the first identification code, and the attribute information of the source operand field can be determined according to the second identification code.

[0082] The above steps S402 to S403 provide a method for implementing the step of "determining the type of the instruction and the attribute information of the fields in the instruction according to the opcode". In this method, if it is detected that the instruction needs to obtain the source operand field, the opcode corresponding to the instruction that needs to obtain the source operand field is parsed to obtain the parsing result, and the type of the instruction and the attribute information of the source operand field are determined according to the parsing result. By parsing the opcode, the type of the instruction and the attribute information of the source operand field can be directly obtained, which can reduce the complexity of decoding.

[0083] Step S404: determining a field of a corresponding type from a designated encoding position in the instruction according to the attribute information of the field.

[0084] Step S405, obtaining corresponding operands according to the fields of the corresponding types, and outputting the operands.

[0085] The present application also provides another method for processing instruction data, the method comprising:

[0086] Step S501, determining the operation code in the compiled instruction.

[0087] Step S502: If it is detected that the instruction needs to obtain a source operand field, the opcode corresponding to the instruction that needs to obtain a source operand field is parsed to obtain a parsing result.

[0088] Step S503: Determine the type of the instruction and the attribute information of the source operand field according to the parsing result.

[0089] Step S504: Determine the type of the instruction according to the first identification code parsed from the operation code.

[0090] Here, the decoding unit parses the first part of the operation code, that is, parses the first identification code of the operation code, and can determine the type of the instruction.

[0091] Step S505: Determine the number and type of the source operand fields according to the second identification code parsed from the operation code.

[0092] Here, the decoding unit parses the second part of the operation code, that is, parses the second identification code of the operation code, and can determine the number and type of source operand fields.

[0093] Step S506: Determine a field of a corresponding type from a specified encoding position in the instruction according to the number and type of the source operand fields.

[0094] Here, the corresponding type of field can be determined from the specified encoding position in the instruction according to the number and type of source operand fields. For example, for source operand one, there are three cases: the instruction does not need to obtain source operand one, and the instruction is directly transmitted to the read unit; the instruction needs to obtain source operand one, and the number and address of the source register need to be intercepted from the instruction encoding; the instruction needs to obtain source operand one, and the read address is fixed and no other decoding operations are required. For source operand two, there are four cases: the instruction does not need to obtain source operand two, and it is directly transmitted to the read unit; the instruction needs to obtain source operand two, and the number and address of the source register need to be intercepted from the instruction encoding; the instruction needs to obtain source operand two, and the required source register is intercepted from the instruction encoding and converted; the instruction needs to obtain source operand two, and the read address is fixed and no other decoding operations are required.

[0095] The above-mentioned steps S504 to S506 provide a method for implementing the step of "determining a field of a corresponding type from a designated encoding position in the instruction according to the attribute information of the field". In this method, the type of the instruction is determined according to the first identification code parsed from the opcode; the number and type of source operand fields are determined according to the second identification code parsed from the opcode; and the source operand fields are determined from the designated encoding position in the instruction according to the number and type of source operand fields. The source operand fields can be directly determined from the designated encoding position in the instruction according to the number and type of source operand fields, which can reduce the complexity of decoding.

[0096] Step S507, obtaining corresponding operands according to the fields of the corresponding types, and outputting the operands.

[0097] The present application also provides another method for processing instruction data, the method comprising:

[0098] Step S601, determining the operation code in the compiled instruction.

[0099] Step S602: If it is detected that the instruction needs to obtain a source operand field, the opcode corresponding to the instruction that needs to obtain a source operand field is parsed to obtain a parsing result.

[0100] Step S603: Determine the type of the instruction and the attribute information of the source operand field according to the parsing result.

[0101] Step S604: Determine the type of the instruction according to the first identification code parsed from the operation code.

[0102] Step S605: Determine the number and type of the source operand fields according to the second identification code parsed from the operation code.

[0103] Step S606: Determine a field of a corresponding type from a specified encoding position in the instruction according to the number and type of the source operand fields.

[0104] Step S607 : acquiring corresponding source operand fields from designated encoding positions in the instruction according to the number and type of the source operand fields.

[0105] Step S608: Determine the number and address of the source operand according to the source operand field.

[0106] Here, the decoding unit determines the source operand field according to the fixed position of the source operand field in the instruction encoding, obtains the number and address of the source operand, and sends them to the reading unit.

[0107] Step S609, acquiring the source operand according to the number and address of the source operand, and outputting the source operand.

[0108] The above steps S608 to S609 provide a method for implementing the step of "obtaining the corresponding operand according to the field of the corresponding type, and outputting the operand". In this method, the number and address of the source operand are determined according to the source operand field; the source operand is obtained according to the number and address of the source operand, and the source operand is output. The source operand field can be determined directly from the specified encoding position in the instruction according to the number and type of the source operand field, and then the corresponding source operand can be directly obtained according to the source operand field, which can reduce the complexity of decoding.

[0109] In other embodiments, the function of the instruction is determined according to the type of instruction, and the source operand is processed according to the function of the instruction.

[0110] Figure 3 A flowchart of a method for processing an instruction source operand of a network processor provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, the method comprises the following steps:

[0111] In step S31, the compiling unit places the same fields between various instructions at fixed positions in the instruction code.

[0112] Here, the instructions are first encoded using a fixed-length encoding method, and then each encoded instruction in the instruction set is segmented and classified according to function. Usually, the instructions of the network processor are divided into logical calculation instructions, data upload / download instructions, jump instructions, and some special instructions. Then, according to the function of each type of instruction, the field type required for each instruction is determined.

[0113] In the embodiment of the present application, by adopting a fixed-length encoding method, instructions can be converted into a format that is convenient for storage by the compilation unit, and the decoding unit does not need to record the storage location and length of the instructions, and can directly obtain the encoded instructions in the storage memory.

[0114] Among them, logical calculation instructions usually have a destination register operand field, a common register source operand one field, a common register source operand two field, an immediate source operand two field, etc.; data upload / download instructions usually have a destination register operand field, a conditional register source operand two field, a memory source operand one field, a memory source operand two field, an immediate source operand two field, etc.; jump instructions usually have fields such as labels and conditional register source operand two; special instructions usually complete network service table lookup, co-processing and other operations, and do not require a source operand field.

[0115] Step S32: the compiling unit determines and marks the type of instruction and the source operand of the instruction, and generates an operation code corresponding to the instruction according to the mark.

[0116] Here, the compilation unit judges and marks the type of instruction and the source operands of the instruction, and generates a corresponding instruction opcode, which is directly related to the type of instruction and the number and type of the instruction source operands; and the classification acquisition of the instruction source operands is completed according to the instruction opcode.

[0117] The determination of the type of instruction refers to: classifying the instruction into at least one type according to the functional operation. For example, the instruction can be classified into four types: logic calculation instruction, data upload / download instruction, jump instruction and some special instruction.

[0118] Marking the type of instruction means that the compilation unit generates a corresponding tag according to the type of instruction. For example, instructions can be divided into four types: logic calculation instructions, data upload / download instructions, jump instructions, and special instructions. Then, four corresponding tags are generated according to the four types, namely, logic calculation instructions corresponding to tag 1 00, data upload / download instructions corresponding to tag 2 01, jump instructions corresponding to tag 3 10, and special instructions corresponding to tag 4 11, as the first part of the opcode field encoding of the instruction.

[0119] Judging the source operands of the instructions means classifying the instructions according to the number and type of the source operands.

[0120] Taking the example of dividing instructions into eight types according to the number and type of source operands, namely, logic calculation instructions, data upload / download instructions, jump instructions and special instructions, the types formed are: instructions that do not require source operands or source operands in the form of immediate numbers are type one; instructions that only need to operate a source operand in the form of a conditional register are type two; instructions that only need to operate a source operand in the form of an ordinary register are type three; instructions that only need to operate a source operand in the form of a memory are type four; instructions that need to operate a source operand in the form of an ordinary register and a source operand in the form of a memory are type five; instructions that need to operate a source operand in the form of an ordinary register and a source operand in the form of a conditional register are type six; instructions that need to operate two source operands in the form of ordinary registers are type seven; instructions that need to operate a source operand in the form of a memory and a source operand in the form of a conditional register are type eight.

[0121] The marking of the source operands of the instructions refers to: the compilation unit classifies the instructions according to the number and type of the source operands, obtains the classification results, and marks the classification results. Taking the above eight types as an example, type one corresponds to mark one 000, type two corresponds to mark two 001, type three corresponds to mark three 010, type four corresponds to mark four 011, type five corresponds to mark five 100, type six corresponds to mark six 101, type seven corresponds to mark seven 110, and type eight corresponds to mark eight 111, as the second part of the opcode field encoding of the instruction.

[0122] Step S33, the decoding unit determines whether it is necessary to obtain the source operand according to the operation code. When the source operand needs to be obtained, the decoding unit directly intercepts and obtains the number and address of the source operand in the instruction by using the fixed position of the source operand in the instruction encoding.

[0123] In an embodiment of the present application, the decoding unit determines the second part of the opcode, and divides the source operand one into three situations: the instruction does not need to obtain the source operand one, and directly transmits it to the reading unit, corresponding to 000, 001 and 011 of the second part of the opcode of the above step S32; the instruction needs to obtain the source operand one, and the number and address of the source register need to be intercepted from the instruction code, corresponding to 010, 100, 101 and 110 of the second part of the opcode of the above step S32; the instruction needs to obtain the source operand one, and the read address is fixed and no other decoding operation is required, corresponding to 111 of the second part of the opcode of the above step S32.

[0124] There are four cases for source operand two: the instruction does not need to obtain source operand two and directly passes through the read unit, which corresponds to 000 and 010 in the second part of the opcode of step S32 above; the instruction needs to obtain source operand two, and the number and address of the source register need to be intercepted from the instruction code, which corresponds to 110 in the second part of the opcode of step S32 above; the instruction needs to obtain source operand two, and the required source register is intercepted from the instruction code and converted, which corresponds to 001, 101 and 111 in the second part of the opcode of step S32 above; the instruction needs to obtain source operand two, and the read address is fixed and no other decoding operation is required, which corresponds to 111 in the second part of the opcode of step S32 above.

[0125] The decoding unit needs to include three operation modes, among which, when intercepting the number and address of the source operation, the source operand two condition registers of some instructions need to be converted into ordinary register operations.

[0126] Step S34: the decoding unit obtains the data of the source operand in the core register according to the number and address of the source operand, and sends it to the execution unit.

[0127] After the decoding unit completes the processing, it sends the number and address of the obtained source operand to the reading unit. The reading unit obtains the data of the source operand in the core register and sends it to the execution unit. If there is no source operand, it is directly transmitted to the execution unit.

[0128] Step S35, after the execution unit completes the execution, the processing result is stored in the core register.

[0129] Here, the execution unit processes the instruction according to the instruction function and source operands, and writes the result back into the core register after successful processing.

[0130] Figure 4 A schematic diagram of the composition structure of a network processor instruction source operand processing device provided in an embodiment of the present application, such as Figure 4 As shown, the device comprises:

[0131] The compiling unit 41 is used to place the same fields between instructions at a fixed position in the instruction encoding; and to judge and mark the type of instruction and the source operation of the instruction, and generate the corresponding operation code of the instruction according to the mark.

[0132] The decoding unit 42 is used to determine whether the instruction needs to obtain a source operation based on the operation code of the instruction. When the instruction needs to obtain a source operand, the numbering and address of various forms of source operands are obtained according to the fixed position of the source operand in the instruction encoding, and sent to the reading unit.

[0133] The reading unit 43 is used to obtain the data of the source operand in the core register according to the number and address of the source operand of the instruction.

[0134] The execution unit 44 is used to process the source operand according to the instruction function.

[0135] The output unit 45 is used to store the processing result in the core register.

[0136] In an embodiment of the present application, when the compilation unit converts instructions into binary codes, it places the same fields between instructions at a fixed position in the instruction code to ensure that the same fields between instructions are aligned in the code. In this way, when decoding the instruction, the decoding unit can directly intercept the number and address of the source operand without first distinguishing the various instruction types and then obtaining the source operand from the instruction code. In this way, the decoding unit does not need additional judgment logic, nor does it need to record the position of the source operand in each instruction, which greatly reduces the logical complexity of the decoding unit and saves chip resources.

[0137] Based on the above embodiments, the embodiments of the present application provide a device for processing instruction data. Each unit included in the device, and each sub-unit included in each unit, can be implemented by a processor in a computer device; of course, it can also be implemented by a logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.

[0138] Figure 5 Schematic diagram of the composition structure of the instruction data processing device provided in the embodiment of the present application Figure 1 ,like Figure 5 As shown, the device comprises:

[0139] The first storage unit 51 is configured to store the fields of the same type to a designated encoding position during compilation if it is determined that there are fields of the same type between instructions before compilation.

[0140] The generating unit 52 is configured to generate a corresponding operation code according to the type of each of the pre-compiled instructions and the attribute information of the fields of the same type.

[0141] The second storage unit 53 is configured to store the operation code into the compiled instruction.

[0142] The first output unit 54 is configured to output the compiled instructions.

[0143] In other embodiments, the generation unit is further configured to: if it is determined that the fields of the same type include source operand fields, determine the number and type of the source operand fields; and generate a corresponding opcode according to the type of each pre-compiled instruction and the number and type of the source operand fields.

[0144] In other embodiments, the device further includes: a classification unit, configured to: classify the pre-compiled instructions according to the function to be performed by each pre-compiled instruction to obtain a classification result; correspondingly, the generation unit is also configured to: if it is determined that the fields of the same type include source operand fields, determine the number and type of the source operand fields according to the classification result.

[0145] In other embodiments, the generation unit is further configured to: mark the type of each pre-compiled instruction to generate a first identification code corresponding to each pre-compiled instruction; generate a corresponding second identification code based on the number and type of the source operand fields; and merge the first identification code and the second identification code to generate a corresponding operation code.

[0146] Figure 6Schematic diagram of the composition structure of the instruction data processing device provided in the embodiment of the present application Figure 2 ,like Figure 6 As shown, the device comprises:

[0147] The first determining unit 61 is configured to determine an operation code in the compiled instruction.

[0148] The second determining unit 62 is configured to determine the type of the instruction and attribute information of the fields in the instruction according to the operation code.

[0149] The third determining unit 63 is configured to determine a field of a corresponding type from a designated encoding position in the instruction according to the attribute information of the field.

[0150] The second output unit 64 is configured to obtain a corresponding operand according to the field of the corresponding type and output the operand.

[0151] In other embodiments, the second determination unit is further configured to: if it is detected that the instruction needs to obtain a source operand field, parse the opcode corresponding to the instruction that needs to obtain the source operand field to obtain a parsing result; and determine the type of the instruction and attribute information of the source operand field based on the parsing result.

[0152] In other embodiments, the third determination unit is further configured to: determine the type of the instruction based on a first identification code parsed from the opcode; determine the number and type of source operand fields based on a second identification code parsed from the opcode; and determine the source operand fields from a specified encoding position in the instruction based on the number and type of source operand fields.

[0153] In other embodiments, the second output unit is further configured to: determine the number and address of the source operand according to the source operand field; obtain the source operand according to the number and address of the source operand, and output the source operand.

[0154] It should be noted that in the embodiment of the present application, if the processing method of the above-mentioned instruction data is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.

[0155] Correspondingly, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the instruction data processing method provided in the above embodiment are implemented.

[0156] The description of the device embodiment of the present application is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.

[0157] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0158] It should be noted that Figure 7 A schematic diagram of a computer device structure provided in an embodiment of the present application is shown in FIG. Figure 7 As shown, the computer device 70 at least includes: a processor 71, a communication interface 72 and a memory 73, wherein

[0159] Processor 71 generally controls the overall operation of computer device 70 .

[0160] The communication interface 72 may enable the computer device to communicate with other computer devices or servers via a network.

[0161] The memory 73 is configured to store instructions and applications executable by the processor 71, and can also cache data to be processed or processed by the processor 71 and various modules in the computer device 70 (for example, image data, audio data, voice communication data, and video communication data), which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).

[0162] Of course, the device in the embodiment of the present application may also have other similar protocol interaction implementation cases. Without departing from the spirit and essence of the present application, technicians in this field can make various corresponding changes and deformations according to the embodiment of the present application, but these corresponding changes and deformations should all fall within the scope of protection of the claims attached to the method of the present application.

[0163] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of hardware embodiments, software embodiments, or embodiments in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.

[0164] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that has the functions specified in one or more boxes.

[0165] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0166] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0167] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned sequence numbers of the embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments.

[0168] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0169] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as: multiple modules or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or modules can be electrical, mechanical or other forms.

[0170] The modules described above as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules; they may be located in one place or distributed on multiple network modules; some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.

[0171] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A method for processing instruction data, characterized in that: The method comprises: If it is determined that there are fields of the same type including source operand fields between the instructions before compilation, the number and type of the source operand fields are determined, and during compilation, the fields of the same type are stored in the same bit position preset by each instruction; Marking the type of each of the pre-compiled instructions, and generating a first identification code corresponding to each of the pre-compiled instructions; Generate a corresponding second identification code according to the number and type of the source operand fields; Combining the first identification code and the second identification code to generate a corresponding operation code; storing the opcode into a compiled instruction; The compiled instructions are output.

2. The method according to claim 1, characterized in that: The method further comprises: Classifying the pre-compiled instructions according to the functions to be executed by each pre-compiled instruction to obtain a classification result; Correspondingly, determining the number and type of the source operand fields includes: According to the classification result, the number and type of the source operand fields are determined.

3. A method for processing instruction data, characterized in that: The method comprises: Determine the opcode in the compiled instruction; If it is detected that the instruction needs to obtain a source operand field, parsing an opcode corresponding to the instruction that needs to obtain a source operand field to obtain a parsing result; Determine the type of the instruction according to the first identification code parsed from the opcode; determine the number and type of the source operand fields according to the second identification code parsed from the opcode; determine the source operand fields from a specified encoding position in the instruction according to the number and type of the source operand fields; Obtain a corresponding operand according to the source operand field, and output the operand.

4. The method according to claim 3, characterized in that The acquiring a corresponding operand according to the source operand field and outputting the operand comprises: Determine the number and address of the source operand according to the source operand field; According to the number and address of the source operand, the source operand is obtained and output.

5. A device for processing instruction data, characterized in that: The device comprises: A first storage unit is configured to determine the number and type of source operand fields if it is determined that there are fields of the same type between instructions before compilation, including source operand fields, and store the fields of the same type to the same bit position preset by each instruction during compilation; a generating unit configured to mark the type of each of the pre-compiled instructions and generate a first identification code corresponding to each of the pre-compiled instructions; generate a corresponding second identification code according to the number and type of the source operand fields; and combine the first identification code and the second identification code to generate a corresponding operation code; a second storage unit configured to store the opcode into the compiled instruction; The first output unit is configured to output the compiled instructions.

6. A device for processing instruction data, characterized in that: The device comprises: A first determining unit configured to determine an opcode in a compiled instruction; The second determining unit is configured to parse the opcode corresponding to the instruction that needs to obtain the source operand field if it is detected that the instruction needs to obtain the source operand field, and obtain the parsing result; the third determining unit is configured to determine the type of the instruction according to the first identification code parsed from the opcode; determine the number and type of the source operand field according to the second identification code parsed from the opcode; and determine the source operand field from a specified encoding position in the instruction according to the number and type of the source operand field; The second output unit is configured to obtain a corresponding operand according to the source operand field and output the operand.

7. A computer device, characterized in that: The computer device comprises at least: a processor and a storage medium configured to store executable instructions, wherein: The processor is configured to execute the stored executable instructions, and the executable instructions are configured to execute the instruction data processing method provided in any one of claims 1 to 4 above.

8. A computer-readable storage medium, wherein the computer storage medium stores computer-executable instructions, wherein the computer-executable instructions are configured to execute the steps in the instruction data processing method provided in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Microcontroller unit

    CN101071410A

  • Assembler based on user describing and realizing method thereof

    CN101118498A

  • Device for symmetrically encoding 16 / 32-bit mixed instruction and device for decoding 16 / 32-bit mixed instruction

    CN102141903A

  • Instruction set design method for embedded graphic processing unit

    CN104731558A

  • Instruction decoder for microprocessor system

    DE19737658A1