diff --git a/README.md b/README.md index 73cca69f..9995ff45 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,8 @@ For more information, please visit [**Github Wiki**](https://github.com/VisorFol ### Supported Platforms -| Atmel | SiFive | STMicro | TI | Raspberry Pi | -| ---------- | ------------- | ----------- | ----------- | -------------| -| ATMega328P | FE310-G002 | Coming soon | Coming soon | Coming soon | -| ATMega2560 | QEMU SiFive-E | | | | +| Atmel | SiFive | STMicro | TI | Raspberry Pi | ibex | +| ---------- | ------------- | ----------- | ----------- | ------------- | ------------- | +| ATMega328P | FE310-G002 | Coming soon | Coming soon | Coming soon | simple-system | +| ATMega2560 | QEMU SiFive-E | | | | | diff --git a/mk/lib.mk b/mk/lib.mk index 9864eb5d..05278625 100644 --- a/mk/lib.mk +++ b/mk/lib.mk @@ -1,6 +1,6 @@ # # CYANCORE LICENSE -# Copyrights (C) 2019, Cyancore Team +# Copyrights (C) 2024, Cyancore Team # # File Name : lib.mk # Description : This file accumulates all the object files @@ -18,10 +18,11 @@ include mk/lobj.mk LIB := $(addprefix $(OUT)/$(DIR)/,$(LIB)) DEP_LIB_PATH += -L $(OUT)/$(DIR) DEP_LIBS += $(LIB) +AR_FLAGS ?= rcs -$(LIB): $(LIB_OBJS) +$(LIB): $(LIB_OBJS) | $$(@D)/ @echo "Lib: Generating $(@F) ..." - $(AR) rc $@ $^ + $(AR) $(AR_FLAGS) $@ $^ LIB_INCLUDE_PATH:= LIB_OBJS := diff --git a/mk/tc.mk b/mk/tc.mk index cda078c8..7bb51c83 100644 --- a/mk/tc.mk +++ b/mk/tc.mk @@ -1,6 +1,6 @@ # # CYANCORE LICENSE -# Copyrights (C) 2019, Cyancore Team +# Copyrights (C) 2024, Cyancore Team # # File Name : tc.mk # Description : This file defines toolchain specific variables @@ -16,6 +16,7 @@ $(eval $(call get_tc_version,$(TC))) # Sets TC_VER TI := $(TOOLS_ROOT)/arm-toolchain/lib/gcc/arm-none-eabi/$(TC_VER)/include-fixed/ TI += $(TOOLS_ROOT)/arm-toolchain/arm-none-eabi/include/ TL := $(TOOLS_ROOT)/arm-toolchain/lib/gcc/arm-none-eabi/$(TC_VER)/$(TL_TYPE)/ +TCL := $(TOOLS_ROOT)/arm-toolchain/arm-none-eabi/lib/ endif ifeq ($(findstring riscv,$(ARCH)),riscv) @@ -24,6 +25,7 @@ $(eval $(call get_tc_version,$(TC))) # Sets TC_VER TI := $(TOOLS_ROOT)/risc-v-toolchain/lib/gcc/riscv64-unknown-elf/$(TC_VER)/include-fixed/ TI += $(TOOLS_ROOT)/risc-v-toolchain/riscv64-unknown-elf/include/ TL := $(TOOLS_ROOT)/risc-v-toolchain/lib/gcc/riscv64-unknown-elf/$(TC_VER)/rv$(BIT)$(ARCH_VARIANT)/$(ARCH_ABI)/ +TCL := $(TOOLS_ROOT)/risc-v-toolchain/riscv64-unknown-elf/lib/rv$(BIT)$(ARCH_VARIANT)/$(ARCH_ABI) endif ifeq ($(findstring avr,$(ARCH)),avr) @@ -31,6 +33,7 @@ TC ?= $(TOOLS_ROOT)/avr-toolchain/bin/avr $(eval $(call get_tc_version,$(TC))) # Sets TC_VER TI := $(TOOLS_ROOT)/avr-toolchain/lib/gcc/avr/$(TC_VER)/include-fixed TL := $(TOOLS_ROOT)/avr-toolchain/lib/gcc/avr/$(TC_VER)/$(ARCH)$(ARCH_VARIANT)/ +TCL := $(TOOLS_ROOT)/avr-toolchain/avr/lib/$(ARCH)$(ARCH_VARIANT) endif ifneq ($(ARCH),) diff --git a/projects/demo_ibex_ss/project.c b/projects/demo_ibex_ss/project.c index 89c64a0e..9388dc2c 100644 --- a/projects/demo_ibex_ss/project.c +++ b/projects/demo_ibex_ss/project.c @@ -10,10 +10,12 @@ #include #include +#include #include #include #include #include +#include void plug() { @@ -21,23 +23,9 @@ void plug() driver_setup_all(); printf("Demo Program!\n"); + mdelay(1000); + printf("Bye...\n"); + exit(EXIT_SUCCESS); return; } - -void play() -{ - static unsigned char i = 0; - char progress[] = "-\\|/"; - uint64_t time; - char c = progress[(i++) % strlen(progress)]; - get_timestamp(&time); - time /= 1000U; - - printf("[%012llu] Running Blinky ... [%c]", time, c); - - mdelay(500); - - printf("\r"); - return; -} diff --git a/src/include/compiler_macros.h b/src/include/compiler_macros.h index 4e76a572..f50c78a5 100644 --- a/src/include/compiler_macros.h +++ b/src/include/compiler_macros.h @@ -1,6 +1,6 @@ /* * CYANCORE LICENSE - * Copyrights (C) 2019, Cyancore Team + * Copyrights (C) 2024, Cyancore Team * * File Name : compiler_macro.h * Description : This file defines the compiler macro utilities @@ -10,22 +10,23 @@ #pragma once -#define _PRAGMA(x) _Pragma (#x) -#define INFO(x) _PRAGMA(message (#x)) -#define WARN(x) _PRAGMA(GCC warning #x) -#define ERROR(x) _PRAGMA(GCC error #x) -#define TODO(x) INFO(TODO: x) +#define _PRAGMA(x) _Pragma (#x) +#define INFO(x) _PRAGMA(message (#x)) +#define WARN(x) _PRAGMA(GCC warning #x) +#define ERROR(x) _PRAGMA(GCC error #x) +#define TODO(x) INFO(TODO: x) -#define _ATTRIBUTE(x) __attribute__((x)) -#define _WEAK _ATTRIBUTE(weak) -#define _UNUSED _ATTRIBUTE(unused) -#define _INLINE _ATTRIBUTE(always_inline) -#define _NOINLINE _ATTRIBUTE(noinline) -#define _ALIGN(x) _ATTRIBUTE(aligned(x)) -#define _SECTION(x) _ATTRIBUTE(section(x)) -#define _DEPRICATE _ATTRIBUTE(depricated) -#define _ALIAS(x) _ATTRIBUTE(alias(x)) -#define _FALLTHROUGH _ATTRIBUTE(fallthrough) -#define _NORETURN _ATTRIBUTE(noreturn) -#define _NAKED _ATTRIBUTE(naked) -#define EXPORT_C(x) extern "C" x; x +#define _ATTRIBUTE(x) __attribute__((x)) +#define _WEAK _ATTRIBUTE(weak) +#define _UNUSED _ATTRIBUTE(unused) +#define _INLINE _ATTRIBUTE(always_inline) +#define _NOINLINE _ATTRIBUTE(noinline) +#define _ALIGN(x) _ATTRIBUTE(aligned(x)) +#define _SECTION(x) _ATTRIBUTE(section(x)) +#define _DEPRICATE _ATTRIBUTE(depricated) +#define _ALIAS(x) _ATTRIBUTE(alias(x)) +#define _FALLTHROUGH _ATTRIBUTE(fallthrough) +#define _NORETURN _ATTRIBUTE(noreturn) +#define _NAKED _ATTRIBUTE(naked) +#define EXPORT_C(x) extern "C" x; x +#define EXPORT_C_PROTO(x) extern "C" { x } diff --git a/src/lib/libnmath/arithmetic/arithmetic.c b/src/lib/libnmath/arithmetic/arithmetic.c index 1d1efa46..0e2aceaa 100644 --- a/src/lib/libnmath/arithmetic/arithmetic.c +++ b/src/lib/libnmath/arithmetic/arithmetic.c @@ -1,6 +1,6 @@ /* * CYANCORE LICENSE - * Copyrights (C) 2019, Cyancore Team + * Copyrights (C) 2024, Cyancore Team * * File Name : arithmetic.c * Description : This file contains sources of neo-math function @@ -25,36 +25,6 @@ unsigned int clog2(unsigned long num) return (num > 1) ? (1 + clog2((num & 0x01) ? ((num + 1) >> 1) : (num >> 1))) : 0; } -/** - * ceiling - * - * @brief Determines the ceiling of the input number - * - * @param[in] num: Input number - * - * @return ceiling - */ -double ceiling(double num) -{ - long inum = (long) num; - return (double)(num - inum) ? (inum + 1) : num; -} - -/** - * floor - * - * @brief Determing the floor of the input number - * - * @param[in] num: Input number - * - * @return floor - */ -double floor(double num) -{ - long inum = (long) num; - return (double)inum; -} - /** * gcd - Greatest Common Divisor * diff --git a/src/lib/libnmath/build.mk b/src/lib/libnmath/build.mk index afadb4ad..212c04e4 100644 --- a/src/lib/libnmath/build.mk +++ b/src/lib/libnmath/build.mk @@ -1,6 +1,6 @@ # # CYANCORE LICENSE -# Copyrights (C) 2019, Cyancore Team +# Copyrights (C) 2024, Cyancore Team # # File Name : build.mk # Descrption : This script accumulates sources and build @@ -21,3 +21,5 @@ include $(NMATH_PATH)/dsp/build.mk DIR := $(NMATH_PATH) include mk/lib.mk + +include $(NMATH_PATH)/libm/build.mk diff --git a/src/lib/libnmath/include/nmath.h b/src/lib/libnmath/include/nmath.h index 4db5ee7e..6de51482 100644 --- a/src/lib/libnmath/include/nmath.h +++ b/src/lib/libnmath/include/nmath.h @@ -1,6 +1,6 @@ /* * CYANCORE LICENSE - * Copyrights (C) 2019, Cyancore Team + * Copyrights (C) 2024, Cyancore Team * * File Name : nmath.h * Description : This file contains prototypes of neo-math function @@ -11,8 +11,6 @@ #pragma once #include unsigned int clog2(unsigned long num); -double ceiling(double num); -double floor(double num); unsigned long gcd(unsigned long a, unsigned long b); unsigned long lcd(unsigned int *a, unsigned int n); long mod(long a, long b); diff --git a/src/lib/libnmath/libm/build.mk b/src/lib/libnmath/libm/build.mk new file mode 100644 index 00000000..12e4dd88 --- /dev/null +++ b/src/lib/libnmath/libm/build.mk @@ -0,0 +1,24 @@ +# +# CYANCORE LICENSE +# Copyrights (C) 2024, Cyancore Team +# +# File Name : build.mk +# Descrption : This script generates tcmath library +# it uses toolchain's libm.a +# Primary Author : Akash Kollipara [akashkollipara@gmail.com] +# Organisation : Cyancore Core-Team +# + +TCMATH_PATH := $(GET_PATH) + +LIB_OBJS := $$(TCL)/libm.a + +LIB := libtcmath.a +LIB_INCLUDE += $(TCMATH_PATH)/include/ +DEP_LIBS_ARG += -ltcmath + +AR_FLAGS := rcsT + +DIR := $(TCMATH_PATH) + +include mk/lib.mk diff --git a/src/lib/libnmath/libm/include/math.h b/src/lib/libnmath/libm/include/math.h new file mode 100644 index 00000000..ffd56e81 --- /dev/null +++ b/src/lib/libnmath/libm/include/math.h @@ -0,0 +1,148 @@ +/* + * CYANCORE LICENSE + * Copyrights (C) 2024, Cyancore Team + * + * File Name : math.h + * Description : This file contains prototypes of math function + * It is same as the one in toolchain but tailored + * for cyancore + * Primary Author : Akash Kollipara [akashkollipara@gmail.com] + * Organisation : Cyancore Core-Team + */ + +#pragma once +#include + +#define M_E 2.7182818284590452354 +#define M_LOG2E 1.4426950408889634074 /* log_2 e */ +#define M_LOG10E 0.43429448190325182765 /* log_10 e */ +#define M_LN2 0.69314718055994530942 /* log_e 2 */ +#define M_LN10 2.30258509299404568402 /* log_e 10 */ +#define M_PI 3.14159265358979323846 /* pi */ +#define M_PI_2 1.57079632679489661923 /* pi/2 */ +#define M_PI_4 0.78539816339744830962 /* pi/4 */ +#define M_1_PI 0.31830988618379067154 /* 1/pi */ +#define M_2_PI 0.63661977236758134308 /* 2/pi */ +#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ +#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ +#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ +#define NAN __builtin_nan("") +#define INFINITY __builtin_inf() + +#ifdef __cplusplus +EXPORT_C_PROTO( +#endif + +extern double cos(double); +#define cosf cos + +extern double sin(double); +#define sinf sin + +extern double tan(double); +#define tanf tan + +extern double fabs(double); +#define fabsf fabs + +extern double fmod(double, double); +#define fmodf fmod + +extern double modf(double, double *); + +extern float modff (float, float *); + +extern double sqrt(double); + +extern float sqrtf (float); + +extern double cbrt(double); +#define cbrtf cbrt + +extern double hypot (double, double); +#define hypotf hypot + +extern double square(double); +#define squaref square + +extern double floor(double); +#define floorf floor + +extern double ceil(double); +#define ceilf ceil + +extern double frexp(double, int *); +#define frexpf frexp + +extern double ldexp(double, int); +#define ldexpf ldexp + +extern double exp(double); +#define expf exp + +extern double cosh(double); +#define coshf cosh + +extern double sinh(double); +#define sinhf sinh + +extern double tanh(double); +#define tanhf tanh + +extern double acos(double); +#define acosf acos + +extern double asin(double); +#define asinf asin + +extern double atan(double); +#define atanf atan + +extern double atan2(double, double); +#define atan2f atan2 + +extern double log(double); +#define logf log + +extern double log10(double); +#define log10f log10 + +extern double pow(double, double); +#define powf pow + +extern int isnan(double); +#define isnanf isnan + +extern int isinf(double); +#define isinff isinf + +extern int signbit (double); +#define signbitf signbit + +extern double fdim (double, double); +#define fdimf fdim + +extern double fma (double, double, double); +#define fmaf fma + +extern double fmax (double, double); +#define fmaxf fmax + +extern double fmin (double, double); +#define fminf fmin + +extern double trunc (double); +#define truncf trunc + +extern double round (double); +#define roundf round + +extern long lround (double); +#define lroundf lround + +extern long lrint (double); +#define lrintf lrint + +#ifdef __cplusplus +) +#endif diff --git a/src/platform/ibex/simple_system/platform/platform.c b/src/platform/ibex/simple_system/platform/platform.c index 40a3d0fd..d2f58be4 100644 --- a/src/platform/ibex/simple_system/platform/platform.c +++ b/src/platform/ibex/simple_system/platform/platform.c @@ -19,7 +19,9 @@ #include #include #include +#include +static void platform_sim_halt(); void platform_early_setup() { @@ -76,6 +78,7 @@ void platform_setup() cyancore_insignia(); platform_print_cpu_info(); platform_memory_layout(); + atexit(&platform_sim_halt); return; } @@ -84,3 +87,9 @@ void platform_cpu_setup() arch_ei(); return; } + +static void platform_sim_halt() +{ + uintptr_t sim_ctrl_base = 0x20000; + MMIO32(sim_ctrl_base + 0x8) = 1; +}