| 1 |
184 |
ja_rd |
#-- Bring toolchain config parameters from the common makefile
|
| 2 |
191 |
ja_rd |
include ../common/makefile
|
| 3 |
90 |
ja_rd |
|
| 4 |
177 |
ja_rd |
#-- Configure the VHDL simulation environment ----------------------------------
|
| 5 |
|
|
|
| 6 |
|
|
# Simulation length in cycles; long enough to let the program run to completion.
|
| 7 |
143 |
ja_rd |
SIM_LENGTH = 400000000
|
| 8 |
90 |
ja_rd |
|
| 9 |
177 |
ja_rd |
|
| 10 |
|
|
#-- Configure the memory map ---------------------------------------------------
|
| 11 |
|
|
# FIXME this info is redundant with the linker script
|
| 12 |
|
|
|
| 13 |
90 |
ja_rd |
# FPGA Block RAM parameters
|
| 14 |
|
|
BRAM_START = 0xbfc00000
|
| 15 |
229 |
ja_rd |
CODE_BRAM_SIZE = 512
|
| 16 |
90 |
ja_rd |
# External RAM parameters (size in words)
|
| 17 |
177 |
ja_rd |
XRAM_SIZE = 200000
|
| 18 |
90 |
ja_rd |
XRAM_START = 0x00000000
|
| 19 |
177 |
ja_rd |
# External FLASH parameters (size in words)
|
| 20 |
|
|
# Note te size is for simulation only
|
| 21 |
|
|
FLASH_START = 0xb0000000
|
| 22 |
|
|
FLASH_SIM_SIZE = 65536
|
| 23 |
90 |
ja_rd |
|
| 24 |
177 |
ja_rd |
#-- Configure the code ---------------------------------------------------------
|
| 25 |
90 |
ja_rd |
|
| 26 |
177 |
ja_rd |
# Options for 'boot' code running from BRAM at 0xbfc00000:
|
| 27 |
|
|
# 1.- Put the code in internal BRAM and the data in external SRAM.
|
| 28 |
|
|
# 2.- Do not use any of the standard libraries and use libsoc instead.
|
| 29 |
|
|
LFLAGS_BOOT = -L $(LIB_PATH) -Ttext $(BRAM_START) -Tdata $(XRAM_START) \
|
| 30 |
|
|
-nodefaultlibs -nostdlib -ereset -I elf32-big -defsym entry=$(FLASH_START)
|
| 31 |
|
|
CFLAGS_BOOT = -O2 -Wall -c -s -fno-builtin -nodefaultlibs -nostdlib \
|
| 32 |
|
|
-msoft-float -mips1 -G0
|
| 33 |
|
|
AFLAGS_BOOT = --defsym RUN_FROM_BRAM=1 --defsym XRAM_BASE=$(XRAM_START)
|
| 34 |
90 |
ja_rd |
|
| 35 |
|
|
|
| 36 |
177 |
ja_rd |
# Options for 'main' code running from FLASH at 0xb0000000:
|
| 37 |
|
|
# 1.- Put the code in FLASH and the data in external SRAM.
|
| 38 |
|
|
# 2.- Do not use any of the standard libraries and use libsoc instead.
|
| 39 |
182 |
ja_rd |
LFLAGS_MAIN = -T$(LINK_SCRIPT) -L $(LIB_PATH) \
|
| 40 |
177 |
ja_rd |
-nodefaultlibs -nostdlib -eentry -I elf32-big
|
| 41 |
|
|
CFLAGS_MAIN = -O2 -Wall -c -s -fno-builtin -nodefaultlibs -nostdlib \
|
| 42 |
|
|
-msoft-float -mips1 -G0
|
| 43 |
|
|
AFLAGS_MAIN = --defsym XRAM_BASE=$(XRAM_START)
|
| 44 |
90 |
ja_rd |
|
| 45 |
245 |
ja_rd |
# Options for 'main' code running from XRAM at 0x00000000:
|
| 46 |
|
|
# 1.- Put the code and the data in external XRAM.
|
| 47 |
|
|
# 2.- Do not use any of the standard libraries and use libsoc instead.
|
| 48 |
|
|
LINK_SCRIPT_XRAM=$(SRC_DIR)/common/xram.lds
|
| 49 |
|
|
LFLAGS_SD = -T$(LINK_SCRIPT_XRAM) -L $(LIB_PATH) \
|
| 50 |
|
|
-nodefaultlibs -nostdlib -eentry -I elf32-big
|
| 51 |
|
|
|
| 52 |
|
|
|
| 53 |
177 |
ja_rd |
# Object files for main program
|
| 54 |
|
|
OBJS = c_startup.o main.o actions1.o actions2.o init.o misc.o \
|
| 55 |
|
|
score.o adv_baremetal.o
|
| 56 |
|
|
SRCS = actions1.c actions2.c main.c init.c misc.c score.c adv_baremetal.c
|
| 57 |
90 |
ja_rd |
|
| 58 |
|
|
|
| 59 |
177 |
ja_rd |
#-- Targets & rules ------------------------------------------------------------
|
| 60 |
90 |
ja_rd |
|
| 61 |
245 |
ja_rd |
# Use this target to make a 'bootloadable' binary of adventure as 'code.bin'.
|
| 62 |
|
|
# You can then boot this file from an SD card using the sdboot demo bootloader.
|
| 63 |
|
|
sd: code.bin
|
| 64 |
|
|
@# This comment prevents use of implicit rule so our rules are used instead.
|
| 65 |
|
|
@# This will save us a few harmless linker warnings.
|
| 66 |
|
|
|
| 67 |
|
|
code.bin: code.axf
|
| 68 |
|
|
# Extract object code to be placed in code space
|
| 69 |
|
|
$(COPY) -I elf32-big -O binary code.axf code.bin
|
| 70 |
|
|
|
| 71 |
|
|
code.axf: $(OBJS)
|
| 72 |
|
|
$(LD) $(LFLAGS_SD) -Map adventure.map -s -N -o code.axf $(OBJS) -lsoc
|
| 73 |
|
|
-@$(DUMP) -m mips --disassemble adventure.axf > adventure.lst
|
| 74 |
|
|
|
| 75 |
|
|
|
| 76 |
177 |
ja_rd |
adventure: adventure.bin bootstrap
|
| 77 |
|
|
@# This comment prevents use of implicit rule so our rules are used instead.
|
| 78 |
|
|
@# This will save us a few harmless linker warnings.
|
| 79 |
90 |
ja_rd |
|
| 80 |
177 |
ja_rd |
adventure.bin: adventure.axf
|
| 81 |
|
|
# Extract object code to be placed in code space
|
| 82 |
|
|
$(COPY) -I elf32-big -O binary adventure.axf adventure.bin
|
| 83 |
|
|
|
| 84 |
|
|
adventure.axf: $(OBJS)
|
| 85 |
|
|
$(LD) $(LFLAGS_MAIN) -Map adventure.map -s -N -o adventure.axf $(OBJS) -lsoc
|
| 86 |
|
|
-@$(DUMP) -m mips --disassemble adventure.axf > adventure.lst
|
| 87 |
90 |
ja_rd |
|
| 88 |
177 |
ja_rd |
c_startup.o: $(SRC_DIR)/common/c_startup.s
|
| 89 |
|
|
$(AS) $(AFLAGS_MAIN) -o c_startup.o $(SRC_DIR)/common/c_startup.s
|
| 90 |
|
|
|
| 91 |
|
|
|
| 92 |
|
|
actions1.o: misc.h main.h share.h funcs.h
|
| 93 |
|
|
main.o: misc.h adv_baremetal.h
|
| 94 |
|
|
actions2.o: misc.h main.h share.h funcs.h
|
| 95 |
|
|
init.o: misc.h main.h share.h funcs.h
|
| 96 |
|
|
misc.o: misc.h main.h
|
| 97 |
|
|
score.o: misc.h main.h share.h
|
| 98 |
|
|
adv_baremetal.o: adv_baremetal.h
|
| 99 |
|
|
|
| 100 |
|
|
|
| 101 |
|
|
#-- Compilation of 'boot' code to be run from BRAM
|
| 102 |
|
|
|
| 103 |
|
|
bootstrap.o: $(SRC_DIR)/common/bootstrap.s
|
| 104 |
|
|
$(AS) -defsym XRAM_BASE=$(XRAM_START) -o bootstrap.o $(SRC_DIR)/common/bootstrap.s
|
| 105 |
|
|
|
| 106 |
|
|
opcode_emu.o: $(SRC_DIR)/common/opcode_emu.s
|
| 107 |
|
|
$(AS) $(AFLAGS) -o opcode_emu.o $(SRC_DIR)/common/opcode_emu.s
|
| 108 |
|
|
|
| 109 |
|
|
bootstrap.axf: bootstrap.o opcode_emu.o
|
| 110 |
|
|
$(LD) $(LFLAGS_BOOT) -Map bootstrap.map -s -N -o bootstrap.axf bootstrap.o opcode_emu.o
|
| 111 |
|
|
-@$(DUMP) -I elf32-big --disassemble bootstrap.axf > bootstrap.lst
|
| 112 |
|
|
|
| 113 |
|
|
bootstrap: bootstrap.axf
|
| 114 |
|
|
$(COPY) -I elf32-big -j .text -j .rodata -O binary bootstrap.axf bootstrap.code
|
| 115 |
|
|
$(COPY) -I elf32-big -j .sbss -j .data -j .bss -O binary bootstrap.axf bootstrap.data
|
| 116 |
|
|
|
| 117 |
|
|
|
| 118 |
|
|
#-- Let's make some implicit rules explicit for clarity (well, 'clarity')
|
| 119 |
|
|
|
| 120 |
|
|
%.o: %.c
|
| 121 |
|
|
$(CC) $(CFLAGS_MAIN) $< -o $@
|
| 122 |
|
|
|
| 123 |
|
|
|
| 124 |
|
|
#-- Targets that build the synthesizable vhdl; meant for direct invocation -----
|
| 125 |
|
|
|
| 126 |
|
|
|
| 127 |
|
|
|
| 128 |
229 |
ja_rd |
#-- Create VHDL package with data and parameters for simulation
|
| 129 |
193 |
ja_rd |
sim: bootstrap adventure demo
|
| 130 |
229 |
ja_rd |
$(VHDL_OBJ_PKG) --project="Adventure" \
|
| 131 |
|
|
--package sim_params_pkg \
|
| 132 |
|
|
--bin bootstrap.code --name obj_code --bram_size $(CODE_BRAM_SIZE) \
|
| 133 |
|
|
--name sram_init --xram_size $(XRAM_SIZE) \
|
| 134 |
|
|
--bin adventure.bin --name prom_init --flash_size $(FLASH_SIM_SIZE) \
|
| 135 |
|
|
--output $(TB_DIR)/sim_params_pkg.vhdl \
|
| 136 |
|
|
-s $(SIM_LENGTH) --log_trigger=0xb0000000 \
|
| 137 |
90 |
ja_rd |
|
| 138 |
|
|
|
| 139 |
|
|
# Create VHDL file for hardware demo
|
| 140 |
177 |
ja_rd |
demo: bootstrap adventure
|
| 141 |
229 |
ja_rd |
$(VHDL_OBJ_PKG) --project="Adventure" \
|
| 142 |
|
|
--package obj_code_pkg \
|
| 143 |
|
|
--bin bootstrap.code --name obj_code \
|
| 144 |
|
|
--output $(DEMO_DIR)/../SoC/bootstrap_code_pkg.vhdl
|
| 145 |
177 |
ja_rd |
|
| 146 |
|
|
|
| 147 |
|
|
#-- And now the usual housekeeping stuff ---------------------------------------
|
| 148 |
|
|
|
| 149 |
|
|
.PHONY: clean
|
| 150 |
|
|
|
| 151 |
|
|
clean:
|
| 152 |
|
|
-$(RM) *.o *.obj *.map *.lst *.hex *.exe *.axf *.code *.data *.bin
|