aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/cxxdemo/Makefile
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2015-11-04 01:12:37 +0100
committerClifford Wolf <clifford@clifford.at>2015-11-04 12:55:33 +0100
commit4015d4a5ab90f9b225275325d52262523c3cfc31 (patch)
treea1bc875c5705859990b13e3c146a7a2198f50cc8 /scripts/cxxdemo/Makefile
parent8d9f048785a4972fee5817cc64ddb2097034b122 (diff)
downloadpicorv32-4015d4a5ab90f9b225275325d52262523c3cfc31.tar.gz
picorv32-4015d4a5ab90f9b225275325d52262523c3cfc31.zip
Added scripts/cxxdemo/
Diffstat (limited to 'scripts/cxxdemo/Makefile')
-rw-r--r--scripts/cxxdemo/Makefile36
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/cxxdemo/Makefile b/scripts/cxxdemo/Makefile
new file mode 100644
index 0000000..3d10104
--- /dev/null
+++ b/scripts/cxxdemo/Makefile
@@ -0,0 +1,36 @@
+CXX = riscv32-unknown-elf-g++
+CC = riscv32-unknown-elf-gcc
+AS = riscv32-unknown-elf-gcc
+CXXFLAGS = -MD -Os -Wall -std=c++11
+CCFLAGS = -MD -Os -Wall -std=c++11
+LDFLAGS = -Wl,--gc-sections
+LDLIBS = -lstdc++
+
+test: testbench.exe firmware.hex
+ vvp -N testbench.exe
+
+testbench.exe: testbench.v ../../picorv32.v
+ iverilog -o testbench.exe testbench.v ../../picorv32.v
+ chmod -x testbench.exe
+
+firmware.hex: firmware.elf start.elf
+ riscv32-unknown-elf-objcopy -O verilog start.elf start.tmp
+ riscv32-unknown-elf-objcopy -O verilog firmware.elf firmware.tmp
+ cat start.tmp firmware.tmp > firmware.hex
+ rm -f start.tmp firmware.tmp
+
+firmware.elf: firmware.o syscalls.o
+ $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
+ chmod -x firmware.elf
+
+start.elf: start.S start.ld
+ $(CC) -nostdlib -o start.elf start.S -T start.ld $(LDLIBS)
+ chmod -x start.elf
+
+clean:
+ rm -f *.o *.d *.tmp start.elf
+ rm -f firmware.elf firmware.hex
+ rm -f testbench.exe testbench.vcd
+
+-include *.d
+.PHONY: test clean