Compare commits
No commits in common. "f99db9409f88f7c59b783ac10cdbaae7f5960ed4" and "339d6b0f2c4c457a1d054cc9d8db89d2e6b2c7b0" have entirely different histories.
f99db9409f
...
339d6b0f2c
@ -1 +1 @@
|
|||||||
Subproject commit 6e2a7a12fe59238fca0a807cee68f3a4a2678c5c
|
Subproject commit f21ea46befe7401cc35205d3b64e3991504b6289
|
@ -1,31 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.21)
|
|
||||||
project(coremark C)
|
|
||||||
set(TARGET coremark)
|
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
|
||||||
|
|
||||||
# Source files
|
|
||||||
set(SOURCES
|
|
||||||
core_portme.c
|
|
||||||
cvt.c
|
|
||||||
ee_printf.c
|
|
||||||
cm/core_list_join.c
|
|
||||||
cm/core_main.c
|
|
||||||
cm/core_matrix.c
|
|
||||||
cm/core_state.c
|
|
||||||
cm/core_util.c
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create executable
|
|
||||||
add_executable(coremark ${SOURCES})
|
|
||||||
target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/cm)
|
|
||||||
target_compile_options(${TARGET} PRIVATE -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -fno-builtin-strnlen -fno-common -funroll-loops -finline-functions -falign-functions=16 -falign-jumps=4 -falign-loops=4 -finline-limit=1000 -fno-if-conversion2 -fselective-scheduling -fno-crossjumping -freorder-blocks-and-partition -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -fno-common -funroll-loops -finline-functions -falign-functions=16 -falign-jumps=4 -falign-loops=4 -finline-limit=1000 -fno-if-conversion2 -fselective-scheduling -fno-crossjumping -freorder-blocks-and-partition )
|
|
||||||
target_compile_definitions(${TARGET} PRIVATE PERFORMANCE_RUN=1 CLOCKS_PER_SEC=10000000 FLAGS_STR="" PERFORMANCE_RUN=1 CLOCKS_PER_SEC=10000000 ITERATIONS=600)
|
|
||||||
|
|
||||||
set(BOARD "iss" CACHE STRING "Target board")
|
|
||||||
add_subdirectory(../../bare-metal-bsp bsp)
|
|
||||||
target_link_libraries(${TARGET} PRIVATE bsp)
|
|
||||||
target_link_options(${TARGET} PRIVATE LINKER:-Map=${TARGET}.map)
|
|
||||||
|
|
||||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
|
||||||
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
|
|
||||||
COMMENT "Creating disassembly for ${TARGET}")
|
|
@ -1,109 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 3,
|
|
||||||
"vendor": {
|
|
||||||
"conan": {}
|
|
||||||
},
|
|
||||||
"cmakeMinimumRequired": {
|
|
||||||
"major": 3,
|
|
||||||
"minor": 24,
|
|
||||||
"patch": 0
|
|
||||||
},
|
|
||||||
"configurePresets": [
|
|
||||||
{
|
|
||||||
"name": "ISS_Debug",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "iss",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Moonlight_Debug",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "TGC_Debug",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ISS_Debug_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "iss",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Moonlight_Debug_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "TGC_Debug_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ISS_Release",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "iss",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Moonlight_Release",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "TGC_Release",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ISS_Release_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "iss",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Moonlight_Release_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "TGC_Release_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -15,58 +15,55 @@ limitations under the License.
|
|||||||
|
|
||||||
Original Author: Shay Gal-on
|
Original Author: Shay Gal-on
|
||||||
*/
|
*/
|
||||||
#include "core_portme.h"
|
|
||||||
#include "coremark.h"
|
#include "coremark.h"
|
||||||
#include <unistd.h>
|
#include "core_portme.h"
|
||||||
// Read cycle CSR
|
//Read cycle CSR
|
||||||
unsigned long long _read_cycle() {
|
unsigned long long _read_cycle()
|
||||||
|
{
|
||||||
unsigned long long result;
|
unsigned long long result;
|
||||||
unsigned long lower;
|
unsigned long lower;
|
||||||
unsigned long upper1;
|
unsigned long upper1;
|
||||||
unsigned long upper2;
|
unsigned long upper2;
|
||||||
|
|
||||||
asm volatile("repeat_cycle_%=: csrr %0, cycleh;\n"
|
asm volatile (
|
||||||
|
"repeat_cycle_%=: csrr %0, cycleh;\n"
|
||||||
" csrr %1, cycle;\n"
|
" csrr %1, cycle;\n"
|
||||||
" csrr %2, cycleh;\n"
|
" csrr %2, cycleh;\n"
|
||||||
" bne %0, %2, repeat_cycle_%=;\n"
|
" bne %0, %2, repeat_cycle_%=;\n"
|
||||||
: "=r"(upper1), "=r"(lower),
|
: "=r" (upper1),"=r" (lower),"=r" (upper2) // Outputs : temp variable for load result
|
||||||
"=r"(upper2) // Outputs : temp variable for load result
|
|
||||||
:
|
:
|
||||||
:);
|
:
|
||||||
|
);
|
||||||
*(unsigned long *)(&result) = lower;
|
*(unsigned long *)(&result) = lower;
|
||||||
*((unsigned long *)(&result) + 1) = upper1;
|
*((unsigned long *)(&result)+1) = upper1;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// extern volatile int tohost;
|
volatile int tohost;
|
||||||
// extern volatile int fromhost;
|
volatile int fromhost;
|
||||||
|
|
||||||
void write_hex(int fd, uint32_t hex);
|
void exit(int n){
|
||||||
|
tohost = 0x1;
|
||||||
void exit(int n) {
|
for (;;);
|
||||||
write_hex(STDERR_FILENO, 1);
|
|
||||||
// tohost = 0x1;
|
|
||||||
for (;;)
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __libc_init_array(void) {
|
void __libc_init_array (void) {
|
||||||
/*
|
/*
|
||||||
size_t count;
|
size_t count;
|
||||||
size_t i;
|
size_t i;
|
||||||
count = __preinit_array_end - __preinit_array_start;
|
count = __preinit_array_end - __preinit_array_start;
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
__preinit_array_start[i] ();
|
__preinit_array_start[i] ();
|
||||||
|
|
||||||
#ifdef HAVE_INIT_FINI
|
#ifdef HAVE_INIT_FINI
|
||||||
_init ();
|
_init ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
count = __init_array_end - __init_array_start;
|
count = __init_array_end - __init_array_start;
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
__init_array_start[i] ();
|
__init_array_start[i] ();
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
#if VALIDATION_RUN
|
#if VALIDATION_RUN
|
||||||
volatile ee_s32 seed1_volatile = 0x3415;
|
volatile ee_s32 seed1_volatile = 0x3415;
|
||||||
@ -92,7 +89,10 @@ volatile ee_s32 seed5_volatile = 0;
|
|||||||
time.h and windows.h definitions included.
|
time.h and windows.h definitions included.
|
||||||
*/
|
*/
|
||||||
CORETIMETYPE
|
CORETIMETYPE
|
||||||
barebones_clock() { return (CORETIMETYPE)_read_cycle(); }
|
barebones_clock()
|
||||||
|
{
|
||||||
|
return (CORETIMETYPE)_read_cycle();
|
||||||
|
}
|
||||||
/* Define : TIMER_RES_DIVIDER
|
/* Define : TIMER_RES_DIVIDER
|
||||||
Divider to trade off timer resolution and total time that can be
|
Divider to trade off timer resolution and total time that can be
|
||||||
measured.
|
measured.
|
||||||
@ -118,7 +118,11 @@ static CORETIMETYPE start_time_val, stop_time_val;
|
|||||||
example code) or zeroing some system parameters - e.g. setting the cpu clocks
|
example code) or zeroing some system parameters - e.g. setting the cpu clocks
|
||||||
cycles to 0.
|
cycles to 0.
|
||||||
*/
|
*/
|
||||||
void start_time(void) { GETMYTIME(&start_time_val); }
|
void
|
||||||
|
start_time(void)
|
||||||
|
{
|
||||||
|
GETMYTIME(&start_time_val);
|
||||||
|
}
|
||||||
/* Function : stop_time
|
/* Function : stop_time
|
||||||
This function will be called right after ending the timed portion of the
|
This function will be called right after ending the timed portion of the
|
||||||
benchmark.
|
benchmark.
|
||||||
@ -127,7 +131,11 @@ void start_time(void) { GETMYTIME(&start_time_val); }
|
|||||||
example code) or other system parameters - e.g. reading the current value of
|
example code) or other system parameters - e.g. reading the current value of
|
||||||
cpu cycles counter.
|
cpu cycles counter.
|
||||||
*/
|
*/
|
||||||
void stop_time(void) { GETMYTIME(&stop_time_val); }
|
void
|
||||||
|
stop_time(void)
|
||||||
|
{
|
||||||
|
GETMYTIME(&stop_time_val);
|
||||||
|
}
|
||||||
/* Function : get_time
|
/* Function : get_time
|
||||||
Return an abstract "ticks" number that signifies time on the system.
|
Return an abstract "ticks" number that signifies time on the system.
|
||||||
|
|
||||||
@ -138,8 +146,10 @@ void stop_time(void) { GETMYTIME(&stop_time_val); }
|
|||||||
controlled by <TIMER_RES_DIVIDER>
|
controlled by <TIMER_RES_DIVIDER>
|
||||||
*/
|
*/
|
||||||
CORE_TICKS
|
CORE_TICKS
|
||||||
get_time(void) {
|
get_time(void)
|
||||||
CORE_TICKS elapsed = (CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
|
{
|
||||||
|
CORE_TICKS elapsed
|
||||||
|
= (CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
|
||||||
return elapsed;
|
return elapsed;
|
||||||
}
|
}
|
||||||
/* Function : time_in_secs
|
/* Function : time_in_secs
|
||||||
@ -149,7 +159,9 @@ get_time(void) {
|
|||||||
floating point. Default implementation implemented by the EE_TICKS_PER_SEC
|
floating point. Default implementation implemented by the EE_TICKS_PER_SEC
|
||||||
macro above.
|
macro above.
|
||||||
*/
|
*/
|
||||||
secs_ret time_in_secs(CORE_TICKS ticks) {
|
secs_ret
|
||||||
|
time_in_secs(CORE_TICKS ticks)
|
||||||
|
{
|
||||||
secs_ret retval = ((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
|
secs_ret retval = ((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -160,12 +172,17 @@ ee_u32 default_num_contexts = 1;
|
|||||||
Target specific initialization code
|
Target specific initialization code
|
||||||
Test for some common mistakes.
|
Test for some common mistakes.
|
||||||
*/
|
*/
|
||||||
void portable_init(core_portable *p, int *argc, char *argv[]) {
|
void
|
||||||
if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
|
portable_init(core_portable *p, int *argc, char *argv[])
|
||||||
ee_printf("ERROR! Please define ee_ptr_int to a type that holds a "
|
{
|
||||||
|
if (sizeof(ee_ptr_int) != sizeof(ee_u8 *))
|
||||||
|
{
|
||||||
|
ee_printf(
|
||||||
|
"ERROR! Please define ee_ptr_int to a type that holds a "
|
||||||
"pointer!\n");
|
"pointer!\n");
|
||||||
}
|
}
|
||||||
if (sizeof(ee_u32) != 4) {
|
if (sizeof(ee_u32) != 4)
|
||||||
|
{
|
||||||
ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
|
ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
|
||||||
}
|
}
|
||||||
p->portable_id = 1;
|
p->portable_id = 1;
|
||||||
@ -174,4 +191,8 @@ void portable_init(core_portable *p, int *argc, char *argv[]) {
|
|||||||
/* Function : portable_fini
|
/* Function : portable_fini
|
||||||
Target specific final code
|
Target specific final code
|
||||||
*/
|
*/
|
||||||
void portable_fini(core_portable *p) { p->portable_id = 0; }
|
void
|
||||||
|
portable_fini(core_portable *p)
|
||||||
|
{
|
||||||
|
p->portable_id = 0;
|
||||||
|
}
|
||||||
|
@ -16,7 +16,6 @@ limitations under the License.
|
|||||||
|
|
||||||
#include <coremark.h>
|
#include <coremark.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#define ZEROPAD (1 << 0) /* Pad with zero */
|
#define ZEROPAD (1 << 0) /* Pad with zero */
|
||||||
#define SIGN (1 << 1) /* Unsigned/signed long */
|
#define SIGN (1 << 1) /* Unsigned/signed long */
|
||||||
@ -28,26 +27,31 @@ limitations under the License.
|
|||||||
|
|
||||||
#define is_digit(c) ((c) >= '0' && (c) <= '9')
|
#define is_digit(c) ((c) >= '0' && (c) <= '9')
|
||||||
|
|
||||||
static char *digits = "0123456789abcdefghijklmnopqrstuvwxyz";
|
static char * digits = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||||
static char *upper_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
static char * upper_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
static ee_size_t strnlen(const char *s, ee_size_t count);
|
static ee_size_t strnlen(const char *s, ee_size_t count);
|
||||||
|
|
||||||
static ee_size_t strnlen(const char *s, ee_size_t count) {
|
static ee_size_t
|
||||||
|
strnlen(const char *s, ee_size_t count)
|
||||||
|
{
|
||||||
const char *sc;
|
const char *sc;
|
||||||
for (sc = s; *sc != '\0' && count--; ++sc)
|
for (sc = s; *sc != '\0' && count--; ++sc)
|
||||||
;
|
;
|
||||||
return sc - s;
|
return sc - s;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int skip_atoi(const char **s) {
|
static int
|
||||||
|
skip_atoi(const char **s)
|
||||||
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (is_digit(**s))
|
while (is_digit(**s))
|
||||||
i = i * 10 + *((*s)++) - '0';
|
i = i * 10 + *((*s)++) - '0';
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *number(char *str, long num, int base, int size, int precision,
|
static char *
|
||||||
int type) {
|
number(char *str, long num, int base, int size, int precision, int type)
|
||||||
|
{
|
||||||
char c, sign, tmp[66];
|
char c, sign, tmp[66];
|
||||||
char *dig = digits;
|
char *dig = digits;
|
||||||
int i;
|
int i;
|
||||||
@ -61,21 +65,28 @@ static char *number(char *str, long num, int base, int size, int precision,
|
|||||||
|
|
||||||
c = (type & ZEROPAD) ? '0' : ' ';
|
c = (type & ZEROPAD) ? '0' : ' ';
|
||||||
sign = 0;
|
sign = 0;
|
||||||
if (type & SIGN) {
|
if (type & SIGN)
|
||||||
if (num < 0) {
|
{
|
||||||
|
if (num < 0)
|
||||||
|
{
|
||||||
sign = '-';
|
sign = '-';
|
||||||
num = -num;
|
num = -num;
|
||||||
size--;
|
size--;
|
||||||
} else if (type & PLUS) {
|
}
|
||||||
|
else if (type & PLUS)
|
||||||
|
{
|
||||||
sign = '+';
|
sign = '+';
|
||||||
size--;
|
size--;
|
||||||
} else if (type & SPACE) {
|
}
|
||||||
|
else if (type & SPACE)
|
||||||
|
{
|
||||||
sign = ' ';
|
sign = ' ';
|
||||||
size--;
|
size--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type & HEX_PREP) {
|
if (type & HEX_PREP)
|
||||||
|
{
|
||||||
if (base == 16)
|
if (base == 16)
|
||||||
size -= 2;
|
size -= 2;
|
||||||
else if (base == 8)
|
else if (base == 8)
|
||||||
@ -86,8 +97,10 @@ static char *number(char *str, long num, int base, int size, int precision,
|
|||||||
|
|
||||||
if (num == 0)
|
if (num == 0)
|
||||||
tmp[i++] = '0';
|
tmp[i++] = '0';
|
||||||
else {
|
else
|
||||||
while (num != 0) {
|
{
|
||||||
|
while (num != 0)
|
||||||
|
{
|
||||||
tmp[i++] = dig[((unsigned long)num) % (unsigned)base];
|
tmp[i++] = dig[((unsigned long)num) % (unsigned)base];
|
||||||
num = ((unsigned long)num) / (unsigned)base;
|
num = ((unsigned long)num) / (unsigned)base;
|
||||||
}
|
}
|
||||||
@ -102,10 +115,12 @@ static char *number(char *str, long num, int base, int size, int precision,
|
|||||||
if (sign)
|
if (sign)
|
||||||
*str++ = sign;
|
*str++ = sign;
|
||||||
|
|
||||||
if (type & HEX_PREP) {
|
if (type & HEX_PREP)
|
||||||
|
{
|
||||||
if (base == 8)
|
if (base == 8)
|
||||||
*str++ = '0';
|
*str++ = '0';
|
||||||
else if (base == 16) {
|
else if (base == 16)
|
||||||
|
{
|
||||||
*str++ = '0';
|
*str++ = '0';
|
||||||
*str++ = digits[33];
|
*str++ = digits[33];
|
||||||
}
|
}
|
||||||
@ -124,8 +139,9 @@ static char *number(char *str, long num, int base, int size, int precision,
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *eaddr(char *str, unsigned char *addr, int size, int precision,
|
static char *
|
||||||
int type) {
|
eaddr(char *str, unsigned char *addr, int size, int precision, int type)
|
||||||
|
{
|
||||||
char tmp[24];
|
char tmp[24];
|
||||||
char *dig = digits;
|
char *dig = digits;
|
||||||
int i, len;
|
int i, len;
|
||||||
@ -133,7 +149,8 @@ static char *eaddr(char *str, unsigned char *addr, int size, int precision,
|
|||||||
if (type & UPPERCASE)
|
if (type & UPPERCASE)
|
||||||
dig = upper_digits;
|
dig = upper_digits;
|
||||||
len = 0;
|
len = 0;
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
tmp[len++] = ':';
|
tmp[len++] = ':';
|
||||||
tmp[len++] = dig[addr[i] >> 4];
|
tmp[len++] = dig[addr[i] >> 4];
|
||||||
@ -151,26 +168,32 @@ static char *eaddr(char *str, unsigned char *addr, int size, int precision,
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *iaddr(char *str, unsigned char *addr, int size, int precision,
|
static char *
|
||||||
int type) {
|
iaddr(char *str, unsigned char *addr, int size, int precision, int type)
|
||||||
|
{
|
||||||
char tmp[24];
|
char tmp[24];
|
||||||
int i, n, len;
|
int i, n, len;
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
tmp[len++] = '.';
|
tmp[len++] = '.';
|
||||||
n = addr[i];
|
n = addr[i];
|
||||||
|
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
tmp[len++] = digits[0];
|
tmp[len++] = digits[0];
|
||||||
else {
|
else
|
||||||
if (n >= 100) {
|
{
|
||||||
|
if (n >= 100)
|
||||||
|
{
|
||||||
tmp[len++] = digits[n / 100];
|
tmp[len++] = digits[n / 100];
|
||||||
n = n % 100;
|
n = n % 100;
|
||||||
tmp[len++] = digits[n / 10];
|
tmp[len++] = digits[n / 10];
|
||||||
n = n % 10;
|
n = n % 10;
|
||||||
} else if (n >= 10) {
|
}
|
||||||
|
else if (n >= 10)
|
||||||
|
{
|
||||||
tmp[len++] = digits[n / 10];
|
tmp[len++] = digits[n / 10];
|
||||||
n = n % 10;
|
n = n % 10;
|
||||||
}
|
}
|
||||||
@ -192,41 +215,51 @@ static char *iaddr(char *str, unsigned char *addr, int size, int precision,
|
|||||||
|
|
||||||
#if HAS_FLOAT
|
#if HAS_FLOAT
|
||||||
|
|
||||||
char *ecvtbuf(double arg, int ndigits, int *decpt, int *sign, char *buf);
|
char * ecvtbuf(double arg, int ndigits, int *decpt, int *sign, char *buf);
|
||||||
char *fcvtbuf(double arg, int ndigits, int *decpt, int *sign, char *buf);
|
char * fcvtbuf(double arg, int ndigits, int *decpt, int *sign, char *buf);
|
||||||
static void ee_bufcpy(char *d, char *s, int count);
|
static void ee_bufcpy(char *d, char *s, int count);
|
||||||
|
|
||||||
void ee_bufcpy(char *pd, char *ps, int count) {
|
void
|
||||||
|
ee_bufcpy(char *pd, char *ps, int count)
|
||||||
|
{
|
||||||
char *pe = ps + count;
|
char *pe = ps + count;
|
||||||
while (ps != pe)
|
while (ps != pe)
|
||||||
*pd++ = *ps++;
|
*pd++ = *ps++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_float(double value, char *buffer, char fmt, int precision) {
|
static void
|
||||||
|
parse_float(double value, char *buffer, char fmt, int precision)
|
||||||
|
{
|
||||||
int decpt, sign, exp, pos;
|
int decpt, sign, exp, pos;
|
||||||
char *digits = NULL;
|
char *digits = NULL;
|
||||||
char cvtbuf[80];
|
char cvtbuf[80];
|
||||||
int capexp = 0;
|
int capexp = 0;
|
||||||
int magnitude;
|
int magnitude;
|
||||||
|
|
||||||
if (fmt == 'G' || fmt == 'E') {
|
if (fmt == 'G' || fmt == 'E')
|
||||||
|
{
|
||||||
capexp = 1;
|
capexp = 1;
|
||||||
fmt += 'a' - 'A';
|
fmt += 'a' - 'A';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fmt == 'g') {
|
if (fmt == 'g')
|
||||||
|
{
|
||||||
digits = ecvtbuf(value, precision, &decpt, &sign, cvtbuf);
|
digits = ecvtbuf(value, precision, &decpt, &sign, cvtbuf);
|
||||||
magnitude = decpt - 1;
|
magnitude = decpt - 1;
|
||||||
if (magnitude < -4 || magnitude > precision - 1) {
|
if (magnitude < -4 || magnitude > precision - 1)
|
||||||
|
{
|
||||||
fmt = 'e';
|
fmt = 'e';
|
||||||
precision -= 1;
|
precision -= 1;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
fmt = 'f';
|
fmt = 'f';
|
||||||
precision -= decpt;
|
precision -= decpt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fmt == 'e') {
|
if (fmt == 'e')
|
||||||
|
{
|
||||||
digits = ecvtbuf(value, precision + 1, &decpt, &sign, cvtbuf);
|
digits = ecvtbuf(value, precision + 1, &decpt, &sign, cvtbuf);
|
||||||
|
|
||||||
if (sign)
|
if (sign)
|
||||||
@ -238,18 +271,22 @@ static void parse_float(double value, char *buffer, char fmt, int precision) {
|
|||||||
buffer += precision;
|
buffer += precision;
|
||||||
*buffer++ = capexp ? 'E' : 'e';
|
*buffer++ = capexp ? 'E' : 'e';
|
||||||
|
|
||||||
if (decpt == 0) {
|
if (decpt == 0)
|
||||||
|
{
|
||||||
if (value == 0.0)
|
if (value == 0.0)
|
||||||
exp = 0;
|
exp = 0;
|
||||||
else
|
else
|
||||||
exp = -1;
|
exp = -1;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
exp = decpt - 1;
|
exp = decpt - 1;
|
||||||
|
|
||||||
if (exp < 0) {
|
if (exp < 0)
|
||||||
|
{
|
||||||
*buffer++ = '-';
|
*buffer++ = '-';
|
||||||
exp = -exp;
|
exp = -exp;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
*buffer++ = '+';
|
*buffer++ = '+';
|
||||||
|
|
||||||
buffer[2] = (exp % 10) + '0';
|
buffer[2] = (exp % 10) + '0';
|
||||||
@ -258,29 +295,39 @@ static void parse_float(double value, char *buffer, char fmt, int precision) {
|
|||||||
exp = exp / 10;
|
exp = exp / 10;
|
||||||
buffer[0] = (exp % 10) + '0';
|
buffer[0] = (exp % 10) + '0';
|
||||||
buffer += 3;
|
buffer += 3;
|
||||||
} else if (fmt == 'f') {
|
}
|
||||||
|
else if (fmt == 'f')
|
||||||
|
{
|
||||||
digits = fcvtbuf(value, precision, &decpt, &sign, cvtbuf);
|
digits = fcvtbuf(value, precision, &decpt, &sign, cvtbuf);
|
||||||
if (sign)
|
if (sign)
|
||||||
*buffer++ = '-';
|
*buffer++ = '-';
|
||||||
if (*digits) {
|
if (*digits)
|
||||||
if (decpt <= 0) {
|
{
|
||||||
|
if (decpt <= 0)
|
||||||
|
{
|
||||||
*buffer++ = '0';
|
*buffer++ = '0';
|
||||||
*buffer++ = '.';
|
*buffer++ = '.';
|
||||||
for (pos = 0; pos < -decpt; pos++)
|
for (pos = 0; pos < -decpt; pos++)
|
||||||
*buffer++ = '0';
|
*buffer++ = '0';
|
||||||
while (*digits)
|
while (*digits)
|
||||||
*buffer++ = *digits++;
|
*buffer++ = *digits++;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
pos = 0;
|
pos = 0;
|
||||||
while (*digits) {
|
while (*digits)
|
||||||
|
{
|
||||||
if (pos++ == decpt)
|
if (pos++ == decpt)
|
||||||
*buffer++ = '.';
|
*buffer++ = '.';
|
||||||
*buffer++ = *digits++;
|
*buffer++ = *digits++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
*buffer++ = '0';
|
*buffer++ = '0';
|
||||||
if (precision > 0) {
|
if (precision > 0)
|
||||||
|
{
|
||||||
*buffer++ = '.';
|
*buffer++ = '.';
|
||||||
for (pos = 0; pos < precision; pos++)
|
for (pos = 0; pos < precision; pos++)
|
||||||
*buffer++ = '0';
|
*buffer++ = '0';
|
||||||
@ -291,8 +338,11 @@ static void parse_float(double value, char *buffer, char fmt, int precision) {
|
|||||||
*buffer = '\0';
|
*buffer = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
static void decimal_point(char *buffer) {
|
static void
|
||||||
while (*buffer) {
|
decimal_point(char *buffer)
|
||||||
|
{
|
||||||
|
while (*buffer)
|
||||||
|
{
|
||||||
if (*buffer == '.')
|
if (*buffer == '.')
|
||||||
return;
|
return;
|
||||||
if (*buffer == 'e' || *buffer == 'E')
|
if (*buffer == 'e' || *buffer == 'E')
|
||||||
@ -300,26 +350,33 @@ static void decimal_point(char *buffer) {
|
|||||||
buffer++;
|
buffer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*buffer) {
|
if (*buffer)
|
||||||
|
{
|
||||||
int n = strnlen(buffer, 256);
|
int n = strnlen(buffer, 256);
|
||||||
while (n > 0) {
|
while (n > 0)
|
||||||
|
{
|
||||||
buffer[n + 1] = buffer[n];
|
buffer[n + 1] = buffer[n];
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
|
|
||||||
*buffer = '.';
|
*buffer = '.';
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
*buffer++ = '.';
|
*buffer++ = '.';
|
||||||
*buffer = '\0';
|
*buffer = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cropzeros(char *buffer) {
|
static void
|
||||||
|
cropzeros(char *buffer)
|
||||||
|
{
|
||||||
char *stop;
|
char *stop;
|
||||||
|
|
||||||
while (*buffer && *buffer != '.')
|
while (*buffer && *buffer != '.')
|
||||||
buffer++;
|
buffer++;
|
||||||
if (*buffer++) {
|
if (*buffer++)
|
||||||
|
{
|
||||||
while (*buffer && *buffer != 'e' && *buffer != 'E')
|
while (*buffer && *buffer != 'e' && *buffer != 'E')
|
||||||
buffer++;
|
buffer++;
|
||||||
stop = buffer--;
|
stop = buffer--;
|
||||||
@ -332,8 +389,9 @@ static void cropzeros(char *buffer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *flt(char *str, double num, int size, int precision, char fmt,
|
static char *
|
||||||
int flags) {
|
flt(char *str, double num, int size, int precision, char fmt, int flags)
|
||||||
|
{
|
||||||
char tmp[80];
|
char tmp[80];
|
||||||
char c, sign;
|
char c, sign;
|
||||||
int n, i;
|
int n, i;
|
||||||
@ -345,15 +403,21 @@ static char *flt(char *str, double num, int size, int precision, char fmt,
|
|||||||
// Determine padding and sign char
|
// Determine padding and sign char
|
||||||
c = (flags & ZEROPAD) ? '0' : ' ';
|
c = (flags & ZEROPAD) ? '0' : ' ';
|
||||||
sign = 0;
|
sign = 0;
|
||||||
if (flags & SIGN) {
|
if (flags & SIGN)
|
||||||
if (num < 0.0) {
|
{
|
||||||
|
if (num < 0.0)
|
||||||
|
{
|
||||||
sign = '-';
|
sign = '-';
|
||||||
num = -num;
|
num = -num;
|
||||||
size--;
|
size--;
|
||||||
} else if (flags & PLUS) {
|
}
|
||||||
|
else if (flags & PLUS)
|
||||||
|
{
|
||||||
sign = '+';
|
sign = '+';
|
||||||
size--;
|
size--;
|
||||||
} else if (flags & SPACE) {
|
}
|
||||||
|
else if (flags & SPACE)
|
||||||
|
{
|
||||||
sign = ' ';
|
sign = ' ';
|
||||||
size--;
|
size--;
|
||||||
}
|
}
|
||||||
@ -393,12 +457,14 @@ static char *flt(char *str, double num, int size, int precision, char fmt,
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int ee_vsprintf(char *buf, const char *fmt, va_list args) {
|
static int
|
||||||
|
ee_vsprintf(char *buf, const char *fmt, va_list args)
|
||||||
|
{
|
||||||
int len;
|
int len;
|
||||||
unsigned long num;
|
unsigned long num;
|
||||||
int i, base;
|
int i, base;
|
||||||
char *str;
|
char * str;
|
||||||
char *s;
|
char * s;
|
||||||
|
|
||||||
int flags; // Flags to number()
|
int flags; // Flags to number()
|
||||||
|
|
||||||
@ -407,8 +473,10 @@ static int ee_vsprintf(char *buf, const char *fmt, va_list args) {
|
|||||||
// from string
|
// from string
|
||||||
int qualifier; // 'h', 'l', or 'L' for integer fields
|
int qualifier; // 'h', 'l', or 'L' for integer fields
|
||||||
|
|
||||||
for (str = buf; *fmt; fmt++) {
|
for (str = buf; *fmt; fmt++)
|
||||||
if (*fmt != '%') {
|
{
|
||||||
|
if (*fmt != '%')
|
||||||
|
{
|
||||||
*str++ = *fmt;
|
*str++ = *fmt;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -417,7 +485,8 @@ static int ee_vsprintf(char *buf, const char *fmt, va_list args) {
|
|||||||
flags = 0;
|
flags = 0;
|
||||||
repeat:
|
repeat:
|
||||||
fmt++; // This also skips first '%'
|
fmt++; // This also skips first '%'
|
||||||
switch (*fmt) {
|
switch (*fmt)
|
||||||
|
{
|
||||||
case '-':
|
case '-':
|
||||||
flags |= LEFT;
|
flags |= LEFT;
|
||||||
goto repeat;
|
goto repeat;
|
||||||
@ -439,10 +508,12 @@ static int ee_vsprintf(char *buf, const char *fmt, va_list args) {
|
|||||||
field_width = -1;
|
field_width = -1;
|
||||||
if (is_digit(*fmt))
|
if (is_digit(*fmt))
|
||||||
field_width = skip_atoi(&fmt);
|
field_width = skip_atoi(&fmt);
|
||||||
else if (*fmt == '*') {
|
else if (*fmt == '*')
|
||||||
|
{
|
||||||
fmt++;
|
fmt++;
|
||||||
field_width = va_arg(args, int);
|
field_width = va_arg(args, int);
|
||||||
if (field_width < 0) {
|
if (field_width < 0)
|
||||||
|
{
|
||||||
field_width = -field_width;
|
field_width = -field_width;
|
||||||
flags |= LEFT;
|
flags |= LEFT;
|
||||||
}
|
}
|
||||||
@ -450,11 +521,13 @@ static int ee_vsprintf(char *buf, const char *fmt, va_list args) {
|
|||||||
|
|
||||||
// Get the precision
|
// Get the precision
|
||||||
precision = -1;
|
precision = -1;
|
||||||
if (*fmt == '.') {
|
if (*fmt == '.')
|
||||||
|
{
|
||||||
++fmt;
|
++fmt;
|
||||||
if (is_digit(*fmt))
|
if (is_digit(*fmt))
|
||||||
precision = skip_atoi(&fmt);
|
precision = skip_atoi(&fmt);
|
||||||
else if (*fmt == '*') {
|
else if (*fmt == '*')
|
||||||
|
{
|
||||||
++fmt;
|
++fmt;
|
||||||
precision = va_arg(args, int);
|
precision = va_arg(args, int);
|
||||||
}
|
}
|
||||||
@ -464,7 +537,8 @@ static int ee_vsprintf(char *buf, const char *fmt, va_list args) {
|
|||||||
|
|
||||||
// Get the conversion qualifier
|
// Get the conversion qualifier
|
||||||
qualifier = -1;
|
qualifier = -1;
|
||||||
if (*fmt == 'l' || *fmt == 'L') {
|
if (*fmt == 'l' || *fmt == 'L')
|
||||||
|
{
|
||||||
qualifier = *fmt;
|
qualifier = *fmt;
|
||||||
fmt++;
|
fmt++;
|
||||||
}
|
}
|
||||||
@ -472,7 +546,8 @@ static int ee_vsprintf(char *buf, const char *fmt, va_list args) {
|
|||||||
// Default base
|
// Default base
|
||||||
base = 10;
|
base = 10;
|
||||||
|
|
||||||
switch (*fmt) {
|
switch (*fmt)
|
||||||
|
{
|
||||||
case 'c':
|
case 'c':
|
||||||
if (!(flags & LEFT))
|
if (!(flags & LEFT))
|
||||||
while (--field_width > 0)
|
while (--field_width > 0)
|
||||||
@ -497,12 +572,17 @@ static int ee_vsprintf(char *buf, const char *fmt, va_list args) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
if (field_width == -1) {
|
if (field_width == -1)
|
||||||
|
{
|
||||||
field_width = 2 * sizeof(void *);
|
field_width = 2 * sizeof(void *);
|
||||||
flags |= ZEROPAD;
|
flags |= ZEROPAD;
|
||||||
}
|
}
|
||||||
str = number(str, (unsigned long)va_arg(args, void *), 16, field_width,
|
str = number(str,
|
||||||
precision, flags);
|
(unsigned long)va_arg(args, void *),
|
||||||
|
16,
|
||||||
|
field_width,
|
||||||
|
precision,
|
||||||
|
flags);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'A':
|
case 'A':
|
||||||
@ -510,10 +590,16 @@ static int ee_vsprintf(char *buf, const char *fmt, va_list args) {
|
|||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
if (qualifier == 'l')
|
if (qualifier == 'l')
|
||||||
str = eaddr(str, va_arg(args, unsigned char *), field_width, precision,
|
str = eaddr(str,
|
||||||
|
va_arg(args, unsigned char *),
|
||||||
|
field_width,
|
||||||
|
precision,
|
||||||
flags);
|
flags);
|
||||||
else
|
else
|
||||||
str = iaddr(str, va_arg(args, unsigned char *), field_width, precision,
|
str = iaddr(str,
|
||||||
|
va_arg(args, unsigned char *),
|
||||||
|
field_width,
|
||||||
|
precision,
|
||||||
flags);
|
flags);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -539,7 +625,11 @@ static int ee_vsprintf(char *buf, const char *fmt, va_list args) {
|
|||||||
#if HAS_FLOAT
|
#if HAS_FLOAT
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
str = flt(str, va_arg(args, double), field_width, precision, *fmt,
|
str = flt(str,
|
||||||
|
va_arg(args, double),
|
||||||
|
field_width,
|
||||||
|
precision,
|
||||||
|
*fmt,
|
||||||
flags | SIGN);
|
flags | SIGN);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -571,9 +661,31 @@ static int ee_vsprintf(char *buf, const char *fmt, va_list args) {
|
|||||||
|
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
|
|
||||||
void uart_send_char(char c) { write(STDOUT_FILENO, &c, 1); }
|
void
|
||||||
|
uart_send_char(char c)
|
||||||
|
{
|
||||||
|
#if defined(BOARD_ehrenberg) || defined(BOARD_tgc_vp)
|
||||||
|
while (get_uart_rx_tx_reg_tx_free(uart)==0) ;
|
||||||
|
uart_write(uart, c);
|
||||||
|
if (c == '\n') {
|
||||||
|
while (get_uart_rx_tx_reg_tx_free(uart)==0) ;
|
||||||
|
uart_write(uart, '\r');
|
||||||
|
}
|
||||||
|
#elif defined(BOARD_iss)
|
||||||
|
*((uint32_t*) 0xFFFF0000) = c;
|
||||||
|
#else
|
||||||
|
while (UART0_REG(UART_REG_TXFIFO) & 0x80000000) ;
|
||||||
|
UART0_REG(UART_REG_TXFIFO) = c;
|
||||||
|
if (c == '\n') {
|
||||||
|
while (UART0_REG(UART_REG_TXFIFO) & 0x80000000) ;
|
||||||
|
UART0_REG(UART_REG_TXFIFO) = '\r';
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int ee_printf(const char *fmt, ...) {
|
int
|
||||||
|
ee_printf(const char *fmt, ...)
|
||||||
|
{
|
||||||
char buf[1024], *p;
|
char buf[1024], *p;
|
||||||
va_list args;
|
va_list args;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
@ -582,7 +694,8 @@ int ee_printf(const char *fmt, ...) {
|
|||||||
ee_vsprintf(buf, fmt, args);
|
ee_vsprintf(buf, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
p = buf;
|
p = buf;
|
||||||
while (*p) {
|
while (*p)
|
||||||
|
{
|
||||||
uart_send_char(*p);
|
uart_send_char(*p);
|
||||||
n++;
|
n++;
|
||||||
p++;
|
p++;
|
||||||
|
1
benchmarks/dhrystone/.gitignore
vendored
1
benchmarks/dhrystone/.gitignore
vendored
@ -1,3 +1,2 @@
|
|||||||
dhrystone
|
dhrystone
|
||||||
/dhrystone.dis
|
/dhrystone.dis
|
||||||
build/
|
|
@ -1,19 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.21)
|
|
||||||
project(dhrystone C)
|
|
||||||
set(TARGET dhrystone)
|
|
||||||
|
|
||||||
set(ITERATIONS 50000)
|
|
||||||
|
|
||||||
add_executable(${TARGET} dhry_1.c dhry_2.c dhry_stubs.c)
|
|
||||||
target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_LIST_DIR})
|
|
||||||
target_compile_options(${TARGET} PRIVATE -fno-inline -fno-builtin-printf -fno-common -Wno-implicit -funroll-loops -fpeel-loops -fgcse-sm -fgcse-las)
|
|
||||||
target_compile_definitions(${TARGET} PRIVATE ITERATIONS=${ITERATIONS} HZ=32768 TIME NO_INIT)
|
|
||||||
|
|
||||||
set(BOARD "iss" CACHE STRING "Target board")
|
|
||||||
add_subdirectory(../../bare-metal-bsp bsp)
|
|
||||||
target_link_libraries(${TARGET} PRIVATE bsp)
|
|
||||||
target_link_options(${TARGET} PRIVATE LINKER:-Map=${TARGET}.map)
|
|
||||||
|
|
||||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
|
||||||
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
|
|
||||||
COMMENT "Creating disassembly for ${TARGET}")
|
|
@ -1,109 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 3,
|
|
||||||
"vendor": {
|
|
||||||
"conan": {}
|
|
||||||
},
|
|
||||||
"cmakeMinimumRequired": {
|
|
||||||
"major": 3,
|
|
||||||
"minor": 24,
|
|
||||||
"patch": 0
|
|
||||||
},
|
|
||||||
"configurePresets": [
|
|
||||||
{
|
|
||||||
"name": "ISS_Debug",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "iss",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Moonlight_Debug",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "TGC_Debug",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ISS_Debug_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "iss",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Moonlight_Debug_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "TGC_Debug_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ISS_Release",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "iss",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Moonlight_Release",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "TGC_Release",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ISS_Release_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "iss",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Moonlight_Release_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "TGC_Release_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,5 +1,4 @@
|
|||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <unistd.h>
|
|
||||||
#ifndef ITERATIONS
|
#ifndef ITERATIONS
|
||||||
#define ITERATIONS 20000
|
#define ITERATIONS 20000
|
||||||
#endif
|
#endif
|
||||||
@ -7,16 +6,20 @@
|
|||||||
/* The functions in this file are only meant to support Dhrystone on an
|
/* The functions in this file are only meant to support Dhrystone on an
|
||||||
* embedded RV32 system and are obviously incorrect in general. */
|
* embedded RV32 system and are obviously incorrect in general. */
|
||||||
|
|
||||||
long time(void) { return get_timer_value(); }
|
long time(void)
|
||||||
|
{
|
||||||
|
return get_timer_value();
|
||||||
|
}
|
||||||
|
|
||||||
// set the number of dhrystone iterations
|
// set the number of dhrystone iterations
|
||||||
void __wrap_scanf(const char *fmt, int *n) { *n = ITERATIONS; }
|
void __wrap_scanf(const char* fmt, int* n)
|
||||||
|
{
|
||||||
// extern volatile uint64_t tohost;
|
*n = ITERATIONS;
|
||||||
|
}
|
||||||
void exit(int n) {
|
|
||||||
// tohost = 0x1;
|
extern volatile uint32_t tohost;
|
||||||
write_hex(STDERR_FILENO, 1);
|
|
||||||
for (;;)
|
void exit(int n){
|
||||||
;
|
tohost = 0x1;
|
||||||
|
for (;;);
|
||||||
}
|
}
|
||||||
|
1
hello-world/.gitignore
vendored
1
hello-world/.gitignore
vendored
@ -1,3 +1,2 @@
|
|||||||
/hello
|
/hello
|
||||||
/hello.dis
|
/hello.dis
|
||||||
build/
|
|
@ -1,13 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.21)
|
|
||||||
project(hello-world C)
|
|
||||||
set(TARGET hello)
|
|
||||||
add_executable(${TARGET} hello.c)
|
|
||||||
|
|
||||||
set(BOARD "iss" CACHE STRING "Target board")
|
|
||||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../bare-metal-bsp bsp)
|
|
||||||
target_link_libraries(${TARGET} PRIVATE bsp)
|
|
||||||
target_link_options(${TARGET} PRIVATE LINKER:-Map=${TARGET}.map)
|
|
||||||
|
|
||||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
|
||||||
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
|
|
||||||
COMMENT "Creating disassembly for ${TARGET}")
|
|
@ -1,109 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 3,
|
|
||||||
"vendor": {
|
|
||||||
"conan": {}
|
|
||||||
},
|
|
||||||
"cmakeMinimumRequired": {
|
|
||||||
"major": 3,
|
|
||||||
"minor": 24,
|
|
||||||
"patch": 0
|
|
||||||
},
|
|
||||||
"configurePresets": [
|
|
||||||
{
|
|
||||||
"name": "ISS_Debug",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "iss",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Moonlight_Debug",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "TGC_Debug",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ISS_Debug_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "iss",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Moonlight_Debug_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "TGC_Debug_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ISS_Release",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "iss",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Moonlight_Release",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "TGC_Release",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ISS_Release_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "iss",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Moonlight_Release_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "TGC_Release_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,21 +1,24 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <string.h>
|
#include "encoding.h"
|
||||||
|
|
||||||
|
int factorial(int i){
|
||||||
|
|
||||||
int factorial(int i) {
|
|
||||||
volatile int result = 1;
|
volatile int result = 1;
|
||||||
for (int ii = 1; ii <= i; ii++) {
|
for (int ii = 1; ii <= i; ii++) {
|
||||||
result = result * ii;
|
result = result * ii;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
int result = factorial(10);
|
{
|
||||||
printf("Factorial is %d", result);
|
volatile int result = factorial (10);
|
||||||
|
printf("Factorial is %d\n", result);
|
||||||
|
printf("End of execution");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user