1 |
176 |
ja_rd |
#-- Set up the toolchain -------------------------------------------------------
|
2 |
2 |
ja_rd |
|
3 |
176 |
ja_rd |
BIN_MIPS = C:/dev/embedded/SourceryGpp/mips-elf-11-03.52/bin
|
4 |
|
|
CC = $(BIN_MIPS)/mips-sde-elf-gcc.exe $(CFLAGS)
|
5 |
|
|
AS = $(BIN_MIPS)/mips-sde-elf-as
|
6 |
|
|
LD = $(BIN_MIPS)/mips-sde-elf-ld
|
7 |
|
|
DUMP = $(BIN_MIPS)/mips-sde-elf-objdump
|
8 |
|
|
COPY = $(BIN_MIPS)/mips-sde-elf-objcopy
|
9 |
|
|
TO_VHDL = python ../bin2hdl.py
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
#-- Set up the code structure --------------------------------------------------
|
13 |
|
|
|
14 |
|
|
# VHDL test bench directory, where VHDL output files will be created
|
15 |
|
|
TB_DIR = ../../vhdl/tb
|
16 |
|
|
# VHDL DE-1 board demo root directory, for vhdl output
|
17 |
|
|
DEMO_DIR = ../../vhdl/demo
|
18 |
|
|
# Root test code source directory, where python script and vhdl templates are
|
19 |
|
|
SRC_DIR = ..
|
20 |
|
|
LIB_PATH = $(SRC_DIR)/common/libsoc
|
21 |
181 |
ja_rd |
LINK_SCRIPT = $(SRC_DIR)/common/bram.lds
|
22 |
176 |
ja_rd |
|
23 |
|
|
#-- Configure the application --------------------------------------------------
|
24 |
|
|
|
25 |
|
|
# Simulation length in cycles; long enough to let the program run to completion.
|
26 |
111 |
ja_rd |
SIM_LENGTH = 90000
|
27 |
176 |
ja_rd |
|
28 |
66 |
ja_rd |
# FPGA Block RAM parameters
|
29 |
|
|
BRAM_START = 0xbfc00000
|
30 |
|
|
CODE_BRAM_SIZE = 2048
|
31 |
|
|
# External RAM parameters (size in words)
|
32 |
|
|
XRAM_SIZE = 1024
|
33 |
176 |
ja_rd |
XRAM_START = 0x00000000
|
34 |
2 |
ja_rd |
|
35 |
176 |
ja_rd |
|
36 |
|
|
# 1.- Put the code in internal BRAM and the data in external SRAM.
|
37 |
|
|
# 2.- Do not use any of the standard libraries and use libsoc instead.
|
38 |
|
|
|
39 |
|
|
LFLAGS = -T$(LINK_SCRIPT) -L $(LIB_PATH) \
|
40 |
|
|
-Ttext $(BRAM_START) -Tdata $(XRAM_START) \
|
41 |
|
|
-nodefaultlibs -nostdlib -ereset -I elf32-big
|
42 |
|
|
CFLAGS = -O2 -Wall -c -s -fno-builtin -nodefaultlibs -nostdlib \
|
43 |
|
|
-msoft-float -mips1 -G0
|
44 |
|
|
AFLAGS = --defsym XRAM_BASE=$(XRAM_START)
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
OBJS = bootstrap.o opcode_emu.o c_startup.o hello.o
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
#-- Targets & rules ------------------------------------------------------------
|
51 |
|
|
|
52 |
|
|
hello: hello.code hello.data
|
53 |
|
|
@# This comment prevents use of implicit rule so our rules are used instead.
|
54 |
|
|
@# This will save us a few harmless linker warnings.
|
55 |
|
|
|
56 |
|
|
hello.axf: $(OBJS)
|
57 |
|
|
$(LD) $(LFLAGS) -Map hello.map -s -N -o hello.axf $(OBJS) -lsoc
|
58 |
|
|
-@$(DUMP) -m mips --disassemble hello.axf > hello.lst
|
59 |
|
|
|
60 |
|
|
hello.code: hello.axf
|
61 |
66 |
ja_rd |
# Extract object code to be placed in code space
|
62 |
176 |
ja_rd |
$(COPY) -I elf32-big -O binary hello.axf hello.code
|
63 |
|
|
|
64 |
|
|
hello.data: hello.axf
|
65 |
66 |
ja_rd |
# Extract object code to be placed in data space
|
66 |
176 |
ja_rd |
$(COPY) -I elf32-big -j.data -j.bss -O binary hello.axf hello.data
|
67 |
49 |
ja_rd |
|
68 |
123 |
ja_rd |
|
69 |
176 |
ja_rd |
|
70 |
|
|
bootstrap.o: $(SRC_DIR)/common/bootstrap.s
|
71 |
|
|
$(AS) $(AFLAGS) -o bootstrap.o $(SRC_DIR)/common/bootstrap.s
|
72 |
|
|
|
73 |
|
|
c_startup.o: $(SRC_DIR)/common/c_startup.s
|
74 |
|
|
$(AS) $(AFLAGS) -o c_startup.o $(SRC_DIR)/common/c_startup.s
|
75 |
|
|
|
76 |
|
|
opcode_emu.o: $(SRC_DIR)/common/opcode_emu.s
|
77 |
|
|
$(AS) $(AFLAGS) -o opcode_emu.o $(SRC_DIR)/common/opcode_emu.s
|
78 |
|
|
|
79 |
|
|
hello.o: hello.c
|
80 |
|
|
$(CC) $(CFLAGS) -o hello.o hello.c
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
#-- Targets that build the synthesizable vhdl; meant for direct invocation -----
|
85 |
|
|
|
86 |
|
|
#-- Create VHDL file for simulation test bench using TB2 template
|
87 |
|
|
sim: hello
|
88 |
34 |
ja_rd |
$(TO_VHDL) --code hello.code --data hello.data \
|
89 |
176 |
ja_rd |
--code_size $(CODE_BRAM_SIZE) --data_size $(XRAM_SIZE) \
|
90 |
|
|
--log_trigger=0xbfc00000 \
|
91 |
49 |
ja_rd |
-s $(SIM_LENGTH) -v $(SRC_DIR)\\mips_tb2_template.vhdl \
|
92 |
|
|
-o $(TB_DIR)\\mips_tb2.vhdl -e mips_tb2
|
93 |
2 |
ja_rd |
|
94 |
176 |
ja_rd |
#-- Create VHDL file for simulation test bench using TB0 template
|
95 |
|
|
sim_bram: hello
|
96 |
123 |
ja_rd |
$(TO_VHDL) --code hello.code --data hello.data \
|
97 |
|
|
--code_size $(CODE_BRAM_SIZE) --data_size $(XRAM_SIZE) \
|
98 |
|
|
-s $(SIM_LENGTH) -v $(SRC_DIR)\\mips_tb0_template.vhdl \
|
99 |
|
|
-o $(TB_DIR)\\mips_tb2.vhdl -e mips_tb2
|
100 |
49 |
ja_rd |
|
101 |
176 |
ja_rd |
#-- Create VHDL file for hardware demo
|
102 |
|
|
demo: hello
|
103 |
34 |
ja_rd |
$(TO_VHDL) --code hello.code --data hello.data \
|
104 |
49 |
ja_rd |
--code_size $(CODE_BRAM_SIZE) --data_size $(XRAM_SIZE) \
|
105 |
|
|
-v $(SRC_DIR)/mips_mpu1_template.vhdl \
|
106 |
|
|
-o $(DEMO_DIR)/mips_mpu.vhdl -e mips_mpu
|
107 |
176 |
ja_rd |
|
108 |
|
|
|
109 |
|
|
#-- And now the usual housekeeping stuff ---------------------------------------
|
110 |
|
|
|
111 |
|
|
.PHONY: clean
|
112 |
|
|
|
113 |
|
|
clean:
|
114 |
|
|
-$(RM) *.o *.obj *.map *.lst *.hex *.exe *.axf *.code *.data *.bin
|