-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
51 lines (37 loc) · 1.42 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
###################################################
## MIPS Compilation path
MIPS_CC = mips-linux-gnu-gcc
MIPS_OBJCOPY = mips-linux-gnu-objcopy
# Turn on all warnings, and enable optimisations
MIPS_CPPFLAGS = -W -Wall -O3 -fno-builtin -march=mips1 -mfp32
# Avoid standard libraries etc. being brought in, and link statically
MIPS_LDFLAGS = -nostdlib -Wl,-melf32btsmip -march=mips1 -nostartfiles -mno-check-zero-division -Wl,--gpsize=0 -static -Wl,-Bstatic
MIPS_LDFLAGS += -Wl,--build-id=none
# Compile a c file into a MIPS object file
%.mips.o : %.c
$(MIPS_CC) $(MIPS_CPPFLAGS) -c $< -o $@
%.mips.o : %.s
$(MIPS_CC) $(MIPS_CPPFLAGS) -S $< -o $@
# Link a MIPS object file and place it at the locations required in the
# spec using linker.ld
%.mips.elf : %.mips.o
$(MIPS_CC) $(MIPS_CPPFLAGS) $(MIPS_LDFLAGS) -T src/linker.ld $< -o $@
# Extract just the binary instructions from the object file
%.mips.bin : %.mips.elf
$(MIPS_OBJCOPY) -O binary --only-section=.text $< $@
# For example, if you have testbench/test.c, you can do:
#
# make testbench/test.mips.bin
###################################################
## Simulator
# Build the simulation binary
bin/mips_simulator : src/simulator.cpp
mkdir -p bin
g++ -W -Wall src/simulator.cpp -o bin/mips_simulator
# In order to comply with spec
simulator : bin/mips_simulator
###################################################
## Testbench
testbench :
echo "No testbench yet"
exit 1