Decoding method, processor, chip and electronic device
The proposed decoding method and processor architecture improve decoding efficiency by using a switching mark to facilitate parallel decoding across multiple decoder groups and integrating a microinstruction cache, addressing throughput limitations in existing processors.
Patent Information
- Application Number
- JP2024532283
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2022-10-31
- Filing Date
- 2023-02-27
- Publication Date
- 2024-11-13
- Estimated Expiration
- 2043-02-27
AI Technical Summary
Existing processors face challenges in improving decoding efficiency due to limitations in throughput and complexity when using multiple decoder groups for parallel instruction decoding.
A decoding method and processor architecture that utilizes a switching mark to indicate instruction positions for decoder group switching, allowing parallel decoding of instructions and microinstructions, and incorporates a microinstruction cache for enhanced retrieval speed.
Enhances decoding efficiency by enabling parallel decoding of instructions across multiple decoder groups and supports both decoder and microinstruction cache modes, improving overall processor performance.
Smart Images

Figure 2024542273000001_ABST
Abstract
Description
[Technical field]
[0001] This application claims priority to Chinese Patent Application No. 202211350246.2 filed on October 31, 2022, and the contents disclosed in the above Chinese patent application are hereby incorporated in their entirety as part of this application.
[0002] The embodiments of the present disclosure relate to a decoding method, a processor, a chip and an electronic device. [Background technology]
[0003] In modern processors, instructions need to go through a process of fetching, decoding, and executing, where decoding is the process of analyzing and translating the fetched instruction to obtain a micro-instruction (micro-op, Uop). Decoding is an important operation of a processor, and how to improve the decoding performance of a processor has been a topic of research for those skilled in the art. Summary of the Invention [Means for solving the problem]
[0004] In view of the above, embodiments of the present disclosure provide a decoding method, a processor, a chip, and an electronic device for achieving parallel decoding of instructions and obtaining a microinstruction sequence that matches the fetch order, thereby improving the decoding performance of the processor.
[0005] To achieve the above objectives, the embodiments of the present disclosure provide the following technical solutions.
[0006] An embodiment of the present disclosure is a decoding method applied to a processor, comprising: generating a fetch request carrying at least one switch mark indicating an instruction position where at least a switch of decoder groups is to occur; in response to a microinstruction being obtained by decoding a decoder group, obtaining the instruction stream fetched by said fetch request, determining an instruction position in said instruction stream at which a decoder group is switched in accordance with a switching mark carried by said fetch request, allocating said instruction stream to a plurality of decoder groups in accordance with said instruction position for parallel decoding, and attaching a switching mark to a target microinstruction obtained by decoding a target instruction, which is an instruction corresponding to said instruction position; In response to obtaining a microinstruction by searching a microinstruction cache, if the fetch request hits in the microinstruction cache, obtaining a microinstruction corresponding to the fetch request and not marked with a switching mark from the microinstruction cache.
[0007] The embodiment of the present disclosure includes: a branch prediction unit for generating a fetch request carrying at least one switch mark indicating an instruction position at which at least a switch of decoder groups is to occur; an instruction cache responsive to the decoding of a decoder group resulting in a microinstruction, for obtaining the instruction stream fetched by said fetch request, and for determining, in response to a switch mark carried by said fetch request, an instruction position in said instruction stream at which a switch between decoder groups is to be made; an instruction allocation unit for allocating the instruction stream to a plurality of decoder groups for parallel decoding according to the instruction position; a decoder group for decoding the assigned instruction to obtain a microinstruction, the number of the decoder groups being plural, wherein when the decoder group decodes a target instruction, a switching mark is added to a target microinstruction obtained by decoding the target instruction, the target instruction being an instruction corresponding to the instruction position; The processor further includes a microinstruction cache for, in response to a microinstruction being obtained by searching the microinstruction cache, retrieving from the microinstruction cache a microinstruction corresponding to the fetch request and not marked for switching if the fetch request hits in the microinstruction cache.
[0008] An embodiment of the present disclosure further provides a chip including the above-mentioned processor.
[0009] An embodiment of the present disclosure further provides an electronic device including the above-mentioned chip.
[0010] The decoding method provided by the embodiment of the present disclosure may be applied to a processor, and at least one switching mark indicating an instruction position where at least a decoder group switching is performed may be carried in a fetch request. Thus, when the processor responds to the microinstruction being obtained by decoding the decoder group, the processor may obtain the instruction stream fetched by the fetch request, and determine the instruction position in the instruction stream where the decoder group switching is performed according to the switching mark carried in the fetch request, and further assign the instruction stream to multiple decoder groups for parallel decoding according to the instruction position, and add switching marks to target microinstructions obtained by decoding a target instruction, which is an instruction corresponding to the instruction position, and subsequently fuse the microinstructions obtained by decoding the multiple decoder groups according to the switching marks added to the target microinstructions to obtain a microinstruction corresponding to a fetch order. When the processor responds to the microinstruction being obtained by searching a microinstruction cache, if the fetch request hits in the microinstruction cache, the embodiment of the present disclosure may not decode an instruction by a decoder group, but may obtain the microinstruction corresponding to the fetch request from the microinstruction cache.
[0011] In an embodiment of the present disclosure, in a processor having a microinstruction cache and a decoder, a fetch request may carry a switching mark, and the switching mark may indicate at least an instruction position where a switching of a decoder group is performed, so that in a decoder mode in which a microinstruction is obtained by decoding a decoder group, the switching mark is transparently transmitted through a target instruction and a target microinstruction to support parallel decoding of a plurality of decoder groups, and the decoded microinstructions can be fused according to the fetch order of the instructions, improving the decoding efficiency, while in a microinstruction cache mode in which a processor obtains a microinstruction by searching a microinstruction cache, the embodiment of the present disclosure does not need to perform processing based on the switching mark carried in the fetch request, and is compatible with the microinstruction cache mode of the processor. In a processor supporting a decoder mode and a microinstruction cache mode, the embodiment of the present disclosure may support parallel decoding and improve the decoding performance. [Brief description of the drawings]
[0012] In order to more clearly describe the embodiments of the present disclosure, the following briefly introduces the drawings required to be used in the embodiments. Obviously, the drawings in the following description are only embodiments of the present disclosure, and those skilled in the art can obtain other drawings from the provided drawings without paying creative labor. [Figure 1A] FIG. 1A is an architecture block diagram of a processor. [Figure 1B] FIG. 1B is another architecture block diagram of a processor. [Figure 2A] FIG. 2A is an architectural block diagram of one of the processors provided in accordance with at least one embodiment of the present disclosure. [Figure 2B] FIG. 2B is a flowchart of an option for a decoding method provided in accordance with at least one embodiment of the present disclosure. [Figure 2C]FIG. 2C is yet another architectural block diagram of a processor provided in accordance with at least one embodiment of the present disclosure. [Figure 3A] FIG. 3A is a schematic diagram of instruction stream segmentation provided in accordance with at least one embodiment of the present disclosure. [Figure 3B] FIG. 3B is a schematic diagram of microinstruction fusion provided in accordance with at least one embodiment of the present disclosure. [Figure 4A] FIG. 4A is an architectural block diagram of a processor having a microinstruction cache. [Figure 4B] FIG. 4B is yet another architectural block diagram of a processor provided in accordance with at least one embodiment of the present disclosure. [Figure 5A] FIG. 5A is a schematic diagram of options for retaining microinstructions in a microinstruction cache mode provided by at least one embodiment of the present disclosure. [Figure 5B] FIG. 5B is a schematic diagram of another option for retaining microinstructions in a microinstruction cache mode provided by at least one embodiment of the present disclosure. [Figure 6] FIG. 6 is a flowchart of another optional decoding method provided by at least one embodiment of the present disclosure. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0013] In the following, the technical solutions in the embodiments of the present disclosure are clearly and completely described in combination with the accompanying drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only some embodiments of the present disclosure, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments in the present disclosure without paying creative labor, belong to the scope of protection of the present disclosure.
[0014] An instruction is a command that controls a computer to perform operations, and is also called a machine instruction. The role of an instruction is to coordinate the operational relationships between each hardware component, reflect the basic functions of a computer, and is the smallest functional unit at which a computer operates. When a computer executes an operation command, the processor must process the instruction and convert it into a machine language that the machine can understand. In a processor, instruction processing is generally achieved using pipeline technology.
[0015] In the pipeline operation of a processor, an instruction needs to go through processing processes such as instruction fetch, decode, and execute. Fetch is to fetch an instruction corresponding to the execution of a program from the processor cache or main memory, decode operation is to decode the fetched instruction to determine the opcode and / or address code of the instruction, and execute operation is to execute an instruction operation according to the obtained opcode and / or address code, and to realize the execution of the program. Here, since there is a branch instruction that changes the flow of the program, when processing a branch instruction, in order to solve the pipeline delay caused by the processor waiting for the execution result of the branch instruction before deciding the next fetch, a branch prediction unit may be further provided at the head of the pipeline where the processor processes the instruction to realize the branch prediction of the instruction.
[0016] FIG. 1A illustrates an exemplary architecture block diagram of a processor including a branch prediction unit 101, an instruction cache 102, and a decoder group 103.
[0017] The branch prediction unit 101 is a digital circuit that can predict an instruction and generate a fetch request based on the branch prediction result. The branch prediction result is, for example, whether the current instruction is a branch instruction or not, the branch result (direction, address, destination address, etc.) of the branch instruction, etc. In one implementation, the branch prediction unit may perform a branch prediction of an instruction based on the historical execution information and result of the branch instruction, thereby obtaining a fetch address range of the instruction, and generate a fetch request. The fetch request generated by the branch prediction unit includes fetch addresses of several instructions for reading corresponding instructions from the instruction cache 102.
[0018] Instructions are stored in the instruction cache 102, and the instruction cache 102 stores instructions primarily through instruction cache blocks. In the instruction cache, each instruction cache block corresponds to a Tag tag for identifying the instruction cache block in the instruction cache, so that the instruction cache can find the corresponding instruction cache block based on the Tag when fetching in response to a fetch request. A fetch address generated by the branch prediction unit may correspond to multiple instructions forming an instruction stream. Optionally, the instruction cache 102 may be a cache portion for storing instructions located in a level 1 cache of the processor.
[0019] The fetch address generated by the branch prediction unit has a tag area (address identification area) and an index area (address index area). The index area in the fetch address allows the tags of multiple instruction cache blocks in the instruction cache to be read out. Furthermore, a matching determination is made between the tags of the multiple instruction cache blocks in the read instruction cache and the tag of the fetch address, and the storage location in the instruction cache of the instruction corresponding to the fetch address (i.e. the location of the instruction cache block) is obtained, and the corresponding instruction is then read out.
[0020] The decoder group 103 can analyze and translate the instruction, and the decoder group can obtain the decoded instruction by decoding the instruction. The decoded instruction can be a machine executable operation information obtained by translating the instruction, such as a machine executable Uop (micro-op) formed by a control field, that is, the decoder can decode the instruction, thereby obtaining a micro-op.
[0021] The processor architecture shown in FIG. 1A uses a single decoder group to decode instructions, and is limited by the throughput of the decoder group, making it difficult to effectively improve the efficiency of instruction decoding. Based on this, a processor that uses multiple decoder groups to decode instructions in parallel has emerged. FIG. 1B is a diagram illustrating an example of another architecture block diagram of a processor. As shown by combining FIG. 1A and FIG. 1B, the processor shown in FIG. 1B is provided with multiple decoder groups 1031-103n, and the specific value of n may depend on the specific design of the processor and is not limited to the embodiment of the present disclosure. Based on the multiple decoder groups 1031-103n provided by the processor, the instruction cache 102 assigns the instruction stream fetched based on the fetch request to the multiple decoder groups for decoding, and the multiple decoder groups may decode the instructions in parallel and output the microinstructions obtained by the decoding, thereby improving the efficiency of instruction decoding.
[0022] In one example, the multiple decoder groups may be, for example, two decoder groups, decoder group 0 and decoder group 1, respectively. Here, the decoder group 0 may perform decoding on an instruction at the same time as the decoder group 1 may perform decoding on an instruction. For example, in one clock cycle of the processor, the decoder group 0 and the decoder group 1 may simultaneously perform decoding operations on instructions to obtain microinstructions, thereby realizing parallel decoding of instructions. At the same time, the decoder group 0 and the decoder group 1 may not decode in the order of instructions, and may support parallel decoding of instructions. Note that in practical applications, the processor may have two or more decoder groups as necessary, and for ease of understanding, the embodiment of the present disclosure only shows an example of two decoder groups.
[0023] However, since multiple decoder groups decode instructions in parallel, unlike a single decoder group sequentially decodes instructions, multiple decoder groups need to face more complicated situations when performing parallel instruction decoding, such as how to allocate the instruction stream fetched from the instruction cache to multiple decoder groups, how to fuse the microinstructions obtained by decoding the multiple decoder groups, and how to make the microinstructions finally executed correspond to the fetch order of the instructions. To solve the above problems, an embodiment of the present disclosure provides a further improved processor architecture, and FIG. 2A exemplarily illustrates an architecture block diagram of a processor provided by at least one embodiment of the present disclosure. As shown in Figure 1B and Figure 2A, the processor shown in Figure 2A further includes an instruction allocation unit 201 for dividing the instruction stream fetched by the instruction cache 102, thereby obtaining a plurality of instruction groups to be assigned to decoder groups for parallel decoding; at the same time, in order to provide a basis for dividing the instruction stream, the embodiment of the present disclosure carries a switching mark in the fetch request, which can indicate at least the instruction position where the decoder group switching is performed, and the switching mark is transparently transmitted to the process of the instruction cache fetching the instruction stream according to the fetch request, so that the instruction allocation unit 201 can divide the instruction stream according to the instruction position where the decoder group switching is performed, and the divided plurality of instruction groups of the instruction stream can be assigned to a plurality of decoder groups for parallel decoding, which technically supports parallel decoding of instructions in a plurality of decoder groups. Furthermore, the switching mark may be transparently transmitted to a microinstruction through an instruction corresponding to the instruction position, which technically supports that after each decoder group decodes to obtain a microinstruction, the microinstruction can be fused based on the switching mark in the microinstruction, and the fused result of the microinstruction can be associated with a fetch order.
[0024] As an optional implementation, Fig. 2B exemplarily illustrates an optional flowchart of a decoding method provided by at least one embodiment of the present disclosure. This decoding method may be considered as a method flow when a processor decodes using a decoder group, i.e., a method flow in which a microinstruction is obtained by decoding the decoder group. Referring to Fig. 2B, the method flow may include the following steps:
[0025] In step S21, a fetch request is generated which carries at least one switching mark indicating the instruction position where at least a decoder group switching takes place.
[0026] In some embodiments, the fetch request generated by the branch prediction unit may include a portable switching mark. When the branch prediction unit performs branch prediction, the branch prediction direction is mainly divided into two types: a jump branch instruction and a non-jump branch instruction, and accordingly, the fetch address generated by the branch prediction unit may be divided into two types: a fetch address corresponding to the jump branch prediction direction and a fetch address corresponding to the non-jump branch prediction direction. As an optional implementation, the embodiment of the present disclosure may provide a switching mark according to an address position corresponding to the jump branch prediction direction, and generate a fetch request carrying at least one switching mark.
[0027] In some embodiments, the switch mark is not limited to being set in the fetch request based on the branch prediction status by the branch prediction unit, but may be set by other mechanisms. As an optional implementation, after the branch prediction unit generates the fetch request (without carrying the switch mark), the embodiments of the present disclosure may utilize other devices in the processor (e.g., an instruction cache) to set the switch mark in the fetch request. In one implementation, the instruction cache may set the switch mark in the fetch request based on an instruction boundary that may represent the end location of an instruction after obtaining the fetch request of the branch prediction unit.
[0028] In step S22, the instruction stream fetched by the fetch request is obtained, and the instruction position in the instruction stream where the decoder group is to be switched is determined according to the switch mark carried in the fetch request.
[0029] The instruction cache receives a fetch request from the branch prediction unit and fetches instructions according to a fetch address in the fetch request, thereby obtaining an instruction stream corresponding to the fetch request. If the fetch request carries a switching mark and the switching mark indicates at least an instruction position where a switch of decoder groups is to be performed, the instruction cache may determine an instruction position in the instruction stream where a switch of decoder groups is to be performed according to the switching mark carried in the fetch request.
[0030] It will be understood that an instruction stream is a set of instruction sequences containing several instructions, and if there is no clear boundary in the instruction sequence, it is not possible to determine the end position of an instruction in the instruction sequence. In an embodiment of the present disclosure, if the boundary of the instruction stream can be determined by determining an instruction position in the instruction stream where a decoder group is switched in response to a switching mark carried in the fetch request, the instruction position may be the end position. If an instruction corresponding to the instruction position is taken as a target instruction, the instruction position becomes the end position of the target instruction, and thereby the end position of the target instruction in the instruction stream can be determined according to the instruction position indicated by the switching mark carried in the fetch request.
[0031] In addition, since the switching mark is used to indicate at least the instruction position where the decoder group switching is performed, its setting position in the fetch request does not affect the instruction stream fetched by the instruction cache and does not destroy the structure of the fetched instruction stream. In the embodiment of the present disclosure, the specific setting position and expression form of the switching mark are not limited, and for example, it may be an indication area existing outside the instruction stream fetched by the instruction cache, or may be represented by a switching mark indication bit.
[0032] In step S23, the instruction stream is assigned to a plurality of decoder groups according to the instruction position for parallel decoding, and a switching mark is attached to a target microinstruction obtained by decoding a target instruction, which is an instruction corresponding to the instruction position.
[0033] In some embodiments, based on the instruction stream fetched by the instruction cache, the instruction allocation unit may allocate the instruction stream to multiple decoder groups for parallel decoding according to the instruction position (i.e., the instruction position at which the decoder group switching occurs). In one optional example, the instruction allocation unit may split the instruction stream to obtain multiple instruction groups according to the instruction position, and further allocate the multiple instruction groups to multiple decoder groups for parallel decoding by the multiple decoder groups.
[0034] Furthermore, in some embodiments, the instruction allocation unit dividing the instruction stream according to the instruction position may be dividing the instruction stream into a plurality of instruction groups with the instruction position in the instruction stream as a boundary, where a target instruction that is a boundary between two adjacent instruction groups is divided as being in a previous instruction group. Thus, when allocating the instruction stream to a plurality of decoder groups for parallel decoding, the instruction allocation unit may allocate a decoder group different from the decoder group allocated to the previous instruction group to the next instruction group according to a switching mark corresponding to the target instruction divided as being in the previous instruction group, where the switching mark corresponding to the target instruction may be a switching mark corresponding to indicating the end position of the target instruction.
[0035] In addition, after the multiple decoder groups perform the decoding operations on the assigned instruction groups to obtain microinstructions, in order to enable the microinstructions decoded by the multiple decoder groups to be merged according to the fetch order, the embodiment of the present disclosure may analyze and translate the target instruction corresponding to the instruction position, and then mark the target microinstruction obtained by decoding the target instruction with a switch mark. As an optional realization, the target microinstruction obtained by decoding the target instruction may be a combination of two microinstructions, one of which is a microinstruction without a switch mark and the other is a microinstruction with a switch mark.
[0036] In some embodiments, the embodiments of the present disclosure may, after obtaining the microinstructions decoded by the multiple decoder groups, fuse the microinstructions decoded by the multiple decoder groups according to the switching marks attached to the target microinstructions to obtain microinstructions corresponding to the fetch order. It can be understood that in order to realize a complete operation on the program, the microinstructions decoded by the multiple decoder groups need to be fuse, and the order of the microinstruction sequence obtained by fusing the microinstructions also needs to correspond to the fetch order.
[0037] In an embodiment of the present disclosure, when a switching mark is carried in a fetch request, the switching mark indicates at least an instruction position where a decoder group is switched. Thereby, an instruction stream fetched by a fetch request is obtained, and an instruction position in the instruction stream where a decoder group is switched is determined according to the switching mark carried in the fetch request, and the instruction stream is assigned to a plurality of decoder groups according to the instruction position for parallel decoding, and a switching mark may be added to a target microinstruction obtained by decoding a target instruction that is an instruction corresponding to the instruction position. In an embodiment of the present disclosure, the switching mark may indicate an instruction position where a decoder group is switched by the switching mark, and the switching mark may be transparently transmitted to an instruction position in the fetched instruction stream by the fetch request, thereby realizing the division of the fetched instruction stream based on the instruction position, and the assignment to a plurality of decoder groups for parallel decoding, thereby effectively improving the decoding efficiency of the processor. Furthermore, the embodiments of the present disclosure may transparently transmit a switching mark to a target microinstruction by analyzing and translating a boundary target instruction, and after obtaining microinstructions decoded by multiple decoder groups, may fuse the microinstructions decoded by the multiple decoder groups according to the switching mark to obtain a microinstruction corresponding to a fetch order, in order to facilitate accurate execution of the microinstructions.
[0038] In some embodiments, Figure 2C illustrates yet another architecture block diagram of a processor provided in accordance with at least one embodiment of the present disclosure. As illustrated in Figure 2A and Figure 2C in combination, in the processor illustrated in Figure 2C, each decoder group is provided with a corresponding instruction queue and a microinstruction queue, for example, decoder groups 1031-103n are provided with instruction queues 2021-202n and microinstruction queues 2031-203n, respectively, and one decoder group corresponds to one instruction queue and one microinstruction queue. Here, the instruction queue of the decoder group is for holding the instruction group that the instruction allocation unit assigns to the decoder group, that is, the instruction queue may hold the instruction to be decoded by the decoder group, for example, the instruction queue 2021 holds the instruction to be decoded by the decoder group 1031, similarly, the instruction queue 202n holds the instruction to be decoded by the decoder group 103n, where, when realizing the parallel decoding of the multiple decoder groups, as long as the speed of holding the instruction to be decoded in the instruction queue of each decoder group is guaranteed to be faster than the decoding speed of the decoder group, the decoder group can continuously obtain and decode the instruction from the instruction queue, thereby realizing the parallel decoding of the multiple decoder groups. The microinstruction queue of the decoder group is for holding the microinstruction obtained by decoding the decoder group, for example, the microinstruction queue 2031 holds the microinstruction obtained by decoding the decoder group 1031, similarly, the microinstruction queue 203n holds the microinstruction obtained by decoding the decoder group 103n. In order to fuse the microinstructions decoded by each decoder group, the processor is further provided with a fusion unit 204 capable of reading and fusing instructions from multiple microinstruction queues so as to correspond the order of the fused microinstructions to the fetch order.
[0039] Based on the principle of the method flow shown in Figure 2B, the processor architecture shown in Figure 2C, in the decoding process, transmits the switching mark in the fetch request transparently to the microinstruction by the corresponding instruction to realize parallel decoding of multiple decoder groups, and the microinstruction may be fused according to the fetch order, and the optional specific process is as follows:
[0040] The branch prediction unit 101 generates a fetch request carrying a switching mark, issues the fetch request to the instruction cache 102, and reads a corresponding instruction stream in response to the fetch request in the instruction cache 102. Here, the switching mark in the fetch request indicates the instruction position where the decoder group switching is performed, and does not affect the fetch address searching for an instruction corresponding to the instruction position in the instruction cache.
[0041] The instruction cache 102 reads the instruction stream in response to the fetch address of the fetch request, where the switching mark carried in the fetch request does not affect the fetching of instructions in the instruction cache. After reading the instruction stream, the instruction cache 102 can determine, in response to the switching mark carried in the fetch request, the instruction position in the instruction stream where the decoder group switching occurs.
[0042] The instruction allocation unit 201 divides the instruction stream according to the instruction position, obtains a plurality of instruction groups, and assigns the plurality of instruction groups to the instruction queues 2021-202n corresponding to the decoder groups 1031-103n. As an optional implementation, the switching mark may indicate a plurality of instruction positions, and thus a plurality of instruction positions may be determined in the instruction stream. When the instruction allocation unit divides the instruction stream, when one of the instruction positions is recognized in the instruction stream, the division may be performed once, and the target instruction corresponding to the instruction position may be divided to be in a previous instruction group, and a decoder group different from the decoder group assigned to the previous instruction group may be assigned to the next instruction group according to the switching mark corresponding to the target instruction divided to be in the previous instruction group. In this way, the instruction stream is divided into a plurality of instruction groups using the instruction position as a boundary, and the plurality of instruction groups are assigned to a plurality of decoder groups for parallel decoding.
[0043] In some embodiments, the instruction allocation unit 201 may hold a first instruction group of the multiple instruction groups in an instruction queue corresponding to a default decoder group based on an instruction queue for holding instructions to be decoded that is set corresponding to the decoder group, but for an instruction group that is not the first instruction group of the multiple instruction groups, may determine a decoder group from the multiple decoder groups that is different from the decoder group assigned to the previous instruction group according to a switching mark corresponding to a target instruction in the previous instruction group, and further hold this non-first instruction group in an instruction queue corresponding to the determined decoder group.
[0044] In implementing the option of allocating a decoder group to a non-first instruction group of the plurality of instruction groups, a decoder group to be allocated to each of the non-first instruction groups may be determined from the plurality of decoder groups in sequence according to the order of the plurality of decoder groups in response to a switching mark corresponding to a target instruction in an instruction group preceding the non-first instruction group. For example, if the first decoder group 1031 is a default decoder group, the first instruction group after the splitting of the instruction stream is allocated to the decoder group 1031, and then each of the non-first instruction groups is allocated to a decoder group following the decoder group 1031 in sequence up to decoder group 103n in accordance with the order of the decoder groups.
[0045] In addition, the allocation principle by which the instruction allocation unit allocates decoder groups to instruction groups may be to allocate according to the order of the decoder groups, and allocate a decoder group to the next instruction group different from the decoder group allocated to the previous instruction group according to the switching mark corresponding to the target instruction in the previous instruction group, thereby realizing a rational allocation of instruction groups in the instruction queues corresponding to the decoder groups, ensuring that multiple decoder groups can read instructions to be decoded in the corresponding instruction queues, and realizing parallel decoding of multiple decoder groups.
[0046] In addition, in another option, the switching mark may further include information of the decoder group to be switched, so as to specifically indicate the decoder group to be switched. Thereby, the instruction allocation unit can assign a specific decoder group to the next instruction group based on the switching mark corresponding to the target instruction in the previous instruction group, and realizes assigning the decoder group to the instruction group without following the order of the decoder group. For example, for the decoder groups 1031 to 103n, according to the appearance order of the switching mark, if the information of the decoder group 103n is recorded in the first switching mark, the first instruction group is assigned to the default decoder group, and the next instruction group is assigned to the decoder group 103n specifically indicated by the first switching mark, and decoding is performed by the decoder group 103n; if the next switching mark specifically indicates the decoder group 1031, the decoder group to be assigned to the next instruction group is 1031, and decoding is performed by the decoder group 1031; in this way, the instruction allocation unit assigns the corresponding decoder group to the instruction group according to the decoder group to be switched specifically indicated in the switching mark until the assignment of the instruction group is completed.
[0047] Furthermore, the default decoder group may be the first decoder group assigned according to the order, or may be a decoder group designated and assigned by the processor, and this disclosure does not unduly limit this.
[0048] Next, referring to FIG. 2C, the decoder groups 1031-103n store the decoded microinstructions in corresponding microinstruction queues 2031-203n, where, if the instruction to be decoded is a target instruction, the decoder groups 1031-103n may decode and obtain a target microinstruction corresponding to the target instruction, and may attach a switching mark to the target microinstruction according to the instruction position in the target instruction corresponding to the switching mark.
[0049] The fusion unit 204 reads microinstructions in the microinstruction queues 2031-203n and fuses the read microinstructions to obtain a sequence of microinstructions that can be executed. When the fusion unit 204 realizes the fusion of microinstructions in the microinstruction queues 2031-203n, the fusion unit 204 may sequentially read and fuse the microinstructions in the microinstruction queues 2031-203n based on the switching marks attached to the target microinstructions. For example, the fusion unit reads microinstructions in the microinstruction queue 2031 according to the order of the microinstruction queue, and when a target microinstruction marked with a switching mark is read in the microinstruction queue 2031, the fusion unit switches to the next microinstruction queue in the microinstruction queue 2031 in order and reads a microinstruction in that microinstruction queue. When a target microinstruction marked with a switching mark is read in this microinstruction queue, the fusion unit similarly switches to the next microinstruction queue and continues reading the microinstructions until the reading of the microinstruction is completed.
[0050] In some embodiments, the first microinstruction queue of microinstructions read by the fusion unit may correspond to the first assigned instruction queue of an instruction group (e.g., a microinstruction queue and an instruction queue belonging to the same decoder group), and in one example, if the instruction allocation unit assigns the first instruction group to the instruction queue 2021 corresponding to the decoder group 1031, the fusion unit will first read the microinstructions in the microinstruction queue 2031 when fusing microinstructions to support the fused microinstruction queue being associated with the fetch order.
[0051] In some other embodiments, the switch mark corresponding to the target instruction may specifically indicate the decoder group to be switched, or the switch mark attached to the target microinstruction obtained by decoding the target instruction may specifically indicate the microinstruction queue to be switched. Thus, when the fusion unit fuses microinstructions, it realizes reading out of the order of the microinstruction queue based on the read microinstruction queue that can be switched based on the switch mark attached to the target microinstruction. In one example, assuming that the target microinstruction exists in the microinstruction queue 2031 and the switch mark attached to the target microinstruction specifically indicates the microinstruction queue sequence 203n to be switched, when the fusion unit reads the switch mark attached to the target microinstruction in the microinstruction queue 2031, it may switch to the microinstruction queue 203n to continue reading the microinstruction, and when the fusion unit reads that the switch microinstruction queue 2031 specifically indicates the switch mark attached to the target microinstruction in the microinstruction queue 203n, it switches to the microinstruction queue 2031 to read the microinstruction.
[0052] In order to facilitate understanding of the principle of dividing an instruction stream based on the position of an instruction in the instruction stream where the decoder group is switched, two decoder groups are introduced as an example below. FIG. 3A exemplarily illustrates a schematic diagram of dividing an instruction stream. As shown in FIG. 3A, the instruction stream includes instructions 310-31m, where m is the number of instructions in the instruction stream, and may be determined according to the actual situation, and the embodiment of the present disclosure is not limited thereto. In the instructions 310-31m, if the instruction position where the decoder group is switched, which is indicated by the switching mark, is as shown by the dashed arrow in the figure, the instruction 31k corresponding to the instruction position may be the target instruction, and the instruction position may be the end position of the target instruction 31k, where the switching mark may be set by, for example, a branch prediction unit.
[0053] As shown in FIG. 3A, the embodiment of the present disclosure may divide the instruction stream 310-31m using the instruction position as a boundary for dividing the instruction stream. Here, the target instruction 31k is adjacent to the instruction 31k+1, and when dividing the instruction stream according to the instruction position, the target instruction 31k is divided to be in the previous instruction group (i.e., the instruction 310-31k are one group), and the instruction 31k+1 is divided to be in the next instruction group (i.e., the instruction 31k+1-31m are one group), thereby obtaining two adjacent different instruction groups. When there are multiple switching marks, there are multiple instruction positions in the instruction stream and multiple corresponding target instructions, and the instruction stream may be divided according to this method to obtain multiple instruction groups.
[0054] 3A, an embodiment of the present disclosure may allocate the first separated instruction group (i.e., instruction 310 through target instruction 31k) to an instruction queue corresponding to decoder group 0 according to the order of decoder group 0 and decoder group 1, and perform a decode operation on instruction 310 through target instruction 31k by decoder group 0. Since target instruction 31k is an instruction corresponding to the instruction position where the decoder group is switched, it is necessary to allocate a decoder group other than decoder group 0 to instructions after target instruction 31k. Based on this, the instruction group of instruction 31k+1 through instruction 31m is allocated to an instruction queue corresponding to decoder group 1, and a decode operation is performed on instruction 31k+1 through instruction 31m by decoder group 1.
[0055] In order to facilitate understanding of the principle of fusing microinstructions based on the microinstructions marked with a switch mark, two decoder groups are introduced as examples below: Figure 3B shows an exemplary schematic diagram of fusing microinstructions.
[0056] The decoder group 0 decodes the instruction group of instruction 310 to target instruction 31k to obtain microinstruction 320 to target microinstruction 32k (not shown), where the decoder group 0 analyzes and translates the target instruction 31k to obtain a target microinstruction 32k which is a combination of microinstruction 32k' and microinstruction 32k'', where microinstruction 32k' is a microinstruction without a switching mark and microinstruction 32k'' is a microinstruction with a switching mark. The decoder group 1 decodes the instruction group of instruction 31k+1 to instruction 31m to obtain microinstruction 32k+1 to microinstruction 32m. The microinstruction 320 to target microinstruction 32k are stored in the microinstruction queue of the decoder group 0, and the microinstruction 32k+1 to microinstruction 32m are stored in the microinstruction queue of the decoder group 1.
[0057] When fusing microinstructions, a microinstruction may be read first from the microinstruction queue of decoder group 0 according to the order of the decoder groups, and when a microinstruction 32k'' marked with a switch mark is read out of the target microinstruction 32k, the microinstruction queue of decoder group 1 is switched to read the microinstruction, i.e., when a microinstruction marked with a switch mark is read out from the currently read microinstruction queue, the next microinstruction queue is switched to read the microinstruction until the reading of the microinstruction is completed. The fetched instruction stream is divided according to the instruction position corresponding to the indication of the switch mark in the target instruction, and assigned to multiple decoder groups for parallel decode. Therefore, when the decoded microinstruction is read out, the microinstruction may be read out by switching among the microinstruction queues of the multiple decoder groups according to the switch mark marked in the target instruction, and the read microinstruction can be associated with the fetch order.
[0058] As described above, when a processor has multiple decoder groups, the switch mark of a fetch request indicates the instruction position where the decoder group is switched, and the switch mark is transparently transmitted to the microinstruction obtained by decoding the decoder group according to the target instruction in the instruction stream according to the fetch request, thereby realizing the support of parallel decoding of multiple decoder groups and sequential fusion of microinstructions, and effectively improving the decoding efficiency of the processor. Although the multiple decoder groups of a processor can realize parallel decoding of instructions, the process of fetching and decoding must be passed to obtain the microinstructions, which makes the process of obtaining the microinstructions more complicated. Based on this, the embodiment of the present disclosure further provides a high-performance processor with a Micro-Op Cache (OC: microinstruction cache) to improve the acquisition speed of the microinstructions.
[0059] 4A is an architecture block diagram of a processor having a microinstruction cache. As shown in FIG. 4A, a branch prediction unit 101 issues fetch requests it generates to a microinstruction cache 104, which may be used to cache microinstructions. In some embodiments, the microinstruction cache 104 may include multiple table entries, each of which may accommodate multiple microinstructions. A fetch request generated by the branch prediction unit 101 may correspond to multiple microinstruction cache table entries.
[0060] When the fetch request generated by the branch prediction unit performs a microinstruction acquisition in the microinstruction cache, the microinstruction cache may perform a hit check between the start address of the fetch request and the address of the first microinstruction of all table entries, and if there is a hit, obtain the microinstruction in the first table entry. If the end address of the last microinstruction in the table entry of the microinstruction cache is smaller than the end address of the address range of the fetch request, it is necessary to further perform a hit check with the address of the first microinstruction of all table entries using the end address of the address range corresponding to the last microinstruction, and if there is a hit, obtain the microinstruction in the second table entry. By repeating the above process until the end address of the address range in the fetch request is smaller than the end address of the last microinstruction in the table entry, it is possible to realize reading the microinstruction from the microinstruction cache based on the fetch request.
[0061] In some embodiments, if all of the addresses in the fetch request generated by the branch prediction unit can hit in the microinstruction cache, the microinstruction cache can output the corresponding microinstruction, and if the starting address in the fetch request generated by the branch prediction unit does not hit a table entry in the microinstruction cache, the microinstruction cache cannot output the microinstruction.
[0062] Based on a processor having a microinstruction cache and a decoder group, the processor may include a plurality of decode modes, including a decoder mode in which a microinstruction is obtained by decoding the decoder group, and a microinstruction cache mode in which a microinstruction is obtained by searching the microinstruction cache. Figure 4B illustrates, by way of example, another architecture block diagram of a processor provided in accordance with at least one embodiment of the present disclosure.
[0063] As shown in FIG. 4B, the processor of an embodiment of the present disclosure is compatible with a decoder mode and a microinstruction cache mode, and a fetch request carrying a switching mark generated by the branch prediction unit 101 can obtain a microinstruction through two paths, which may be a path in which the microinstruction is obtained by decoding a decoder group (corresponding to the decoder mode) and a path in which the microinstruction is obtained by searching a microinstruction cache (corresponding to the microinstruction cache mode).
[0064] In response to obtaining a microinstruction by decoding the decoder group, i.e., in the decoder mode, the branch prediction unit 101 issues a fetch request carrying a switching mark to the instruction cache 102, which fetches an instruction stream according to the address in the fetch request, divides the instruction stream according to the instruction position in the instruction stream via the instruction allocation unit 201, obtains a plurality of instruction groups, and assigns the obtained plurality of instruction groups to instruction queues 2021-202n corresponding to the plurality of decoder groups. The plurality of decoder groups 1031-103n reads instructions to be decoded in the corresponding instruction queues 2021-202n, performs a decoding operation, obtains a microinstruction, and further holds the decoded microinstruction in the corresponding microinstruction queue, and may further cache the decoded microinstruction in the microinstruction cache based on the existence of the microinstruction cache 104.
[0065] In response to a microinstruction being obtained by searching the microinstruction cache, i.e., in the microinstruction cache mode, the branch prediction unit 101 issues a fetch request carrying a switching mark to the instruction cache 102, so that a microinstruction can be output correspondingly by the microinstruction cache in response to a hit of the fetch request in the microinstruction cache, and based on the existence of a microinstruction queue, the obtained microinstruction can be retained in a microinstruction queue corresponding to a default decoder group.
[0066] In some embodiments, if the fetch request hits the microinstruction cache, the retrieved microinstruction is stored in a microinstruction queue corresponding to a default decoder group, where the microinstruction queue corresponding to the default decoder group may be a microinstruction queue corresponding to the first decoder group determined according to the order, or may be a microinstruction queue corresponding to a processor specified decoder group, or may be a microinstruction queue corresponding to a decoder group determined based on whether the last instruction decoded by the decoder group before the decode mode was switched to the microinstruction cache mode is in an instruction position corresponding to the indication of the switching mark.
[0067] In one optional implementation, if there is no instruction position corresponding to the indication of the switching mark in the last instruction decoded by the decoder group before the processor's decoding mode is switched from the decoder mode to the microinstruction cache mode, the microinstruction read in the microinstruction cache is held in the microinstruction queue corresponding to the decoder group which decoded the last instruction before the decoding mode was switched. FIG. 5A is a schematic diagram of an option to switch to a microinstruction cache mode and hold microinstructions in at least one embodiment of the present disclosure. As shown in FIG. 5A, in decoder mode, an instruction stream (i.e., instruction 510 to instruction 51m) is read from the instruction cache in response to a fetch request. Here, if the instruction position at which the decoder group is switched, as indicated by the switching mark, is as shown by the dashed line in the figure, instruction 51k corresponding to this instruction position is the target instruction, and there is no instruction position at the end of the instruction stream at which the decoder group is switched. The instruction stream is divided according to the instruction position to obtain two adjacent different instruction groups (i.e., instruction 510 to instruction 51k and instruction 51k+1 to instruction 51m), and the corresponding decoder groups are assigned. Then, the last instruction 51m is decoded by decoder group 1 to obtain microinstruction 52m without a switching mark, and is held in the corresponding microinstruction queue 1. After the decode mode is switched to the microinstruction cache mode, when the fetch address is searched for and hit in the microinstruction cache and a microinstruction (i.e., microinstruction 530 to microinstruction 53m) is read, the read microinstruction 530 to microinstruction 53m are correspondingly stored in the microinstruction queue 1.
[0068] As another optional implementation, if the last instruction decoded by the decoder group before the processor's decode mode switches from the decoder mode to the microinstruction cache mode corresponds to the instruction position indicated by the switching mark at which the decoder group is to be switched, the microinstruction read in the microinstruction cache is retained in the microinstruction queue corresponding to the post-switching decoder group indicated by the switching mark, in accordance with the switching mark corresponding to the last instruction. FIG. 5B is a schematic diagram of another option for switching to a microinstruction cache mode and holding microinstructions in at least one embodiment of the present disclosure. As shown in FIG. 5B, in decoder mode, an instruction stream (i.e., instruction 510 to instruction 51m) is read from the instruction cache in response to a fetch request, where the last instruction 51m corresponds to an instruction position where the decoder group is switched, as indicated by a switching mark (the instruction position indicated by switching mark 2 in the figure). After dividing the instruction stream and assigning the decoder groups, instructions 510 to 51k are decoded by decoder group 0, instructions 51k+1 to 51m are decoded by decoder group 1, and among microinstructions 52m' and 52m'' obtained by decoding the last instruction 51m by decoder group 1, microinstruction 52m'' is marked with a switching mark, and the microinstruction obtained by decoding by decoder group 1 is held in the corresponding microinstruction queue 1. After the decode mode is switched to the microinstruction cache mode, when the fetch address is searched for and hit in the microinstruction cache and a microinstruction (i.e., microinstruction 530 to microinstruction 53m) is read out, the read microinstruction 530 to microinstruction 53m are stored in the microinstruction queue (i.e., microinstruction queue 0) corresponding to the destination decoder group (i.e., decoder group 0) indicated by the switching mark corresponding to the last instruction 51m before the decode mode is switched.
[0069] It will be appreciated that the switch mark carried in the fetch request indicates at least the instruction location where the switch of decoder groups will occur, but because the microinstruction cache mode does not decode instructions via decoder groups, the microinstruction cache may not respond to the switch mark carried in the fetch request, and the microinstructions retrieved may not be marked with a switch mark.
[0070] In some other embodiments, in the microinstruction cache mode, if the fetch request does not hit in the microinstruction cache, the decoder mode may be entered, and the instruction corresponding to the fetch request is decoded in parallel by a plurality of decoder groups in the decoder mode to obtain a microinstruction, and the microinstruction obtained by decoding in the decoder mode may be stored in the microinstruction cache. Here, when switching to the decoder mode, the instruction stream fetched by the fetch request is divided according to the instruction position indicated by the switching mark, and then the first instruction group of the obtained plurality of instruction groups is assigned to an instruction queue corresponding to a default decoder group, and the instruction queue corresponding to the default decoder group may be an instruction queue corresponding to the first decoder group determined according to the order, or may be an instruction queue corresponding to a decoder group designated by the processor, or may be an instruction queue corresponding to the corresponding decoder group determined according to whether or not the last instruction decoded by the decoder group before entering the microinstruction cache mode exists in accordance with the instruction position indicated by the switching mark.
[0071] In one optional realization, if the last instruction decoded by the decoder group before the processor's decode mode is switched to the microinstruction cache mode does not have an instruction position corresponding to the switch mark, then after switching from the microinstruction cache mode to the decoder mode, the first instruction group of the multiple instruction groups obtained by splitting the instruction stream is assigned to the instruction queue corresponding to the decoder group that decoded the last instruction before switching from the microinstruction cache mode. With continued reference to Figure 5A, if the last instruction 51m decoded by the decoder group 1 before the processor's decode mode is switched to the microinstruction cache mode does not have an instruction position corresponding to the switch mark, so that the fetch address in the fetch request does not hit in the microinstruction cache when switching to the microinstruction cache mode, then the decode mode is switched back to the decoder group mode and the first instruction group obtained by splitting the instruction stream (i.e., instructions 510 to 51k) is assigned to the instruction queue 1 corresponding to the decoder group 1 according to the instruction position (position shown by the dashed line in Figure 5A) indicated by the switch mark carried in the fetch request.
[0072] In another optional implementation, if the last instruction decoded by a decoder group before the processor decode mode is switched to the microinstruction cache mode contains an instruction position corresponding to the indication of the switching mark, then after switching from the microinstruction cache mode to the decoder mode, the first instruction group out of the multiple instruction groups obtained by dividing the instruction stream is assigned to the instruction queue corresponding to the decoder group to which the switch is to be made, as indicated by the switching mark corresponding to the last instruction, before switching from the microinstruction cache mode. Continuing to refer to FIG. 5B, before the processor's decode mode switches to the microinstruction cache mode, the last instruction 51m decoded by decoder group 1 has an instruction position corresponding to the indication of the switching mark, so that when switching to the microinstruction cache mode, if the fetch address in the fetch request does not hit in the microinstruction cache, the decode mode switches back to decoder group mode, and the first instruction group (i.e., instructions 510 to 51k) obtained by dividing the instruction stream is assigned to instruction queue 0 corresponding to decoder group 0 after switching, as indicated by the switching mark corresponding to the last instruction 51m before switching from the microinstruction cache mode, in accordance with the instruction position indicated by the switching mark carried in the fetch request (the position indicated by switching mark 2 in FIG. 5B).
[0073] In an embodiment of the present disclosure, in a processor having a microinstruction cache and a decoder, a fetch request may carry a switching mark, and the switching mark may indicate at least an instruction position where a switching of a decoder group is performed, so that in a decoder mode (corresponding to a microinstruction being obtained by decoding a decoder group), the switching mark may be transmitted transparently through a target instruction and a microinstruction, thereby realizing support for parallel decoding of a plurality of decoder groups and improving decoding efficiency; while, for a microinstruction cache mode of the processor (corresponding to a microinstruction being obtained by searching a microinstruction cache), the embodiment of the present disclosure may not perform processing based on the switching mark carried in the fetch request, thereby being compatible with the microinstruction cache mode of the processor. The embodiment of the present disclosure may realize support for parallel decoding in a processor supporting a decoder mode and a microinstruction cache mode, and improve decoding performance. That is, the embodiment of the present disclosure may support parallel decoding in the decoder mode and improve decoding performance when the processor is compatible with the microinstruction cache mode.
[0074] As an optional example, Fig. 6 shows a flowchart of another optional decoding method provided by an embodiment of the present disclosure, which can be executed by the processor shown in Fig. 4B, where the contents described below can be referred to correspondingly with the contents described above. Referring to Fig. 6, the method may include the following steps:
[0075] Step S60: A fetch request is generated.
[0076] Optionally, step S60 may be performed by a branch prediction unit, which may set a switch mark in the fetch request to indicate the instruction position where the decoder group switch is to be performed depending on the branch prediction jump result.
[0077] Step S61: Determine whether or not the current processor is in the microinstruction cache mode. If NO, execute step S62; if YES, execute step S69.
[0078] Here, in the microinstruction cache mode, a microinstruction is obtained by searching a microinstruction cache.
[0079] Step S62: The instruction cache is accessed, and the instruction stream is fetched in response to the fetch request.
[0080] Furthermore, when an instruction caches an instruction stream read in response to a fetch request, the switching mark carried in the fetch request is transmitted transparently outside the fetched instruction stream, and based on the switching mark indicating at least the instruction position where the decoder group switching occurs, the instruction position in the instruction stream where the decoder group switching occurs can be determined, and further a target instruction corresponding to said instruction position can be determined.
[0081] Step S63: Determine whether or not a switching mark is present in the fetch request. If NO, execute step S64; if YES, execute step S65.
[0082] Step S64: Send the instruction stream to a default decoder group, decode the instructions by the default decoder group, and store the obtained microinstructions in a corresponding microinstruction queue.
[0083] It can be understood that the switching mark carried in the fetch request is used to indicate at least the instruction position where the decoder group switching is performed, and when the switching mark is not present in the fetch request, there is no need to switch the decoder group, and the instruction stream is decoded by the default decoder group, and the obtained microinstruction is stored in the microinstruction queue corresponding to the default decoder group. Here, the default decoder group may be the first decoder group assigned according to the order, or may be a decoder group designated and assigned by the processor, and in the instruction processing process, for each fetch request, the default decoder group may be the decoder group to which the current switch is made, and the default decoder group in the embodiment of the present disclosure is not designated as a fixed decoder group, but may be selected according to actual needs.
[0084] Step S65: The instruction stream is separated according to the switching mark, and the target instruction and the instruction preceding the target instruction are assigned to an instruction queue corresponding to a default decoder group, and the microinstruction obtained by decoding the target instruction is stored in the corresponding microinstruction queue, where the switching mark is attached to the target microinstruction obtained by decoding the target instruction.
[0085] Step S66: It is determined whether or not there is a target command corresponding to the switching mark among the remaining commands. If NO, step S67 is executed; if YES, step S68 is executed.
[0086] Step S67: The remaining instructions are assigned to an instruction queue corresponding to a next decoder group different from the previous decoder group, and are decoded by this next decoder group, and the obtained microinstructions are stored in the corresponding microinstruction queue.
[0087] Step S68: The target instruction and the instruction preceding the target instruction are assigned to an instruction queue corresponding to a next decoder group different from the previous decoder group, and decoded by this next decoder group. The microinstruction obtained is stored in the corresponding microinstruction queue. Here, a switch mark is added to the microinstruction obtained by decoding the target instruction, and the process returns to step S66 for execution.
[0088] Since instructions are assigned to the instruction queue of a decoder group, and the decoder group reads and decodes instructions from the instruction queue, when the speed at which instructions are assigned to the instruction queue is faster than the decoding speed of the decoder group, the embodiment of the present disclosure can realize a method of dividing an instruction stream and assigning it to the instruction queues of multiple decoder groups, and having the multiple decoder groups perform parallel decoding based on the instructions assigned to the instruction queues. Furthermore, steps S65 to S68 are an optional realization method according to the embodiment of the present disclosure, in which the instruction stream is divided based on a switching mark corresponding to a target instruction, multiple instruction groups are obtained, and the multiple instruction groups are assigned to multiple decoder groups for parallel decoding.
[0089] Step S69: Fetch a microinstruction from the microinstruction cache, and store the obtained microinstruction in the corresponding microinstruction queue.
[0090] The selection of the microinstruction queue is as described above and will not be described here.
[0091] Note that the prerequisite for fetching a microinstruction in the microinstruction cache based on a fetch request is that the fetch request hits the microinstruction cache. If the fetch request does not hit the microinstruction cache, the decoder mode is entered and step S62 is executed.
[0092] Here, in the decoder mode, a microinstruction is obtained by decoding a decoder group.
[0093] Step S70: A microinstruction is read from the microinstruction queue corresponding to the first decoder group.
[0094] Step S71: Determine whether or not the read microinstruction has a switching mark. If YES, execute step S72. If NO, return to step S70 and execute until reading of the microinstruction is completed.
[0095] Step S72: Switch to the microinstruction queue corresponding to the next decoder group to read out a microinstruction, and return to step S71.
[0096] After the reading of the microinstruction is completed, the embodiments of the present disclosure may further execute the microinstruction.
[0097] The embodiments of the present disclosure can provide support for parallel decoding in a processor that supports a decoder mode and a microinstruction cache mode, thereby improving decoding performance.
[0098] The embodiment of the present disclosure further provides a processor, the configuration of which may refer to FIG. 4B, where the contents described below may be considered as a decoding method provided by the processor to realize the embodiment of the present disclosure, and a functional module that is set as necessary, and the contents described below may be mutually correspondingly referred to the contents described above. The processor includes at least: a branch prediction unit for generating a fetch request carrying at least one switch mark indicating an instruction position at which at least a switch of decoder groups is to occur; an instruction cache responsive to the decoding of a decoder group resulting in a microinstruction, for obtaining the instruction stream fetched by said fetch request, and for determining, in response to a switch mark carried by said fetch request, an instruction position in said instruction stream at which a switch between decoder groups is to be made; an instruction allocation unit for allocating the instruction stream to a plurality of decoder groups for parallel decoding according to the instruction position; a decoder group for decoding the assigned instruction to obtain a microinstruction, the number of the decoder groups being plural, wherein when the decoder group decodes a target instruction, a switching mark is added to a target microinstruction obtained by decoding the target instruction, the target instruction being an instruction corresponding to the instruction position; and a microinstruction cache for obtaining, in response to a search of the microinstruction cache for obtaining, from the microinstruction cache, a microinstruction corresponding to the fetch request and not having a switching mark, if the fetch request hits in the microinstruction cache.
[0099] Optionally, the instruction location is an end location of a target instruction, and the step for the instruction cache determining, in response to a switch mark carried in the fetch request, an instruction location in the instruction stream at which a decoder group switch occurs, comprises: determining an end location of the target instruction in the instruction stream in response to an instruction location indicated by a switching mark carried in the fetch request.
[0100] Optionally, the step of the instruction allocation unit for allocating the instruction stream to a plurality of decoder groups for parallel decoding according to the instruction position comprises: The method may further include dividing the instruction stream into a plurality of instruction groups according to the instruction position, and allocating the plurality of instruction groups to a plurality of decoder groups for parallel decoding.
[0101] Optionally, the instruction allocation unit's step of partitioning the instruction stream into a plurality of instruction groups according to the instruction location comprises: splitting the instruction stream into a plurality of instruction groups using the instruction positions in the instruction stream as boundaries, whereby a target instruction that is a boundary between two adjacent instruction groups is split as being in a previous instruction group; The step of the instruction allocation unit allocating the plurality of instruction groups to a plurality of decoder groups for parallel decoding comprises: and allocating a decoder group to the next instruction group that is different from the decoder group assigned to the previous instruction group in response to a switch mark corresponding to the target instruction that was carved out as being in the previous instruction group.
[0102] optionally configuring an instruction queue corresponding to one decoder group for holding instructions to be decoded; the instruction allocation unit assigning a decoder group to a next instruction group different from the decoder group assigned to the previous instruction group in response to a switching mark corresponding to a target instruction that has been carved out as being in the previous instruction group, retaining a first instruction group of the plurality of instruction groups in an instruction queue corresponding to a default decoder group; For a non-first instruction group of the plurality of instruction groups, determining a decoder group from the plurality of decoder groups different from the decoder group assigned to the previous instruction group in accordance with a switching mark corresponding to a target instruction in the previous instruction group, and storing the non-first instruction group in an instruction queue corresponding to the determined decoder group.
[0103] Optionally, the step of the instruction allocation unit determining, for an instruction group that is not a first one of the plurality of instruction groups, a decoder group from the plurality of decoder groups different from a decoder group assigned to a previous instruction group in response to a switching mark corresponding to a target instruction in the previous instruction group, comprises: For a non-first instruction group of the plurality of instruction groups, determining a decoder group to be assigned to each of the non-first instruction groups sequentially from the plurality of decoder groups in accordance with an order of the plurality of decoder groups in response to a switching mark corresponding to a target instruction in an instruction group preceding the non-first instruction group.
[0104] Optionally, the instruction allocation unit retaining a first instruction group of the plurality of instruction groups in an instruction queue corresponding to a default decoder group comprises: after exiting a microinstruction cache mode and entering a decoder mode, allocating a first instruction group of the plurality of instruction groups to an instruction queue corresponding to a default decoder group, the decoder mode in which a microinstruction is obtained by decoding a decoder group, and the microinstruction cache mode in which a microinstruction is obtained by searching a microinstruction cache; where, if there is no instruction position corresponding to the indication of the switching mark in the last instruction decoded by the decoder group before the decode mode is switched to the microinstruction cache mode, after the decode mode is subsequently switched to the decoder mode, the first instruction group is assigned to an instruction queue corresponding to the decoder group which decoded this last instruction; If an instruction position corresponding to the instruction indicated by the switching mark exists in the last instruction decoded by the decoder group before the decode mode is switched to the microinstruction cache mode, after the decode mode is subsequently switched to the decoder mode, the first instruction group is assigned to an instruction queue corresponding to the decoder group indicated by the switching mark corresponding to this last instruction.
[0105] Optionally, the processor further includes a fusion unit for, in the decoder mode, fusing the microinstructions decoded by the multiple decoder groups in accordance with a switching mark attached to the target microinstruction to obtain a microinstruction corresponding to a fetch order.
[0106] Optionally, one microinstruction queue is configured for each decoder group, the decoder group is also used to hold the decoded microinstructions in a corresponding microinstruction queue; The step of the fusion unit fusing the microinstructions obtained by decoding the microinstructions obtained by the plurality of decoder groups in accordance with the switching marks attached to the target microinstructions to obtain a microinstruction corresponding to a fetch order includes: and fusing microinstructions by switching in the microinstruction queues corresponding to each decoder group in response to a switching mark attached to the target microinstruction to obtain a microinstruction corresponding to a fetch order.
[0107] Optionally, the step of the fusion unit switching and fusing microinstructions in the microinstruction queues corresponding to each decoder group in response to a switching mark attached to the target microinstruction to obtain a microinstruction corresponding to a fetch order comprises: The method includes starting to read microinstructions from a microinstruction queue corresponding to a default decoder group, and if a switching mark is attached to the read microinstruction, determining a next microinstruction queue to switch and read microinstructions from according to the switching mark attached to the microinstruction until reading of the microinstructions in the microinstruction queues corresponding to each decoder group is completed.
[0108] Optionally, the step of determining a next microinstruction queue from which to switch and read a microinstruction in response to a switch mark attached to the microinstruction by the fusion unit if the read microinstruction has a switch mark attached thereto comprises: If a switching mark is attached to the read microinstruction, the microinstruction queue for reading the microinstruction is switched in order from the microinstruction queue of each decoder group according to the switching mark attached to the microinstruction and in accordance with the order of the microinstruction queue.
[0109] Optionally, the microinstruction cache is also used in a microinstruction cache mode to hold fetched microinstructions in a microinstruction queue corresponding to a default decoder group; the decoder group is also used to store the decoded microinstructions in a microinstruction cache; Now, in the microinstruction cache mode, if the fetch request does not hit in the microinstruction cache, the decoder mode is entered.
[0110] In an embodiment of the present disclosure, a chip is also provided that may include the above-described processor.
[0111] An embodiment of the present disclosure further provides an electronic device that can include the above chip.
[0112] Although multiple embodiments of the present disclosure have been described above, the optional aspects introduced by each embodiment may be combined and cross-referenced with each other without contradiction, thereby expanding the various possible embodiments, all of which may be considered to be disclosures of embodiments of the present disclosure.
[0113] Although the embodiments of the present disclosure have been disclosed as above, the present disclosure is not limited thereto. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the present disclosure, so the scope of protection of the present disclosure shall be limited by the scope of the claims.
Claims
1. A decoding method applied to a processor, comprising: generating a fetch request carrying at least one switch mark indicating an instruction position where at least a switch of decoder groups is to occur; in response to a microinstruction being obtained by decoding a decoder group, obtaining the instruction stream fetched by said fetch request, determining an instruction position in said instruction stream at which a decoder group is switched in accordance with said switching mark carried by said fetch request, allocating said instruction stream to a plurality of decoder groups in accordance with said instruction position for parallel decoding, and attaching said switching mark to a target microinstruction obtained by decoding a target instruction which is an instruction corresponding to said instruction position; in response to a microinstruction being obtained by searching a microinstruction cache, if the fetch request is a hit in the microinstruction cache, obtaining from the microinstruction cache the microinstruction corresponding to the fetch request.
2. the instruction position being an end position of the target instruction, and determining the instruction position in the instruction stream at which a decoder group switch occurs in response to the switch mark carried in the fetch request comprises:
2. The method of claim 1, further comprising: determining an end position of the target instruction in the instruction stream in response to the instruction position indicated by the switching mark carried in the fetch request.
3. The above-mentioned allocating the instruction stream to a plurality of decoder groups according to the instruction position for parallel decoding includes:
3. The decoding method according to claim 1, further comprising: dividing the instruction stream into a plurality of instruction groups according to the instruction position; and allocating the plurality of instruction groups to a plurality of decoder groups for parallel decoding.
4. The above-mentioned dividing the instruction stream into a plurality of instruction groups according to the instruction position includes: splitting the instruction stream into a plurality of instruction groups using the instruction positions in the instruction stream as boundaries, wherein a target instruction that is a boundary between two adjacent instruction groups is split as being in a previous instruction group; The above-mentioned assigning the plurality of instruction groups to the plurality of decoder groups for parallel decoding includes:
4. The method of claim 3, further comprising: allocating a decoder group to a next instruction group that is different from the decoder group assigned to the previous instruction group in response to a switching mark corresponding to a target instruction that has been carved out as being in the previous instruction group.
5. setting up an instruction queue corresponding to one decoder group to hold instructions to be decoded, and allocating to a next instruction group a decoder group different from the decoder group assigned to the previous instruction group in response to a switching mark corresponding to a target instruction that has been partitioned as in the previous instruction group; retaining a first instruction group of the plurality of instruction groups in an instruction queue corresponding to a default decoder group; 5. The decoding method according to claim 4, further comprising: for a non-first instruction group of the plurality of instruction groups, determining a decoder group from the plurality of decoder groups different from a decoder group assigned to the previous instruction group in accordance with a switching mark corresponding to a target instruction in the previous instruction group, and storing the non-first instruction group in an instruction queue corresponding to the determined decoder group.
6. determining, for the non-first instruction group of the plurality of instruction groups, a decoder group different from the decoder group assigned to the previous instruction group from the plurality of decoder groups in response to a switching mark corresponding to a target instruction in the previous instruction group, 6. The method of claim 5, further comprising: for the non-first instruction groups of the plurality of instruction groups, determining from the plurality of decoder groups a decoder group to be assigned to each of the non-first instruction groups in sequence according to an order of the plurality of decoder groups in response to a switching mark corresponding to a target instruction in an instruction group preceding the non-first instruction group.
7. The step of storing a first instruction group of the plurality of instruction groups in an instruction queue corresponding to a default decoder group includes: after exiting a microinstruction cache mode and entering a decoder mode, assigning the first instruction group of the plurality of instruction groups to an instruction queue corresponding to a default decoder group, the decoder mode in which a microinstruction is obtained by decoding a decoder group, and the microinstruction cache mode in which a microinstruction is obtained by searching the microinstruction cache; where, if the instruction position corresponding to the indication of the switching mark does not exist in the last instruction decoded by the decoder group before the decode mode is switched to the microinstruction cache mode, after the decode mode is subsequently switched to the decoder mode, the first instruction group is assigned to an instruction queue corresponding to the decoder group which decoded the last instruction; 7. The decoding method according to claim 5, further comprising: if, before the decode mode is switched to the microinstruction cache mode, the instruction position corresponding to the indication of the switching mark is present in the last instruction decoded by a decoder group, after the decode mode is subsequently switched to the decoder mode, allocating the first instruction group to an instruction queue corresponding to the decoder group indicated by the switching mark corresponding to the last instruction.
8. 7. The decoding method of claim 1, wherein the processor includes a plurality of decoding modes including a decoder mode in which a microinstruction is obtained by decoding a decoder group, and a microinstruction cache mode in which a microinstruction is obtained by searching a microinstruction cache.
9. 9. The decoding method according to claim 8, further comprising: in the decoder mode, fusing microinstructions obtained by decoding the multiple decoder groups according to the switching mark attached to the target microinstruction to obtain a microinstruction corresponding to a fetch order.
10. A microinstruction queue is set corresponding to one decoder group, and the decoding method includes: The method further includes storing the microinstructions decoded by each decoder group in a corresponding microinstruction queue; The above-mentioned, in accordance with the switching mark attached to the target microinstruction, the microinstructions obtained by decoding the plurality of decoder groups are merged to obtain a microinstruction corresponding to a fetch order, 10. The method of claim 9, further comprising: fusing microinstructions by switching in a microinstruction queue corresponding to each decoder group in response to the switching mark attached to the target microinstruction to obtain a microinstruction corresponding to a fetch order.
11. The above-mentioned switching and fusing microinstructions in the microinstruction queues corresponding to each decoder group according to the switching marks attached to the target microinstructions to obtain microinstructions corresponding to the fetch order is performed by:
11. The decoding method according to claim 10, further comprising: starting to read a microinstruction from a microinstruction queue corresponding to a default decoder group; and, if the read microinstruction has the switching mark attached, determining a next microinstruction queue from which to switch and read a microinstruction, depending on the switching mark attached to the microinstruction, until reading of the microinstruction in the microinstruction queues corresponding to each decoder group is completed.
12. The above-mentioned, if a switching mark is attached to the read microinstruction, determining a next microinstruction queue from which to switch and read a microinstruction in accordance with the switching mark attached to the microinstruction; 12. The decoding method according to claim 11, further comprising: if the read microinstruction has the switching mark attached, switching the microinstruction queue from which the microinstruction is read from the microinstruction queues of each decoder group in order according to the switching mark attached to the microinstruction, in accordance with the order of the microinstruction queues.
13. 11. The decoding method according to claim 10, wherein in said microinstruction cache mode, the obtained microinstruction is held in a microinstruction queue corresponding to a default decoder group.
14. entering said decoder mode if, in said microinstruction cache mode, said fetch request does not hit in said microinstruction cache; 14. The decoding method according to claim 8, further comprising: in said decoder mode, storing in said microinstruction cache microinstructions obtained by decoding said decoder group.
15. a branch prediction unit configured to generate a fetch request carrying at least one switch mark indicating an instruction position at which at least a switch of decoder groups is to occur; an instruction cache configured to, in response to a microinstruction being obtained by decoding a decoder group, obtain the instruction stream fetched by said fetch request, and to determine, in response to said switch mark carried by said fetch request, an instruction position in said instruction stream at which a switch between decoder groups is to be made; an instruction allocation unit configured to allocate the instruction stream to a plurality of decoder groups for parallel decoding according to the instruction location; a decoder group configured to decode an assigned instruction to obtain a microinstruction, the number of the decoder groups being plural, wherein when the decoder group decodes a target instruction, the target microinstruction obtained by decoding the target instruction is marked with the switching mark, and the target instruction is an instruction corresponding to the instruction position; a microinstruction cache configured to, in response to a microinstruction being obtained by searching the microinstruction cache, obtain from the microinstruction cache a microinstruction corresponding to the fetch request that is not marked with the switching mark if the fetch request is a hit in the microinstruction cache.
16. the instruction location being an end location of the target instruction, and the instruction cache determining, in response to the switch mark carried in the fetch request, the instruction location in the instruction stream at which a decoder group switch occurs; 16. The processor of claim 15, further comprising: determining an end location of the target instruction in the instruction stream in response to the instruction location indicated by the switch mark carried in the fetch request.
17. The instruction allocation unit allocates the instruction stream to a plurality of decoder groups according to the instruction position for parallel decoding, 17. The processor of claim 15, further comprising: an instruction allocation unit for dividing the instruction stream into a plurality of instruction groups according to the instruction position, and allocating the plurality of instruction groups to a plurality of decoder groups for parallel decoding.
18. The instruction allocation unit divides the instruction stream according to the instruction position to obtain a plurality of instruction groups, the instruction allocation unit dividing the instruction stream into a plurality of instruction groups using the instruction positions in the instruction stream as boundaries, wherein a target instruction that is a boundary between two adjacent instruction groups is divided as being in a previous instruction group; and assigning a different decoder group to the next instruction group than the decoder group assigned to the previous instruction group in response to a switching mark corresponding to the target instruction carved out as in the previous instruction group.
19. setting up an instruction queue corresponding to one of the decoder groups for holding instructions to be decoded; the instruction allocation unit assigning a decoder group to a next instruction group different from the decoder group assigned to the previous instruction group in response to a switching mark corresponding to a target instruction that has been carved out as being in the previous instruction group; the instruction allocation unit storing a first instruction group of the plurality of instruction groups in an instruction queue corresponding to a default decoder group; 20. The processor of claim 18, further comprising: for a non-first instruction group of the plurality of instruction groups, determining a decoder group from the plurality of decoder groups different from a decoder group assigned to a previous instruction group in response to a switching mark corresponding to a target instruction in the previous instruction group, and storing the non-first instruction group in an instruction queue corresponding to the determined decoder group.
20. 20. The processor of claim 15, further comprising a fusion unit arranged to fuse microinstructions decoded by the plurality of decoder groups in accordance with the switching mark attached to a target microinstruction in a decoder mode to obtain a microinstruction corresponding to a fetch order, the fusion unit being arranged such that in the decoder mode, a microinstruction is obtained by decoding the decoder groups.
21. one instruction queue is set corresponding to one decoder group, and the decoder group is also configured to hold the microinstruction obtained by decoding in the corresponding microinstruction queue; The fusion unit fuses the microinstructions obtained by decoding the microinstructions obtained by the plurality of decoder groups in accordance with the switching mark attached to the target microinstruction to obtain a microinstruction corresponding to a fetch order, 21. The processor of claim 20, further comprising: switching in a microinstruction queue corresponding to each decoder group to fuse microinstructions in response to the switching mark attached to the target microinstruction to obtain a microinstruction corresponding to a fetch order.
22. The microinstruction cache is also arranged to, in a microinstruction cache mode, hold the retrieved microinstruction in a microinstruction queue corresponding to a default decoder group, the microinstruction cache mode being such that a microinstruction is obtained by searching the microinstruction cache; the decoder group is also configured to store the decoded microinstructions in the microinstruction cache; 22. The processor of claim 21, wherein in said microinstruction cache mode, if said fetch request does not hit in said microinstruction cache, said decoder mode is entered.
23. A chip comprising a processor according to any one of claims 15 to 22.
24. 24. An electronic device comprising the chip according to claim 23.
Citation Information
Patent Citations
Processor and program generator
JP1999312084A
Operation Cache
JP2019537163A
Method and system using tagged instructions to allow out-of-program-order instruction decoding
US6212621B1
System and method for load balancing in out-of-order clustered decoding
WO2018063702A2
Operation cache
WO2018106736A1
