# Real-Time Optimization of RISC-V Processors Based on Branch Prediction and Division Data Dependency
## 4 Experiment and Result Analysis
### Processor Real-Time Testing and Performance Analysis
#### 4.3.1 CoreMark Overall Performance Testing and Comparative Analysis  
The H\({}_{\text{rtp}}\) parameter calculation formulas are shown in (1) and (2).  
In the formula, T\({}_{\text{k}}\) is the indicator of whether the hardware meets the system's real-time requirements. T\({}_{\text{d}}\) (the data corresponding to Task in Table 9) is generally provided by the real-time system. T\({}_{\text{wcet}}\) refers to the Worst-Case Execution Time (WCET) of the processor when running Task A, which can be determined through various analysis methods. Since the calculation of T\({}_{\text{wcet}}\) is not the focus of this paper, we directly provide assumed WCET values for the three processors, as shown in Table 10.  
First, analyze the H\({}_{\text{rtp}}\) of the Rev-riscv-III processor. Since T\({}_{\text{wcet}}\) > T\({}_{\text{d}}\), this indicates that in this case, T\({}_{\text{k}}\) = 0 and H\({}_{\text{rtp}}\) = 0; the processor cannot meet the real-time metrics allocated by the real-time system, making it unsuitable for this real-time system.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Processor Name** & **T\({}_{\text{wcet}}\) of Processor for** & **The System-Specified T\({}_{\text{d}}\)** \\  & **Task A** & **for Task A** \\ \hline Rev-riscv & 90 s & \\ Rev-riscv-II & 90 s & 100 s \\ Rev-riscv-III & 110 s & \\ \hline \hline \end{tabular}
\end{table}
Table 10: The processor’s WCET and the system-required maximum task execution time for Task A.  
Figure 14: Diagram of the Interaction between autonomous driving real-time system and processor.  
For the other two processors, \(\rm T_{\rm tweet}<T_{d}\), and \(\rm T_{k}=1\); therefore, a detailed calculation of \(\rm H_{\rm rtp}\) can be performed to evaluate the real-time performance metrics of Rev-riscv and Rev-riscv-II under these conditions.  
Assuming that the real-time system places high importance on fluctuations in processor execution time, the value of A is set to 100 under these conditions. The \(\rm H_{\rm rtp}\) parameter calculation formulas are revised as shown in (3) and (4).  
\[\rm H_{\rm rtp}=T_{k}ln(\mu+100*\frac{\sigma^{2}}{\mu}) \tag{3}\]  
\[\rm T_{k}=\left\{\begin{array}{l}1\;(T_{\rm tweet}<T_{d})\\ 0\;(T_{\rm tweet}\;\geq\;T_{d})\end{array}\right. \tag{4}\]  
The CoreMark benchmark scores were obtained for the unoptimized Rev-riscv processor and the Rev-riscv-II processor, which has been optimized for branch prediction and division data dependency. Each processor was run 100 times, and the data before and after optimization were compared. The detailed runtime data are shown in Table 11.  
The score time-frequency distribution of the Rev-riscv processor is shown in Figure 15a. The score time-frequency distribution of the Rev-riscv-II processor is shown in in Figure 15b. From the qualitative analysis of the data distribution, the \(\mu\) (mean) and \(\sigma\) (standard deviation) of Rev-riscv-II are slightly better than those of Rev-riscv, which roughly suggests that the real-time performance of Rev-riscv-II is slightly better than that of Rev-riscv.  
By comparing the detailed calculated values of \(\rm H_{\rm rtp}\), it can be seen that the value for Rev-riscv-II is slightly smaller than that for Rev-riscv, indicating that the real-time performance of Rev-riscv-II is slightly better than that of Rev-riscv. This is consistent with the qualitative analysis results.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Test Item** & **Rev-Riscv** & **Rev-Riscv-II** \\ \hline Number of Tests & 100 & 100 \\ Mean Runtime & 77.7191 s & 74.0996 s \\ Variance of Runtime & 3.47505 & 2.85681 \\ \(\rm H_{\rm rtp}\) Value & 4.4091 & 4.3578 \\ \hline \hline \end{tabular}
\end{table}
Table 11: Test data for Rev-riscv and Rev-riscv-II when running the CoreMark benchmark program.  
Figure 15: Time–frequency distribution of Rev-riscv and Rev-riscv-II.