1 | # where is soclib? |
---|
2 | SOCLIB_DIR=$(shell soclib-cc --getpath) |
---|
3 | |
---|
4 | # name definitions |
---|
5 | SOCLIB_DESC=desc.py |
---|
6 | SOCLIB_TOP=top.cpp |
---|
7 | SIMULATOR_BINARY=system.x |
---|
8 | SIMULATOR_CMD=./$(SIMULATOR_BINARY) --nobanner |
---|
9 | |
---|
10 | # extra arguments for compilation |
---|
11 | #SOCLIB_CC_ARGS=-v |
---|
12 | SOCLIB_CC_ARGS+=-b common:mips32 |
---|
13 | |
---|
14 | # extra arguments for execution |
---|
15 | # gdb |
---|
16 | # F: start the simulation in a frozen state so it can be attached with a gdb client |
---|
17 | # X: disable automatic break whenever an exception is caught, the exception handler will be called transparently |
---|
18 | # S: make the simulation stop and wait for a gdb attachment whenever an exception is caught |
---|
19 | # C: dump a trace of every inter-functions branch |
---|
20 | # T: exit the simulator on trap exception |
---|
21 | # Z: same as C but display only function's entrypoint |
---|
22 | # W: disable automatic break whenever a watchpoint is hit, just report it on stderr (watchpoints can be defined using SOCLIB_GDB_WATCH) |
---|
23 | SIMULATOR_GDB= |
---|
24 | ifeq ("$(origin GDB)", "command line") |
---|
25 | ifeq ($(GDB), 1) |
---|
26 | SIMULATOR_GDB=SOCLIB_GDB=FCX |
---|
27 | else |
---|
28 | SIMULATOR_GDB=SOCLIB_GDB=$(GDB) |
---|
29 | endif |
---|
30 | endif |
---|
31 | # trace |
---|
32 | SIMULATOR_TRACE= |
---|
33 | ifeq ("$(origin TRACE)", "command line") |
---|
34 | SIMULATOR_TRACE=--trace $(TRACE) |
---|
35 | endif |
---|
36 | # vmlinux |
---|
37 | SIMULATOR_VMLINUX=./vmlinux |
---|
38 | ifeq ("$(origin VMLINUX)", "command line") |
---|
39 | SIMULATOR_VMLINUX=$(VMLINUX) |
---|
40 | endif |
---|
41 | |
---|
42 | # recipes |
---|
43 | all: $(SIMULATOR_BINARY) |
---|
44 | |
---|
45 | $(SIMULATOR_BINARY): $(SOCLIB_DESC) $(SOCLIB_TOP) |
---|
46 | soclib-cc $(SOCLIB_CC_ARGS) -P -p $(SOCLIB_DESC) -o $(SIMULATOR_BINARY) |
---|
47 | |
---|
48 | run_tsar_boot: all tsar_boot.bin disk.img |
---|
49 | $(SIMULATOR_GDB) $(SIMULATOR_CMD) --rom tsar_boot.bin --dsk disk.img $(SIMULATOR_TRACE) |
---|
50 | |
---|
51 | run_dummy_boot: all vmlinux disk.img |
---|
52 | $(SIMULATOR_GDB) $(SIMULATOR_CMD) --rom $(SIMULATOR_VMLINUX) --dsk disk.img --dummy-boot $(SIMULATOR_TRACE) |
---|
53 | |
---|
54 | cscope.out: |
---|
55 | soclib-cc -p $(SOCLIB_DESC) --tags |
---|
56 | |
---|
57 | clean: |
---|
58 | soclib-cc -P -p $(SOCLIB_DESC) -x -o $(SIMULATOR_BINARY) |
---|
59 | rm -f $(SIMULATOR_BINARY) *.o vci* |
---|
60 | |
---|
61 | .PHONY: $(SIMULATOR_BINARY) |
---|