3-phase PV router
Loading...
Searching...
No Matches
test_main.cpp File Reference

Unity-based unit tests for assembly multiplication functions. More...

#include <Arduino.h>
#include <unity.h>
#include "../halt_after_tests.h"
#include "mult_asm.h"
Include dependency graph for test_main.cpp:

Go to the source code of this file.

Functions

void loop ()
 
void setUp (void)
 
void setup ()
 
void tearDown (void)
 
void test_assembly_vs_standard (void)
 Compare assembly results with standard multiplication.
 
void test_edge_cases (void)
 Test edge cases and potential overflow scenarios.
 
void test_mult16x8_q8_basic (void)
 Test basic functionality of mult16x8_q8.
 
void test_mult16x8_q8_rounding (void)
 Test rounding behavior of mult16x8_q8.
 
void test_multS16x16_to32_basic (void)
 Test basic functionality of multS16x16_to32.
 
void test_multU16x16_to32_basic (void)
 Test basic functionality of multU16x16_to32 (unsigned)
 
void test_multU24x16_to32_hi8_basic (void)
 Test multU24x16_to32_hi8: (a x b) >> 8, a on 24 bits (energy bucket, #120)
 
void test_performance_isr_simulation (void)
 ISR-like performance test simulating real-world usage.
 
void test_performance_mult16x8_q8 (void)
 Performance comparison for Q8 fractional multiplication.
 
void test_performance_multS16x16_to32 (void)
 Performance comparison between assembly and standard multiplication.
 
void test_performance_multU16x16_to32 (void)
 Performance comparison for unsigned multiplication (multU16x16_to32)
 
void test_q8_conversion_helpers (void)
 Test Q8 format conversion helpers.
 

Variables

volatile uint8_t g_optimizer_defeat = 0
 
uint8_t i = 0
 
uint8_t max_blinks = 1
 

Detailed Description

Unity-based unit tests for assembly multiplication functions.

Version
0.1
Date
2026-11-24

This file contains comprehensive unit tests for the assembly-optimized multiplication functions using the Unity testing framework.

Based on:

  • florentbr's optimization suggestions for PVRouter
  • avrfreertos multiplication optimizations by feilipu
  • OpenMusicLabs AVR assembly techniques

Definition in file test_main.cpp.

Function Documentation

◆ loop()

void loop ( )

Definition at line 885 of file test_main.cpp.

Here is the call graph for this function:

◆ setUp()

void setUp ( void )

Definition at line 27 of file test_main.cpp.

◆ setup()

void setup ( )

Definition at line 876 of file test_main.cpp.

◆ tearDown()

void tearDown ( void )

Definition at line 32 of file test_main.cpp.

◆ test_assembly_vs_standard()

void test_assembly_vs_standard ( void )

Compare assembly results with standard multiplication.

Definition at line 397 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_edge_cases()

void test_edge_cases ( void )

Test edge cases and potential overflow scenarios.

Definition at line 285 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_mult16x8_q8_basic()

void test_mult16x8_q8_basic ( void )

Test basic functionality of mult16x8_q8.

Definition at line 193 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_mult16x8_q8_rounding()

void test_mult16x8_q8_rounding ( void )

Test rounding behavior of mult16x8_q8.

Definition at line 261 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_multS16x16_to32_basic()

void test_multS16x16_to32_basic ( void )

Test basic functionality of multS16x16_to32.

Definition at line 40 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_multU16x16_to32_basic()

void test_multU16x16_to32_basic ( void )

Test basic functionality of multU16x16_to32 (unsigned)

Definition at line 87 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_multU24x16_to32_hi8_basic()

void test_multU24x16_to32_hi8_basic ( void )

Test multU24x16_to32_hi8: (a x b) >> 8, a on 24 bits (energy bucket, #120)

Definition at line 139 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_performance_isr_simulation()

void test_performance_isr_simulation ( void )

ISR-like performance test simulating real-world usage.

Definition at line 754 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_performance_mult16x8_q8()

void test_performance_mult16x8_q8 ( void )

Performance comparison for Q8 fractional multiplication.

Definition at line 650 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_performance_multS16x16_to32()

void test_performance_multS16x16_to32 ( void )

Performance comparison between assembly and standard multiplication.

Definition at line 448 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_performance_multU16x16_to32()

void test_performance_multU16x16_to32 ( void )

Performance comparison for unsigned multiplication (multU16x16_to32)

Definition at line 550 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_q8_conversion_helpers()

void test_q8_conversion_helpers ( void )

Test Q8 format conversion helpers.

Definition at line 241 of file test_main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_optimizer_defeat

volatile uint8_t g_optimizer_defeat = 0

Definition at line 25 of file test_main.cpp.

◆ i

uint8_t i = 0

Definition at line 882 of file test_main.cpp.

◆ max_blinks

uint8_t max_blinks = 1

Definition at line 883 of file test_main.cpp.