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 |
388 |
rhoads |
@echo make targets = count, opcodes, pi, test, run, tohex,\
|
48 |
389 |
rhoads |
bootldr, toimage, eterm
|
49 |
363 |
rhoads |
|
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 |
389 |
rhoads |
# Terminal program that will download a new image.
|
73 |
|
|
# For Linux, use any serial port program at 57600 baud 8-bits;1-stop bit
|
74 |
|
|
# This mode does not support Ethernet packet transfers.
|
75 |
|
|
eterm: etermip.c
|
76 |
|
|
-@$(CC_X86) -o etermip.exe etermip.c
|
77 |
|
|
|
78 |
363 |
rhoads |
# Terminal program that will download a new image and supports Ethernet
|
79 |
|
|
# traffic over UART. Get wpcap.lib from http://www.winpcap.org/.
|
80 |
|
|
# Requires Windows OS
|
81 |
386 |
rhoads |
# Uses wpcap.lib for receiving and transmitting raw Ethernet packets
|
82 |
|
|
# Get wpcap.lib from http://www.winpcap.org/.
|
83 |
389 |
rhoads |
etermip: etermip.c
|
84 |
363 |
rhoads |
@echo Get wpcap.lib from http://www.winpcap.org/
|
85 |
386 |
rhoads |
-@$(CC_X86) -DUSE_WPCAP -o etermip.exe etermip.c wpcap.lib
|
86 |
363 |
rhoads |
|
87 |
|
|
nomult.exe: nomult.c
|
88 |
|
|
-@$(CC_X86) -o nomult.exe nomult.c
|
89 |
|
|
|
90 |
|
|
download: etermip
|
91 |
|
|
@echo Reset board before downloading code
|
92 |
|
|
etermip
|
93 |
|
|
|
94 |
|
|
opcodes:
|
95 |
|
|
$(AS_MIPS) -o opcodes.o opcodes.asm
|
96 |
|
|
$(LD_MIPS) -Ttext 0 -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 |
|
|
opcodes2:
|
102 |
|
|
$(AS_MIPS) -o opcodes.o opcodes.asm
|
103 |
|
|
$(LD_MIPS) -Ttext 0x10000000 -eentry -Map test.map -s -N -o test.axf opcodes.o
|
104 |
|
|
-@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
105 |
|
|
$(CONVERT_BIN)
|
106 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
107 |
|
|
|
108 |
|
|
test:
|
109 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
110 |
|
|
$(GCC_MIPS) test.c
|
111 |
|
|
$(GCC_MIPS) no_os.c
|
112 |
|
|
$(LD_MIPS) -Ttext 0 -eentry -Map test.map -s -N -o test.axf \
|
113 |
|
|
boot.o test.o no_os.o
|
114 |
|
|
-@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
115 |
|
|
$(CONVERT_BIN)
|
116 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
117 |
|
|
|
118 |
|
|
count:
|
119 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
120 |
|
|
$(GCC_MIPS) count.c
|
121 |
|
|
$(GCC_MIPS) no_os.c
|
122 |
|
|
$(LD_MIPS) -Ttext 0 -eentry -Map test.map -s -N -o test.axf \
|
123 |
|
|
boot.o count.o no_os.o
|
124 |
|
|
-$(DUMP_MIPS) --disassemble test.axf > test.lst
|
125 |
|
|
$(CONVERT_BIN)
|
126 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
127 |
|
|
|
128 |
|
|
count_le:
|
129 |
|
|
$(AS_MIPS) -EL -o boot.o boot.asm
|
130 |
|
|
$(GCC_MIPS) -EL count.c
|
131 |
|
|
$(GCC_MIPS) -EL no_os.c
|
132 |
|
|
$(LD_MIPS) -EL -Ttext 0 -eentry -Map test.map -s -N -o test.axf \
|
133 |
|
|
boot.o count.o no_os.o
|
134 |
|
|
-$(DUMP_MIPS) --disassemble test.axf > test.lst
|
135 |
|
|
$(CONVERT_BIN)
|
136 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
137 |
|
|
|
138 |
|
|
count2:
|
139 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
140 |
|
|
$(GCC_MIPS) count.c
|
141 |
|
|
$(GCC_MIPS) no_os.c
|
142 |
|
|
$(LD_MIPS) -Ttext 0x10000000 -eentry -Map test.map -s -N -o test.axf \
|
143 |
|
|
boot.o count.o no_os.o
|
144 |
|
|
-$(DUMP_MIPS) --disassemble test.axf > test.lst
|
145 |
|
|
$(CONVERT_BIN)
|
146 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
147 |
|
|
|
148 |
|
|
count3:
|
149 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
150 |
|
|
$(GCC_MIPS) count.c
|
151 |
|
|
$(GCC_MIPS) no_os.c
|
152 |
386 |
rhoads |
$(LD_MIPS) -Ttext 0x2000 -eentry -Map test.map -s -N -o test.axf \
|
153 |
363 |
rhoads |
boot.o count.o no_os.o
|
154 |
|
|
-$(DUMP_MIPS) --disassemble test.axf > test.lst
|
155 |
|
|
$(CONVERT_BIN)
|
156 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
157 |
|
|
|
158 |
|
|
count5: nomult.exe
|
159 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
160 |
|
|
$(AS_MIPS) -o mult_sim.o mult_sim.asm
|
161 |
|
|
$(GCC_MIPS) count.c
|
162 |
|
|
$(GCC_MIPS) no_os.c
|
163 |
|
|
$(LD_MIPS) -Ttext 0x10000000 -eentry -Map test.map -s -N -o test.axf \
|
164 |
|
|
boot.o mult_sim.o count.o no_os.o
|
165 |
|
|
-$(DUMP_MIPS) --disassemble test.axf > test.lst
|
166 |
|
|
$(CP) test.axf test_old.axf
|
167 |
|
|
nomult test.axf test.lst test.map
|
168 |
|
|
-$(DUMP_MIPS) --disassemble test.axf > test2.lst
|
169 |
|
|
$(CONVERT_BIN)
|
170 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
171 |
|
|
|
172 |
|
|
pi:
|
173 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
174 |
|
|
$(GCC_MIPS) pi.c
|
175 |
|
|
$(LD_MIPS) -Ttext 0 -eentry -Map test.map -s -N -o test.axf \
|
176 |
|
|
boot.o pi.o
|
177 |
|
|
@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
178 |
|
|
$(CONVERT_BIN)
|
179 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
180 |
|
|
|
181 |
|
|
pi2:
|
182 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
183 |
|
|
$(GCC_MIPS) pi.c
|
184 |
|
|
$(LD_MIPS) -Ttext 0x10000000 -eentry -Map test.map -s -N -o test.axf \
|
185 |
|
|
boot.o pi.o
|
186 |
|
|
@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
187 |
|
|
$(CONVERT_BIN)
|
188 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
189 |
|
|
|
190 |
|
|
pi5: nomult.exe
|
191 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
192 |
|
|
$(AS_MIPS) -o mult_sim.o mult_sim.asm
|
193 |
|
|
$(GCC_MIPS) pi.c
|
194 |
|
|
$(LD_MIPS) -Ttext 0x0 -eentry -Map test.map -s -N -o test.axf \
|
195 |
|
|
boot.o mult_sim.o pi.o
|
196 |
|
|
@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
197 |
|
|
nomult test.axf test.lst test.map
|
198 |
|
|
@$(DUMP_MIPS) --disassemble test.axf > test2.lst
|
199 |
|
|
$(CONVERT_BIN)
|
200 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
201 |
|
|
|
202 |
|
|
ddr_test:
|
203 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
204 |
|
|
$(GCC_MIPS) ddr_init.c -DDDR_TEST_MAIN
|
205 |
|
|
$(GCC_MIPS) no_os.c
|
206 |
|
|
$(LD_MIPS) -Ttext 0x0 -eentry -Map test.map -s -N -o test.axf \
|
207 |
|
|
boot.o ddr_init.o no_os.o
|
208 |
|
|
@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
209 |
|
|
$(CONVERT_BIN)
|
210 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
211 |
|
|
|
212 |
|
|
memtest:
|
213 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
214 |
|
|
$(GCC_MIPS) memtest.c
|
215 |
386 |
rhoads |
$(LD_MIPS) -Ttext 0x2000 -eentry -o test.axf boot.o memtest.o
|
216 |
363 |
rhoads |
$(CONVERT_BIN)
|
217 |
|
|
|
218 |
|
|
memtest2:
|
219 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
220 |
|
|
$(GCC_MIPS) -DINIT_DDR memtest.c
|
221 |
|
|
$(GCC_MIPS) ddr_init.c
|
222 |
|
|
$(LD_MIPS) -Ttext 0x0 -eentry -o test.axf boot.o memtest.o ddr_init.o
|
223 |
|
|
$(CONVERT_BIN)
|
224 |
|
|
|
225 |
|
|
memtest3:
|
226 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
227 |
|
|
$(GCC_MIPS) memtest.c
|
228 |
|
|
$(LD_MIPS) -Ttext 0x10000000 -eentry -o test.axf boot.o memtest.o
|
229 |
|
|
$(CONVERT_BIN)
|
230 |
|
|
|
231 |
|
|
bootldr:
|
232 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
233 |
|
|
$(GCC_MIPS) bootldr.c
|
234 |
|
|
$(GCC_MIPS) no_os.c
|
235 |
|
|
$(GCC_MIPS) -DDLL_DISABLE ddr_init.c
|
236 |
|
|
$(LD_MIPS) -Ttext 0 -eentry -Map test.map -s -N -o test.axf \
|
237 |
|
|
boot.o bootldr.o no_os.o ddr_init.o
|
238 |
|
|
@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
239 |
|
|
$(CONVERT_BIN)
|
240 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
241 |
|
|
@echo Next do "make toimage" for Xilinx or "make tohex" for Altera.
|
242 |
|
|
|
243 |
|
|
bootldr2:
|
244 |
|
|
$(AS_MIPS) -o boot.o boot.asm
|
245 |
|
|
$(GCC_MIPS) bootldr.c
|
246 |
|
|
$(GCC_MIPS) no_os.c
|
247 |
|
|
$(GCC_MIPS) -DDLL_DISABLE ddr_init.c
|
248 |
|
|
$(LD_MIPS) -Ttext 0x1000 -eentry -Map test.map -s -N -o test.axf \
|
249 |
|
|
boot.o bootldr.o no_os.o ddr_init.o
|
250 |
|
|
@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
251 |
|
|
$(CONVERT_BIN)
|
252 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
253 |
|
|
|
254 |
|
|
bootldr_little_endian: convert_le.exe
|
255 |
|
|
$(AS_MIPS) -EL -o boot.o boot.asm
|
256 |
|
|
$(GCC_MIPS) -EL bootldr.c
|
257 |
|
|
$(GCC_MIPS) -EL no_os.c
|
258 |
|
|
$(GCC_MIPS) -EL ddr_init.c
|
259 |
|
|
$(LD_MIPS) -EL -Ttext 0 -eentry -Map test.map -s -N -o test.axf \
|
260 |
|
|
boot.o bootldr.o no_os.o ddr_init.o
|
261 |
|
|
@$(DUMP_MIPS) --disassemble test.axf > test.lst
|
262 |
|
|
$(LINUX_PWD)convert_le.exe
|
263 |
|
|
$(CP) code.txt $(VHDL_DIR)
|
264 |
|
|
|
265 |
|
|
# Run a MIPS opcode simulator
|
266 |
|
|
run: mlite.exe
|
267 |
|
|
@$(LINUX_PWD)mlite.exe test.bin
|
268 |
|
|
|
269 |
|
|
run_little_endian: mlite.exe
|
270 |
|
|
@$(LINUX_PWD)mlite.exe test.bin L
|
271 |
|
|
|
272 |
|
|
disassemble: mlite.exe
|
273 |
|
|
$(LINUX_PWD)mlite.exe test.bin BD > test.txt
|
274 |
|
|
|
275 |
|
|
# Used by Altera FPGAs for ram image
|
276 |
|
|
tohex: bintohex.exe
|
277 |
|
|
$(LINUX_PWD)bintohex.exe test.bin
|
278 |
|
|
$(CP) code*.hex $(VHDL_DIR)
|
279 |
|
|
|
280 |
|
|
# Used by Xilinx FPGAs for ram image
|
281 |
|
|
toimage:
|
282 |
|
|
$(LINUX_PWD)ram_image.exe ../vhdl/ram_xilinx.vhd ../vhdl/code.txt ../vhdl/ram_image.vhd
|
283 |
|
|
|
284 |
|
|
|