Superscalar processor, and method, device and equipment for debugging superscalar processor
By introducing CSR and transmit logic modules into the superscalar processor, the sequential execution of the debug mode is solved, and the debugging function is difficult to implement in out-of-order execution mode is simplified, and the debugging process is reduced and the hardware design complexity is reduced.
Patent Information
- Application Number
- CN202410947991.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-15
- Publication Date
- 2024-11-12
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The out-of-order execution mode of the superscalar processor increases the difficulty of implementing the debugging function and complicates the design of the debugging function.
The first CSR and transmit logic module are introduced into the superscalar processor. By configuring the value of the CSR, the processor is controlled to convert from out-of-order execution to sequential execution, implement debugging mode, and resume out-of-order execution after debugging, and close the performance module To reduce debugging complexity.
The debugging process is simplified through the sequential execution mode, reducing the complexity of the hardware design of the superscalar processor, and improving the ease of implementation of the debugging function.
Smart Images

Figure CN118939498A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of debugging technology, and in particular to a superscalar processor, a debugging method, a device and equipment for a superscalar processor. Background Art
[0002] In the field of debugging technology, processor hardware often provides a debugging function so that a debugger can obtain internal status information of the processor.
[0003] For superscalar processors, since superscalar processors can execute multiple instructions out of order in each clock cycle, the pipeline design of superscalar processor hardware is relatively complex, and multiple instructions are issued out of order, which increases the difficulty of hardware implementation of the debug function. Summary of the invention
[0004] The embodiments of the present application provide a superscalar processor, a debugging method, a device and an apparatus for the superscalar processor to reduce the difficulty of hardware implementation of the debugging function. The technical solution is as follows:
[0005] In one aspect, a superscalar processor is provided, the superscalar processor comprising:
[0006] A first CSR (Control and Status Register), configured to be a first value when the superscalar processor enters a debug mode;
[0007] The emission logic module is used to change the execution mode of the pipeline in the superscalar processor from out-of-order execution to in-order execution when the value of the first CSR is a first value.
[0008] In one possible implementation, the superscalar processor further includes a reorder buffer, which is connected to the transmission logic module; the reorder buffer is used to send a first signal to the transmission logic module when the instruction in the reorder buffer is empty, and to send a second signal to the transmission logic module when the instruction in the reorder buffer is not empty; the transmission logic module is used to, when the superscalar processor operates in the debug mode, transmit an instruction in sequence if the first signal sent by the reorder buffer is received, and suspend the transmission of instructions if the second signal sent by the reorder buffer is received.
[0009] In one possible implementation, the superscalar processor further includes a performance module and a second CSR connected to the performance module, the performance module including at least one of a branch prediction submodule, an instruction prefetch submodule, a data prefetch submodule, a speculative execution submodule or a cache submodule; at least one of the branch prediction submodule, the instruction prefetch submodule, the data prefetch submodule, the speculative execution submodule or the cache submodule is used to shut down when the value of the second CSR is configured to be a first value, and to start up when the value of the second CSR is configured to be a second value.
[0010] In a possible implementation manner, the first CSR is used to receive a debugging instruction, and based on the debugging instruction, the value of the first CSR is configured to be the first value.
[0011] In a possible implementation, the first CSR is further configured to be a second value when debugging of the superscalar processor is completed; the emission logic module is further used to change the execution mode of the pipeline in the superscalar processor from sequential execution to out-of-order execution when the value of the first CSR is the second value.
[0012] On the other hand, a debugging method for a superscalar processor is also provided, the method comprising:
[0013] receiving a debug instruction, and controlling the superscalar processor to operate in a debug mode based on the debug instruction, wherein the debug mode is used for an issue logic module of the superscalar processor to change the execution mode of the pipeline in the superscalar processor from out-of-order execution to sequential execution, wherein the sequential execution instructs the issue logic module to issue instructions sequentially one by one;
[0014] Instructions executed by the superscalar processor are debugged.
[0015] In one possible implementation, controlling the superscalar processor to operate in debug mode based on the debug instruction includes: configuring the value of a first control status register CSR corresponding to the emission logic module to a first value based on the debug instruction, the value of the first CSR being the first value indicating that the superscalar processor operates in the debug mode.
[0016] In a possible implementation, after controlling the superscalar processor to operate in debug mode based on the debug instruction, it further includes: clearing instructions in a reorder buffer of the superscalar processor; the emission logic module sequentially emits instructions one by one, including: when the instruction in the reorder buffer is empty, the emission logic module emits an instruction in sequence, and when the instruction in the reorder buffer is not empty, suspends the emission of instructions.
[0017] In a possible implementation, before debugging the instructions executed by the superscalar processor, it also includes: controlling the performance module of the superscalar processor to be turned off, and the performance module includes at least one of a branch prediction submodule, an instruction prefetch submodule, a data prefetch submodule, a speculative execution submodule or a cache submodule.
[0018] In a possible implementation, controlling the performance module of the superscalar processor to shut down includes: configuring the value of a second control status register CSR corresponding to the performance module to a first value, the value of the second CSR being the first value used to shut down the performance module.
[0019] In a possible implementation, after debugging the instructions executed by the superscalar processor, the method further includes: configuring the value of the second CSR to a second value, wherein the value of the second CSR is the second value used to start the performance module.
[0020] In a possible implementation, after debugging the instructions executed by the superscalar processor, it also includes: receiving non-debug instructions, and controlling the superscalar processor to operate in a non-debug mode based on the non-debug instructions, wherein the non-debug mode is used for the emission logic module of the superscalar processor to change the execution mode of the pipeline in the superscalar processor from sequential execution to out-of-order execution, and the out-of-order execution instructs the emission logic module to emit multiple out-of-order instructions.
[0021] In one possible implementation, controlling the superscalar processor to operate in the non-debug mode based on the non-debug instruction includes: configuring the value of the first CSR corresponding to the emission logic module to a second value based on the non-debug instruction, the value of the first CSR being the second value indicating that the superscalar processor operates in the non-debug mode.
[0022] On the other hand, a debugging device for a superscalar processor is also provided, the device comprising:
[0023] A control module, configured to receive a debug instruction, and based on the debug instruction, control the superscalar processor to operate in a debug mode, wherein the debug mode is used for an issue logic module of the superscalar processor to change an execution mode of a pipeline in the superscalar processor from out-of-order execution to sequential execution, wherein the sequential execution instructs the issue logic module to issue instructions sequentially one by one;
[0024] A debugging module is used to debug instructions executed by the superscalar processor.
[0025] In a possible implementation, the control module is used to configure the value of a first control status register CSR corresponding to the emission logic module to a first value based on the debug instruction, and the value of the first CSR is the first value indicating that the superscalar processor operates in the debug mode.
[0026] In a possible implementation, the device further includes: a clearing module for clearing instructions in a reorder buffer of the superscalar processor; the transmitting logic module transmitting instructions sequentially one by one includes: the transmitting logic module transmitting an instruction in sequence when the instructions in the reorder buffer are empty, and suspending the transmission of instructions when the instructions in the reorder buffer are not empty.
[0027] In a possible implementation, the control module is also used to control the shutdown of a performance module of the superscalar processor, wherein the performance module includes at least one of a branch prediction submodule, an instruction prefetch submodule, a data prefetch submodule, a speculative execution submodule or a cache submodule.
[0028] In a possible implementation, the control module is used to configure the value of a second control status register CSR corresponding to the performance module to a first value, and the value of the second CSR is the first value used to shut down the performance module.
[0029] In a possible implementation manner, the control module is further used to configure the value of the second CSR to a second value, and the value of the second CSR is the second value used to start the performance module.
[0030] In a possible implementation, the control module is further used to receive non-debug instructions, and based on the non-debug instructions, control the superscalar processor to operate in a non-debug mode, wherein the non-debug mode is used for the emission logic module of the superscalar processor to change the execution mode of the pipeline in the superscalar processor from sequential execution to out-of-order execution, and the out-of-order execution instructs the emission logic module to emit multiple out-of-order instructions.
[0031] In a possible implementation, the control module is used to configure the value of the first CSR corresponding to the emission logic module to a second value based on the non-debug instruction, and the value of the first CSR is the second value to indicate that the superscalar processor operates in the non-debug mode.
[0032] On the other hand, a computer device is provided, comprising the superscalar processor and a memory as described in the above aspect, wherein at least one computer program is stored in the memory, and the at least one computer program is loaded and executed by the superscalar processor so that the computer device implements the superscalar processor debugging method as described in the above aspect.
[0033] On the other hand, a computer-readable storage medium is provided, in which at least one computer program is stored. The at least one computer program is loaded and executed by the superscalar processor described in the above-mentioned one aspect, so that the computer implements the debugging method of the superscalar processor described in the above-mentioned other aspect.
[0034] On the other hand, a computer program product or a computer program is also provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. The superscalar processor of the computer device described in the above-mentioned first aspect reads the computer instructions from the computer-readable storage medium, and the superscalar processor executes the computer instructions, so that the computer device executes the superscalar processor debugging method described in the above-mentioned second aspect.
[0035] The technical solution provided by the embodiments of the present application brings at least the following beneficial effects:
[0036] The technical solution provided by the present application adds a first CSR in a superscalar processor, and the value of the first CSR is a first value to indicate that the superscalar processor operates in debug mode, so that by configuring the value of the first CSR to the first value, the emission logic module of the superscalar processor can be controlled to change the execution mode of the pipeline in the superscalar processor from out-of-order execution to sequential execution, and then debug the instructions executed by the superscalar processor when the emission logic module emits instructions one by one sequentially, so as to reduce the difficulty of implementing the debugging function on the superscalar processor, thereby reducing the complexity of the hardware design of the superscalar processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0038] Figure 1 is a structural diagram of a superscalar processor provided in an embodiment of the present application;
[0039] Figure 2 is a schematic diagram of the structure of another superscalar processor provided in an embodiment of the present application;
[0040] Figure 3 is a schematic diagram of the structure of another superscalar processor provided in an embodiment of the present application;
[0041] Figure 4It is a schematic diagram of an implementation environment of a superscalar processor debugging method provided by an embodiment of the present application;
[0042] Figure 5 is a flow chart of a superscalar processor debugging method provided by an embodiment of the present application;
[0043] Figure 6 This is a schematic diagram of a command transmission scenario provided by an embodiment of the present application;
[0044] Figure 7 It is a structural schematic diagram of a superscalar processor debugging device provided in an embodiment of the present application;
[0045] Figure 8 It is a structural diagram of a server provided in an embodiment of the present application;
[0046] Fig. 9 It is a structural diagram of a terminal provided in an embodiment of the present application. DETAILED DESCRIPTION
[0047] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0048] It should be noted that the terms "first", "second", etc. (if any) in the specification of the present application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described here can be implemented in an order other than those illustrated or described here. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are only examples of devices and methods consistent with some aspects of the present application.
[0049] In the field of debugging technology, common debugging operations include but are not limited to: general purpose registers (GPR) values, reading control status registers (CSR) values, reading memory contents, setting breakpoints, and single step debugging. Setting breakpoints refers to setting an interrupt mark in a program instruction so that the execution is interrupted when the breakpoint is reached and the debugging state is entered. Single step debugging means that during the debugging process, the application is executed step by step according to a certain execution unit and pauses after each step. The single step debugging process allows the user to observe the behavior of the application in each step, thereby debugging the execution flow of the application.
[0050] For scalar processors, since they process one instruction in the same clock cycle, the pipeline design of the scalar processor hardware is relatively simple, and the instructions are issued sequentially one by one, making the hardware implementation of the debug function relatively easy. However, superscalar processors have the ability to execute multiple instructions in parallel in each clock cycle. The issuance and execution of instructions in superscalar processors are no longer carried out in sequence, but in a disorderly manner, which increases the difficulty of implementing the debug function.
[0051] See also Figure 1 , the embodiment of the present application provides a superscalar processor 100 to reduce the difficulty of implementing the debugging function. Figure 1 As shown, the superscalar processor 100 includes a first CSR 102, which is configured to a first value when the superscalar processor 100 enters a debug mode; and a transmission logic module 101, which is used to change the execution mode of the pipeline in the superscalar processor 100 from out-of-order execution to sequential execution when the value of the first CSR 102 is the first value.
[0052] The superscalar processor 100 is a processor that can execute multiple instructions concurrently in one clock cycle, and improves the performance of the processor through instruction-level parallelism, that is, in the same clock cycle, the superscalar processor 100 can simultaneously execute instructions from different program threads, or execute instructions that can be executed in parallel in the same thread. The first CSR 102 is used to indicate the working mode of the superscalar processor 100. When the value of the first CSR 102 is the first value, it indicates that the superscalar processor 100 is currently working in debug mode.
[0053] The issue logic module 101 is used to fetch instructions from the instruction queue or cache and send the instructions to the execution unit of the superscalar processor 100 for execution. In the superscalar processor 100, the issue logic module 101 manages the concurrent issuance of multiple instructions. When the superscalar processor 100 is in the debug mode (i.e., the value of the first CSR 102 is the first value), the issue logic module 101 changes the way of sending instructions, no longer concurrently sending multiple instructions, but sending instructions one by one sequentially, thereby reducing the difficulty of debugging implementation.
[0054] In a possible implementation, Figure 2As shown, the superscalar processor 100 also includes a reorder buffer 103 (Reorder Buffer, ROB), which is connected to the emission logic module 101; the reorder buffer 103 is used to send a first signal to the emission logic module 101 when the instruction in the reorder buffer 103 is empty, and send a second signal to the emission logic module 101 when the instruction in the reorder buffer 103 is not empty; the emission logic module 101 is used to, when the superscalar processor 100 operates in debug mode, if the first signal sent by the reorder buffer 103 is received, an instruction is emitted in sequence, if the second signal sent by the reorder buffer 103 is received, the emission of instructions is suspended.
[0055] The reorder buffer 103 is used to store instructions that have been issued but not yet completed by the transmission logic module 101. When the instructions in the reorder buffer 103 are empty, the reorder buffer 103 sends a first signal to the transmission logic module 101, indicating that there are no instructions in the current reorder buffer 103. In the debug mode, the transmission logic module 101, upon receiving the first signal, takes out an instruction from the instruction queue or cache in sequence and transmits it to the reorder buffer 103 to ensure the sequential execution of the program. When the instructions in the reorder buffer 103 are not empty, the reorder buffer 103 sends a second signal to the transmission logic module 101, indicating that there are instructions in the current reorder buffer 103. In the debug mode, after receiving the second signal, the transmission logic module 101 suspends the transmission of new instructions until the instructions in the reorder buffer 103 are executed.
[0056] In a possible implementation, Figure 3 As shown, the superscalar processor 100 also includes a performance module 104 and a second CSR 105 connected to the performance module 104, the performance module 104 includes at least one of a branch prediction module, an instruction prefetch module, a data prefetch module, a speculative execution module or a cache module; at least one of the branch prediction module, the instruction prefetch module, the data prefetch module, the speculative execution module or the cache module is used to shut down when the value of the second CSR 105 is a first value, and start up when the value of the second CSR 105 is a second value.
[0057] The performance module 104 is a collection of a series of components in the superscalar processor 100 that are responsible for improving the processor performance. Among them, the branch prediction module is used to predict the result of the branch instruction to be executed, so that the superscalar processor 100 can fetch values and prepare execution paths in advance, reducing pipeline pauses caused by branch instructions. The instruction prefetch module is used to prefetch instructions from the memory to the cache of the superscalar processor 100 in advance according to the execution mode and historical behavior of the instructions, so that they can be quickly accessed when needed. The data prefetch module is used to predict the data required for the next step of the program and load it from the memory to the cache in advance. The speculative execution module is used to speculate the result of the condition before the processor waits for certain conditions (such as memory access results) to be determined, and continue to execute subsequent instructions based on the speculated results; if the speculation is correct, the superscalar processor 100 will avoid waiting time; if the speculation is wrong, the superscalar processor 100 cancels the result of speculative execution. The cache module includes an instruction cache and a data cache, which are used to store recently used instructions and data for fast access.
[0058] The second CSR 105 is used to control the on or off state of the performance module 104. When the value of the second CSR 105 is the first value, the performance module 104 is turned off. This means that the above-mentioned branch prediction, instruction prefetching, data prefetching, speculative execution and other functions will not work, thereby avoiding the increase in the difficulty of implementing the debugging function caused by the execution order or execution mode of the program instructions being changed by the performance module 104. When the value of the second CSR 105 is the second value, the performance module 104 is started. At this time, the various components in the performance module 104 will start to work to optimize the performance of the superscalar processor 100.
[0059] Optionally, in the case where the performance module 104 includes at least two modules among a branch prediction module, an instruction prefetch module, a data prefetch module, a speculative execution module or a cache module, at least two modules may be connected to a second CSR 105 in common, and then at least two modules are shut down or started in common according to the value of the second CSR 105; or, each of the at least two modules is connected to a corresponding second CSR 105, and each module is shut down or started in common according to the value of the corresponding second CSR 105. For example, the performance module 104 includes a branch prediction module, an instruction prefetch module, a data prefetch module, a speculative execution module and a cache module, the branch prediction module is connected to the second CSR 1, the instruction prefetch module is connected to the second CSR 2, the data prefetch module is connected to the second CSR 3, the speculative execution module is connected to the second CSR 4, and the cache module is connected to the second CSR 5.
[0060] In one possible implementation, the first CSR 102 is also configured to a second value when the debugging of the superscalar processor 100 is completed; the emission logic module 101 is also used to change the execution mode of the pipeline in the superscalar processor 100 from sequential execution to out-of-order execution when the value of the first CSR 102 is the second value.
[0061] In a possible implementation, the first CSR 102 is used to receive a debug instruction, and adjust the value of the first CSR 102 to a first value based on the debug instruction; the first CSR 102 is also used to receive a non-debug instruction, and adjust the value of the first CSR 102 to a second value based on the non-debug instruction. The value of the first CSR 102 can be controlled by a user, for example, the user changes the debug instruction sent to the first CSR 102 in the debugger interface, and changes the value of the first CSR 102 to the first value through the debug instruction, thereby entering the debug mode. The debugger can be software for debugging a program of a processor.
[0062] For working modes other than debug mode, the superscalar processor 100 can increase the processing speed by sending multiple out-of-order instructions in parallel by the emission logic module 101. The setting of the first CSR 102 enables the superscalar processor 100 to switch freely between debug mode and non-debug mode according to user needs. The embodiment of the present application does not limit the first value and the second value, for example, the first value is 1 and the second value is 0; or the first value is 0 and the second value is 1.
[0063] The superscalar processor provided in the embodiment of the present application adds a first CSR in the superscalar processor, and the value of the first CSR is a first value indicating that the superscalar processor operates in debug mode, so that by configuring the value of the first CSR to the first value, the emission logic module of the superscalar processor can be controlled to change the execution mode of the pipeline in the superscalar processor from out-of-order execution to sequential execution. The sequential execution instructs the emission logic module to emit instructions one by one sequentially, and then the instructions executed by the superscalar processor are debugged when the emission logic module emits instructions one by one sequentially, so as to reduce the difficulty of implementing the debugging function on the superscalar processor, thereby reducing the complexity of the hardware design of the superscalar processor.
[0064] The present application embodiment provides a superscalar processor debugging method to reduce the difficulty of implementing the debugging function. Figure 4 , Figure 4A schematic diagram of an implementation environment of the method provided in the embodiment of the present application is shown. The implementation environment may include: a computer device 401. The embodiment of the present application does not limit the product form of the computer device 401. Regardless of the product form, the computer device 401 is equipped with a superscalar processor; or the computer device 401 is connected to a device equipped with a superscalar processor via a wired or wireless method, wherein the superscalar processor may be Figure 1-3 The superscalar processor shown.
[0065] For example, the computer device 401 may be a terminal or a server. Optionally, the terminal may be an intelligent device such as a mobile phone, a tablet computer, a personal computer, etc. The server may be a single server, or a server cluster consisting of multiple servers, or a cloud computing service center. The terminal and the server establish a communication connection via a wired or wireless network.
[0066] Those skilled in the art should understand that the above-mentioned computer device 401, terminal and server are only examples, and other existing or future computer devices, terminals or servers, if applicable to the present application, should also be included in the protection scope of the present application and are included here by reference.
[0067] The present application embodiment provides a superscalar processor debugging method, which is described by taking a computer device executing the method as an example. For example, the computer device can be Figure 4 The computer device 401 shown. Figure 5 As shown, the debugging method of the superscalar processor includes but is not limited to the following steps 501-502.
[0068] Step 501, receiving a debug instruction, and controlling the superscalar processor to operate in a debug mode based on the debug instruction.
[0069] Superscalar processors use complex hardware structures to implement out-of-order execution of instructions to improve the throughput and performance of the processor. In debug mode, the issue logic module of the superscalar processor changes the execution mode of the pipeline in the superscalar processor from out-of-order execution to sequential execution. The issue logic module of the superscalar processor no longer issues multiple instructions concurrently, but issues them one by one in sequence, thereby simplifying the debugging process.
[0070] The emission logic module of the superscalar processor may emit instructions in a manner of concurrently emitting multiple instructions or sequentially emitting instructions one by one. In one possible implementation, the process of controlling the superscalar processor to operate in a debug mode based on a debug instruction includes configuring the value of a first CSR corresponding to the emission logic module to a first value based on the debug instruction, and the value of the first CSR to indicate that the superscalar processor operates in the debug mode is the first value. Figure 1Taking the control superscalar processor shown as an example, the emission logic module is connected to the first CSR, and the emission logic module can obtain the value of the first CSR. When the value of the first CSR becomes the first value, the emission logic module determines that the superscalar processor is operating in debug mode, and then emits instructions one by one sequentially.
[0071] CSR is a register inside a superscalar processor, which is used to store various status information that controls the operation of the superscalar processor. CSR can be read and written through specific instructions or interfaces to control the behavior of the superscalar processor. In the design of the superscalar processor, one or more CSRs are set to control the debugging behavior of the superscalar processor so that the superscalar processor supports the debug mode. Among them, the CSR corresponding to the transmission logic module can control the way the transmission logic module sends instructions, and the CSR corresponding to the transmission logic module is the first CSR in the embodiment of the present application.
[0072] The user can send an instruction or command through the debugger to set the value of the first CSR to the first value. The debugger can be GDB (GNU symbolic debugger), Open OCD (Open On-Chip Debugger), etc. Optionally, a debug instruction is sent to the first CSR through the debugger, and the value of the first CSR is configured to the first value based on the debug instruction. When the value of the first CSR is set to the first value, the emission logic module corresponding to the first CSR changes the mode of transmitting the instruction to send it one by one in sequence.
[0073] The superscalar processor includes a reorder buffer (ROB), which is used to store instructions that have been issued by the emission logic module but have not yet been executed by the superscalar processor. In the case where the emission logic module sends instructions one by one in sequence, it is necessary to ensure that there is an instruction in the reorder buffer at the same time. In a possible implementation, after controlling the superscalar processor to work in debug mode based on debug instructions, it also includes: clearing the instructions in the reorder buffer of the superscalar processor; the emission logic module sequentially emits instructions one by one, including: the emission logic module emits an instruction in sequence when the instruction in the reorder buffer is empty, and suspends the emission of instructions when the instruction in the reorder buffer is not empty.
[0074] Optionally, the reorder buffer is connected to the transmission logic module. When the instruction is empty, the reorder buffer sends a first signal to the transmission logic module. The transmission logic module transmits an instruction to the reorder buffer in sequence based on the first signal.
[0075] Since superscalar processors support instruction-level parallel processing, the order of issuing and executing instructions may be different, and the reorder buffer can also be used to ensure the correctness of the final execution result. In debug mode, it is necessary to ensure that the order of issuing and executing instructions is consistent with the order in the program source code, so the out-of-order instructions originally stored in the reorder buffer need to be cleared.
[0076] When the instruction in the reorder buffer is empty, the emission logic module will emit an instruction in sequence, which will be placed in the reorder buffer and wait for the execution unit to be idle for execution. When the instruction in the reorder buffer is not empty, the emission logic module will suspend the emission of new instructions to ensure that the instructions that have been emitted to the reorder buffer can be executed in sequence and will not be disrupted by new instructions.
[0077] See also Figure 6 A schematic diagram of an instruction emission scenario is shown, in which, in non-debug mode, Issue logic (i.e., emission logic module) issues (Issue) multiple transmission instruction queues (Issue queue) in parallel, and obtains operation results FU0, FU1, and FU2 through execution and storage (Execute&Memory). The execution stage is to send micro-operation control signals to the corresponding components in the superscalar processor according to a certain timing through the operation controller to implement the specific operation required by the instruction. Storage refers to accessing memory, reading operands, and other operations according to the needs of the instruction. The write back stage (Write Back, WB) writes the operation result data of the execution instruction stage back to the ROB, and completes the commit and completion (Commit&Retire) in the ROB. Commit refers to the operation of confirming all changes in the instruction and permanently saving the instruction to the database, and completion indicates that the instruction is completed.
[0078] In the debug mode, a first CSR corresponding to the transmit logic module, namely, an In-order_en (arranged in order) register, is provided, and the value of the first CSR is a first value, and the first value indicates the debug mode. The embodiment of the present application does not limit the specific value of the first value, and it can be freely set by the user, for example, the first value is 1.
[0079] In the debug mode, when the instruction in the ROB is empty, the ROB sends a first signal to the transmit logic module. When the transmit logic module receives the first signal, it determines that there is no instruction in the ROB, and the transmit logic module sends an instruction to the ROB in sequence. When the instruction in the ROB is not empty, the ROB sends a second signal to the transmit logic module. When the transmit logic module receives the second signal, it determines that there is an instruction in the ROB, and the transmit logic module stops sending instructions to the ROB.
[0080] Step 502: Debug the instructions executed by the superscalar processor.
[0081] When a superscalar processor is in debug mode, the debug mode allows the user to control the execution behavior of the processor so that the user can analyze and debug. Instructions are executed in the execution unit of the superscalar processor, and the execution results are written to the physical register stack and sent to the target location through the bypass network. During the debugging process, the user can monitor the execution of each instruction, including the various stages of instruction issuance, execution, and writeback. If an error or exception is found during the execution process, the execution process of the processor can be paused, and the status of the registers and memory related to the execution process can be viewed to locate the error and troubleshoot the problem.
[0082] In addition, you can set breakpoints, single-step, or modify register and memory values to more finely control the execution behavior of the processor, thereby discovering potential problems or verifying the effects of repairs. A breakpoint is a mark that pauses the program when it is executed, allowing it to view and modify the program's status. Single-step is a function provided by the debugger that allows the user to control the execution of the program instruction by instruction, including Step Into, which enters a subroutine or function call, Step Over, which executes the current line but does not enter the subroutine, and Step Out, which returns from the current subroutine or function call. During debugging, users can directly modify the register values in the processor or the values in the memory to test different input conditions or simulate certain situations to view the behavior of the program.
[0083] In addition, the superscalar processor hardware also includes modules such as branch prediction module, instruction prefetch module, data prefetch module, speculative execution module, cache module, etc. for improving processor performance, which increases the difficulty of implementing debugging functions such as setting breakpoints and single-step debugging. And because the debugging function is coupled with the superscalar processor hardware's instruction execution, interrupt exception handling, privilege mode switching and other functions, the design complexity is relatively high.
[0084] During the debugging process, the performance may change the execution order or mode of instructions, thereby interfering with the debugging process. Therefore, before debugging the instructions executed by the superscalar processor, the method further includes: controlling the performance module of the superscalar processor to be turned off, wherein the performance module includes at least one of a branch prediction submodule, an instruction prefetch submodule, a data prefetch submodule, a speculative execution submodule, or a cache submodule, so as to reduce the difficulty of debugging.
[0085] In a possible implementation, the process of controlling the shutdown of a performance module of a superscalar processor includes: configuring the value of a second CSR corresponding to the performance module to be a first value, the value of the second CSR being the first value used to shut down the performance module. Optionally, a debugger sends a debug instruction to the second CSR, and the value of the second CSR changes to the first value based on the debug instruction.
[0086] The second CSR is associated with a performance module of a superscalar processor, and the performance module is turned off by setting one or some bits of the second CSR to a specific value (e.g., a first value). The first value is preset, and the first value can be changed. The debugger is a software tool for a user to control and observe a program while the program is running. In the case of debugging a superscalar processor, the debugger can provide an interface that allows the user to read and modify various registers of the processor, including the first CSR and the second CSR.
[0087] In a possible implementation, after debugging the instructions executed by the superscalar processor, the method further includes: configuring the value of the second CSR to be a second value, and the value of the second CSR being the second value is used to start the performance module.
[0088] During the debugging process, the performance module is temporarily shut down in order to accurately track and observe the execution of instructions. However, after debugging is completed, in order for the processor to run efficiently, the performance module needs to be restarted. The user connects to the running superscalar processor, determines the second CSR, and in the debugger interface, the user modifies the value of the second CSR to the second value. The value of the second CSR is modified to the second value, so that the performance module of the processor is restarted.
[0089] In a possible implementation, after debugging the instructions executed by the superscalar processor, it also includes: receiving non-debug instructions, and controlling the superscalar processor to operate in a non-debug mode based on the non-debug instructions. The non-debug mode is used for the emission logic module of the superscalar processor to change the execution mode of the pipeline in the superscalar processor from sequential execution to out-of-order execution. The out-of-order execution instructs the emission logic module to emit multiple out-of-order instructions.
[0090] In non-debugging mode, the superscalar processor executes according to the instruction flow of the program and optimizes the execution process as much as possible to improve performance, that is, multiple instructions are issued in one clock cycle, and the execution order of instructions may not be the order in which the instructions appear in the program. When debugging is completed, the user exits the debugging mode. For example, sending a specific command or setting a specific register value makes the processor exit the debugging mode, so that the superscalar processor can run efficiently.
[0091] In a possible implementation, the process of controlling a superscalar processor to operate in a non-debug mode based on a non-debug instruction includes configuring the value of a first CSR corresponding to an emission logic module to a second value based on the non-debug instruction, and the value of the first CSR is the second value to indicate that the superscalar processor operates in a non-debug mode. When the debugging task is completed, the superscalar processor needs to be switched from the debug mode back to the non-debug mode. The value of the first CSR is configured to the second value to indicate that the processor is in a non-debug mode.
[0092] Exemplarily, the debugging process of the superscalar processor may include starting a debugger corresponding to the superscalar processor, checking the state of the first CSR of the superscalar processor, and ensuring that the system is in a debuggable state. Through the debugger, the value of the in-order_en CSR (i.e., the first CSR) is set to 1 (i.e., the first value) to enable the debugging mode of the superscalar processor. The corresponding second CSR is configured to disable modules such as the branch prediction module, the instruction / data prefetch module, the speculative execution logic, and the cache.
[0093] The debugger flushes the pipeline of the superscalar processor (i.e. Figure 6 ), make sure that all instructions are cleared. After clearing the pipeline, use the debugger to control the superscalar processor and perform the following operations: Set breakpoints, that is, set breakpoints at specific code locations so that the superscalar processor will pause when it reaches the breakpoint. Single-step debugging, that is, by single-stepping instructions, the execution process of the superscalar processor is gradually tracked. Read registers or memory, which can be GPRs (General-Purpose Registers), CSRs, etc., to check the status and data of the superscalar processor.
[0094] After debugging is completed, perform the following operations to restore the original configuration of the superscalar processor, set in-order_enCSR to 0 (i.e., the second value), and restore the superscalar processor to work in non-debugging mode. Re-enable modules such as the branch prediction module, instruction / data prefetch module, speculative execution logic, and cache that were disabled during debugging.
[0095] In summary, the method provided by the embodiment of the present application is that when the superscalar out-of-order processor works in debug mode, the emission logic module can emit instructions one by one in sequence, thereby reducing the difficulty of implementing the debugging function. In addition, the method avoids interference with program instructions during the operation of the performance module by shutting down the performance module of the superscalar processor, thereby further reducing the difficulty of implementing the debugging function.
[0096] See also Figure 7 , Figure 7 A schematic diagram of the structure of a superscalar processor debugging device provided in an embodiment of the present application is shown in FIG. Figure 7 As shown, the device comprises:
[0097] The control module 701 is used to receive a debug instruction, and control the superscalar processor to work in a debug mode based on the debug instruction. The debug mode is used for the launch logic module of the superscalar processor to change the execution mode of the pipeline in the superscalar processor from out-of-order execution to sequential execution. The sequential execution instructs the launch logic module to sequentially launch instructions one by one.
[0098] The debugging module 702 is used to debug the instructions executed by the superscalar processor.
[0099] In a possible implementation, the control module 701 is used to configure the value of the first control status register CSR corresponding to the transmit logic module to a first value based on the debug instruction, and the value of the first CSR is the first value indicating that the superscalar processor operates in debug mode.
[0100] In a possible implementation, the device further includes: a clearing module for clearing instructions in a reorder buffer of a superscalar processor; the transmitting logic module transmitting instructions sequentially one by one includes: the transmitting logic module transmitting an instruction in sequence when the instructions in the reorder buffer are empty, and suspending the transmission of instructions when the instructions in the reorder buffer are not empty.
[0101] In one possible implementation, the control module 701 is also used to control the shutdown of a performance module of the superscalar processor, where the performance module includes at least one of a branch prediction submodule, an instruction prefetch submodule, a data prefetch submodule, a speculative execution submodule, or a cache submodule.
[0102] In a possible implementation, the control module 701 is used to configure the value of the second control status register CSR corresponding to the performance module to be a first value, and the value of the second CSR is the first value for shutting down the performance module.
[0103] In a possible implementation manner, the control module 701 is further configured to configure the value of the second CSR to be a second value, and the value of the second CSR being the second value is used to start the performance module.
[0104] In one possible implementation, the control module 701 is also used to receive non-debug instructions, and control the superscalar processor to operate in a non-debug mode based on the non-debug instructions. The non-debug mode is used for the emission logic module of the superscalar processor to change the execution mode of the pipeline in the superscalar processor from sequential execution to out-of-order execution. The out-of-order execution instructs the emission logic module to emit multiple out-of-order instructions.
[0105] In a possible implementation, the control module 701 is used to configure the value of the first CSR corresponding to the emission logic module to a second value based on the non-debug instruction, and the value of the first CSR is the second value to indicate that the superscalar processor operates in the non-debug mode.
[0106] It should be noted that the above Figure 7 The debugging device for the superscalar processor provided in the embodiment only uses the division of the above-mentioned functional modules as an example to implement its functions. In actual functions, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above-mentioned embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments.
[0107] Figure 8 This is a schematic diagram of the structure of a server provided by an embodiment of the present application. The server may have relatively large differences due to different configurations or performances, and may include one or more processors 801 and one or more memories 802, wherein the one or more memories 802 store at least one computer program, and the at least one computer program is loaded and executed by the one or more processors 801, so that the server implements the superscalar processor debugging method provided by the above-mentioned various method embodiments. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output, and the server may also include other components for implementing device functions, which will not be described in detail here.
[0108] Fig. 9 1 is a schematic diagram of a terminal structure provided in an embodiment of the present application, so that the terminal 900 implements the debugging method of the superscalar processor provided in each of the above method embodiments. The terminal 900 may be, for example, a smart phone, a tablet computer, a player, a laptop computer or a desktop computer. The terminal 900 may also be called a user equipment, a portable terminal, a laptop terminal, a desktop terminal or other names.
[0109] exist Fig. 9 In the depiction, the terminal 900 is shown to include a processor 901 (the processor 901 may be a superscalar processor), which may include Figure 1 , Figure 2 or Figure 3 The transmit logic module 101, the first CSR 102, the reorder buffer 103, the performance module 104 or the second CSR 105 in the embodiment. Fig. 9 In the embodiment, the processor 901 is coupled to the memory 902, and it should be understood that the terminal 900 also supports other memory configurations known in the art.
[0110] The memory 902 may include one or more computer-readable storage media, which may be non-transitory. The memory 902 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 902 is used to store at least one instruction, which is used to be executed by the processor 901 so that the terminal implements the debugging method of the superscalar processor provided in the method embodiment of the present application.
[0111] Fig. 9 Also shown is a display 906 coupled to the processor 901, which is coupled to the processor 901 via a display controller 904. In some cases, the terminal 900 can be used for wireless communication. Fig. 9 Also shown are a speaker 909 and a microphone 910 coupled to the processor 901 via a codec 911 ; and a wireless antenna 908 coupled to the wireless controller 905 .
[0112] The display 906 is used to display the UI (User Interface). The UI may include graphics, text, icons, videos and any combination thereof. When the display 906 is a touch display screen, the display 906 also has the ability to collect touch signals on the surface or above the surface of the display 906. At this time, the display 906 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display 906 can be one, set on the front panel of the terminal; in other embodiments, the display 906 can be at least two, respectively set on different surfaces of the terminal or in a folding design; in other embodiments, the display 906 can be a flexible display screen, set on a curved surface or a folding surface of the terminal. Even, the display 906 can also be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display 906 can be made of materials such as LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode) and the like.
[0113] Microphone 910 is used to collect sound waves from the user and the environment, and input the sound waves to processor 901 for processing. For the purpose of stereo sound collection or noise reduction, there can be multiple microphones 910, which are respectively arranged at different parts of the terminal. Microphone 910 can also be an array microphone or an omnidirectional collection microphone. Speaker 909 is used to convert electrical signals from processor 901 into sound waves. Speaker 909 can be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert electrical signals into sound waves audible to humans, but also convert electrical signals into sound waves inaudible to humans for purposes such as ranging.
[0114] The processor 901 and the memory 902 may be included in a system-in-package or system-on-chip device.
[0115] Input device 907 and power supply 903 are coupled to system-on-chip device 912. Optionally, as Fig. 9 As shown, when one or more optional blocks are present, the display 906, input device 907, speaker 909, microphone 910, wireless antenna 908, and power supply 903 are external to the system-on-chip device 912. However, each of the display 906, input device 907, speaker 909, microphone 910, wireless antenna 908, and power supply 903 may be coupled to a component of the system-on-chip device 912, such as an interface or controller.
[0116] The power supply 903 is used to power various components in the terminal. The power supply 903 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 903 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.
[0117] In one possible implementation, the superscalar processor 901 and the memory 902 may be integrated into a set-top box, a server, a music player, a video player, an entertainment unit, a navigation device, a personal digital assistant (PDA), a fixed location data unit, a computer, a laptop computer, a tablet computer, a communication device, a mobile phone, or other similar devices.
[0118] The method described in conjunction with the embodiment of the present application can be directly implemented in the software module executed by the superscalar processor. The software module can reside in a random access memory (Random Access Memory, RAM) memory, a flash memory, a read-only memory (Read Only Memory, ROM) memory, an electrically programmable read-only memory (ErasableProgrammable Read Only Memory, EPROM) memory, an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM) memory, a register, a hard disk, a removable disk, a compact disc read-only memory (Compact Disc Read-Only Memory, CDROM) or any other form of storage medium known in the art. The storage medium is coupled to the superscalar processor so that the superscalar processor can read information from the storage medium and write information to the storage medium. Optionally, the storage medium can be integrated with the superscalar processor.
[0119] Those skilled in the art will understand that Fig. 9 The structure shown in the figure does not constitute a limitation on the terminal, and may include more or less components than those shown in the figure, or combine certain components, or adopt a different component arrangement.
[0120] In an exemplary embodiment, a server is also provided. The structure and function of the server can refer to the above Fig. 9 The structure and functions of the terminal are shown.
[0121] In an exemplary embodiment, a computer device is also provided, the computer device comprising a processor and a memory, wherein at least one computer program is stored in the memory. The at least one computer program is loaded and executed by one or more processors, so that the computer device implements any of the above-mentioned superscalar processor debugging methods.
[0122] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, in which at least one computer program is stored. The at least one computer program is loaded and executed by a processor of a computer device so that the computer implements any of the above-mentioned superscalar processor debugging methods.
[0123] In one possible implementation, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, etc.
[0124] In an exemplary embodiment, a computer program product or a computer program is also provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes any of the above-mentioned superscalar processor debugging methods.
[0125] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions. For example, the instructions involved in this application are all obtained with full authorization.
[0126] It should be understood that the "plurality" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.
[0127] The above description is only an exemplary embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A superscalar processor, characterized in that: The superscalar processor comprises: A first control status register CSR, configured to be a first value when the superscalar processor enters a debug mode; The emission logic module is used to change the execution mode of the pipeline in the superscalar processor from out-of-order execution to in-order execution when the value of the first CSR is a first value.
2. The superscalar processor according to claim 1, characterized in that: The superscalar processor also includes a reorder buffer, wherein the reorder buffer is connected to the transmit logic module; The reorder buffer is configured to send a first signal to the transmit logic module when the instruction in the reorder buffer is empty, and send a second signal to the transmit logic module when the instruction in the reorder buffer is not empty; The transmission logic module is used to, when the superscalar processor operates in the debug mode, transmit an instruction in sequence if the first signal sent by the reorder buffer is received, and suspend the transmission of instructions if the second signal sent by the reorder buffer is received.
3. The superscalar processor according to claim 1 or 2, characterized in that: The superscalar processor also includes a performance module and a second CSR connected to the performance module, the performance module including at least one of a branch prediction submodule, an instruction prefetch submodule, a data prefetch submodule, a speculative execution submodule, or a cache submodule; At least one of the branch prediction submodule, the instruction prefetch submodule, the data prefetch submodule, the speculative execution submodule or the cache submodule is used to shut down when the value of the second CSR is a first value, and to start up when the value of the second CSR is a second value.
4. The superscalar processor according to claim 1 or 2, characterized in that: The first CSR is used to receive a debugging instruction, and configure the value of the first CSR to the first value based on the debugging instruction.
5. The superscalar processor according to claim 1 or 2, characterized in that: The first CSR is further configured to be a second value when the superscalar processor debugging ends; The transmit logic module is further configured to change the execution mode of the pipeline in the superscalar processor from sequential execution to out-of-order execution when the value of the first CSR is a second value.
6. A method for debugging a superscalar processor, characterized in that: The method comprises: receiving a debug instruction, and controlling the superscalar processor to operate in a debug mode based on the debug instruction, wherein the debug mode is used for an issue logic module of the superscalar processor to change the execution mode of the pipeline in the superscalar processor from out-of-order execution to sequential execution, wherein the sequential execution instructs the issue logic module to issue instructions sequentially one by one; Instructions executed by the superscalar processor are debugged.
7. The method according to claim 6, characterized in that The step of controlling the superscalar processor to operate in a debug mode based on the debug instruction includes: The value of a first control status register CSR corresponding to the emission logic module is configured to be a first value based on the debugging instruction, and the value of the first CSR is the first value indicating that the superscalar processor operates in the debugging mode.
8. The method according to claim 6, characterized in that After controlling the superscalar processor to operate in the debug mode based on the debug instruction, the method further includes: Clear the instructions in the reorder buffer of the superscalar processor; the transmission logic module transmits instructions one by one in sequence, including: when the instructions in the reorder buffer are empty, the transmission logic module transmits an instruction in sequence, and when the instructions in the reorder buffer are not empty, suspends the transmission of instructions.
9. The method according to claim 6, characterized in that Before debugging the instructions executed by the superscalar processor, the method further includes: A performance module of the superscalar processor is controlled to be closed, wherein the performance module includes at least one of a branch prediction submodule, an instruction prefetch submodule, a data prefetch submodule, a speculative execution submodule or a cache submodule.
10. The method according to claim 9, characterized in that The step of controlling the performance module of the superscalar processor to be shut down comprises: The value of the second control status register CSR corresponding to the performance module is configured as a first value, and the value of the second CSR is the first value used to shut down the performance module.
11. The method according to claim 10, characterized in that After debugging the instructions executed by the superscalar processor, the method further includes: The value of the second CSR is configured as a second value, and the value of the second CSR is the second value used to start the performance module.
12. The method according to any one of claims 6 to 11, characterized in that: After debugging the instructions executed by the superscalar processor, the method further includes: Receive non-debug instructions, and control the superscalar processor to operate in a non-debug mode based on the non-debug instructions. The non-debug mode is used for the emission logic module of the superscalar processor to change the execution mode of the pipeline in the superscalar processor from sequential execution to out-of-order execution. The out-of-order execution indicates that the emission logic module emits multiple out-of-order instructions.
13. The method according to claim 12, characterized in that The step of controlling the superscalar processor to operate in a non-debug mode based on the non-debug instruction includes: The value of the first CSR corresponding to the issue logic module is configured as a second value based on the non-debug instruction, and the value of the first CSR is the second value to indicate that the superscalar processor operates in the non-debug mode.
14. A computer device, characterized in that: The computer device comprises a superscalar processor and a memory as described in any one of claims 1-5, wherein the memory stores at least one computer program or instruction, and the at least one computer program or instruction is loaded and executed by the superscalar processor so that the computer device implements the debugging method of the superscalar processor as described in any one of claims 6-13.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one program code, and the at least one program code is loaded and executed by the superscalar processor described in any one of claims 1-5, so that the computer implements the debugging method of the superscalar processor described in any one of claims 6-13.
Citation Information
Patent Citations
Debug support for block-based processor
CN108027731A
Instruction processing device and method, processor system and equipment
CN115794229A
Method and apparatus for controlling execution of speculations in a processor based on monitoring power consumption
US20030182542A1
System and method for control registers accessed via private operations
US20060136608A1
Processors with branch instruction, circuits, systems and processes of manufacture and operation
US20090106541A1
