1 # Copyright 2018 Jacob Lifshay
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to deal
5 # in the Software without restriction, including without limitation the rights
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 # copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice shall be included in all
11 # copies or substantial portions of the Software.
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 LIBGCC
:= $(shell riscv32-unknown-elf-g
++ -print-libgcc-file-name
)
24 LIBGCC_DIR
:= $(dir $(LIBGCC
))
26 all: ram0_byte0.hex ..
/output.bit emulated
27 ..
/output.bit
: ram.elf ..
/main.bit
28 bash
-c
'. /opt/Xilinx/14.7/ISE_DS/settings64.sh; data2mem -bm ../cpu.bmm -bd ram.elf -bt ../main.bit -o b ../output.bit'
29 ram0_byte0.hex
: ram.bin generate_hex_files.sh Makefile
30 .
/generate_hex_files.sh
31 generate_hex_files.sh
: make_block_memory.sh
32 .
/make_block_memory.sh
-s
33 ram.bin
: ram-stripped.elf Makefile
34 riscv32-unknown-elf-objcopy
-O binary
--pad-to
0x18000 ram.elf ram.bin
38 ram-stripped.elf
: Makefile ram.elf
39 riscv32-unknown-elf-strip
-o ram-stripped.elf ram.elf
40 ram.elf
: $(OBJECTS
) Makefile ram.
ld
41 riscv32-unknown-elf-ld
-o ram.elf
$(OBJECTS
) -static
-T ram.
ld -L
$(LIBGCC_DIR
) -L
/opt
/riscv
/riscv32-unknown-elf
/lib
-lgcc
-lc
42 startup.o
: startup.S Makefile
43 riscv32-unknown-elf-g
++ -c
-o startup.o startup.S
-march
=rv32i
-mabi
=ilp32
44 main.o
: main.
cpp Makefile
45 start.o
: start.
cpp Makefile
46 main-emulated.o
: main.
cpp Makefile
47 g
++ -g
-c
-o main-emulated.o
-std
=c
++14 -Wall main.
cpp -DEMULATE_TARGET
48 emulated
: main-emulated.o Makefile
49 g
++ -g
-o emulated
-std
=c
++14 -Wall main-emulated.o
-static
52 riscv32-unknown-elf-g
++ -Os
-c
-o
$@
$< -std
=c
++14 -Wall
-march
=rv32i
-mabi
=ilp32
-fno-exceptions
55 rm -f ram
*.hex ram.bin ram.elf ram-stripped.elf
*.o emulated generate_hex_files.sh