Parallel instruction extraction method and readable storage medium

MYUI2022006163UUndetermined Publication Date: 2022-06-16GUANGDONG STARFIVE TECH LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
MYUI2022006163
Authority / Receiving Office
MY · MY
Patent Type
Utility models
Current Assignee / Owner
Priority Date
2020-12-16
Filing Date
2021-11-09
Publication Date
2022-06-16
Estimated Expiration
2041-11-09

AI Technical Summary

Technical Problem

Existing technology cannot meet the high-bandwidth requirements of high-performance processors for fetching multiple instructions per clock cycle. Logical links are relatively long, and serial sequential fetching results in insufficient performance.

Method used

Using the parallel instruction extraction method, the effective instruction vector is generated through the instruction end position vector s_mark_end, and logical AND and OR operations are used to perform parallel decoding and instruction address calculation, supporting high-performance processors to extract more than 8 instructions per clock cycle, optimizing Jump and prediction of branch instructions to deal with interference between threads.

Benefits of technology

There is no serial dependency between each instruction, the timing is easy to converge, and the main frequency performance of the processor is improved, which is especially suitable for the high bandwidth requirements of high-performance processors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure UI2022006163_DRAWING_001
    Figure UI2022006163_DRAWING_001
  • Figure UI2022006163_DRAWING_002
    Figure UI2022006163_DRAWING_002
  • Figure UI2022006163_DRAWING_003
    Figure UI2022006163_DRAWING_003
Patent Text Reader

Abstract

The invention relates to the technical field of a processor, in particular to a method for parallel extracting instructions and a readable storage medium. The method generates a valid vector of fetched instructions according to the end position vector s_mark_end of the instruction, and performs parallel decoding of instructions at each position, calculation of instruction address and branch instruction target address operation through logical “AND” and logical “OR” operations. Ultimately, multiple instructions are fetched in parallel. The present invention is a method for generating a valid vector of fetching instructions according to the end position vector s_mark_end of the instruction, and extracting multiple instructions in parallel through logical “AND” and logical “OR” operations. The invention can extract a plurality of instructions in parallel at the same time, there is no serial dependence relationship between each instruction, and the time sequence is easy to converge, so a higher main frequency can he obtained. The invention is particularly suitable for high- performance processors that extract more than 8 instructions per clock cycle.
Need to check novelty before this filing date? Find Prior Art

Description

A Method and Readable Storage Medium for Parallel Instruction Fetching Technical Field The present invention relates to the technical field of processors, and in particular to a method and a readable storage medium for parallel instruction fetching. Background Art After more than 50 years of development of microprocessors, the architecture of microprocessors has experienced vigorous development along with semiconductor processes. From single-core to physical multi-core and logical multi-core; from sequential execution to out-of-order execution; from single-issue to multi-issue; especially in the server field, the performance of processors has been continuously pursued. Currently, server chips are basically superscalar out-of-order execution architectures, and the processing bandwidth of processors is getting higher and higher, reaching 8 or even more instructions per clock cycle. In the instruction fetch unit, when fetching multiple instructions simultaneously, each instruction is serially fetched one by one, and the logical link is relatively long. Currently, high-performance processors need to fetch 8 or even higher bandwidth per clock cycle, and the clock frequency requirement is relatively high. The current implementation methods cannot meet the requirements. Summary of the Invention Aiming at the deficiencies of the prior art, the present invention discloses a method and a readable storage medium for parallel instruction fetching, which are used to solve the problem that when fetching multiple instructions simultaneously in the instruction fetch unit, each instruction is serially fetched one by one, and the logical link is relatively long. Currently, high-performance processors need to fetch 8 or even higher bandwidth per clock cycle, and the clock frequency requirement is relatively high. The current implementation methods cannot meet the requirements. The present invention is realized through the following technical solutions: In a first aspect, the present invention discloses a method for parallel instruction fetching, characterized in that the method generates a valid vector for fetching instructions according to the end position vector s_mark_end of the instructions, and performs parallel decoding of instructions at each position, calculation of instruction addresses, and calculation of branch instruction target addresses through logical "AND" and logical "OR" operations, and finally fetches multiple instructions in parallel. Furthermore, in the method, first, the lower 2 bits of the first instruction are judged. If the lower 2 bits are 00, 01 or 10, then the length of the first instruction is 16 bits. If the lower 2 bits are 11, then the length of the first instruction is 32 bits. Then, starting from the next byte after the end position of this instruction, the second instruction is judged, and the judgment process is similar to that of judging the first instruction to obtain the length of the second instruction, and so on, to obtain the length of each instruction in the cacheline. After obtaining the length of each instruction, the end position vector s_end_mark of each instruction in the instruction stream is obtained. Further, in the method, when writing an instruction, calculate the end position vector s_end_mark of each instruction. The instructions returned from the writing party are in cacheline units, and each cacheline is 64 bytes. The high and low 32-byte instructions of the instruction are respectively used to calculate the end position vector of the instruction. The speculative calculation offsets of the high 32-byte instruction are 0 and 2 for the end position vectors s_end_mark_0 and s_end_mark_1 of the instructions. Select one of the high 32-byte vectors according to the end position vector of the low 32-byte instruction as the final end vector of the high 32-byte instruction. The end position vector of the instruction is written simultaneously with the instruction. Further, in the method, when the instruction fetch unit starts fetching instructions, read the end position vector of the instruction while reading the instruction to check the prediction information of the BPU and extract the instruction. The end position vector s_mark_end of the instruction indicates whether this position is the end of an instruction. When it is 1, it indicates the end position of an instruction; when it is 0, it indicates that it is not the end position of an instruction. Further, in the method, the bandwidth of the instruction fetch unit is 32 bytes per clock cycle. While fetching instructions, perform prediction on the jump of the branch instruction. Predict according to the high 2 bytes of the branch instruction. If it is predicted that the branch instruction jumps, then jump to the target address. After fetching the instruction from the target address, it is necessary to perform an instruction alias error check, that is, determine whether the predicted jump branch instruction is a branch instruction and whether the type of the branch instruction is also the same. Further, in the method, multiple threads are supported, and all threads share the BPU prediction unit. Therefore, the prediction information between threads will interfere with each other. The interference results include: The BPU may take the middle content of an instruction, that is, not the end of a branch instruction, as the end position of the branch instruction that jumps; The types of branch instructions do not match. If this BPU information is written by a JA, but when a JALR instruction may be predicted according to the information of JAL. Further, in the method, the BPU information includes the prediction offset pred_offset and the instruction type pred_type of the BPU. The BPU generates a refresh according to the predicted target of the BPU and fetches instructions again. When extracting instructions, detect s_mark_end

[0020] Whether it is 1. If not, the position predicted by pred_offset is not the end position of a branch instruction, but the middle of an instruction. Then, generate a refresh from the address one plus the end of the nearest instruction to pred_offset, fetch the instruction again, and clear the incorrect prediction information of this instruction in the BPU at the same time. Further, in the method, if pred_offset is the end position of a branch instruction, but when fetching the instruction, it is simultaneously determined that the position corresponding to s_mark_end is a branch instruction, and if the type of the branch instruction is different from the predicted type pred_type of the BPU, this is also an alias error. There is no error in the instruction predicted to jump, but the predicted target address is incorrect. In this case, the instruction is fetched again from the position of pred_offset + 1, and the error information corresponding to this position in the BPU is cleared. Only when both the predicted position and type of the BPU are correct, the prediction information of the BPU is correct; otherwise, a refresh needs to be generated and the instruction is fetched again from the correct address. Further, in the method, when each instruction has been extracted from the instruction stream, it is determined according to the prediction information of the BPU whether there is a branch instruction in the instruction and whether a jump occurs. In the instruction, if there are multiple branch instructions, the first instruction has the highest priority, followed by the second instruction, and so on. A refresh is generated according to the target address of the branch instruction, and the fetch unit fetches the instruction again according to this new address. If there is no branch instruction, all the instructions are written into the instruction queue. In a second aspect, the present invention discloses a readable storage medium, including a memory storing execution instructions. When a processor executes the execution instructions stored in the memory, the processor hardware executes the method for parallel instruction fetching described in the first aspect. The beneficial effects of the present invention are as follows: The present invention generates a valid instruction fetch vector according to the end position vector s_mark_end of the instruction, and through logical "AND" and logical "OR" operations, it is a method for parallel fetching of multiple instructions. Multiple instructions can be fetched in parallel at the same time, and there is no serial dependency between each instruction, so the timing is easy to converge, and a higher main frequency can be obtained. It is particularly suitable for high-performance processors that fetch more than 8 instructions per clock cycle. BRIEF DESCRIPTION OF THE DRAWINGS In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts. FIG. 1 is a schematic diagram of the RISC V instruction mode of the present invention; FIG. 2 is a top-level diagram of the fetch unit according to an embodiment of the present invention; FIG. 3 is an instruction boundary identification diagram according to an embodiment of the present invention; FIG. 4 is an end position vector diagram of an instruction according to an embodiment of the present invention; FIG. 5 is a diagram of a jump occurring in a cross-boundary instruction according to an embodiment of the present invention; Figure 6 is the alias error check diagram of the embodiment of the present invention; Figure 7 is the parallel extraction instruction diagram of the embodiment of the present invention; Figure 8 is the generation logic diagram of the second instruction of the embodiment of the present invention; Figure 9 is the calculation instruction address and branch target address diagram of the embodiment of the present invention Figure 10 is the cross - boundary instruction diagram of the embodiment of the present invention. Specific embodiments To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention. Embodiment 1 This embodiment is a method for generating an extraction instruction valid vector according to the end - position vector s_mark_end of an instruction, and parallelly extracting multiple instructions through logical "AND" and logical "OR" operations. This embodiment is not limited to chips such as CPUs, GPUs, and DSPs; nor is it limited to any instruction set and any implementation process and other conditions. To facilitate the description of the principle of this method, the RISC - V instruction set is mainly used as an example for illustration. The RISC - V instruction set supports instruction lengths of 16bit, 32bit, 48bit, 64bit, etc., as shown in Figure 1. In this article, instructions with lengths of 16bit and 32bit are mainly used as examples to describe the method proposed in this article. To facilitate the description of the principle of this method, it is assumed that the instruction fetch bandwidth is 32 bytes each time, and 8 instructions are fetched each time. The lowest 2 bits of a 16 - bit instruction are 00, 01, or 10. The lowest 2 bits of a 32 - bit instruction are 11. Therefore, when judging the length of the current instruction, only the lowest 2 bits of the instruction need to be judged. First, judge the lowest 2 bits of the first instruction. If the lowest 2 bits are 00, 01, or 10, then the length of the first instruction is 16 bits. If the lowest 2 bits are 11, then the length of the first instruction is 32 bits. Then, start judging the second instruction from the next byte after the end position of this instruction. The judgment process is similar to that of judging the first instruction, and the length of the second instruction can be obtained. By analogy, the length of each instruction in the cacheline can be obtained, as shown in Figure 2. After obtaining the length of each instruction, the end - position vector s_end_mark of each instruction in the instruction stream is obtained. When an instruction is written from L2 to L1, the end position vector s_end_mark of each instruction is calculated. The instructions returned from L2 are in cacheline units. As shown in Figure 3, each cacheline is 64 bytes, and the high and low 32-byte instructions are respectively used to calculate the end position vector of the instruction. For the high 32-byte instruction, two kinds of end position vectors of the instruction s_end_mark_0 and s_end_mark_1 with offsets of 0 and 2 are speculated and calculated. According to the end position vector of the low 32-byte instruction, a high 32-byte vector is selected as the final end vector of the high 32-byte instruction, as shown in Figure 3. The end position vector of the instruction is written into L1 together with the instruction. Embodiment 2 This embodiment is not limited to chips such as CPUs, GPUs, and DSPs; nor is it limited to any instruction set and any implementation process. The RISC-V instruction set is mainly used as an example for illustration. When the instruction fetch unit starts fetching instructions and reads the instructions in the L1 CACHE, the end position vector of the instruction is read out simultaneously to verify the prediction information of the BPU and extract the instructions. The end position vector s_mark_end of the instruction indicates whether this position is the end of an instruction. When it is 1, it indicates the end position of an instruction; when it is 0, it indicates that it is not the end position of an instruction, that is, it may be the opcode of the instruction or the immediate number inside the instruction, etc. In Figure 4, the first instruction LUI has a length of 4 bytes and s_mark_end

[0028] is 1; the second instruction is C.ADDI, and C.ADDI is a 16-bit compressed instruction, and s_mark_end

[0026] is 1; the third instruction AUIPC has a length of 4 bytes and s_mark_end

[0022] is 1; the fourth instruction JAL has a length of 4 bytes and s_mark_end

[0018] is 1; the fifth instruction LB has a length of 4 bytes and s_mark_end

[0014] is 1; the sixth instruction LH has a length of 4 bytes and s_mark_end

[0010] is 1; the seventh instruction ADDI has a length of 4 bytes and s_mark_end[6] is 1; the eighth instruction SRAI has a length of 4 bytes and s_mark_end[2] is 1; the ninth instruction BNE has a length of 4 bytes, and this instruction spans 32 bytes. Therefore, the end position of the instruction BNE is not in the current instruction block, as shown in Figure 4. The bandwidth of the instruction fetch unit is 32 bytes per clock cycle. Since 16-bit / 32-bit mixed instructions are supported, it is possible for a branch instruction to span two adjacent instruction blocks. The lower 2 bytes of the branch instruction are at the end of a 32-byte instruction block block0, while the upper 2 bytes are at the head of the adjacent instruction block block1, as shown in Figure 5. While fetching instructions, the jump of the branch instruction is predicted. Prediction is made based on the upper 2 bytes of the branch instruction. If it is predicted that the branch instruction jumps, then it jumps to the target address. After the instruction is fetched from the target address, an instruction alias error check is required, that is, to determine whether the predicted jump branch instruction is a branch instruction and whether the type of the branch instruction is also the same. Since multiple threads are supported and all threads share the BPU prediction unit, the prediction information between threads will interfere with each other. The results of the interference include: 1. The BPU may take the middle content of an instruction, that is, not the end of a branch instruction, as the end position of the branch instruction that jumps. 2. The types of branch instructions do not match. If this BPU information is written by a JA, but when a JALR instruction may make a prediction based on the information of JAL. The BPU prediction information includes the prediction offset pred_offset and the instruction type pred_type of the BPU, as shown in Figure 6. pred_offset is 5’d11, that is, the position in the BPU prediction diagram is the end position of a branch instruction and a jump occurs. The BPU generates a flush based on the predicted target of the BPU and fetches instructions again. When fetching instructions, it is detected whether s_mark_end

[0020] is 1. It is actually found that s_mark_end

[0020] is 0, that is, the position predicted by pred_offset is not the end position of a branch instruction, but the middle of an instruction. At this time, a flush needs to be generated from the address one plus the end of the nearest instruction to pred_offset, and instructions are fetched again, and at the same time, the incorrect prediction information of this instruction in the BPU is cleared. Similarly, if pred_offset is the end position of a branch instruction, but when fetching instructions, it is also determined that the position corresponding to s_mark_end is a branch instruction, and if the type of the branch instruction is different from the type pred_type predicted by the BPU, this is also an alias error at this time. The predicted jump instruction has no error, but the predicted target address is incorrect. It is necessary to re-fetch the instruction from the position where pred_offset is incremented by 1 and clear the error information corresponding to this position in the BPU. Only when the position and type predicted by the BPU are both correct, the prediction information of the BPU is correct; otherwise, a refresh needs to be generated to re-fetch the instruction from the correct address. In this embodiment, 8 instruction valid vectors are generated in parallel according to the instruction end vector. At the same time, 32-byte instructions are decoded speculatively in parallel, the instruction addresses are calculated, the target addresses of the instructions are calculated, and so on. Then, the 8 instruction valid vectors are subjected to "AND" and "OR" logical operations with the speculative decoding, instruction address calculation, target address calculation of the instructions, etc., to obtain the fetched instructions and related attributes, as shown in FIG. 7. Embodiment 3 This embodiment is described by taking the logic for generating the valid vector of the second instruction as an example. s_prt represents the offset of the first instruction in the 32-byte instruction stream. s_mark_end represents the instruction end position vector in the 32-byte instruction stream. Each bit of s_mark_end being 1 indicates the end position of an instruction. Inst_2_val represents the valid vector of the second instruction in the 32-byte instruction stream. The positions where it is 1 indicate the byte where the second instruction starts. Taking 4 bytes from this position is a complete instruction (if it is a 16-bit compressed instruction, it has also been decoded into a 32-bit instruction). The valid vector inst_2_val of the second instruction and the 16 instructions obtained by speculative decoding are first subjected to an "AND" operation and then an "OR" operation to obtain the second instruction. S_ptr and s_mark_end form a 35-bit instruction position identification vector, and this vector is mapped to another one-hot form vector inst_2_val. The logical mapping relationship for generating the valid vector of the second instruction is shown in the following table: Table 1 Mapping of the valid vector of the second instruction Similarly, the valid vectors of the remaining instructions can be obtained. The instruction fetch unit decodes 32 bytes each time. The length of the RISC-V instruction is 2 or 4. Therefore, the start positions of the operation codes of the instructions are at even positions 0, 2, 4,..., 30. Similarly, the end positions of the instructions are at odd positions 1, 3, 5,..., 31. If the instruction starts from position 0, then the valid vector inst_2_val[0] of this instruction is 1; at the same time, take the instruction inst0 obtained by speculative decoding, and the length is taken as 4 bytes. When the instruction is a C extension instruction, it has been decoded as an instruction with a length of 4 bytes during speculative decoding. If the instruction starts from position 2, then the valid vector inst_2_val[2] of this instruction is 1; at the same time, take the instruction inst1 obtained by speculative decoding. If the instruction starts from position 4, then the valid vector inst_2_val[4] of this instruction is 1; at the same time, take the instruction inst2 obtained by speculative decoding. If the instruction starts from position 6, then the valid vector inst_2_val[6] of this instruction is 1; at the same time, take the instruction inst3 obtained by speculative decoding. If the instruction starts from position 8, then the valid vector inst_2_val[8] of this instruction is 1; at the same time, take the instruction inst4 obtained by speculative decoding. If the instruction starts from position 10, then the valid vector inst_2_val

[0010] of this instruction is 1; at the same time, take the instruction inst5 obtained by speculative decoding. If the instruction starts from position 12, then the valid vector inst_2_val

[0012] of this instruction is 1; at the same time, take the instruction inst6 obtained by speculative decoding. If the instruction starts from position 14, then the valid vector inst_2_val

[0014] of this instruction is 1; at the same time, take the instruction inst7 obtained by speculative decoding. If the instruction starts from position 16, then the valid vector inst_2_val

[0016] of this instruction is 1; at the same time, take the instruction inst8 obtained by speculative decoding. If the instruction starts from position 18, then the valid vector inst_2_val

[0018] of this instruction is 1; at the same time, take the instruction inst9 obtained by speculative decoding. If the instruction starts from position 20, then the valid vector inst_2_val

[0020] of this instruction is 1; at the same time, take the instruction inst10 obtained by speculative decoding. If the instruction starts from position 22, then the valid vector inst_2_val

[0022] of this instruction is 1; at the same time, take the instruction inst11 obtained by speculative decoding. If the instruction starts from position 24, then the valid vector inst_2_val

[0024] of this instruction is 1; at the same time, take the instruction inst12 obtained by speculative decoding. If the instruction starts from position 26, then the valid vector inst_2_val

[0026] of this instruction is 1; meanwhile, fetch the instruction inst13 obtained by speculative decoding. If the instruction starts from position 28, then the valid vector inst_2_val

[0028] of this instruction is 1; meanwhile, fetch the instruction inst14 obtained by speculative decoding. If the instruction starts from position 30 and if the current instruction does not cross the boundary, then the valid vector inst_2_val

[0030] of this instruction is 1; meanwhile, fetch the instruction inst15 obtained by speculative decoding. If the current instruction crosses the boundary, then the current instruction is invalid until the next 32-byte instruction stream is valid, and then this instruction is fetched. If the offset of the first instruction is not 0 but starts from a non-zero offset. Then the start position of the first instruction is the position of this offset. The positions of other instructions start with the same offset in sequence. The logical expression for obtaining the second instruction is: Inst_2 = ({32{inst_2_val[0]}}&inst0)| ({32{inst_2_val[2]}}&inst1)| ({32{inst_2_val[4]}}&inst2)| ({32{inst_2_val[6]}}&inst3)| ({32{inst_2_val[8]}}&inst4)| ({32{inst_2_val

[0010] }}&inst5)| ({32{inst_2_val

[0012] }}&inst6)| ({32{inst_2_val

[0014] }}&inst7)| ({32{inst_2_val

[0016] }}&inst8)| ({32{inst_2_val

[0018] }}&inst9)| ({32{inst_2_val

[0020] }}&inst10)| ({32{inst_2_val

[0022] }}&inst11)| ({32{inst_2_val

[0024] }}&inst12)| ({32{inst_2_val

[0026] }}&inst13)| ({32{inst_2_val

[0028] }}&inst14)| ({32{inst_2_val

[0030] }}&inst15)); Inst0, inst1, …… inst15 are 16 speculated instructions. The circuit implemented by the second instruction is realized by a logical "AND" and a logical "OR" gate, as shown in Figure 8. For other instructions, according to the same principle, logical expressions and logical circuit diagrams can be obtained. Embodiment 4 When calculating the address and target address of the instruction in this embodiment, it is also speculative calculation. The fetch unit fetches 32 bytes each time, and the fetch address is fetch_address, which is the base address for calculating the instruction address. Since the length of RISC V instructions is 2 or 4, the speculated instruction addresses for 16 positions are respectively: base_address, base_address + 2, base_address + 4, base_address + 8, base_address + 10, base_address + 12, base_address + 14, base_address + 16, base_address + 18, base_address + 20, base_address + 22, base_address + 24, base_address + 28, and base_address + 30. The address of the second instruction, inst_2_addr, is also obtained using a logic similar to that for generating the second instruction. As shown below: Inst_2_addr = ({64{inst_2_val[0]}}&base_address)| ({64{inst_2_val[2]}}&(base_address + 2))| ({64{inst_2_val[4]}}&(base_address + 4))| ({64{inst_2_val[6]}}&(base_address + 6))| ({64{inst_2_val[8]}}&(base_address + 8))| ({64{inst_2_val

[0010] }}&(base_address + 10))| ({64{inst_2_val

[0012] }}&(base_address + 12))| ({64{inst_2_val

[0014] }}&(base_address+14))| ({64{inst_2_val

[0016] }}&(base_address+16))| ({64{inst_2_val

[0018] }}&(base_address+18))| ({64{inst_2_val

[0020] }}&(base_address+20))| ({64{inst_2_val

[0022] }}&(base_address+22))| ({64{inst_2_val

[0024] }}&(base_address+24))| ({64{inst_2_val

[0026] }}&(base_address+26))| ({64{inst_2_val

[0028] }}&(base_address+28))| ({64{inst_2_val

[0030] }}&(base_address+30))); The instructions fetched by the instruction fetch unit, and the branch instructions in the instructions include JAL, JALR, BEQ, BNE, BLT, BGE, BLTU, BGEU, C.JAL, C.J, C.BEQZ, C.BNEZ, C.JR, C.JALR. Among them, the target addresses of the instructions JAL, BEQ, BNE, BLT, BGE, BLTU, BGEU, C.JAL, C.J, C.BEQZ, C.BNEZ are the sum of the instruction address and the offset. Similarly, it is also assumed that every 2 bytes of offset is a branch instruction, so it is also speculated that the target addresses of each instruction are calculated in parallel. The speculated target addresses of the instructions at 16 positions are: base_address+offset, base_address+2+offset, base_address+4+offset, base_address+8+offset, base_address+10+offset, base_address+12+offset, base_address+14+offset, base_address+16+offset, base_address+18+offset, base_address+20+offset, base_address+22+offset, base_address+24+offset, base_address+28+offset and base_address+30+offset. Offset is the offset of the branch instruction. Inst is the instruction. The conditional instruction immediate value cond_imm of the 32-bit instruction is: cond_imm: {inst

[0031] ,inst[7],inst[30:25],inst[11:8],1'b0}; The unconditional instruction immediate value of the 32-bit instruction is: uncond_imm: {inst

[0031] ,inst[19:12],inst

[0020] ,inst[30:21],1'b0}; The conditional instruction immediate value cond_imm_c of the 16-bit compressed instruction is: cond_imm_c: {inst

[0012] ,inst[6:5],inst[2],inst[11:10],inst[4:3],1'b0}; The unconditional instruction immediate number uncond_imm_c of the 16-bit compression instruction is: uncond_imm_c: {inst

[0012] , inst[8], inst[10:9], inst[6], inst[7], inst[2], inst

[0011] , inst[5:3], 1'b0}; Each position may be one of these 4 branch instructions. Therefore, the instruction type is judged at each position first, and then the offset of different types is calculated. The target address Inst_2_target_addr of the second instruction can also obtain a logical expression similar to Inst_2_addr, as shown in Figure 9. Example 5 In this embodiment, the specific branch instruction type br_type at each position is judged. br_type[0] is the conditional instruction of the 32-bit instruction; br_type[1] is the unconditional instruction of the 32-bit instruction; br_type[2] is the conditional instruction of the 16-bit instruction; br_type[3] is the unconditional instruction of the 16-bit instruction. Therefore, the offset of the branch instruction is obtained according to br_type and cond_imm, uncond_imm, cond_imm_c and uncond_imm_c. Since both 16-bit and 32-bit instructions are supported, there are 16-bit and 32-bit mixed instructions in the instruction stream. Each 32-byte instruction includes 8 - 16 instructions. Therefore, a 32-bit instruction may span consecutive adjacent 32-byte instruction streams. In the instruction extraction module, a 2-byte register is used to save the high 2 bytes of the 32-byte instruction stream, and these 2 bytes are used as the 2 bytes of the cross-boundary instruction. At the same time, it is judged whether this situation of cross-boundary instructions occurs in the current 32-byte instruction stream. If it occurs, a valid indication signal for cross-boundary instructions needs to be generated. When the adjacent 32-byte instruction block reaches the instruction fetch pipeline stage, if the valid indication signal for cross-boundary instructions is 1, it means that the first instruction has a cross-boundary situation. At this time, the first instruction consists of two parts, as shown in Figure 10. If the valid indication signal for cross-boundary instructions is 0, it means that the first instruction does not have a cross-boundary situation. The first instruction is the first instruction of the current 32-byte instruction block. Other instructions are fetched sequentially from the subsequent instruction stream of the first instruction. When a branch instruction has a cross-boundary situation, the BPU prediction information of the instruction also needs to be saved until the adjacent instruction stream is valid, and the prediction information of the first instruction is obtained, similar to the processing method of obtaining the first instruction. When each instruction has been fetched from the instruction stream, it is determined, according to the prediction information of the BPU, whether there is a branch instruction among the 8 instructions and whether a jump occurs. Among the 8 instructions, if there are multiple branch instructions, the first instruction has the highest priority, followed by the second instruction, and so on. A refresh is generated according to the target address of the branch instruction, and the instruction fetch unit fetches instructions again according to this new address. If there is no branch instruction, all instructions are written into the instruction queue. Embodiment 6 This embodiment discloses a readable storage medium, including a memory storing execution instructions. When a processor executes the execution instructions stored in the memory, the processor hardware executes a method for parallel instruction fetching. In summary, the present invention provides a method for parallel instruction fetching by generating an instruction fetch valid vector according to the instruction end position vector s_mark_end and performing logical "AND" and logical "OR" operations. Multiple instructions can be fetched in parallel at the same time. There is no serial dependency between each instruction, the timing is easy to converge, and a higher main frequency can be obtained. It is particularly suitable for high-performance processors that fetch more than 8 instructions per clock cycle. The above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments or perform equivalent replacements for some of the technical features. However, such modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for parallel instruction extraction, characterized in that, the method generates an instruction extraction valid vector according to the end position vector s_mark_end of the instruction, and through logical "AND" and logical "OR" operations, performs parallel decoding of instructions at each position, calculates the instruction address and the target address of the branch instruction, and finally extracts multiple instructions in parallel.

2. The method for parallel instruction extraction according to claim 1, characterized in that, in this method, first, the lower 2 bits of the first instruction are judged. If the lower 2 bits are 00, 01 or 10, then the length of the first instruction is 16 bits. If the lower 2 bits are 11, then the length of the first instruction is 32 bits. Then, starting from the next byte after the end position of this instruction, the second instruction is judged. The judgment process is similar to that of judging the first instruction to obtain the length of the second instruction, and so on, to obtain the length of each instruction in the cacheline. After obtaining the length of each instruction, the end position vector s_end_mark of each instruction in the instruction stream is obtained.

3. The method for parallel instruction extraction according to claim 1, characterized in that, in this method, when writing an instruction, the end position vector s_end_mark of each instruction is calculated. The instructions returned from the writing party are in units of cacheline, and each cacheline is 64 bytes. The upper and lower 32 bytes of the instruction are respectively calculated to obtain the end position vector of the instruction. For the upper 32-byte instruction, the end position vectors s_end_mark_0 and s_end_mark_1 of the instructions with offsets of 0 and 2 are speculated and calculated. According to the end position vector of the lower 32-byte instruction, one of the upper 32-byte vectors is selected as the final instruction end vector of the upper 32-byte instruction, and the end position vector of the instruction is written together with the instruction.

4. The method for parallel instruction extraction according to claim 1, characterized in that, in this method, when the fetch unit starts fetching instructions, the end position vector of the instruction is read while reading the instruction to verify the prediction information of the BPU and extract the instruction. The end position vector s_mark_end of the instruction indicates whether this position is the end of an instruction. When it is 1, it indicates the end position of an instruction; when it is 0, it indicates that it is not the end position of an instruction.

5. The method for parallel instruction extraction according to claim 4, characterized in that, in this method, the bandwidth of the fetch unit is 32 bytes per clock cycle. While fetching instructions, the jump of the branch instruction is predicted. The prediction is made according to the upper 2 bytes of the branch instruction. If it is predicted that the branch instruction jumps, then it jumps to the target address. When the instruction from the target address is fetched back, an instruction alias error check needs to be performed, that is, it is determined whether the predicted jump branch instruction is a branch instruction and whether the type of the branch instruction is also the same.

6. The method for parallel instruction extraction according to claim 1, characterized in that, In the method described above, multiple threads are supported, and all threads share the BPU prediction unit. Therefore, the prediction information between threads will interfere with each other. The results of the interference include: The BPU may take the middle content of an instruction, that is, not the end of a branch instruction, as the end position of a branch instruction that causes a jump; The type of the branch instruction does not match. If this BPU information is written by a JA, but a JALR instruction may make a prediction based on the information of JAL.

7. The method for parallel instruction extraction according to claim 6, characterized in that, In the method described above, the BPU information includes the prediction offset pred_offset and the instruction type pred_type of the BPU. The BPU generates a refresh based on the target predicted by the BPU and re-fetches the instruction. When extracting the instruction, it is detected whether s_mark_end[20] is 1. If not, the position predicted by pred_offset is not the end of a branch instruction but the middle of an instruction. Then, a refresh is generated at the address obtained by adding 1 to the end address of the nearest instruction to pred_offset, and the instruction is re-fetched. At the same time, the incorrect prediction information of this instruction in the BPU is cleared.

8. The method for parallel instruction extraction according to claim 1, characterized in that, In the method described above, if pred_offset is the end position of a branch instruction, but when fetching the instruction, it is simultaneously determined that the position corresponding to s_mark_end is a branch instruction. If the type of the branch instruction is different from the predicted type pred_type of the BPU, this is also an alias error. The prediction of the instruction that is predicted to jump is correct, but the predicted target address is incorrect. Then, the instruction is re-fetched from the position obtained by adding 1 to pred_offset, and the incorrect information corresponding to this position in the BPU is cleared. Only when the position and type predicted by the BPU are both correct, the prediction information of the BPU is correct; otherwise, a refresh needs to be generated and the instruction is re-fetched from the correct address.

9. The method for parallel instruction extraction according to claim 1, characterized in that, In the method described above, when each instruction has been extracted from the instruction stream, it is judged whether there is a branch instruction in the instruction according to the prediction information of the BPU and whether a jump occurs. In the instruction, if there are multiple branch instructions, the first instruction has the highest priority, followed by the second instruction, and so on. A refresh is generated according to the target address of the branch instruction, and the fetch unit re-fetches the instruction according to this new address. If there is no branch instruction, all instructions are written into the instruction queue.

10. A readable storage medium, including a memory storing execution instructions. When a processor executes the execution instructions stored in the memory, the processor hardware executes the method for parallel instruction extraction as described in any one of claims 1-9.