# An Empirical Study of the Code Generation of Safety-Critical Software Using LLMs
## 4 Experiments
### Software Requirements Analysis in Nuclear and Automotive Domain
#### 4.1.2 Requirements for Cruise Control Functions of Automobiles  
In the automotive domain, we investigate code generation based on LLMs using a typical car cruise control function as an example (referred to as the CruiseControl software 1.0). This example is derived from a demo of the SCADE software (16.4). Based on system requirements and conceptual design, the overall requirement description for the cruise control function is as follows in Box 3:  
**Box 3. ** The overall requirement description for cruise control function. The CC system connects to the car through various inputs such as enabling/disabling the CC, setting/resuming cruise speed, sensors for the accelerator and brake pedals, and car speed. It delivers outputs such as cruise speed value, throttle command, and cruise state. The CC system's behavior is defined by the car's state and driver's actions. Initially, the CC is off when the car starts. It can be turned on by the driver and automatically turns off when the off button is pressed. The CC regulates car speed when the car speed is within the limit and the accelerator pedal is not pressed. It is disabled when the accelerator pedal is pressed or the car speed is outside the limit, and resumes to the ON state when the accelerator pedal is not pressed and the car speed is within the limit. The CC is interrupted when the brake is pressed and resumes to either the ON or STDBY states when the resume button is pressed. When the CC is off, the car speed is controlled using the accelerator pedal. When the CC is on, the car speed is automatically regulated. The throttle command is limited to ensure comfort during automatic regulation. The cruise speed is managed only when the CC is enabled. It can be set to the current speed, increased or decreased by a certain increment, and maintained within a specified range. The accelerator and brake pedals are detected as pressed when their values are above a certain minimum. The CC parameters include minimum and maximum speeds, speed increment, proportional and integral gains for the regulation algorithm, maximum throttle saturation, and minimum pedal press detection. After the specific requirements analysis, the itemized software requirements that have been identified are as follows in Box 4:  
**Box 4. ** The itemized software requirements for cruise control function. 1. Input signal names and sources:  
CC_INR_01: From the cruise control switch, signal ON for open of cruise control function, signal OFF for close of cruise control function. CC_INR_02: From the cruise control switch, signal Resume for cruise control resuming (Resume the CC after braking). CC_INR_03: From the cruise control speed setting switch, signal Set to set the current speed as the cruise speed. CC_INR_04: From the cruise control speed setting switch, signal QuickDecel to decrease the cruise speed. CC_INR_05: From the cruise control speed setting switch, signal QuickAccel to increase the cruise speed. CC_INR_06: From the throttle sensor, signal Accel for acceleration (accelerator pedal sensor). CC_INR_07: From the brake sensor, signal Brake for braking (brake pedal sensor). CC_INR_08: From the vehicle speed sensor, signal Speed for vehicle speed. 2. Input signal types:  
RNI_INR_03: ON, OFF, Resume, Set, QuickDecel, QuickAccel are digital signals, boolean type. RNI_INR_04: Speed, Accel, Brake are analog signals, floating-point type. 3. Valid range of input signals:  
None. 4. Output signal names and destinations:  
CC_OUTR_01: Cruise speed signal (CruiseSpeed), output to the instrument panel. CC_OUTR_02: Throttle command signal (ThrottleCmd), output to the throttle. CC_OUTR_03: Vehicle cruise state signal (CruiseState), output to the instrument panel. 5. Output signal types:  
CC_OUTR_04: CruiseSpeed is an analog signal, floating-point type. CC_OUTR_05: ThrottleCmd is a digital signal, boolean type. CC_OUTR_06: CruiseState is a multi-state signal, including four states: OFF, ON, STDBY, INT. **Box 4**. _Cont_. 6. Valid range of output signals:  
None. 7.