1 |
363 |
rhoads |
# The CC_X86 is for compiling tools on your PC.
|
2 |
|
|
# The GCC_MIPS is for compiling code on the target.
|
3 |
|
|
# Convert_bin changes test.axf into code.txt which is used by the VHDL.
|
4 |
|
|
# Convert_bin == "objcopy -I elf32-big -O binary test.axf test.bin"
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
ifeq ($(LANG),)
|
8 |
|
|
|
9 |
|
|
# Customize for Windows
|
10 |
|
|
# The MIPS gcc compiler must use the cygwin1.dll that came with the compiler.
|
11 |
|
|
CC_X86 = cl /O1 /nologo
|
12 |
|
|
CP = copy
|
13 |
|
|
RM = del
|
14 |
|
|
DWIN32 = -DWIN32
|
15 |
|
|
BIN_MIPS = ..\gccmips_elf
|
16 |
|
|
VHDL_DIR = ..\vhdl
|
17 |
|
|
LINUX_PWD =
|
18 |
|
|
GCC_MIPS = $(BIN_MIPS)\gcc $(CFLAGS)
|
19 |
|
|
AS_MIPS = $(BIN_MIPS)\as
|
20 |
|
|
LD_MIPS = $(BIN_MIPS)\ld
|
21 |
|
|
DUMP_MIPS = $(BIN_MIPS)\objdump
|
22 |
|
|
CONVERT_BIN = $(LINUX_PWD)convert_bin.exe
|
23 |
|
|
|
24 |
|
|
else
|
25 |
|
|
|
26 |
|
|
# Customized for Linux
|
27 |
|
|
# See http://www.opencores.com/projects.cgi/web/mips/linux_tools.htm
|
28 |
|
|
CC_X86 = gcc -Wall -O -g
|
29 |
|
|
CP = cp
|
30 |
|
|
RM = rm -rf
|
31 |
|
|
DWIN32 =
|
32 |
|
|
BIN_MIPS =
|
33 |
|
|
VHDL_DIR = ../vhdl
|
34 |
|
|
LINUX_PWD = ./
|
35 |
|
|
GCC_MIPS = $(BIN_MIPS)mips-elf-gcc $(CFLAGS)
|
36 |
|
|
AS_MIPS = $(BIN_MIPS)mips-elf-as
|
37 |
|
|
LD_MIPS = $(BIN_MIPS)mips-elf-ld
|
38 |
|
|
DUMP_MIPS = $(BIN_MIPS)mips-elf-objdump
|
39 |
|
|
CONVERT_BIN = $(LINUX_PWD)convert_bin.exe
|
40 |
|
|
#CONVERT_BIN = $(BIN_MIPS)mips-elf-objcopy -I elf32-big -O binary test.axf test.bin
|
41 |
|
|
|
42 |
|
|
endif
|
43 |
|
|
|
44 |
|
|
CFLAGS = -O2 -Wall -c -s
|
45 |
|
|
|
46 |
|
|
all: convert_bin.exe tracehex.exe bintohex.exe ram_image.exe
|
47 |
|
|
@echo make targets = count, opcodes, pi, test, run, tohex, \
|
48 |
|
|
bootldr, toimage, etermip
|
49 |
|
|
|
50 |
|
|
clean:
|
51 |
|
|
-$(RM) *.o *.obj *.map *.lst *.hex *.txt *.exe *.axf
|
52 |
|
|
|
53 |
|
|
#Same as "objcopy -I elf32-big -O binary test.axf test.bin"
|
54 |
|
|
convert_bin.exe: convert.c
|
55 |
|
|
@$(CC_X86) -o convert_bin.exe convert.c
|
56 |
|
|
|
57 |
|
|
convert_le.exe: convert.c
|
58 |
|
|
@$(CC_X86) -DLITTLE_ENDIAN -o convert_le.exe convert.c
|
59 |
|
|
|
60 |
|
|
mlite.exe: mlite.c
|
61 |
|
|
@$(CC_X86) -o mlite.exe mlite.c $(DWIN32)
|
62 |
|
|
|
63 |
|
|
tracehex.exe: tracehex.c
|
64 |
|
|
@$(CC_X86) -o tracehex.exe tracehex.c
|
65 |
|
|
|
66 |
|
|
bintohex.exe: bintohex.c
|
67 |
|
|
@$(CC_X86) -o bintohex.exe bintohex.c
|
68 |
|
|
|
69 |
|
|
ram_image.exe: ram_image.c
|
70 |
|
|
@$(CC_X86) -o ram_image.exe ram_image.c
|
71 |
|
|
|
72 |
|
|
# Terminal program that will download a new image and supports Ethernet
|
73 |
|
|
# traffic over UART. Get wpcap.lib from http://www.winpcap.org/.
|
74 |
|
|
# Requires Windows OS
|
75 |
|
|
# For Linux, use any serial port program at 57600 baud 8-bits;1-stop bit
|
76 |
|
|
etermip: etermip.c
|
77 |
|
|
-@$(CC_X86) -o etermip.exe etermip.c wpcap.lib
|
78 |
|
|
@echo Get wpcap.lib from http://www.winpcap.org/
|
79 |
|
|
|
80 |
|
|
nomult.exe: nomult.c
|
81 |
|
|
-@$(CC_X86) -o nomult.exe nomult.c
|
82 |
|
|
|
83 |
|
|
download: etermip
|
84 |
|
|
@echo Reset board before downloading code
|
85 |
|
|
etermip
|
86 |
|
|
|
87 |
|
|
opcodes:
|
88 |
|
|
$(AS_MIPS) -o opcodes.o opcodes.asm
|
89 |
|
|
$(LD_MIPS) -Ttext 0 -eentry -Map test.map -s -N -o test.axf opcodes.o
|
90 |
|
|
-@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
91 |
|
|
$(CONVERT_BIN)
|
92 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
93 |
|
|
|
94 |
|
|
opcodes2:
|
95 |
|
|
$(AS_MIPS) -o opcodes.o opcodes.asm
|
96 |
|
|
$(LD_MIPS) -Ttext 0x10000000 -eentry -Map test.map -s -N -o test.axf opcodes.o
|
97 |
|
|
-@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
98 |
|
|
$(CONVERT_BIN)
|
99 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
100 |
|
|
|
101 |
|
|
test:
|
102 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
103 |
|
|
$(GCC_MIPS) test.c
|
104 |
|
|
$(GCC_MIPS) no_os.c
|
105 |
|
|
$(LD_MIPS) -Ttext 0 -eentry -Map test.map -s -N -o test.axf \
|
106 |
|
|
boot.o test.o no_os.o
|
107 |
|
|
-@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
108 |
|
|
$(CONVERT_BIN)
|
109 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
110 |
|
|
|
111 |
|
|
count:
|
112 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
113 |
|
|
$(GCC_MIPS) count.c
|
114 |
|
|
$(GCC_MIPS) no_os.c
|
115 |
|
|
$(LD_MIPS) -Ttext 0 -eentry -Map test.map -s -N -o test.axf \
|
116 |
|
|
boot.o count.o no_os.o
|
117 |
|
|
-$(DUMP_MIPS) --disassemble test.axf > test.lst
|
118 |
|
|
$(CONVERT_BIN)
|
119 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
120 |
|
|
|
121 |
|
|
count_le:
|
122 |
|
|
$(AS_MIPS) -EL -o boot.o boot.asm
|
123 |
|
|
$(GCC_MIPS) -EL count.c
|
124 |
|
|
$(GCC_MIPS) -EL no_os.c
|
125 |
|
|
$(LD_MIPS) -EL -Ttext 0 -eentry -Map test.map -s -N -o test.axf \
|
126 |
|
|
boot.o count.o no_os.o
|
127 |
|
|
-$(DUMP_MIPS) --disassemble test.axf > test.lst
|
128 |
|
|
$(CONVERT_BIN)
|
129 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
130 |
|
|
|
131 |
|
|
count2:
|
132 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
133 |
|
|
$(GCC_MIPS) count.c
|
134 |
|
|
$(GCC_MIPS) no_os.c
|
135 |
|
|
$(LD_MIPS) -Ttext 0x10000000 -eentry -Map test.map -s -N -o test.axf \
|
136 |
|
|
boot.o count.o no_os.o
|
137 |
|
|
-$(DUMP_MIPS) --disassemble test.axf > test.lst
|
138 |
|
|
$(CONVERT_BIN)
|
139 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
140 |
|
|
|
141 |
|
|
count3:
|
142 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
143 |
|
|
$(GCC_MIPS) count.c
|
144 |
|
|
$(GCC_MIPS) no_os.c
|
145 |
|
|
$(LD_MIPS) -Ttext 0x1000 -eentry -Map test.map -s -N -o test.axf \
|
146 |
|
|
boot.o count.o no_os.o
|
147 |
|
|
-$(DUMP_MIPS) --disassemble test.axf > test.lst
|
148 |
|
|
$(CONVERT_BIN)
|
149 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
150 |
|
|
|
151 |
|
|
count5: nomult.exe
|
152 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
153 |
|
|
$(AS_MIPS) -o mult_sim.o mult_sim.asm
|
154 |
|
|
$(GCC_MIPS) count.c
|
155 |
|
|
$(GCC_MIPS) no_os.c
|
156 |
|
|
$(LD_MIPS) -Ttext 0x10000000 -eentry -Map test.map -s -N -o test.axf \
|
157 |
|
|
boot.o mult_sim.o count.o no_os.o
|
158 |
|
|
-$(DUMP_MIPS) --disassemble test.axf > test.lst
|
159 |
|
|
$(CP) test.axf test_old.axf
|
160 |
|
|
nomult test.axf test.lst test.map
|
161 |
|
|
-$(DUMP_MIPS) --disassemble test.axf > test2.lst
|
162 |
|
|
$(CONVERT_BIN)
|
163 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
164 |
|
|
|
165 |
|
|
pi:
|
166 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
167 |
|
|
$(GCC_MIPS) pi.c
|
168 |
|
|
$(LD_MIPS) -Ttext 0 -eentry -Map test.map -s -N -o test.axf \
|
169 |
|
|
boot.o pi.o
|
170 |
|
|
@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
171 |
|
|
$(CONVERT_BIN)
|
172 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
173 |
|
|
|
174 |
|
|
pi2:
|
175 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
176 |
|
|
$(GCC_MIPS) pi.c
|
177 |
|
|
$(LD_MIPS) -Ttext 0x10000000 -eentry -Map test.map -s -N -o test.axf \
|
178 |
|
|
boot.o pi.o
|
179 |
|
|
@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
180 |
|
|
$(CONVERT_BIN)
|
181 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
182 |
|
|
|
183 |
|
|
pi5: nomult.exe
|
184 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
185 |
|
|
$(AS_MIPS) -o mult_sim.o mult_sim.asm
|
186 |
|
|
$(GCC_MIPS) pi.c
|
187 |
|
|
$(LD_MIPS) -Ttext 0x0 -eentry -Map test.map -s -N -o test.axf \
|
188 |
|
|
boot.o mult_sim.o pi.o
|
189 |
|
|
@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
190 |
|
|
nomult test.axf test.lst test.map
|
191 |
|
|
@$(DUMP_MIPS) --disassemble test.axf > test2.lst
|
192 |
|
|
$(CONVERT_BIN)
|
193 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
194 |
|
|
|
195 |
|
|
ddr_test:
|
196 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
197 |
|
|
$(GCC_MIPS) ddr_init.c -DDDR_TEST_MAIN
|
198 |
|
|
$(GCC_MIPS) no_os.c
|
199 |
|
|
$(LD_MIPS) -Ttext 0x0 -eentry -Map test.map -s -N -o test.axf \
|
200 |
|
|
boot.o ddr_init.o no_os.o
|
201 |
|
|
@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
202 |
|
|
$(CONVERT_BIN)
|
203 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
204 |
|
|
|
205 |
|
|
memtest:
|
206 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
207 |
|
|
$(GCC_MIPS) memtest.c
|
208 |
|
|
$(LD_MIPS) -Ttext 0x1000 -eentry -o test.axf boot.o memtest.o
|
209 |
|
|
$(CONVERT_BIN)
|
210 |
|
|
|
211 |
|
|
memtest2:
|
212 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
213 |
|
|
$(GCC_MIPS) -DINIT_DDR memtest.c
|
214 |
|
|
$(GCC_MIPS) ddr_init.c
|
215 |
|
|
$(LD_MIPS) -Ttext 0x0 -eentry -o test.axf boot.o memtest.o ddr_init.o
|
216 |
|
|
$(CONVERT_BIN)
|
217 |
|
|
|
218 |
|
|
memtest3:
|
219 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
220 |
|
|
$(GCC_MIPS) memtest.c
|
221 |
|
|
$(LD_MIPS) -Ttext 0x10000000 -eentry -o test.axf boot.o memtest.o
|
222 |
|
|
$(CONVERT_BIN)
|
223 |
|
|
|
224 |
|
|
bootldr:
|
225 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
226 |
|
|
$(GCC_MIPS) bootldr.c
|
227 |
|
|
$(GCC_MIPS) no_os.c
|
228 |
|
|
$(GCC_MIPS) -DDLL_DISABLE ddr_init.c
|
229 |
|
|
$(LD_MIPS) -Ttext 0 -eentry -Map test.map -s -N -o test.axf \
|
230 |
|
|
boot.o bootldr.o no_os.o ddr_init.o
|
231 |
|
|
@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
232 |
|
|
$(CONVERT_BIN)
|
233 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
234 |
|
|
@echo Next do "make toimage" for Xilinx or "make tohex" for Altera.
|
235 |
|
|
|
236 |
|
|
bootldr2:
|
237 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
238 |
|
|
$(GCC_MIPS) bootldr.c
|
239 |
|
|
$(GCC_MIPS) no_os.c
|
240 |
|
|
$(GCC_MIPS) -DDLL_DISABLE ddr_init.c
|
241 |
|
|
$(LD_MIPS) -Ttext 0x1000 -eentry -Map test.map -s -N -o test.axf \
|
242 |
|
|
boot.o bootldr.o no_os.o ddr_init.o
|
243 |
|
|
@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
244 |
|
|
$(CONVERT_BIN)
|
245 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
246 |
|
|
|
247 |
|
|
bootldr_little_endian: convert_le.exe
|
248 |
|
|
$(AS_MIPS) -EL -o boot.o boot.asm
|
249 |
|
|
$(GCC_MIPS) -EL bootldr.c
|
250 |
|
|
$(GCC_MIPS) -EL no_os.c
|
251 |
|
|
$(GCC_MIPS) -EL ddr_init.c
|
252 |
|
|
$(LD_MIPS) -EL -Ttext 0 -eentry -Map test.map -s -N -o test.axf \
|
253 |
|
|
boot.o bootldr.o no_os.o ddr_init.o
|
254 |
|
|
@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
255 |
|
|
$(LINUX_PWD)convert_le.exe
|
256 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
257 |
|
|
|
258 |
|
|
# Run a MIPS opcode simulator
|
259 |
|
|
run: mlite.exe
|
260 |
|
|
@$(LINUX_PWD)mlite.exe test.bin
|
261 |
|
|
|
262 |
|
|
run_little_endian: mlite.exe
|
263 |
|
|
@$(LINUX_PWD)mlite.exe test.bin L
|
264 |
|
|
|
265 |
|
|
disassemble: mlite.exe
|
266 |
|
|
$(LINUX_PWD)mlite.exe test.bin BD > test.txt
|
267 |
|
|
|
268 |
|
|
# Used by Altera FPGAs for ram image
|
269 |
|
|
tohex: bintohex.exe
|
270 |
|
|
$(LINUX_PWD)bintohex.exe test.bin
|
271 |
|
|
$(CP) code*.hex $(VHDL_DIR)
|
272 |
|
|
|
273 |
|
|
# Used by Xilinx FPGAs for ram image
|
274 |
|
|
toimage:
|
275 |
|
|
$(LINUX_PWD)ram_image.exe ../vhdl/ram_xilinx.vhd ../vhdl/code.txt ../vhdl/ram_image.vhd
|
276 |
|
|
|
277 |
|
|
|