From fa7e09463520eef4d08d74a78b6ccdb14a032d64 Mon Sep 17 00:00:00 2001 From: davide schiavone Date: Tue, 5 Mar 2024 14:26:16 +0100 Subject: [PATCH] fix new test --- Makefile | 2 +- README.md | 2 +- sw/applications/example_dma/main.c | 2 +- sw/applications/example_ext_memory/main.c | 20 ++++---- sw/applications/hello_world/a.out | Bin 0 -> 16696 bytes sw/applications/hello_world/main.s | 47 ++++++++++++++++++ sw/device/lib/runtime/syscalls.c | 19 +------ .../target/{sim-systemc => systemc}/x-heep.h | 2 +- 8 files changed, 63 insertions(+), 31 deletions(-) create mode 100755 sw/applications/hello_world/a.out create mode 100644 sw/applications/hello_world/main.s rename sw/device/target/{sim-systemc => systemc}/x-heep.h (95%) diff --git a/Makefile b/Makefile index 318a16dbe..de6b9e92c 100644 --- a/Makefile +++ b/Makefile @@ -134,7 +134,7 @@ verible: ## Generates the build folder in sw using CMake to build (compile and linking) ## @param PROJECT= -## @param TARGET=sim(default),sim-systemc,pynq-z2,nexys-a7-100t +## @param TARGET=sim(default),systemc,pynq-z2,nexys-a7-100t ## @param LINKER=on_chip(default),flash_load,flash_exec ## @param COMPILER=gcc(default), clang ## @param COMPILER_PREFIX=riscv32-unknown-(default) diff --git a/README.md b/README.md index ffe080cb3..d6c1861e4 100644 --- a/README.md +++ b/README.md @@ -231,7 +231,7 @@ make app To run any other application, please use the following command with appropiate parameters: ``` -app PROJECT= TARGET=sim(default),pynq-z2 LINKER=on_chip(default),flash_load,flash_exec COMPILER=gcc(default),clang COMPILER_PREFIX=riscv32-unknown-(default) ARCH=rv32imc(default), +app PROJECT= TARGET=sim(default),systemc,pynq-z2,nexys-a7-100t LINKER=on_chip(default),flash_load,flash_exec COMPILER=gcc(default),clang COMPILER_PREFIX=riscv32-unknown-(default) ARCH=rv32imc(default), Params: - PROJECT (ex: , hello_world(default)) diff --git a/sw/applications/example_dma/main.c b/sw/applications/example_dma/main.c index d6b7e4af1..ea842d8a4 100644 --- a/sw/applications/example_dma/main.c +++ b/sw/applications/example_dma/main.c @@ -208,7 +208,7 @@ int main(int argc, char *argv[]) #endif // TEST_ADDRESS_MODE -#if defined(TARGET_SIM) || defined(TARGET_SIM_SYSTEMC) +#if defined(TARGET_SIM) || defined(TARGET_SYSTEMC) #ifdef TEST_ADDRESS_MODE_EXTERNAL_DEVICE diff --git a/sw/applications/example_ext_memory/main.c b/sw/applications/example_ext_memory/main.c index 439b8dccc..13bab9224 100644 --- a/sw/applications/example_ext_memory/main.c +++ b/sw/applications/example_ext_memory/main.c @@ -6,6 +6,7 @@ #include #include #include "core_v_mini_mcu.h" +#include "x-heep.h" #define BUFF_LEN 100 @@ -13,7 +14,7 @@ uint32_t buffer[BUFF_LEN]; uint32_t buffer_copy[BUFF_LEN]; uint32_t buffer_rnd_index[BUFF_LEN]; -#ifdef TARGET_SIM_SYSTEMC +#ifdef TARGET_SYSTEMC #define CACHE_FLUSH 1 #define CACHE_BYPASS 2 #define CACHE_SIZE 32*1024 @@ -23,17 +24,14 @@ int main(int argc, char *argv[]) { -#if !defined(TARGET_SIM) || !defined(TARGET_SIM_SYSTEMC) - #pragma message ( "this application must be ran only in the testbench" ) - return 0; -#endif +#if defined(TARGET_SIM) || defined(TARGET_SYSTEMC) uint32_t* ext_memory = (uint32_t*)EXT_SLAVE_START_ADDRESS; -#ifdef TARGET_SIM_SYSTEMC + #ifdef TARGET_SYSTEMC //last address of systemC memory used as a configuration register to flush or bypass volatile uint32_t* cache_cfg = (uint32_t*)(EXT_SLAVE_START_ADDRESS + CACHE_SIZE - 4); -#endif + #endif uint32_t random_number = 0; @@ -58,11 +56,11 @@ int main(int argc, char *argv[]) myptr1[i] = i*32; } -#ifdef TARGET_SIM_SYSTEMC + #ifdef TARGET_SYSTEMC //make sure you store everything back to main memory and bypass the flash *cache_cfg = CACHE_FLUSH; *cache_cfg = CACHE_BYPASS; -#endif + #endif for(int i=0;i-Vcpwvn)2b~xuJ_Lw%jhOMk4_UNe-GS3IpvHJf-q$w}N z1>@H_Ni6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5YK)a(dpq*nv8%?&VI$obJ`9B_e7HS)U%~(1 iaNF(nNAZUVQk5&RL>Vi}O2GN;Wq+jI(%SGY_WuD-i$2r< literal 0 HcmV?d00001 diff --git a/sw/applications/hello_world/main.s b/sw/applications/hello_world/main.s new file mode 100644 index 000000000..33fd21b07 --- /dev/null +++ b/sw/applications/hello_world/main.s @@ -0,0 +1,47 @@ + .file "main.c" + .text + .section .rodata +.LC0: + .string "hello world!" + .text + .globl main + .type main, @function +main: +.LFB6: + .cfi_startproc + endbr64 + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + subq $16, %rsp + movl %edi, -4(%rbp) + movq %rsi, -16(%rbp) + leaq .LC0(%rip), %rdi + call puts@PLT + movl $0, %eax + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE6: + .size main, .-main + .ident "GCC: (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0" + .section .note.GNU-stack,"",@progbits + .section .note.gnu.property,"a" + .align 8 + .long 1f - 0f + .long 4f - 1f + .long 5 +0: + .string "GNU" +1: + .align 8 + .long 0xc0000002 + .long 3f - 2f +2: + .long 0x3 +3: + .align 8 +4: diff --git a/sw/device/lib/runtime/syscalls.c b/sw/device/lib/runtime/syscalls.c index b3df658e8..84ec4b96a 100644 --- a/sw/device/lib/runtime/syscalls.c +++ b/sw/device/lib/runtime/syscalls.c @@ -35,23 +35,6 @@ extern int errno; #define STDOUT_FILENO 1 -#ifndef _LIBC -/* Provide prototypes for most of the _ names that are - provided in newlib for some compilers. */ -int _close (int __fildes); -pid_t _fork (void); -pid_t _getpid (void); -int _isatty (int __fildes); -int _link (const char *__path1, const char *__path2); -_off_t _lseek (int __fildes, _off_t __offset, int __whence); -ssize_t _read (int __fd, void *__buf, size_t __nbyte); -void * _sbrk (ptrdiff_t __incr); -int _unlink (const char *__path); -ssize_t _write (int __fd, const void *__buf, size_t __nbyte); -int _execve (const char *__path, char * const __argv[], char * const __envp[]); -#endif - - void unimplemented_syscall() { const char *p = "Unimplemented system call called!\n"; @@ -163,7 +146,7 @@ int _isatty(int file) return (file == STDOUT_FILENO); } -int _kill(int pid, int sig) +int _kill(pid_t pid, int sig) { errno = EINVAL; return -1; diff --git a/sw/device/target/sim-systemc/x-heep.h b/sw/device/target/systemc/x-heep.h similarity index 95% rename from sw/device/target/sim-systemc/x-heep.h rename to sw/device/target/systemc/x-heep.h index 150b1c4b9..1c1390cb1 100644 --- a/sw/device/target/sim-systemc/x-heep.h +++ b/sw/device/target/systemc/x-heep.h @@ -14,7 +14,7 @@ extern "C" { #define REFERENCE_CLOCK_Hz 100*1000*1000 #define UART_BAUDRATE 256000 -#define TARGET_SIM_SYSTEMC 1 +#define TARGET_SYSTEMC 1 /** * As the hw is configurable, we can have setups with different number of