Skip to content

Commit 3213d07

Browse files
authored
Merge pull request #663 from ckormanyos/am6254_benches
Am6254 benches
2 parents 04acda9 + a44a0ee commit 3213d07

32 files changed

+683
-436
lines changed

ref_app/ref_app.vcxproj

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,18 +261,50 @@
261261
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
262262
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
263263
</ClCompile>
264+
<ClCompile Include="src\mcal\am6254_soc\mcal_cpu.cpp">
265+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
266+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
267+
</ClCompile>
264268
<ClCompile Include="src\mcal\am6254_soc\mcal_cpu_secure.s">
265269
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
266270
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
267271
</ClCompile>
272+
<ClCompile Include="src\mcal\am6254_soc\mcal_eep.cpp">
273+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
274+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
275+
</ClCompile>
268276
<ClCompile Include="src\mcal\am6254_soc\mcal_gpt.cpp">
269277
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
270278
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
271279
</ClCompile>
280+
<ClCompile Include="src\mcal\am6254_soc\mcal_irq.cpp">
281+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
282+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
283+
</ClCompile>
272284
<ClCompile Include="src\mcal\am6254_soc\mcal_led.cpp">
273285
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
274286
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
275287
</ClCompile>
288+
<ClCompile Include="src\mcal\am6254_soc\mcal_osc.cpp">
289+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
290+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
291+
</ClCompile>
292+
<ClCompile Include="src\mcal\am6254_soc\mcal_port.cpp">
293+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
294+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
295+
</ClCompile>
296+
<ClCompile Include="src\mcal\am6254_soc\mcal_pwm.cpp">
297+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
298+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
299+
</ClCompile>
300+
<ClCompile Include="src\mcal\am6254_soc\mcal_spi.cpp">
301+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
302+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
303+
</ClCompile>
304+
<ClCompile Include="src\mcal\am6254_soc\mcal_wdg.cpp">
305+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
306+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
307+
</ClCompile>
276308
<ClCompile Include="src\mcal\atmega2560\mcal_cpu.cpp">
277309
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
278310
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
@@ -1520,6 +1552,10 @@
15201552
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
15211553
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
15221554
</ClInclude>
1555+
<ClInclude Include="src\mcal\am6254_soc\mcal_osc.h">
1556+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
1557+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
1558+
</ClInclude>
15231559
<ClInclude Include="src\mcal\am6254_soc\mcal_port.h">
15241560
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
15251561
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>

ref_app/ref_app.vcxproj.filters

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,30 @@
12791279
<ClCompile Include="src\mcal\am6254_soc\mcal_cpu_secure.s">
12801280
<Filter>src\mcal\am6254_soc</Filter>
12811281
</ClCompile>
1282+
<ClCompile Include="src\mcal\am6254_soc\mcal_eep.cpp">
1283+
<Filter>src\mcal\am6254_soc</Filter>
1284+
</ClCompile>
1285+
<ClCompile Include="src\mcal\am6254_soc\mcal_cpu.cpp">
1286+
<Filter>src\mcal\am6254_soc</Filter>
1287+
</ClCompile>
1288+
<ClCompile Include="src\mcal\am6254_soc\mcal_irq.cpp">
1289+
<Filter>src\mcal\am6254_soc</Filter>
1290+
</ClCompile>
1291+
<ClCompile Include="src\mcal\am6254_soc\mcal_pwm.cpp">
1292+
<Filter>src\mcal\am6254_soc</Filter>
1293+
</ClCompile>
1294+
<ClCompile Include="src\mcal\am6254_soc\mcal_osc.cpp">
1295+
<Filter>src\mcal\am6254_soc</Filter>
1296+
</ClCompile>
1297+
<ClCompile Include="src\mcal\am6254_soc\mcal_port.cpp">
1298+
<Filter>src\mcal\am6254_soc</Filter>
1299+
</ClCompile>
1300+
<ClCompile Include="src\mcal\am6254_soc\mcal_wdg.cpp">
1301+
<Filter>src\mcal\am6254_soc</Filter>
1302+
</ClCompile>
1303+
<ClCompile Include="src\mcal\am6254_soc\mcal_spi.cpp">
1304+
<Filter>src\mcal\am6254_soc</Filter>
1305+
</ClCompile>
12821306
</ItemGroup>
12831307
<ItemGroup>
12841308
<ClInclude Include="src\math\calculus\derivative.h">
@@ -2922,6 +2946,9 @@
29222946
<ClInclude Include="src\mcal\am6254_soc\mcal_reg.h">
29232947
<Filter>src\mcal\am6254_soc</Filter>
29242948
</ClInclude>
2949+
<ClInclude Include="src\mcal\am6254_soc\mcal_osc.h">
2950+
<Filter>src\mcal\am6254_soc</Filter>
2951+
</ClInclude>
29252952
</ItemGroup>
29262953
<ItemGroup>
29272954
<None Include="src\util\STL\algorithm">

ref_app/src/app/benchmark/readme.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,44 +78,50 @@ $\pi$ using a Gauss AGM method with help
7878
from the [`decwide_t`](https://github.com/ckormanyos/real-time-cpp/blob/master/ref_app/src/math/wide_decimal/decwide_t.h)
7979
template class.
8080

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

8484
| Target | runtime $[ms]$ | relative |
8585
|--------------------|-----------------|------------|
86-
| `am335x` | 1.5 | 1.0 |
87-
| `stm32f446` | 5.1 | 3.4 |
88-
| `rpi_pico2_rp2350` | 6.3 | 4.2 |
89-
| `wch_ch32v307` | 8.0 | 5.3 |
90-
| `xtensa_esp32_s3` | 9.1 | 6.1 |
91-
| `rpi_pico_rp2040` | 19 | 13 |
92-
| `avr` | 420 | 280 |
86+
| `am6254_soc_` | 0.37 | 1.0 |
87+
| `am335x` | 1.5 | 4.0 |
88+
| `stm32f446` | 5.1 | 14 |
89+
| `rpi_pico2_rp2350` | 6.3 | 17 |
90+
| `wch_ch32v307` | 8.0 | 22 |
91+
| `xtensa_esp32_s3` | 9.1 | 25 |
92+
| `rpi_pico_rp2040` | 19 | 51 |
93+
| `avr` | 420 | 760 |
9394

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

103+
The $64$-bit ARM(R)v8-a (i.e., Cortex(R) A53) performs the
104+
calculation (running on one single A53 core of the PocketBeagle2 board)
105+
in $0.37~\text{ms.}$
106+
102107
The $32$-bit ARM(R) Cortex(R) M4F controller on
103108
the `stm32f446` board performs the calculation in
104109
the middle of the two extremes, with a result
105110
of $5.1~\text{ms}$.
106111

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

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

115120
Using only one core (core1) on the $32$-bit ARM(R) Cortex(R) M0+
116121
controller of the `rpi_pico_rp2040` board results in a calculation
117-
time of $19~\text{ms}$. The next generation `rpi_pico2_rp2350`
122+
time of $19~\text{ms.}~$
123+
The next generation `rpi_pico2_rp2350`
118124
with dual ARM(R) Cortex(R) M33 cores definitively improves on this
119-
(still using only core1) with a time of $6.3~\text{ms}$.
125+
(still using only core1) with a time of $6.3~\text{ms.}~$
120126
This is slightly more than $3~\text{ms}$ times faster
121127
than its predecessor.

ref_app/src/mcal/am6254_soc/mcal_benchmark.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
{
1818
namespace benchmark
1919
{
20-
typedef mcal::port::port_pin<mcal::reg::gpio0, 2U> benchmark_port_type;
20+
using benchmark_port_type = mcal::port::port_pin<mcal::reg::gpio0, 36U>;
2121
}
2222
}
2323

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright Christopher Kormanyos 2007 - 2025.
3+
// Distributed under the Boost Software License,
4+
// Version 1.0. (See accompanying file LICENSE_1_0.txt
5+
// or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
//
7+
8+
#include <mcal_cpu.h>
9+
10+
auto mcal::cpu::init() -> void
11+
{
12+
}
Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,59 @@
11
///////////////////////////////////////////////////////////////////////////////
2-
// Copyright Christopher Kormanyos 2007 - 2025.
2+
// Copyright Christopher Kormanyos 2025.
33
// Distributed under the Boost Software License,
44
// Version 1.0. (See accompanying file LICENSE_1_0.txt
55
// or copy at http://www.boost.org/LICENSE_1_0.txt)
66
//
77

8-
#ifndef MCAL_CPU_2009_02_14_H
9-
#define MCAL_CPU_2009_02_14_H
8+
#ifndef MCAL_CPU_2025_07_30_H
9+
#define MCAL_CPU_2025_07_30_H
1010

11+
#if defined(__cplusplus)
1112
#include <cstdint>
13+
#else
14+
#include <stdint.h>
15+
#endif
1216

13-
extern "C" auto hw_acquire_spin_lock(volatile std::uint32_t*) noexcept -> void;
14-
extern "C" auto hw_release_spin_lock(volatile std::uint32_t*) noexcept -> void;
17+
#if defined(__cplusplus)
18+
extern "C"
19+
{
20+
#endif
21+
22+
void mcal_cpu_secure_acquire_spin_lock(volatile uint32_t*);
23+
void mcal_cpu_secure_release_spin_lock(volatile uint32_t*);
24+
25+
static inline void mcal_cpu_nop(void);
26+
27+
#if defined(__cplusplus)
28+
}
29+
#endif
1530

31+
#if defined(__cplusplus)
1632
namespace mcal
1733
{
1834
namespace cpu
1935
{
20-
void init();
36+
auto init() -> void;
2137

2238
inline auto post_init() -> void { }
2339

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

26-
inline auto acquire_spin_lock(volatile std::uint32_t* p_sync) noexcept -> void { hw_acquire_spin_lock(p_sync); }
27-
inline auto release_spin_lock(volatile std::uint32_t* p_sync) noexcept -> void { hw_release_spin_lock(p_sync); }
42+
inline auto acquire_spin_lock(volatile std::uint32_t* p_sync) noexcept -> void { mcal_cpu_secure_acquire_spin_lock(p_sync); }
43+
inline auto release_spin_lock(volatile std::uint32_t* p_sync) noexcept -> void { mcal_cpu_secure_release_spin_lock(p_sync); }
2844
}
2945
}
46+
#endif
47+
48+
#if defined(__cplusplus)
49+
extern "C"
50+
{
51+
#endif
52+
53+
static inline void mcal_cpu_nop(void) { __asm volatile("nop"); }
54+
55+
#if defined(__cplusplus)
56+
}
57+
#endif
3058

31-
#endif // MCAL_CPU_2009_02_14_H
59+
#endif // MCAL_CPU_2025_07_30_H

ref_app/src/mcal/am6254_soc/mcal_cpu_secure.s

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
// ***************************************************************************************
2424

2525
.section .text
26-
.type hw_acquire_spin_lock,@function
26+
.type mcal_cpu_secure_acquire_spin_lock,@function
2727
.align 3
28-
.globl hw_acquire_spin_lock
28+
.globl mcal_cpu_secure_acquire_spin_lock
2929

30-
hw_acquire_spin_lock:
30+
mcal_cpu_secure_acquire_spin_lock:
3131
mov w1, #1
3232
.L_loop:
3333
ldaxr w2, [x0]
@@ -38,11 +38,11 @@ hw_acquire_spin_lock:
3838
ret
3939

4040
.section .text
41-
.type hw_release_spin_lock,@function
41+
.type mcal_cpu_secure_release_spin_lock,@function
4242
.align 3
43-
.globl hw_release_spin_lock
43+
.globl mcal_cpu_secure_release_spin_lock
4444

45-
hw_release_spin_lock:
45+
mcal_cpu_secure_release_spin_lock:
4646
dmb ish
4747
stlr wzr, [x0]
4848
ret
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright Christopher Kormanyos 2007 - 2025.
3+
// Distributed under the Boost Software License,
4+
// Version 1.0. (See accompanying file LICENSE_1_0.txt
5+
// or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
//
7+
8+
#include <mcal_eep.h>
9+
10+
auto mcal::eep::write(const address_type addr, const std::uint8_t data) -> void
11+
{
12+
static_cast<void>(addr);
13+
static_cast<void>(data);
14+
}
15+
16+
auto mcal::eep::read(const address_type addr) -> std::uint8_t
17+
{
18+
static_cast<void>(addr);
19+
20+
return UINT8_C(0);
21+
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
///////////////////////////////////////////////////////////////////////////////
2-
// Copyright Christopher Kormanyos 2007 - 2022.
2+
// Copyright Christopher Kormanyos 2007 - 2025.
33
// Distributed under the Boost Software License,
44
// Version 1.0. (See accompanying file LICENSE_1_0.txt
55
// or copy at http://www.boost.org/LICENSE_1_0.txt)
66
//
77

8-
#ifndef MCAL_EEP_2018_12_15_H_
9-
#define MCAL_EEP_2018_12_15_H_
8+
#ifndef MCAL_EEP_2018_12_15_H
9+
#define MCAL_EEP_2018_12_15_H
1010

1111
#include <cstdint>
1212

@@ -17,11 +17,11 @@
1717
using config_type = void;
1818
using address_type = std::uint32_t;
1919

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

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

27-
#endif // MCAL_EEP_2018_12_15_H_
27+
#endif // MCAL_EEP_2018_12_15_H
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright Christopher Kormanyos 2007 - 2025.
3+
// Distributed under the Boost Software License,
4+
// Version 1.0. (See accompanying file LICENSE_1_0.txt
5+
// or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
//
7+
8+
#include <mcal_irq.h>
9+
10+
auto mcal::irq::init(const config_type*) -> void
11+
{
12+
}

0 commit comments

Comments
 (0)