Skip to content

Commit

Permalink
fix new test
Browse files Browse the repository at this point in the history
  • Loading branch information
davideschiavone committed Mar 5, 2024
1 parent 65ca611 commit fa7e094
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ verible:

## Generates the build folder in sw using CMake to build (compile and linking)
## @param PROJECT=<folder_name_of_the_project_to_be_built>
## @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)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ make app
To run any other application, please use the following command with appropiate parameters:

```
app PROJECT=<folder_name_of_the_project_to_be_built> 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),<any RISC-V ISA string supported by the CPU>
app PROJECT=<folder_name_of_the_project_to_be_built> 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),<any RISC-V ISA string supported by the CPU>
Params:
- PROJECT (ex: <folder_name_of_the_project_to_be_built>, hello_world(default))
Expand Down
2 changes: 1 addition & 1 deletion sw/applications/example_dma/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 11 additions & 9 deletions sw/applications/example_ext_memory/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
#include <stdlib.h>
#include <stdint.h>
#include "core_v_mini_mcu.h"
#include "x-heep.h"

#define BUFF_LEN 100

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
Expand All @@ -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;

Expand All @@ -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<BUFF_LEN;i++){
if (ext_memory[i] != i)
Expand All @@ -74,6 +72,10 @@ int main(int argc, char *argv[])

}

#else
#pragma message ( "this application must be ran only in the testbench" )
#endif

return EXIT_SUCCESS;
}

Binary file added sw/applications/hello_world/a.out
Binary file not shown.
47 changes: 47 additions & 0 deletions sw/applications/hello_world/main.s
Original file line number Diff line number Diff line change
@@ -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:
19 changes: 1 addition & 18 deletions sw/device/lib/runtime/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,6 @@ extern int errno;

#define STDOUT_FILENO 1

#ifndef _LIBC
/* Provide prototypes for most of the _<systemcall> 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";
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fa7e094

Please sign in to comment.