## 4 FPGA-Based Hardware and Software Architecture Design
### Calculation Module  
The input and output signals of the calculation module include the enable signal of the video stream, the line synchronization signal, the field synchronization signal, and the grayscale signal. The function of this module is to use the quaternion signal inputted from the serial port to calculate and obtain the star catalog data within the target sub-area; calculate the right ascension, declination, and star magnitude in the star catalog data to obtain the x-direction coordinate, y-direction coordinate, and the grayscale value of the pixel point; and finally, replace the pixel by pixel one by one according to the coordinates [19]. The main clock of the FPGA chip is 50 MHz, and the 148.5 MHz pixel clock is used in the calculation module [20]. There is a process of transmitting data across the clock \begin{table}
\begin{tabular}{c c c} \hline \hline
**Computational Module** & **Parallel Part** & **Time Saved in Parallel Part** \\ \hline
5.1 & Adder/Subtractor and Multiplier & 290 ns \\
5.3 & Adder/Subtractor & 60 ns \\
5.5 & Adder/Subtractor and Square Calculator & 60 ns \\
5.6 & Adder/Subtractor, Multiplier, and Square Calculator & 40 ns \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Parallel analysis of computational modules. Figure 5: Serial computing schematic. Figure 6: Pipeline computing schematic. domain in the communication, and it is necessary to add two levels of triggers to synchronize the signals for transmitting the data to prevent the phenomenon of race and hazard from occurring. The attitude data is calculated to determine the target subarea boundaries and the attitude transformation matrix, with the target subarea numbering increased from \(30D_{i}+I_{I}\) to \(30D_{i}+J_{r}\) where \(D_{i}\) is increased from \(D_{u}-1\) to \(D_{d}-1\). If the optical axis is pointing at an angle of \(\theta\leq FOV/2\) to the star point, the star point active enable signal oi_en is raised, and the coordinates of the star point are read when the target subarea where the star point data is located is within the boundary and the star point active enable signal is high and reads the star point coordinates pix_x and pix_y. In the effective star point judgment, the judgment condition is replaced by the equivalent of the formula, which is more suitable for FPGA processing. From Equation (12), the valid star point judgment condition can be obtained as follows from Equation (16):  
\[\text{arccos}\theta=\frac{x_{0}x_{1}+y_{0}y_{1}+z_{0}z_{1}}{\sqrt{x_{0}{}^{2}+ y_{0}{}^{2}+z_{0}{}^{2}}\cdot\sqrt{x_{1}{}^{2}+y_{1}{}^{2}+z_{1}{}^{2}}}\leq \frac{FOV}{2} \tag{16}\]  
Since the approximate orientation of the star point has been determined in the previous steps by means of star partitioning, \(\text{arccos}\theta\) should lie within 0\({}^{\circ}\)\(\sim\) 90\({}^{\circ}\), which falls within the monotonically decreasing interval of the cos function, so it can be obtained by Equation (17) as follows:  
\[\left[\cos\left(\frac{FOV}{2}\right)\right]^{2}\cdot\left(x_{0}{}^{2}+y_{0}{}^ {2}+z_{0}{}^{2}\right)\cdot\left(x_{1}{}^{2}+y_{1}{}^{2}+z_{1}{}^{2}\right) \leq(x_{0}x_{1}+y_{0}y_{1}+z_{0}z_{1})^{2} \tag{17}\]  
Calculations are performed using fixed-point decimal calculations, which saves the use of IP cores and reduces computation time compared to floating-point decimal operations. In conventional gesture data calculations, quaternion data in decimal generally retains four significant digits, i.e., thirteen significant digits in binary. Quaternion data values, right ascension and declination values, and trigonometric functions are calculated with values less than 10, and fixed-point arithmetic with 1 integer and 13 decimal places is used in the data calculation, where the bit width of the resultant data from the quadratic operation needs to be twice the width of the previous base data. Thus, a 26-bit reg variable is required in the quadratic operation.