| 1 |
185 |
ja_rd |
#-- Bring toolchain config parameters from the common makefile -----------------
|
| 2 |
191 |
ja_rd |
include ../common/makefile
|
| 3 |
50 |
ja_rd |
|
| 4 |
|
|
# We'll run the simulation for long enough to complete the test
|
| 5 |
109 |
ja_rd |
SIM_LENGTH = 400000
|
| 6 |
66 |
ja_rd |
|
| 7 |
|
|
# FPGA Block RAM parameters
|
| 8 |
|
|
BRAM_START = 0xbfc00000
|
| 9 |
50 |
ja_rd |
CODE_BRAM_SIZE = 2048
|
| 10 |
109 |
ja_rd |
FLASH_START = 0xb0000000
|
| 11 |
66 |
ja_rd |
# External RAM parameters (size in words)
|
| 12 |
50 |
ja_rd |
XRAM_SIZE = 1024
|
| 13 |
90 |
ja_rd |
XRAM_START = 0x00000000
|
| 14 |
50 |
ja_rd |
|
| 15 |
66 |
ja_rd |
|
| 16 |
|
|
LFLAGS = -Ttext $(BRAM_START) -Tdata $(XRAM_START) -eentry -I elf32-big
|
| 17 |
109 |
ja_rd |
LFLAGS_FLASH = -Ttext $(FLASH_START) -eflash_test -I elf32-big
|
| 18 |
50 |
ja_rd |
|
| 19 |
185 |
ja_rd |
OBJS = memtest.o
|
| 20 |
109 |
ja_rd |
|
| 21 |
185 |
ja_rd |
#-- Configuration --------------------------------------------------------------
|
| 22 |
50 |
ja_rd |
|
| 23 |
185 |
ja_rd |
# Set to !=0 to test execution from flash
|
| 24 |
|
|
# (Set to 0 if running on real HW on which you have no initialized FLASH)
|
| 25 |
|
|
EXEC_FLASH = 1
|
| 26 |
50 |
ja_rd |
|
| 27 |
185 |
ja_rd |
#-- Targets & rules ------------------------------------------------------------
|
| 28 |
50 |
ja_rd |
|
| 29 |
185 |
ja_rd |
#-- Main target -- build code for BRAM and FLASH
|
| 30 |
|
|
memtest: memtest.code memtest.data flash.bin
|
| 31 |
|
|
-@# This comment prevents triggering the default rule. Instead, make will
|
| 32 |
|
|
-@# invoke our rules for the dependencies.
|
| 33 |
|
|
|
| 34 |
|
|
#-- Targets for main code to be run from BRAM
|
| 35 |
|
|
|
| 36 |
|
|
memtest.o: memtest.s
|
| 37 |
|
|
$(AS) -defsym TEST_CACHE=1 -defsym EXEC_FLASH=$(EXEC_FLASH) \
|
| 38 |
|
|
-defsym XRAM_BASE=$(XRAM_START) -o memtest.o memtest.s
|
| 39 |
|
|
|
| 40 |
|
|
memtest.axf: memtest.o
|
| 41 |
|
|
$(LD) $(LFLAGS) -Map memtest.map -s -N -o memtest.axf memtest.o
|
| 42 |
|
|
-@$(DUMP) -I elf32-big --disassemble memtest.axf > memtest.lst
|
| 43 |
|
|
|
| 44 |
|
|
# Dump code and data to separate binaries (data binary will be empty but
|
| 45 |
|
|
# TB2 needs it anyway)
|
| 46 |
|
|
|
| 47 |
|
|
memtest.code: memtest.axf
|
| 48 |
|
|
$(COPY) -I elf32-big -j .text -j .rodata -O binary memtest.axf memtest.code
|
| 49 |
|
|
memtest.data: memtest.axf
|
| 50 |
|
|
$(COPY) -I elf32-big -j .sbss -j .data -j .bss -O binary memtest.axf memtest.data
|
| 51 |
|
|
|
| 52 |
|
|
#-- Targets for code to be run from FLASH
|
| 53 |
|
|
|
| 54 |
|
|
flash.o: flash.s
|
| 55 |
|
|
$(AS) -defsym TEST_CACHE=1 -defsym FLASH_BASE=$(FLASH_START) -o flash.o flash.s
|
| 56 |
|
|
|
| 57 |
|
|
flash.axf: flash.o
|
| 58 |
|
|
$(LD) $(LFLAGS_FLASH) -Map flash.map -s -N -o flash.axf flash.o
|
| 59 |
|
|
-@$(DUMP) -I elf32-big --disassemble flash.axf > flash.lst
|
| 60 |
|
|
|
| 61 |
|
|
flash.bin: flash.axf
|
| 62 |
|
|
$(COPY) -I elf32-big -j .text -j .rodata -O binary flash.axf flash.bin
|
| 63 |
|
|
|
| 64 |
|
|
|
| 65 |
|
|
|
| 66 |
|
|
#-- Targets that build the synthesizable vhdl; meant for direct invocation -----
|
| 67 |
|
|
|
| 68 |
50 |
ja_rd |
# Create VHDL file for simulation test bench using TB2 template
|
| 69 |
193 |
ja_rd |
sim: memtest demo
|
| 70 |
109 |
ja_rd |
$(TO_VHDL) --code memtest.code --data memtest.data --log_trigger=0xbfc00000 \
|
| 71 |
149 |
ja_rd |
--flash flash.bin --flash_size 4096 \
|
| 72 |
50 |
ja_rd |
--code_size $(CODE_BRAM_SIZE) --data_size $(XRAM_SIZE) \
|
| 73 |
|
|
-s $(SIM_LENGTH) -v $(SRC_DIR)\\mips_tb2_template.vhdl \
|
| 74 |
|
|
-o $(TB_DIR)\\mips_tb2.vhdl -e mips_tb2
|
| 75 |
193 |
ja_rd |
$(TO_VHDL) --code memtest.code --data memtest.data --log_trigger=0xbfc00000 \
|
| 76 |
|
|
--flash flash.bin --flash_size 4096 \
|
| 77 |
|
|
--code_size $(CODE_BRAM_SIZE) --data_size $(XRAM_SIZE) \
|
| 78 |
|
|
-s $(SIM_LENGTH) -v $(SRC_DIR)/sim_params_template.vhdl \
|
| 79 |
|
|
-o $(TB_DIR)/sim_params_pkg.vhdl -e mips_tb2
|
| 80 |
50 |
ja_rd |
|
| 81 |
|
|
|
| 82 |
|
|
# Create VHDL file for hardware demo
|
| 83 |
185 |
ja_rd |
demo: memtest
|
| 84 |
149 |
ja_rd |
$(TO_VHDL) --code memtest.code --data memtest.data --log_trigger=0xb0000000 \
|
| 85 |
50 |
ja_rd |
--code_size $(CODE_BRAM_SIZE) --data_size $(XRAM_SIZE) \
|
| 86 |
191 |
ja_rd |
-v $(SRC_DIR)/code_rom_template.vhdl -n "Memory test" \
|
| 87 |
|
|
-o $(DEMO_DIR)/code_rom_pkg.vhdl
|
| 88 |
185 |
ja_rd |
|
| 89 |
|
|
|
| 90 |
|
|
#-- And now the usual housekeeping stuff ---------------------------------------
|
| 91 |
|
|
|
| 92 |
|
|
.PHONY: clean
|
| 93 |
|
|
|
| 94 |
|
|
clean:
|
| 95 |
|
|
-$(RM) *.o *.obj *.map *.lst *.hex *.exe *.axf *.code *.data *.bin
|