## 2 Method
### Hardware Implementation and PIL Architecture  
Novel vehicle functions verification and features validation hold increasingly critical importance in the development of on-board vehicle software-hardware platforms. Generally, software implementation of ADAS or Autonomous Driving functions require a development process aimed at improving the overall quality of the software, increasing the development efficiency, and eliminating systematic software bugs. To this extent, the V-cycle process represents the adequate software development process widely used in automotive industry field applications, as represented in Figure 5. The typical V-cycle process insists on a top-down approach for what concerns the designing phase and a bottom-up approach for the validation one. Performing the descending phase of the cycle, the process ensures that the high-level system requirements are respected. On the contrary, the ascending stages avoids costly system-level testing before the functional components have been demonstrated [43]. This section will focus on the descending stages of the V-cycle development process, treating up the embedded software generation for the retained real-time target machines. Algorithms are implemented in the MATLAB/Simulink environment which deploys a model-based design approach that automatically generates embedded software for the target machine. Moreover, the retained MATLAB/Simulink environment is used to create different test case scenarios and verify results for different testing simulation procedures such as model-in-the-loop (MIL) and processor-in-the-loop (PIL). In this work, MIL contains all the subsystems (perception, motion planning, and control, and vehicle model) needed to perform the simulation. Conversely, the retained PIL setup splits these components into two groups: a first set running on the target computer with a compiled application, containing the motion planning and control, and another set, i.e., the vehicle model only, running on the host PC. The command input for the vehicle model plant on the host PC, i.e., the steering angle at the wheels and the acceleration command, are sent via UDP, along with the fed-back information of the vehicle state running on the real-time target machine. UDP is a packet-based protocol that uses an Ethernet board as physical layer. This protocol is advantageous for real-time application because has smaller delay than TCP connection as it does not retransmit lost packets. To this extent, UDP Send and Receive blocks are set in the MATLAB/Simulink environment to interface with the motion planner and controller (target side), as well as the vehicle plant model (host side). Furthermore, simulation pacing option is set to obtain near-real-time simulation also on model running on development computer, thus forcing the  
Figure 5: V-cycle process for software development. synchronization between the plant model running on the development computer and the controller flashed onto the target device. The setup of the PIL test using the Speedgoat Real Time target machine is shown in Figure 6, while the PIL test setup exploiting the functionality of Raspberry Pi 4B board is represented in Figure 7.  
In the preliminary phase of the performed software implementation, it was decided to deploy the embedded software on a low-cost platform, i.e., the Raspberry Pi 4B board with hardware specification shown in Table 2. Raspberry Pi is a small-sized, general-purpose computing device that is capable of running any ARM-compatible operating system. By having an open-source environment, Linux facilitates the application of the Raspberry Pi in the development of embedded control devices. In addition, its integration with MATLAB/Simulink environment facilitates the application building and deployment onto the aforementioned platform.