Skip to content

Commit

Permalink
added the Hello_MaPU examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ShawnLess committed Oct 31, 2017
1 parent 002037c commit 220f34e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,30 @@ The MaPU toolchain relies on an environment variable *MAPU_HOME* which should po
```bash
export MAPU_HOME= <install_dir>
```
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 <stdio.h>

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()
```
9 changes: 9 additions & 0 deletions examples/1.Hello_MaPU/Hello_MaPU.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <stdio.h>

int main(int argc, char *argv[]) {
printf("--------------------------------\n");
printf(">> Hello MaPU!\n");
printf("--------------------------------\n");
return 0;
}

20 changes: 20 additions & 0 deletions examples/1.Hello_MaPU/Makefile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 220f34e

Please sign in to comment.