Skip to content

Add double-precision float multiply example using PRU MAC hardware accelerator#119

Open
Copilot wants to merge 3 commits intomainfrom
copilot/dev-tley-double-float
Open

Add double-precision float multiply example using PRU MAC hardware accelerator#119
Copilot wants to merge 3 commits intomainfrom
copilot/dev-tley-double-float

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 13, 2026

Implements IEEE 754 double-precision (64-bit) float multiplication in optimized PRU assembly using the 32-bit MAC broadside accelerator, located at examples/double_float/. A C reference (main_c_ref.c) using the software FP library path (__mpy2d) is included for comparison.

Algorithm (firmware/main.asm)

  • Splits each 53-bit significand into 21-bit hi + 32-bit lo halves
  • Computes four 32×32→64 hardware MAC partial products (p00, p01, p10, p11) with on-the-fly ADD/ADC carry accumulation into a 106-bit result {pp3:pp2:pp1}
  • Normalises via QBBS do_shift, pp3, 9 (detects leading-1 at bit 104 vs 105)
  • Rounds to nearest using the guard bit from pp1, with mantissa-overflow → exponent-increment handling
; 53-bit × 53-bit via four 32-bit MAC ops
MOV   r28, sigA_lo
MOV   r29, sigB_lo          ; triggers 32×32 hardware multiply
NOP                          ; 1-cycle result latency
XIN   DEVICE_ID, &r26, 4   ; result[31:0]
XIN   DEVICE_ID, &r27, 4   ; result[63:32]
MOV   pp1, r27              ; seed accumulator; repeat for p01, p10, p11

Performance

Implementation Worst-case cycles
Assembly + MAC hardware 85 cycles (~425 ns @ 200 MHz)
C library __mpy2d (software FP) ~200+ cycles

Build infrastructure

Board-specific makefiles and projectspecs for am261x-lp/som, am263px-lp/cc, am263x-lp/cc — mirroring the existing examples/ structure with correct OPEN_PRU_PATH depth (../../../../../..).

Normal numbers only; NaN, Inf, denormals, and zero are not handled.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…h MAC hardware

Co-authored-by: tleyrer <24540697+tleyrer@users.noreply.github.com>
Copilot AI changed the title [WIP] Add optimized double float multiply operation in PRU assembly Add double-precision float multiply example using PRU MAC hardware accelerator Mar 13, 2026
Copilot AI requested a review from tleyrer March 13, 2026 09:00
Co-authored-by: tleyrer <24540697+tleyrer@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@tleyrer tleyrer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks fine

@tleyrer tleyrer marked this pull request as ready for review March 13, 2026 12:18
@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Add double-precision float multiply example using PRU MAC hardware accelerator

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Implements IEEE 754 double-precision (64-bit) float multiplication using PRU MAC hardware
  accelerator with optimized assembly achieving **85 cycles** (~425 ns @ 200 MHz)
• Splits 53-bit significands into 21-bit and 32-bit halves, computes four 32×32→64 MAC partial
  products with on-the-fly carry accumulation into 106-bit result
• Normalizes product via bit 105 detection and rounds to nearest using guard bit, with
  mantissa-overflow → exponent-increment handling
• Includes C reference implementation (main_c_ref.c) using software FP library (__mpy2d) for
  comparison (~200+ cycles)
• Provides comprehensive documentation covering IEEE 754 format, algorithm overview, register
  mapping, memory layout, and performance analysis
• Adds complete build infrastructure with board-specific makefiles and CCS project specifications
  for am261x-lp/som, am263px-lp/cc, and am263x-lp/cc platforms
• Includes linker command files, ROV configuration files, and project build wrappers for both PRU0
  and PRU1 cores across all supported boards
• **Limitations**: Normal numbers only; NaN, Infinity, denormals, and zero are not handled
Diagram
flowchart LR
  A["53-bit × 53-bit<br/>Significands"] -->|"Split into<br/>21-bit + 32-bit"| B["Four 32×32<br/>MAC Operations"]
  B -->|"Accumulate<br/>with carry"| C["106-bit<br/>Product"]
  C -->|"Detect bit 105"| D["Normalize"]
  D -->|"Guard bit<br/>rounding"| E["64-bit Result<br/>85 cycles"]
Loading

Grey Divider

File Changes

1. examples/double_float/firmware/main_c_ref.c 📝 Documentation +93/-0

C reference implementation for double-precision multiply

• Provides C reference implementation of IEEE 754 double-precision multiplication using software FP
 library (__mpy2d)
• Demonstrates equivalent functionality to optimized assembly with cycle count comparison (~200+
 cycles vs ~85 cycles)
• Includes detailed memory layout documentation and union-based double-to-word conversion
• Notes that this file is reference-only and not compiled into default firmware

examples/double_float/firmware/main_c_ref.c


2. examples/double_float/firmware/main.asm ✨ Enhancement +320/-0

PRU assembly double-precision multiply with MAC acceleration

• Implements IEEE 754 double-precision (64-bit) float multiplication using PRU MAC hardware
 accelerator
• Splits 53-bit significands into 21-bit and 32-bit halves, computes four 32×32→64 MAC partial
 products with on-the-fly carry accumulation
• Normalizes product via bit 105 detection and rounds to nearest using guard bit from product
• Achieves worst-case 85 cycles (~425 ns @ 200 MHz) with comprehensive register mapping and memory
 layout

examples/double_float/firmware/main.asm


3. examples/double_float/readme.md 📝 Documentation +169/-0

Complete documentation for double-float multiply example

• Comprehensive documentation of IEEE 754 double-precision format and algorithm overview
• Details PRU MAC broadside accelerator usage (5 cycles per 32×32 multiply) and worst-case cycle
 breakdown (85 cycles total)
• Includes register map, memory layout, performance comparison with C library, and supported
 board/toolchain combinations
• Notes special case limitations (NaN, Infinity, denormals, zero not handled)

examples/double_float/readme.md


View more (66)
4. examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd ⚙️ Configuration changes +43/-0

AM261x PRU0 linker command file configuration

• Defines memory map for AM261x PRU0 with 16 KB instruction RAM and 8 KB data RAMs
• Maps sections (.text, .stack, .bss, .data, etc.) to appropriate memory regions
• Configures 32 KB shared RAM and establishes page-based memory layout

examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd


5. examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd ⚙️ Configuration changes +43/-0

AM261x PRU1 linker command file configuration

• Defines memory map for AM261x PRU1 with swapped data RAM assignments (PRU1_DMEM_1 primary)
• Maps sections to PRU1-specific memory regions with identical layout structure to PRU0
• Configures instruction and shared memory regions

examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd


6. examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd ⚙️ Configuration changes +43/-0

AM261x-som PRU0 linker command file configuration

• Defines memory map for AM261x-som PRU0 with identical structure to am261x-lp variant
• Maps sections to PRU0_DMEM_0 and establishes memory layout for SOM board variant

examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd


7. examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd ⚙️ Configuration changes +43/-0

AM261x-som PRU1 linker command file configuration

• Defines memory map for AM261x-som PRU1 with PRU1_DMEM_1 as primary data RAM
• Mirrors PRU1 memory layout structure from am261x-lp variant

examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd


8. examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd ⚙️ Configuration changes +43/-0

AM263Px PRU0 linker command file configuration

• Defines memory map for AM263Px PRU0 with standard 16 KB instruction and 8 KB data RAM layout
• Maps sections to PRU0_DMEM_0 and configures shared memory regions

examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd


9. examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd ⚙️ Configuration changes +43/-0

AM263Px PRU1 linker command file configuration

• Defines memory map for AM263Px PRU1 with PRU1_DMEM_1 as primary data RAM
• Establishes memory layout for PRU1 core on AM263Px platform

examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd


10. examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd ⚙️ Configuration changes +43/-0

AM263Px-lp PRU0 linker command file configuration

• Defines memory map for AM263Px-lp PRU0 with standard memory layout
• Maps sections to PRU0_DMEM_0 and configures instruction/shared memory regions

examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd


11. examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd ⚙️ Configuration changes +43/-0

AM263Px-lp PRU1 linker command file configuration

• Defines memory map for AM263Px-lp PRU1 with PRU1_DMEM_1 as primary data RAM
• Establishes memory layout for PRU1 core on AM263Px-lp board variant

examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd


12. examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd ⚙️ Configuration changes +43/-0

AM263x PRU0 linker command file configuration

• Defines memory map for AM263x PRU0 with standard 16 KB instruction and 8 KB data RAM layout
• Maps sections to PRU0_DMEM_0 and configures shared memory regions

examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd


13. examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd ⚙️ Configuration changes +43/-0

AM263x PRU1 linker command file configuration

• Defines memory map for AM263x PRU1 with PRU1_DMEM_1 as primary data RAM
• Establishes memory layout for PRU1 core on AM263x platform

examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd


14. examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd ⚙️ Configuration changes +43/-0

AM263x-lp PRU0 linker command file configuration

• Defines memory map for AM263x-lp PRU0 with standard memory layout
• Maps sections to PRU0_DMEM_0 and configures instruction/shared memory regions

examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd


15. examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd ⚙️ Configuration changes +43/-0

AM263x-lp PRU1 linker command file configuration

• Defines memory map for AM263x-lp PRU1 with PRU1_DMEM_1 as primary data RAM
• Establishes memory layout for PRU1 core on AM263x-lp board variant

examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd


16. examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

AM261x-lp PRU0 makefile build configuration

• Defines build configuration for AM261x-lp PRU0 firmware with output naming and hex array
 generation
• Configures compiler flags (-v3 -O2), linker flags, and include paths for PRU toolchain
• Establishes vpath for assembly/C source discovery and post-build hex array generation with
 copyright header

examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile


17. examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

AM261x-lp PRU1 makefile build configuration

• Defines build configuration for AM261x-lp PRU1 firmware with PRU1-specific output naming
• Configures identical compiler/linker flags and build infrastructure as PRU0 variant
• Establishes hex array generation targeting PRU1 firmware naming

examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile


18. examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

AM261x-som PRU0 makefile build configuration

• Defines build configuration for AM261x-som PRU0 firmware with board-specific output naming
• Mirrors AM261x-lp makefile structure with som variant in output names and hex array paths

examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/makefile


19. examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

AM261x-som PRU1 makefile build configuration

• Defines build configuration for AM261x-som PRU1 firmware with PRU1-specific naming
• Establishes build infrastructure identical to PRU0 variant with PRU1 hex array generation

examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/makefile


20. examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

AM263Px-cc PRU0 makefile build configuration

• Defines build configuration for AM263Px-cc PRU0 firmware with platform-specific output naming
• Configures compiler/linker flags and build infrastructure for AM263Px platform

examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile


21. examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

AM263Px-cc PRU1 makefile build configuration

• Defines build configuration for AM263Px-cc PRU1 firmware with PRU1-specific naming
• Establishes build infrastructure for AM263Px platform PRU1 core

examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile


22. examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

AM263Px-lp PRU0 makefile build configuration

• Defines build configuration for AM263Px-lp PRU0 firmware with board variant naming
• Configures compiler/linker flags and build infrastructure for AM263Px-lp platform

examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile


23. examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

AM263Px-lp PRU1 makefile build configuration

• Defines build configuration for AM263Px-lp PRU1 firmware with PRU1-specific naming
• Establishes build infrastructure for AM263Px-lp platform PRU1 core

examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile


24. examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

AM263x-cc PRU0 makefile build configuration

• Defines build configuration for AM263x-cc PRU0 firmware with platform-specific output naming
• Configures compiler/linker flags and build infrastructure for AM263x platform

examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile


25. examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

AM263x-cc PRU1 makefile build configuration

• Defines build configuration for AM263x-cc PRU1 firmware with PRU1-specific naming
• Establishes build infrastructure for AM263x platform PRU1 core

examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile


26. examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

AM263x-lp PRU0 makefile build configuration

• Defines build configuration for AM263x-lp PRU0 firmware with board variant naming
• Configures compiler/linker flags and build infrastructure for AM263x-lp platform

examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile


27. examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

AM263x-lp PRU1 makefile build configuration

• Defines build configuration for AM263x-lp PRU1 firmware with PRU1-specific naming
• Establishes build infrastructure for AM263x-lp platform PRU1 core

examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile


28. examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs ⚙️ Configuration changes +8/-0

AM261x-lp PRU0 ROV configuration file

• Minimal ROV (Runtime Object View) configuration file for AM261x-lp PRU0
• References FreeRTOS ROV plugin for debugging support

examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs


29. examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs ⚙️ Configuration changes +8/-0

AM261x-lp PRU1 ROV configuration file

• Minimal ROV configuration file for AM261x-lp PRU1
• References FreeRTOS ROV plugin for debugging support

examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs


30. examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs 📦 Other +8/-0

AM261x-som PRU

• Minimal ROV configuration file for AM261x-som PRU0
• References FreeRTOS ROV plugin for debugging support

examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs


31. examples/double_float/makefile ⚙️ Configuration changes +111/-0

Top-level build orchestration for double-float multiply example

• Added top-level makefile orchestrating builds across all supported processors (am261x, am263px,
 am263x)
• Defines project metadata, prebuild checks for device compatibility and dependencies
• Routes make commands to board-specific firmware build directories for PRU0 and PRU1 cores
• Implements conditional build logic based on DEVICE and BUILD_MCUPLUS settings

examples/double_float/makefile


32. examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

PRU1 firmware makefile with MAC hardware accelerator build rules

• Comprehensive build configuration for am263px-lp PRU1 firmware compilation
• Defines compiler flags, linker flags, include paths, and output naming conventions
• Implements vpath-based source discovery for assembly and C files across multiple directories
• Post-build hex array generation with copyright header prepending and MCU+ SDK integration

examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile


33. examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

PRU0 firmware makefile for am263x-cc board variant

• Build configuration for am263x-cc PRU0 firmware targeting ICSS_M0 core
• Configures TI PRU compiler with silicon version v3, optimization level O2
• Sets up linker with entry point main, assembly-only firmware mode, and hex array generation
• Includes MCU+ SDK paths and copyright header integration for generated binaries

examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile


34. examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

PRU1 firmware makefile for am263x-cc board variant

• Build configuration for am263x-cc PRU1 firmware with identical structure to PRU0
• Customizes output naming and hex array prefix for PRU1 core differentiation
• Maintains consistent compiler/linker flags and post-build hex generation workflow

examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile


35. examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

PRU0 firmware makefile for am263x-lp board variant

• Build configuration for am263x-lp PRU0 firmware with board-specific paths and naming
• Implements standard TI PRU compiler toolchain integration with v3 silicon version
• Configures assembly-only firmware build with entry point and hex array post-processing

examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile


36. examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile ⚙️ Configuration changes +149/-0

PRU1 firmware makefile for am263x-lp board variant

• Build configuration for am263x-lp PRU1 firmware mirroring PRU0 structure
• Customizes output naming and hex array prefix for PRU1 core identification
• Maintains consistent build flags and post-build hex generation with copyright header

examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile


37. examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec ⚙️ Configuration changes +77/-0

CCS project spec for am263x-lp PRU0 double-float multiply firmware

• CCS project specification for am263x-lp PRU0 firmware with Debug/Release configurations
• Defines compiler build options including include paths, PRU0/SLICE0 defines, and SOC_AM263X
• Links to main.asm firmware and linker.cmd, references API guide documentation
• Configures device core as ICSSM_PRU_0 with MCU+ SDK and OPEN_PRU dependencies

examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec


38. examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec ⚙️ Configuration changes +77/-0

CCS project spec for am263x-lp PRU1 double-float multiply firmware

• CCS project specification for am263x-lp PRU1 firmware with identical structure to PRU0
• Customizes device core to ICSSM_PRU_1 and defines PRU1/SLICE1 compiler flags
• Maintains same source file references and documentation links as PRU0 variant

examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec


39. examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec ⚙️ Configuration changes +77/-0

CCS project spec for am263x-cc PRU0 double-float multiply firmware

• CCS project specification for am263x-cc PRU0 firmware targeting AM263x_CC device
• Configures compiler with PRU0/SLICE0 defines and SOC_AM263X for board-specific builds
• Specifies ICSSM_PRU_0 core with MCU+ SDK integration and documentation references

examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec


40. examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec ⚙️ Configuration changes +77/-0

CCS project spec for am263x-cc PRU1 double-float multiply firmware

• CCS project specification for am263x-cc PRU1 firmware with PRU1-specific configuration
• Customizes device core to ICSSM_PRU_1 and sets PRU1/SLICE1 compiler defines
• Maintains consistent project structure and MCU+ SDK dependencies as PRU0 variant

examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec


41. examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec ⚙️ Configuration changes +77/-0

CCS project spec for am261x-lp PRU0 double-float multiply firmware

• CCS project specification for am261x-lp PRU0 firmware targeting AM261x device
• Configures compiler with PRU0/SLICE0 defines and SOC_AM261X for legacy device support
• Specifies ICSS_M0_PRU_0 core with MCU+ SDK and OPEN_PRU dependencies

examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec


42. examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec ⚙️ Configuration changes +77/-0

CCS project spec for am261x-lp PRU1 double-float multiply firmware

• CCS project specification for am261x-lp PRU1 firmware with PRU1-specific core configuration
• Customizes device core to ICSS_M0_PRU_1 and sets PRU1/SLICE1 compiler defines
• Maintains consistent project metadata and documentation references as PRU0 variant

examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec


43. examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec ⚙️ Configuration changes +77/-0

CCS project spec for am261x-som PRU0 double-float multiply firmware

• CCS project specification for am261x-som PRU0 firmware targeting AM261x SOM variant
• Configures compiler with PRU0/SLICE0 defines and SOC_AM261X for module-specific builds
• Specifies ICSS_M0_PRU_0 core with MCU+ SDK integration and API guide documentation

examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec


44. examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec ⚙️ Configuration changes +77/-0

CCS project spec for am261x-som PRU1 double-float multiply firmware

• CCS project specification for am261x-som PRU1 firmware with PRU1-specific configuration
• Customizes device core to ICSS_M0_PRU_1 and sets PRU1/SLICE1 compiler defines
• Maintains consistent project structure and MCU+ SDK dependencies as PRU0 variant

examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec


45. examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec ⚙️ Configuration changes +77/-0

CCS project spec for am263px-cc PRU0 double-float multiply firmware

• CCS project specification for am263px-cc PRU0 firmware targeting AM263Px device
• Configures compiler with PRU0/SLICE0 defines and SOC_AM263PX for processor-specific builds
• Specifies ICSSM_PRU_0 core with MCU+ SDK and OPEN_PRU dependencies

examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec


46. examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec ⚙️ Configuration changes +77/-0

CCS project spec for am263px-cc PRU1 double-float multiply firmware

• CCS project specification for am263px-cc PRU1 firmware with PRU1-specific core configuration
• Customizes device core to ICSSM_PRU_1 and sets PRU1/SLICE1 compiler defines
• Maintains consistent project metadata and MCU+ SDK integration as PRU0 variant

examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec


47. examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec ⚙️ Configuration changes +77/-0

CCS project spec for am263px-lp PRU0 double-float multiply firmware

• CCS project specification for am263px-lp PRU0 firmware targeting AM263Px launchpad
• Configures compiler with PRU0/SLICE0 defines and SOC_AM263PX for board-specific builds
• Specifies ICSSM_PRU_0 core with MCU+ SDK integration and API guide documentation

examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec


48. examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec ⚙️ Configuration changes +77/-0

CCS project spec for am263px-lp PRU1 double-float multiply firmware

• CCS project specification for am263px-lp PRU1 firmware with PRU1-specific configuration
• Customizes device core to ICSSM_PRU_1 and sets PRU1/SLICE1 compiler defines
• Maintains consistent project structure and MCU+ SDK dependencies as PRU0 variant

examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec


49. examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec ⚙️ Configuration changes +20/-0

CCS project build wrapper for am261x-lp PRU0 firmware

• Auto-generated makefile wrapper for CCS project-based builds of am261x-lp PRU0 firmware
• Invokes CCS Eclipse with project build/clean commands using Release profile by default
• Exports project specification to CCS workspace for IDE integration

examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec


50. examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec ⚙️ Configuration changes +20/-0

CCS project build wrapper for am261x-lp PRU1 firmware

• Auto-generated makefile wrapper for CCS project-based builds of am261x-lp PRU1 firmware
• Configures CCS Eclipse invocation with project-specific naming and Release profile
• Enables IDE-based compilation and project export workflows

examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec


51. examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec ⚙️ Configuration changes +20/-0

CCS project build wrapper for am261x-som PRU0 firmware

• Auto-generated makefile wrapper for CCS project-based builds of am261x-som PRU0 firmware
• Invokes CCS Eclipse with project build/clean commands and project export functionality
• Supports Release profile builds with configurable PROFILE variable

examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec


52. examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec ⚙️ Configuration changes +20/-0

CCS project build wrapper for am261x-som PRU1 firmware

• Auto-generated makefile wrapper for CCS project-based builds of am261x-som PRU1 firmware
• Configures CCS Eclipse invocation with PRU1-specific project naming and Release profile
• Enables IDE-based compilation and project export workflows

examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec


53. examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec ⚙️ Configuration changes +20/-0

CCS project build wrapper for am263px-cc PRU0 firmware

• Auto-generated makefile wrapper for CCS project-based builds of am263px-cc PRU0 firmware
• Invokes CCS Eclipse with project build/clean commands using Release profile by default
• Exports project specification to CCS workspace for IDE integration

examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec


54. examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec ⚙️ Configuration changes +20/-0

CCS project build wrapper for am263px-cc PRU1 firmware

• Auto-generated makefile wrapper for CCS project-based builds of am263px-cc PRU1 firmware
• Configures CCS Eclipse invocation with PRU1-specific project naming and Release profile
• Enables IDE-based compilation and project export workflows

examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec


55. examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec ⚙️ Configuration changes +20/-0

CCS project build wrapper for am263px-lp PRU0 firmware

• Auto-generated makefile wrapper for CCS project-based builds of am263px-lp PRU0 firmware
• Invokes CCS Eclipse with project build/clean commands and project export functionality
• Supports Release profile builds with configurable PROFILE variable

examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec


56. examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec 📦 Other +20/-0
• Auto-generated makefile wrapper for CCS project-based builds

examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec


57. examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs Additional files +8/-0

...

examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs


58. examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs Additional files +8/-0

...

examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs


59. examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs Additional files +8/-0

...

examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs


60. examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs Additional files +8/-0

...

examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs


61. examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs Additional files +8/-0

...

examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs


62. examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec Additional files +20/-0

...

examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec


63. examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs Additional files +8/-0

...

examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs


64. examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec Additional files +20/-0

...

examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec


65. examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs Additional files +8/-0

...

examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs


66. examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec Additional files +20/-0

...

examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec


67. examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs Additional files +8/-0

...

examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/syscfg_c.rov.xs


68. examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec Additional files +20/-0

...

examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile_projectspec


69. examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs Additional files +8/-0

...

examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/syscfg_c.rov.xs


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Mar 13, 2026

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (3) 📎 Requirement gaps (0)

Grey Divider


Action required

1. LBBO/SBBO lack bounds checks 📘 Rule violation ⛨ Security
Description
The new PRU firmware performs LBBO/SBBO memory accesses using offsets without any explicit
bounds validation. This can lead to out-of-bounds reads/writes if the assumed PRU Data RAM
layout/size is incorrect for a target configuration.
Code

examples/double_float/firmware/main.asm[R135-138]

+    LBBO  &lo_A, r1, OFFS_A_LO, 4
+    LBBO  &hi_A, r1, OFFS_A_HI, 4
+    LBBO  &lo_B, r1, OFFS_B_LO, 4
+    LBBO  &hi_B, r1, OFFS_B_HI, 4
Evidence
PR Compliance ID 1 requires bounds validation before PRU load/store instructions; the new code
issues multiple LBBO/SBBO operations with fixed offsets and no prior bounds check or assertion
guarding the address range.

examples/double_float/firmware/main.asm[135-138]
examples/double_float/firmware/main.asm[317-318]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The firmware issues `LBBO`/`SBBO` reads/writes using offsets without any explicit bounds validation, violating the requirement that every PRU memory access be verified to stay within the intended region.

## Issue Context
These accesses assume PRU Data RAM base `r1=0` and fixed offsets (e.g., `OFFS_A_LO`, `OFFS_R_HI`), but there is no proof (check/assertion) that `offset + size` fits within the allocated Data RAM for the target.

## Fix Focus Areas
- examples/double_float/firmware/main.asm[135-138]
- examples/double_float/firmware/main.asm[317-318]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Duplicate main definition 🐞 Bug ✓ Correctness
Description
The ti-pru-cgt makefiles auto-discover and compile all *.c under ../../.. (the firmware/
directory), which includes main_c_ref.c defining int main() while main.asm also defines
main, causing a link-time multiple-definition failure for gmake all builds.
Code

examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[R15-28]

+# which directories to search for assembly & C source files?
+FILES_PATH := .. ../../.. .
+vpath %.asm $(FILES_PATH)
+vpath %.c $(FILES_PATH)
+vpath %.cmd $(FILES_PATH)
+vpath %.obj $(GEN_DIR)
+C_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c)))
+ASM_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm)))
+
+# Generate an object file for every *.asm and *.c source file in FILES_PATH
+OBJECTS := $(patsubst %.asm, $(GEN_DIR)/%.obj, $(notdir \
+	$(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm))))
+OBJECTS += $(patsubst %.c, $(GEN_DIR)/%.obj, $(notdir \
+	$(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c))))
Evidence
The firmware makefile’s FILES_PATH := .. ../../.. . and wildcard $(directory)/*.c logic will
pick up examples/double_float/firmware/main_c_ref.c. That file defines int main(void), while the
assembly firmware also exports a global main label, leading to duplicate symbols during link.

examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[15-28]
examples/double_float/firmware/main_c_ref.c[89-93]
examples/double_float/firmware/main.asm[90-132]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The PRU firmware makefiles auto-discover all `*.c` in `FILES_PATH := .. ../../.. .`. Since `../../..` resolves to `examples/double_float/firmware/`, the reference file `main_c_ref.c` (which defines `int main()`) is compiled and linked alongside `main.asm` (which also defines `main`), causing a duplicate-symbol link failure.

### Issue Context
`main_c_ref.c` is documented as a reference-only implementation and should not be part of the default firmware build.

### Fix Focus Areas
Update all board-specific firmware makefiles to ensure `main_c_ref.c` is excluded from `C_FILES`/`OBJECTS` (or relocate the file so it isn’t discovered):
- examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile[15-28]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. Direct .asg register aliases 📘 Rule violation ✓ Correctness
Description
The new assembly introduces direct register aliasing via multiple .asg rX, name mappings rather
than structured allocation. This increases the risk of register overlap/corruption and reduces
reviewability of register usage.
Code

examples/double_float/firmware/main.asm[R105-120]

+; ── Register aliases ──────────────────────────────────────────────────────────
+    .asg  r2,    lo_A        ; A bits [31:0]
+    .asg  r3,    hi_A        ; A bits [63:32]  → sign[31], exp[30:20], mant[19:0]
+    .asg  r4,    lo_B        ; B bits [31:0]
+    .asg  r5,    hi_B        ; B bits [63:32]
+    .asg  r6,    sigA_lo     ; lower 32 bits of 53-bit significand of A
+    .asg  r7,    sigA_hi     ; upper 21 bits of 53-bit significand of A (bit 20 = implicit 1)
+    .asg  r8,    sigB_lo     ; lower 32 bits of 53-bit significand of B
+    .asg  r9,    sigB_hi     ; upper 21 bits of 53-bit significand of B
+    .asg  r10,   expA        ; 11-bit biased exponent of A
+    .asg  r11,   expB        ; 11-bit biased exponent of B
+    .asg  r12,   res_sign    ; result sign (bit 0)
+    .asg  r13,   res_exp     ; result biased exponent
+    .asg  r22,   pp1         ; accumulated product bits [63:32]
+    .asg  r23,   pp2         ; accumulated product bits [95:64]
+    .asg  r24,   pp3         ; accumulated product bits [105:96]
Evidence
PR Compliance ID 12 requires structured register allocation (.struct/.sassign) instead of direct
register aliases; the new firmware defines many aliases directly with .asg.

examples/double_float/firmware/main.asm[105-120]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The assembly uses direct `.asg` register aliases for many registers, instead of a structured `.struct`/`.sassign` register allocation.

## Issue Context
This code is non-trivial and uses many registers (`r2`..`r29`). Structured allocation reduces overlap risk and makes register side-effects easier to review.

## Fix Focus Areas
- examples/double_float/firmware/main.asm[105-120]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Lowercase labels, uppercase opcodes 📘 Rule violation ✓ Correctness
Description
The new assembly code introduces lowercase labels and uppercase instruction opcodes. This violates
the required assembly style conventions and reduces consistency/readability across the PRU codebase.
Code

examples/double_float/firmware/main.asm[R125-132]

+main:
+
+; ── Initialise registers and MAC unit ────────────────────────────────────────
+init:
+    zero  &r0, 120                  ; clear R0–R29 (120 bytes = 30 × 4-byte registers)
+                                    ; r1 = 0 after zero → used as base address for LBBO/SBBO
+    LDI   r25, MULTIPLY_ONLY        ; MAC control word = 0 (multiply-only mode)
+    XOUT  DEVICE_ID, &r25, 1        ; configure MAC unit
Evidence
PR Compliance ID 17 requires labels to be uppercase and opcodes to be lowercase; the new code uses
labels like main:/init: and uppercase opcodes like LDI/XOUT.

examples/double_float/firmware/main.asm[125-132]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The assembly uses lowercase labels (e.g., `main:`, `init:`) and uppercase opcodes (e.g., `LDI`, `XOUT`), which violates the required PRU assembly code style.

## Issue Context
Style consistency is required for readability and maintainability across PRU examples.

## Fix Focus Areas
- examples/double_float/firmware/main.asm[125-132]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Skipped by examples build 🐞 Bug ⛯ Reliability
Description
The repo-level examples/makefile drives aggregate builds via SUBDIRS, but the new double_float
example is not listed, so make -C examples all will not build/test it.
Code

examples/double_float/makefile[R1-9]

+include ../../imports.mak
+
+#######################
+# project information #
+#######################
+
+PROJECT_NAME := double_float_multiply
+SUPPORTED_PROCESSORS := am261x am263px am263x
+# Does the PRU code have dependencies outside of the open-pru repo?
Evidence
A new example makefile was added under examples/double_float/, but the aggregate
examples/makefile does not include double_float in SUBDIRS, so it will not be built when
users/CI invoke the standard examples build.

examples/double_float/makefile[7-9]
examples/makefile[3-8]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`examples/makefile` does not include the new `examples/double_float` directory in `SUBDIRS`, so aggregate example builds will skip it.

### Issue Context
The PR adds a new example with its own `examples/double_float/makefile`, but it isn’t wired into the standard build entrypoint.

### Fix Focus Areas
- examples/makefile[3-8]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (1)
6. CCS/make silicon mismatch 🐞 Bug ⛯ Reliability
Description
The CCS projectspecs build with -v4 while the gmake firmware makefiles use -v3 for the same
targets, producing different binaries depending on build path and risking mismatched
instruction-set/accelerator semantics.
Code

examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[R47-51]

+CFLAGS := \
+	-v3 -O2 \
+	--display_error_number --diag_wrap=off --diag_warning=225 \
+	--asm_directory=$(GEN_DIR) --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) \
+	-ppd -ppa -g --endian=little
Evidence
The AM261x projectspec explicitly passes -v4, but the corresponding makefile uses -v3. This
mismatch means CCS vs CLI builds may not be equivalent even when compiling the same source.

examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec[31-40]
examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[43-51]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The example’s CCS projectspecs and gmake makefiles specify different silicon version flags (`-v4` vs `-v3`), which can lead to divergent binaries depending on build method.

### Issue Context
For consistency and reproducibility, CCS and makefile builds should use the same `-v` setting for a given target.

### Fix Focus Areas
- examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec[31-40]
- examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[43-51]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Comment on lines +135 to +138
LBBO &lo_A, r1, OFFS_A_LO, 4
LBBO &hi_A, r1, OFFS_A_HI, 4
LBBO &lo_B, r1, OFFS_B_LO, 4
LBBO &hi_B, r1, OFFS_B_HI, 4
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. lbbo/sbbo lack bounds checks 📘 Rule violation ⛨ Security

The new PRU firmware performs LBBO/SBBO memory accesses using offsets without any explicit
bounds validation. This can lead to out-of-bounds reads/writes if the assumed PRU Data RAM
layout/size is incorrect for a target configuration.
Agent Prompt
## Issue description
The firmware issues `LBBO`/`SBBO` reads/writes using offsets without any explicit bounds validation, violating the requirement that every PRU memory access be verified to stay within the intended region.

## Issue Context
These accesses assume PRU Data RAM base `r1=0` and fixed offsets (e.g., `OFFS_A_LO`, `OFFS_R_HI`), but there is no proof (check/assertion) that `offset + size` fits within the allocated Data RAM for the target.

## Fix Focus Areas
- examples/double_float/firmware/main.asm[135-138]
- examples/double_float/firmware/main.asm[317-318]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +15 to +28
# which directories to search for assembly & C source files?
FILES_PATH := .. ../../.. .
vpath %.asm $(FILES_PATH)
vpath %.c $(FILES_PATH)
vpath %.cmd $(FILES_PATH)
vpath %.obj $(GEN_DIR)
C_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c)))
ASM_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm)))

# Generate an object file for every *.asm and *.c source file in FILES_PATH
OBJECTS := $(patsubst %.asm, $(GEN_DIR)/%.obj, $(notdir \
$(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm))))
OBJECTS += $(patsubst %.c, $(GEN_DIR)/%.obj, $(notdir \
$(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c))))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Duplicate main definition 🐞 Bug ✓ Correctness

The ti-pru-cgt makefiles auto-discover and compile all *.c under ../../.. (the firmware/
directory), which includes main_c_ref.c defining int main() while main.asm also defines
main, causing a link-time multiple-definition failure for gmake all builds.
Agent Prompt
### Issue description
The PRU firmware makefiles auto-discover all `*.c` in `FILES_PATH := .. ../../.. .`. Since `../../..` resolves to `examples/double_float/firmware/`, the reference file `main_c_ref.c` (which defines `int main()`) is compiled and linked alongside `main.asm` (which also defines `main`), causing a duplicate-symbol link failure.

### Issue Context
`main_c_ref.c` is documented as a reference-only implementation and should not be part of the default firmware build.

### Fix Focus Areas
Update all board-specific firmware makefiles to ensure `main_c_ref.c` is excluded from `C_FILES`/`OBJECTS` (or relocate the file so it isn’t discovered):
- examples/double_float/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am261x-som/icss_m0_pru0_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am261x-som/icss_m0_pru1_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am263px-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am263x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am263x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am263x-cc/icss_m0_pru0_fw/ti-pru-cgt/makefile[15-28]
- examples/double_float/firmware/am263x-cc/icss_m0_pru1_fw/ti-pru-cgt/makefile[15-28]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feedback seems valid. Is there something in place to prevent the makefile from grabbing main_c_ref.c and using it as a build source?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ask

This feedback seems valid. Is there something in place to prevent the makefile from grabbing main_c_ref.c and using it as a build source?

Answer:

No—based on the new makefile logic shown in the diff, there is currently nothing preventing main_c_ref.c from being auto-discovered and compiled.

Why it gets picked up:

  • The makefiles set FILES_PATH := .. ../../.. .
  • With the makefile located at examples/double_float/firmware/<board>/<core>/ti-pru-cgt/, the ../../.. entry resolves to examples/double_float/firmware/
  • main_c_ref.c lives exactly in that directory (examples/double_float/firmware/main_c_ref.c)
  • C_FILES and OBJECTS are populated via $(wildcard $(directory)/*.c), so main_c_ref.c is included automatically.
  • At link time you then have two entry points:
    • main.asm defines main: (exported with .global main)
    • main_c_ref.c defines int main(void)
      This will typically cause a “multiple definition of main” link error for gmake all.

The comment in main_c_ref.c (“NOT compiled into the default PRU firmware project”) may be true for CCS projects if the projectspec excludes it, but it is not true for these makefile builds as written.

Recommended mitigation (one of):

  • Exclude the reference file in makefiles:
    • e.g. after computing C_FILES, do C_FILES := $(filter-out main_c_ref.c,$(C_FILES))
    • and similarly remove from OBJECTS (or derive OBJECTS from filtered C_FILES/ASM_FILES rather than re-wildcarding).
  • Or move main_c_ref.c into a directory not searched by FILES_PATH (e.g. firmware/ref/), and only include it in a dedicated “C reference” build.
  • Or add a build switch (e.g. BUILD_C_REF=y) that selects either main.asm or main_c_ref.c, but not both.

As-is, the bot’s feedback is valid for the makefile-based builds.

Copy link
Copy Markdown
Collaborator

@pratheesh-ti pratheesh-ti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok

@pratheesh-ti
Copy link
Copy Markdown
Collaborator

@tleyrer please resolve all comments to merge

@@ -0,0 +1,111 @@
include ../../imports.mak
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This project is not actually building because it was not added to the list in examples/makefile. Feedback #1: add project to examples/makefile and make sure it actually shows up in a top-level makefile build.

@@ -0,0 +1,169 @@
# Double Float Multiply (64-bit IEEE 754) using PRU MAC Hardware

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback #2: please add this project to examples/readme.md. It needs both a 1 sentence description of the project, and to be added to the table under "Supported processors per-project"


A companion C reference (`firmware/main_c_ref.c`) shows the equivalent code
that the C compiler produces, where the `*` operator on `double` values is
lowered to a call into the software FP runtime library (`__mpy2d`).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback #3: Please add sections "supported combinations" and "validated HW & SW" to provide future customers with the "known good" reference point for when the project was last tested on hardware. You may use https://github.com/TexasInstruments/open-pru/tree/main/examples/fir as a template.

* Copyright (C) 2024-2025 Texas Instruments Incorporated - http://www.ti.com/
*/

/**
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the AI feedback, I am concerned about this file getting automatically grabbed by the makefile structure, and then the build process not being able to tell whether it is supposed to build with this main function, or the one defined in the ASM file. I imagine it would be safer to change this from a .c file to a .txt file to ensure that the makefile doesn't grab it:

FILES_PATH := .. ../../.. .
vpath %.asm $(FILES_PATH)
vpath %.c $(FILES_PATH)
vpath %.cmd $(FILES_PATH)
vpath %.obj $(GEN_DIR)
C_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c)))
ASM_FILES := $(notdir $(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm)))
OBJECTS := $(patsubst %.asm, $(GEN_DIR)/%.obj, $(notdir \
	$(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.asm))))
OBJECTS += $(patsubst %.c, $(GEN_DIR)/%.obj, $(notdir \
	$(foreach directory, $(FILES_PATH), $(wildcard $(directory)/*.c))))````

Copy link
Copy Markdown
Member

@manojKoppolu manojKoppolu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nick comments need's to be resolved .

  • renaming main_c_ref.c & updating documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants