Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions ref_app/ref_app.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,50 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_cpu.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_cpu_secure.s">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_eep.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_gpt.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_irq.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_led.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_osc.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_port.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_pwm.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_spi.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_wdg.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\mcal\atmega2560\mcal_cpu.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
Expand Down Expand Up @@ -1520,6 +1552,10 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="src\mcal\am6254_soc\mcal_osc.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="src\mcal\am6254_soc\mcal_port.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
Expand Down
27 changes: 27 additions & 0 deletions ref_app/ref_app.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,30 @@
<ClCompile Include="src\mcal\am6254_soc\mcal_cpu_secure.s">
<Filter>src\mcal\am6254_soc</Filter>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_eep.cpp">
<Filter>src\mcal\am6254_soc</Filter>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_cpu.cpp">
<Filter>src\mcal\am6254_soc</Filter>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_irq.cpp">
<Filter>src\mcal\am6254_soc</Filter>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_pwm.cpp">
<Filter>src\mcal\am6254_soc</Filter>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_osc.cpp">
<Filter>src\mcal\am6254_soc</Filter>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_port.cpp">
<Filter>src\mcal\am6254_soc</Filter>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_wdg.cpp">
<Filter>src\mcal\am6254_soc</Filter>
</ClCompile>
<ClCompile Include="src\mcal\am6254_soc\mcal_spi.cpp">
<Filter>src\mcal\am6254_soc</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\math\calculus\derivative.h">
Expand Down Expand Up @@ -2922,6 +2946,9 @@
<ClInclude Include="src\mcal\am6254_soc\mcal_reg.h">
<Filter>src\mcal\am6254_soc</Filter>
</ClInclude>
<ClInclude Include="src\mcal\am6254_soc\mcal_osc.h">
<Filter>src\mcal\am6254_soc</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="src\util\STL\algorithm">
Expand Down
30 changes: 18 additions & 12 deletions ref_app/src/app/benchmark/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,44 +78,50 @@ $\pi$ using a Gauss AGM method with help
from the [`decwide_t`](https://github.com/ckormanyos/real-time-cpp/blob/master/ref_app/src/math/wide_decimal/decwide_t.h)
template class.

A typical range of performance classes is shown in the following table.
A very wide range of microcontroller performance classes is shown in the following table.
The benchmark used is a ${\sim}100$ decimal digit AGM $\pi$ calculation.

| Target | runtime $[ms]$ | relative |
|--------------------|-----------------|------------|
| `am335x` | 1.5 | 1.0 |
| `stm32f446` | 5.1 | 3.4 |
| `rpi_pico2_rp2350` | 6.3 | 4.2 |
| `wch_ch32v307` | 8.0 | 5.3 |
| `xtensa_esp32_s3` | 9.1 | 6.1 |
| `rpi_pico_rp2040` | 19 | 13 |
| `avr` | 420 | 280 |
| `am6254_soc_` | 0.37 | 1.0 |
| `am335x` | 1.5 | 4.0 |
| `stm32f446` | 5.1 | 14 |
| `rpi_pico2_rp2350` | 6.3 | 17 |
| `wch_ch32v307` | 8.0 | 22 |
| `xtensa_esp32_s3` | 9.1 | 25 |
| `rpi_pico_rp2040` | 19 | 51 |
| `avr` | 420 | 760 |

There are strikingly differing performance classes
for the $8$-bit MICROCHIP(R) AVR controller of the ARDUINO
and the $32$-bit ARM(R) 8 controller
of the BeagleBone Black Edition, Rev. C.
The $\pi$ calculation requires approximately
$420~\text{ms}$ and $1.5~\text{ms}$,
$420~\text{ms}$ and $1.5~\text{ms,}~$
respectively, on these two microcontroller systems.

The $64$-bit ARM(R)v8-a (i.e., Cortex(R) A53) performs the
calculation (running on one single A53 core of the PocketBeagle2 board)
in $0.37~\text{ms.}$

The $32$-bit ARM(R) Cortex(R) M4F controller on
the `stm32f446` board performs the calculation in
the middle of the two extremes, with a result
of $5.1~\text{ms}$.

The $32$-bit RISC-V controller (having a novel _open-source_ core)
on the `wch_ch32v307` board boasts a quite respectable
time of $8.0~\text{ms}$.
time of $8.0~\text{ms.}$

Running on only one core (core0) of the $32$-bit
controller of the `xtensa_esp32_s3` board results in
a runtime of $9.1~\text{ms}$ for the calculation.

Using only one core (core1) on the $32$-bit ARM(R) Cortex(R) M0+
controller of the `rpi_pico_rp2040` board results in a calculation
time of $19~\text{ms}$. The next generation `rpi_pico2_rp2350`
time of $19~\text{ms.}~$
The next generation `rpi_pico2_rp2350`
with dual ARM(R) Cortex(R) M33 cores definitively improves on this
(still using only core1) with a time of $6.3~\text{ms}$.
(still using only core1) with a time of $6.3~\text{ms.}~$
This is slightly more than $3~\text{ms}$ times faster
than its predecessor.
2 changes: 1 addition & 1 deletion ref_app/src/mcal/am6254_soc/mcal_benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{
namespace benchmark
{
typedef mcal::port::port_pin<mcal::reg::gpio0, 2U> benchmark_port_type;
using benchmark_port_type = mcal::port::port_pin<mcal::reg::gpio0, 36U>;
}
}

Expand Down
12 changes: 12 additions & 0 deletions ref_app/src/mcal/am6254_soc/mcal_cpu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#include <mcal_cpu.h>

auto mcal::cpu::init() -> void
{
}
46 changes: 37 additions & 9 deletions ref_app/src/mcal/am6254_soc/mcal_cpu.h
Original file line number Diff line number Diff line change
@@ -1,31 +1,59 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2025.
// Copyright Christopher Kormanyos 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef MCAL_CPU_2009_02_14_H
#define MCAL_CPU_2009_02_14_H
#ifndef MCAL_CPU_2025_07_30_H
#define MCAL_CPU_2025_07_30_H

#if defined(__cplusplus)
#include <cstdint>
#else
#include <stdint.h>
#endif

extern "C" auto hw_acquire_spin_lock(volatile std::uint32_t*) noexcept -> void;
extern "C" auto hw_release_spin_lock(volatile std::uint32_t*) noexcept -> void;
#if defined(__cplusplus)
extern "C"
{
#endif

void mcal_cpu_secure_acquire_spin_lock(volatile uint32_t*);
void mcal_cpu_secure_release_spin_lock(volatile uint32_t*);

static inline void mcal_cpu_nop(void);

#if defined(__cplusplus)
}
#endif

#if defined(__cplusplus)
namespace mcal
{
namespace cpu
{
void init();
auto init() -> void;

inline auto post_init() -> void { }

inline auto nop() noexcept -> void { asm volatile("nop"); }

inline auto acquire_spin_lock(volatile std::uint32_t* p_sync) noexcept -> void { hw_acquire_spin_lock(p_sync); }
inline auto release_spin_lock(volatile std::uint32_t* p_sync) noexcept -> void { hw_release_spin_lock(p_sync); }
inline auto acquire_spin_lock(volatile std::uint32_t* p_sync) noexcept -> void { mcal_cpu_secure_acquire_spin_lock(p_sync); }
inline auto release_spin_lock(volatile std::uint32_t* p_sync) noexcept -> void { mcal_cpu_secure_release_spin_lock(p_sync); }
}
}
#endif

#if defined(__cplusplus)
extern "C"
{
#endif

static inline void mcal_cpu_nop(void) { __asm volatile("nop"); }

#if defined(__cplusplus)
}
#endif

#endif // MCAL_CPU_2009_02_14_H
#endif // MCAL_CPU_2025_07_30_H
12 changes: 6 additions & 6 deletions ref_app/src/mcal/am6254_soc/mcal_cpu_secure.s
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
// ***************************************************************************************

.section .text
.type hw_acquire_spin_lock,@function
.type mcal_cpu_secure_acquire_spin_lock,@function
.align 3
.globl hw_acquire_spin_lock
.globl mcal_cpu_secure_acquire_spin_lock

hw_acquire_spin_lock:
mcal_cpu_secure_acquire_spin_lock:
mov w1, #1
.L_loop:
ldaxr w2, [x0]
Expand All @@ -38,11 +38,11 @@ hw_acquire_spin_lock:
ret

.section .text
.type hw_release_spin_lock,@function
.type mcal_cpu_secure_release_spin_lock,@function
.align 3
.globl hw_release_spin_lock
.globl mcal_cpu_secure_release_spin_lock

hw_release_spin_lock:
mcal_cpu_secure_release_spin_lock:
dmb ish
stlr wzr, [x0]
ret
21 changes: 21 additions & 0 deletions ref_app/src/mcal/am6254_soc/mcal_eep.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#include <mcal_eep.h>

auto mcal::eep::write(const address_type addr, const std::uint8_t data) -> void
{
static_cast<void>(addr);
static_cast<void>(data);
}

auto mcal::eep::read(const address_type addr) -> std::uint8_t
{
static_cast<void>(addr);

return UINT8_C(0);
}
14 changes: 7 additions & 7 deletions ref_app/src/mcal/am6254_soc/mcal_eep.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2022.
// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef MCAL_EEP_2018_12_15_H_
#define MCAL_EEP_2018_12_15_H_
#ifndef MCAL_EEP_2018_12_15_H
#define MCAL_EEP_2018_12_15_H

#include <cstdint>

Expand All @@ -17,11 +17,11 @@
using config_type = void;
using address_type = std::uint32_t;

inline void init(const config_type*) { }
inline auto init(const config_type*) -> void { }

inline void write(const address_type addr, const std::uint8_t data) { static_cast<void>(addr); static_cast<void>(data); }
inline std::uint8_t read (const address_type addr) { static_cast<void>(addr); return UINT8_C(0); }
auto write(const address_type addr, const std::uint8_t data) -> void;
auto read (const address_type addr) -> std::uint8_t;
}
}

#endif // MCAL_EEP_2018_12_15_H_
#endif // MCAL_EEP_2018_12_15_H
12 changes: 12 additions & 0 deletions ref_app/src/mcal/am6254_soc/mcal_irq.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#include <mcal_irq.h>

auto mcal::irq::init(const config_type*) -> void
{
}
Loading
Loading