# Real-Time Optimization of RISC-V Processors Based on Branch Prediction and Division Data Dependency
## 2 Related Work  
Currently, methods for evaluating the real-time performance of processors (i.e., the predictability of execution time) primarily use embedded [10; 11; 12; 13] real-time systems as the analysis platform. Research methods focusing on the predictability of processor execution time (i.e., real-time performance) mainly concentrate on the analysis of the Worst-Case Execution Time (WCET) of software programs [14]. WCET serves as a critical basis for task real-time scheduling [9], task priority arbitration [15], resource conflict resolution [15], and inter-task communication [11] and is a trusted foundation for ensuring the safe operation of the system [16]. However, the current WCET research approaches have two significant limitations. Firstly, the worst-case execution paths lack universal representativeness. In actual processor operations, execution paths do not always follow the worst-case execution scenario. This means that WCET alone cannot adequately reflect an objective metric of the processor's actual hardware performance. As a single metric, WCET fails to capture the predictability of execution time across all possible scenarios. Secondly, WCET analysis focuses on the execution time under the worst-case path, which represents the maximum execution time [17]. This approach does not provide a comprehensive analysis of the variability in execution time, which is essential for understanding the predictability of the hardware's execution process. To better quantify the predictability of hardware execution time (i.e., the real-time performance of the hardware execution process) and the quality of predictability (i.e., the quality of real-time performance), this paper proposes a new parameter, Hardware Real-Time Performance (H\({}_{\text{rtp}}\)), building upon the existing WCET analysis methods. This parameter aims to provide a more comprehensive and accurate assessment of the processor's real-time capabilities and the predictability of its execution time. Integrating the aforementioned concepts, we propose a measurement parameter, H\({}_{\text{rtp}}\), to evaluate the \"real-time performance\" and the \"quality of real-time performance\" of hardware. The specific calculation formula is as follows in (1) and (2). \[\text{H}_{\text{rtp}}\text{=T}_{\text{k}}\text{ln}\left(\mu+\text{A}*\frac{ \sigma^{2}}{\mu}\right) \tag{1}\]  
\[\text{T}_{\text{k}}=\left\{ \begin{array}{l}1\left(\text{T}_{\text{wcet}}< \text{T}_{\text{d}}\right)\\ 0\left(\text{T}_{\text{wcet}}\geq\text{T}_{\text{d}}\right)\end{array} \right. \tag{2}\]  
In the formula, T\({}_{\text{k}}\) is used to indicate whether the processor can meet the system's real-time requirements. T\({}_{\text{k}}\) is a flag that takes a value of either 1 or 0. A value of 1 indicatesthat the processor meets the real-time system requirements, while a value of 0 indicates that it does not. \(\ln\left(\mu+A*\frac{\alpha^{2}}{\mu}\right)\) represents the quality of the processor's execution time (i.e., the quality of its real-time performance) under the condition that the real-time requirements are met. The smaller the value of the parameter, the better the real-time performance of the processor. \(\mu\) represents the mean execution time when running specific program instructions, reflecting the \"speed\" of the processor. \(\sigma^{2}\) represents the variance in execution time when running specific program instructions, indicating the \"stability\" of the processor. By considering both \(\mu\) and \(\sigma^{2}\), the assessment of \"hardware (processor) real-time performance\" becomes more accurate and comprehensive, taking into account both the speed and the variability of the processor's operation. A is a weighting constant that ranges between 0 and 100. Users can adjust A based on their specific requirements to balance the importance of \"execution speed\" and \"stability\". For example, in a real-time system where the stability of the processor's operation is significantly more important than its speed, the value of A can be set to the maximum, 100.