From 220f34eb27c53c839eff4bff10310eae65558d20 Mon Sep 17 00:00:00 2001 From: Shaolin Date: Tue, 31 Oct 2017 12:35:35 +0800 Subject: [PATCH] added the Hello_MaPU examples --- README.md | 24 +++++++++++++++++++++++- examples/1.Hello_MaPU/Hello_MaPU.c | 9 +++++++++ examples/1.Hello_MaPU/Makefile | 20 ++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 examples/1.Hello_MaPU/Hello_MaPU.c create mode 100644 examples/1.Hello_MaPU/Makefile diff --git a/README.md b/README.md index bf7076473..d621ff3ae 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,30 @@ The MaPU toolchain relies on an environment variable *MAPU_HOME* which should po ```bash export MAPU_HOME= ``` -For convenience, we can also add the executable directory to the system bin path +For convenience, we can also add the executable directory to the system PATH ```bash export PATH=$PATH:$MAPU_HOME/apc/bin +export PATH=$PATH:$MAPU_HOME/simulator/apc ``` ### Run the simple test +The *examples/1.Hello_MaPU* is the simplest case we can run. The source code is as following: +```c +#include + +int main(int argc, char *argv[]) { + printf("--------------------------------\n"); + printf(">> Hello MaPU!\n"); + printf("--------------------------------\n"); + return 0; +} +``` +Type *make* command in this directory will outputs followings as expected: +```bash +**** REAL SIMULATION **** +info: Entering event queue @ 0. Starting simulation... +-------------------------------- +>> Hello MaPU! +-------------------------------- +hack: be nice to actually delete the event here +Exiting @ tick 21392000 because target called exit() +``` diff --git a/examples/1.Hello_MaPU/Hello_MaPU.c b/examples/1.Hello_MaPU/Hello_MaPU.c new file mode 100644 index 000000000..5e1bbf384 --- /dev/null +++ b/examples/1.Hello_MaPU/Hello_MaPU.c @@ -0,0 +1,9 @@ +#include + +int main(int argc, char *argv[]) { + printf("--------------------------------\n"); + printf(">> Hello MaPU!\n"); + printf("--------------------------------\n"); + return 0; +} + diff --git a/examples/1.Hello_MaPU/Makefile b/examples/1.Hello_MaPU/Makefile new file mode 100644 index 000000000..972eb5799 --- /dev/null +++ b/examples/1.Hello_MaPU/Makefile @@ -0,0 +1,20 @@ +EX_NAME=Hello_MaPU + +# setup the tools +LLVM_BIN_PATH =${MAPU_HOME}/apc/bin +GEM5_SIM_BIN =${MAPU_HOME}/simulator/apc/gem5.opt +GEM5_CFG =${MAPU_HOME}/simulator/apc/system/se.py + +all:run + +compile:${EX_NAME}.c Makefile + ${LLVM_BIN_PATH}/clang -target mspu ${EX_NAME}.c -g -o ${EX_NAME}.s.out + ${LLVM_BIN_PATH}/clang -target mspu ${EX_NAME}.c -S -o ${EX_NAME}.s + ${LLVM_BIN_PATH}/llvm-objdump -arch-name=mspu -t -disassemble ${EX_NAME}.s.out > ${EX_NAME}.s.dis + +run:compile + ${GEM5_SIM_BIN} ${GEM5_CFG} -c ${EX_NAME}.s.out + +clean: + @rm -rf *.lof *.s.out *.map *.mmap *.sct *.tab *.s *.dis *~ *.def *.xml *.data + @rm -rf *.o *.sym *.txt *.ll stderr stdout m5out *.bin