## 4 Case Study  
### Experimental Setup  
As previously mentioned, the Texas Instruments MSP430 microcontroller was used to validate the effectiveness of the proposal presented. This 16-bit microcontroller with Von Neumann architecture was chosen primarily for its extended use in low-power embedded systems and mission-critical systems. Moreover, thanks to its low energy consumption, it has been widely used in space applications, such as picosatellites, where the probabilities of radiation-induced faults are higher [44; 45; 46]. This device has a microprocessor register file comprised of 16 registers in total: The first four registers are special purpose registers, and the last 12 registers are general purpose registers. Instead of using a well-known benchmark set (such as MiBench, available at: [[http://vhosts.eecs.umich.edu/mibench/](http://vhosts.eecs.umich.edu/mibench/)]([http://vhosts.eecs.umich.edu/mibench/](http://vhosts.eecs.umich.edu/mibench/))), we used four representative concept tests with programs that could be implemented in the microcontroller. This decision was made due to the limitations in terms of microcontroller resources. The first two test programs are implementations of iterative algorithms to calculate the Euler number (Euler) and the natural logarithm of 2 (In2), respectively. The algorithms were restricted to working only with integer data. The selection of this pair of algorithms is because they are based on convergent series. Its iterative nature allows us to evaluate the behavior of this type of algorithm against approximation techniques such as loop perforation. In addition, an implementation of the Sobel image filter and the Emboss image filter were used to validate the applicability of the proposal. These algorithms are widely used in the field of image processing, within edge detection algorithms for images. They create images highlighting the edges of a given image. In this case, implementations these algorithms were made in the microcontroller. To do so, we worked with small images of 55 \(\times\) 55 pixels. The resulting (output) and the original image (input), were stored in the RAM memory of the microcontroller. When evidencing the iterative nature of the algorithms used, it was decided to use loop perforation as an AC technique at the approximation stage. The reduction of the number of iterations of the 'for' loops of each algorithm was done by hand. In the case of the first two programs (In2 and Euler), since they are based on convergent series, the upper limits of the conditional expressions in the 'for' statements were reduced, as shown in the code fragments presented in Figure 2.  
The code fragment on the left represents the original loop. The upper limit of the conditional expression in the 'for' statement is represented by the \(ITER\_ORIG\) variable. This value corresponds to the maximum number of iterations. In the case where In2 is 1000 and in the case where Euler is 8, approximated versions are obtained from the original code by halving the maximum number of iterations (i.e., \(ITER\_APPROX\) variable in the code on the right) for each version. The cases of the filter programs (Sobel and Emboss) are somewhat different. Since they are based on a two-dimensional convolution, these algorithms do not have large iterative loops. Instead, the programs are based on nested cycles. Therefore, the perforation was done by increasing the step of the iteration variable, as observed in the code fragments shown in Figure 3. Again, the code on the right represents the perforated loop, and the one on the left represents the original one. In this way, the different approximate versions were obtained for each test program. To determine the percentage of error in the result and the speed-up in execution time, an instruction set simulator (ISS) was used. Since this technique is applied in the high-level source code (in C language), it can be extended to other architectures. In the next stage, the SHE (software hardening environment) [47] tool was used to automate the hardening process.