OpenCores
URL https://opencores.org/ocsvn/forth-cpu/forth-cpu/trunk

Subversion Repositories forth-cpu

[/] [forth-cpu/] [trunk/] [makefile] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 howe.r.j.8
#
2
# Makefile to simulate and synthesize VHDL designs
3
#
4
# @Author      Marc Eberhard/Richard Howe
5 5 howe.r.j.8
# @Copyright   Copyright 2013 Marc Eberhard, 2016,2020 Richard Howe
6 3 howe.r.j.8
# @License     LGPL
7
#
8
# This makefile can build the toolchain, simulators, and the bit
9
# file for the FPGA. Type "make help" at the command line for a
10
# list of options
11
#
12
 
13
NETLIST=top
14 5 howe.r.j.8
CFLAGS=-Wall -Wextra -O2 -g -pedantic
15
CC=gcc
16
TIME=
17 3 howe.r.j.8
#TIME=time -p
18
 
19
OS_FLAGS =
20
# From: https://stackoverflow.com/questions/714100/os-detecting-makefile
21
ifeq ($(OS),Windows_NT)
22
GUI_LDFLAGS = -lfreeglut -lopengl32 -lm
23
DF=
24
EXE=.exe
25
 
26
.PHONY: h2 gui text block
27
 
28
h2:     h2.exe
29
gui:    gui.exe
30
text:   text.exe
31
block:  block.exe
32
 
33
else # assume unixen
34
GUI_LDFLAGS = -lglut -lGL -lm
35
DF=./
36
EXE=
37
endif
38
 
39
.PHONY: simulation viewer synthesis bitfile upload clean run gui-run
40
 
41
## Remember to update the synthesis section as well
42
SOURCES = \
43
        util.vhd \
44
        timer.vhd \
45
        uart.vhd \
46
        kbd.vhd \
47
        vga.vhd \
48
        h2.vhd \
49
        ram.vhd \
50 5 howe.r.j.8
        core.vhd
51 3 howe.r.j.8
 
52
OBJECTS = ${SOURCES:.vhd=.o}
53
 
54
all:
55
        @echo ""
56
        @echo "Simulation:"
57
        @echo ""
58
        @echo "make simulation     - simulate VHDL design"
59
        @echo "make viewer         - start waveform viewer for simulation results"
60
        @echo "make documentation  - build the PDF and HTML documentation"
61
        @echo "make h2${EXE}             - build C based CLI emulator for the VHDL SoC"
62
        @echo "make gui${EXE}            - build C based GUI emulator for the Nexys3 board"
63
        @echo "make run            - run the C CLI emulator on h2.fth"
64 5 howe.r.j.8
        @echo "make gui-run        - run the GUI emulator on ${EFORTH}"
65 3 howe.r.j.8
        @echo ""
66
        @echo "Synthesis:"
67
        @echo ""
68
        @echo "make synthesis      - synthesize design"
69
        @echo "make implementation - implement design"
70
        @echo "make bitfile        - generate bitfile"
71
        @echo ""
72
        @echo "Upload:"
73
        @echo ""
74
        @echo "make upload         - upload design to FPGA"
75
        @echo ""
76
        @echo "Cleanup:"
77
        @echo ""
78
        @echo "make clean          - delete temporary files and cleanup directory"
79
        @echo ""
80
 
81
## Documentation ===========================================================
82
 
83
documentation: readme.pdf readme.htm
84
 
85
%.pdf: %.md
86
        pandoc -V geometry:margin=0.5in --toc $< -o $@
87
 
88
%.htm: %.md
89
        pandoc --toc --self-contained $^ -o $@
90
 
91 5 howe.r.j.8
## Assembler, Virtual Machine and UART communications ======================
92 3 howe.r.j.8
 
93 5 howe.r.j.8
EFORTH=h2.hex
94 3 howe.r.j.8
 
95
h2${EXE}: h2.c h2.h
96
        ${CC} ${CFLAGS} -std=c99 $< -o $@
97
 
98 5 howe.r.j.8
embed${EXE}: embed.c
99
        ${CC} ${CFLAGS} -std=c99 $< -o $@
100 3 howe.r.j.8
 
101 5 howe.r.j.8
${EFORTH}: embed${EXE} embed.blk embed.fth
102
        ${DF}embed${EXE} embed.blk $@ embed.fth
103
 
104 3 howe.r.j.8
block${EXE}: block.c
105
        ${CC} ${CFLAGS} -std=c99 $< -o $@
106
 
107 5 howe.r.j.8
nvram.blk: nvram.txt block${EXE}
108 3 howe.r.j.8
        ${DF}block${EXE} < nvram.txt >  $@
109
 
110 5 howe.r.j.8
run: h2${EXE} ${EFORTH} text.hex nvram.blk
111
        ${DF}h2 -H -r ${EFORTH}
112 3 howe.r.j.8
 
113
h2nomain.o: h2.c h2.h
114
        ${CC} ${CFLAGS} -std=c99 -DNO_MAIN  $< -c -o $@
115
 
116
gui.o: gui.c h2.h
117
        ${CC} ${CFLAGS} -std=gnu99  $< -c -o $@
118
 
119
gui${EXE}: h2nomain.o gui.o
120
        ${CC} ${CFLAGS} $^ ${GUI_LDFLAGS} -o $@
121
 
122 5 howe.r.j.8
gui-run: gui${EXE} ${EFORTH} nvram.blk text.hex
123
        ${DF}$< ${EFORTH}
124 3 howe.r.j.8
 
125
text${EXE}: text.c
126
        ${CC} ${CFLAGS} -std=c99 $< -o $@
127
 
128
text.hex: text${EXE}
129
        ${DF}$< -g > $@
130
 
131
## Simulation ==============================================================
132
 
133
%.o: %.vhd
134 5 howe.r.j.8
        ghdl -a -g $<
135 3 howe.r.j.8
 
136
ram.o: util.o
137
kbd.o: util.o kbd.vhd
138
vga.o: util.o vga.vhd text.hex font.bin
139 5 howe.r.j.8
core.o: util.o h2.o core.vhd ${EFORTH}
140 3 howe.r.j.8
uart.o: util.o uart.vhd
141 5 howe.r.j.8
timer.o: util.o
142
top.o: util.o timer.o core.o uart.o vga.o kbd.o ram.o top.vhd
143 3 howe.r.j.8
tb.o: top.o util.o tb.vhd
144
 
145
tb: ${OBJECTS} tb.o
146
        ghdl -e tb
147
 
148 5 howe.r.j.8
# max stack alloc needed for GHDL >0.35
149
# ghdl -r $< --wave=$<.ghw --max-stack-alloc=16384 --unbuffered --ieee-asserts=disable
150 3 howe.r.j.8
%.ghw: % %.cfg
151 5 howe.r.j.8
        ghdl -r $< --wave=$<.ghw --max-stack-alloc=16384 --ieee-asserts=disable --unbuffered
152 3 howe.r.j.8
 
153
simulation: tb.ghw h2${EXE}
154
 
155
## Simulation ==============================================================
156
 
157
ifeq ($(OS),Windows_NT)
158 5 howe.r.j.8
viewer: simulation signals.tcl
159
        gtkwave -S signals.tcl -f tb.ghw
160 3 howe.r.j.8
else
161 5 howe.r.j.8
viewer: simulation signals.tcl
162
        gtkwave -S signals.tcl -f tb.ghw &> /dev/null&
163 3 howe.r.j.8
endif
164
 
165
USB?=/dev/ttyUSB0
166 5 howe.r.j.8
BAUD?=115200
167
#BAUD?=9600
168 3 howe.r.j.8
 
169
talk:
170 5 howe.r.j.8
        picocom --omap delbs -e b -b ${BAUD} ${USB}
171 3 howe.r.j.8
 
172
bitfile: design.bit
173
 
174
reports:
175
        @[ -d reports    ]    || mkdir reports
176
tmp:
177
        @[ -d tmp        ]    || mkdir tmp
178
tmp/_xmsgs:
179
        @[ -d tmp/_xmsgs ]    || mkdir tmp/_xmsgs
180
 
181
tmp/top.prj: tmp
182
        @rm -f tmp/top.prj
183
        @( \
184
            for f in $(SOURCES); do \
185
                echo "vhdl work \"$$f\""; \
186
            done; \
187
            echo "vhdl work \"top.vhd\"" \
188
        ) > tmp/top.prj
189
 
190
tmp/top.lso: tmp
191
        @echo "work" > tmp/top.lso
192
 
193
tmp/top.xst: tmp tmp/_xmsgs tmp/top.lso tmp/top.lso
194
        @( \
195
            echo "set -tmpdir \"tmp\""; \
196
            echo "set -xsthdpdir \"tmp\""; \
197
            echo "run"; \
198
            echo "-lso tmp/top.lso"; \
199
            echo "-ifn tmp/top.prj"; \
200
            echo "-ofn top"; \
201
            echo "-p xc6slx16-csg324-3"; \
202
            echo "-top top"; \
203
            echo "-opt_mode speed"; \
204
            echo "-opt_level 2" \
205
        ) > tmp/top.xst
206
 
207 5 howe.r.j.8
synthesis: ${EFORTH} text.hex reports tmp tmp/_xmsgs tmp/top.prj tmp/top.xst
208 3 howe.r.j.8
        @echo "Synthesis running..."
209
        @${TIME} xst -intstyle silent -ifn tmp/top.xst -ofn reports/xst.log
210
        @mv _xmsgs/* tmp/_xmsgs
211
        @rmdir _xmsgs
212
        @mv top_xst.xrpt tmp
213
        @grep "ERROR\|WARNING" reports/xst.log | \
214
         grep -v "WARNING.*has a constant value.*This FF/Latch will be trimmed during the optimization process." | \
215
         cat
216 5 howe.r.j.8
        @grep ns reports/xst.log | grep 'Clock period'
217 3 howe.r.j.8
 
218
implementation: reports tmp
219
        @echo "Implementation running..."
220
 
221
        @[ -d tmp/xlnx_auto_0_xdb ] || mkdir tmp/xlnx_auto_0_xdb
222
 
223
        @${TIME} ngdbuild -intstyle silent -quiet -dd tmp -uc top.ucf -p xc6slx16-csg324-3 top.ngc top.ngd
224
        @mv top.bld reports/ngdbuild.log
225
        @mv _xmsgs/* tmp/_xmsgs
226
        @rmdir _xmsgs
227
        @mv xlnx_auto_0_xdb/* tmp
228
        @rmdir xlnx_auto_0_xdb
229
        @mv top_ngdbuild.xrpt tmp
230
 
231
        @${TIME} map -intstyle silent -detail -p xc6slx16-csg324-3 -pr b -c 100 -w -o top_map.ncd top.ngd top.pcf
232
        @mv top_map.mrp reports/map.log
233
        @mv _xmsgs/* tmp/_xmsgs
234
        @rmdir _xmsgs
235
        @mv top_usage.xml top_summary.xml top_map.map top_map.xrpt tmp
236
 
237
        @${TIME} par -intstyle silent -w -ol std top_map.ncd top.ncd top.pcf
238
        @mv top.par reports/par.log
239
        @mv top_pad.txt reports/par_pad.txt
240
        @mv _xmsgs/* tmp/_xmsgs
241
        @rmdir _xmsgs
242
        @mv par_usage_statistics.html top.ptwx top.pad top_pad.csv top.unroutes top.xpi top_par.xrpt tmp
243
 
244
        @#trce -intstyle silent -v 3 -s 3 -n 3 -fastpaths -xml top.twx top.ncd -o top.twr top.pcf -ucf top.ucf
245
        @#mv top.twr reports/trce.log
246
        @#mv _xmsgs/* tmp/_xmsgs
247
        @#rmdir _xmsgs
248
        @#mv top.twx tmp
249
 
250
        @#netgen -intstyle silent -ofmt vhdl -sim -w top.ngc top_xsim.vhd
251
        @#netgen -intstyle silent -ofmt vhdl -sim -w -pcf top.pcf top.ncd top_tsim.vhd
252
        @#mv _xmsgs/* tmp/_xmsgs
253
        @#rmdir _xmsgs
254
        @#mv top_xsim.nlf top_tsim.nlf tmp
255
 
256
 
257
design.bit: reports tmp/_xmsgs
258
        @echo "Generate bitfile running..."
259
        @touch webtalk.log
260
        @${TIME} bitgen -intstyle silent -w top.ncd
261
        @mv top.bit design.bit
262
        @mv top.bgn reports/bitgen.log
263
        @mv _xmsgs/* tmp/_xmsgs
264
        @rmdir _xmsgs
265
        @sleep 5
266
        @mv top.drc top_bitgen.xwbt top_usage.xml top_summary.xml webtalk.log tmp
267
        @grep -i '\(warning\|clock period\)' reports/xst.log
268
 
269
upload:
270
        djtgcfg prog -d Nexys3 -i 0 -f design.bit
271
 
272
design: clean simulation synthesis implementation bitfile
273
 
274
postsyn:
275
        @netgen -w -ofmt vhdl -sim ${NETLIST}.ngc post_synthesis.vhd
276
        @netgen -w -ofmt vhdl -sim ${NETLIST}.ngd post_translate.vhd
277
        @netgen  -pcf ${NETLIST}.pcf -w -ofmt vhdl -sim ${NETLIST}.ncd post_map.vhd
278
 
279
clean:
280 5 howe.r.j.8
        git clean -dffx
281 3 howe.r.j.8
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.