-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
165 lines (127 loc) · 4.11 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
CC:=gcc
CFLAGS:=-Wall -Wextra -std=c99 -O2 -pedantic
GHDL:=ghdl
GOPTS:=--max-stack-alloc=16384 --ieee-asserts=disable
USB:=/dev/ttyUSB0
BAUD:=115200
DIFF:=vimdiff
PROGRAM=subleq.dec
BITS:=16
DEBUG:=0
FAST:=false
CONFIG:=tb.cfg
TOP:=top
GHW:=$(basename ${CONFIG}).ghw
.PHONY: all run diff simulation viewer clean documentation synthesis implementation bitfile
.PRECIOUS: ${GHW}
all: subleq simulation
run: subleq ${PROGRAM}
./subleq ${PROGRAM}
talk:
picocom --omap delbs -e b -b ${BAUD} ${USB}
simulation: ${GHW}
viewer: ${GHW} signals.tcl
gtkwave -S signals.tcl -f $< > /dev/null 2>&1 &
documentation: readme.htm
%.htm: %.md
pandoc $< -o $@
subleq: subleq.c
${CC} ${CFLAGS} $< -o $@
%.an: %.vhd
${GHDL} -a -g $<
touch $@
uart.an: uart.vhd util.an
top.an: top.vhd subleq.an system.an util.an uart.an
tb.an: tb.vhd top.an
tb: tb.an top.an
${GHDL} -e $@
touch $@
system.an: system.vhd subleq.an util.an
gforth.dec: eforth.txt
gforth $< > $@
gforth: subleq gforth.dec
./subleq gforth.dec
${GHW}: tb ${CONFIG} ${PROGRAM}
${GHDL} -r $< --wave=$@ ${GOPTS} '-gbaud=${BAUD}' '-gprogram=${PROGRAM}' '-gN=${BITS}' '-gconfig=${CONFIG}' '-gdebug=${DEBUG}' '-gen_non_io_tb=${FAST}'
SOURCES=top.vhd subleq.vhd uart.vhd system.vhd util.vhd
bitfile: design.bit
reports:
@[ -d reports ] || mkdir reports
tmp:
@[ -d tmp ] || mkdir tmp
tmp/_xmsgs:
@[ -d tmp/_xmsgs ] || mkdir tmp/_xmsgs
tmp/${TOP}.prj: tmp
@rm -f tmp/${TOP}.prj
@( \
for f in ${SOURCES}; do \
echo "vhdl work \"$$f\""; \
done; \
echo "vhdl work \"${TOP}.vhd\"" \
) > tmp/${TOP}.prj
tmp/${TOP}.lso: tmp
@echo "work" > tmp/${TOP}.lso
tmp/${TOP}.xst: tmp tmp/_xmsgs tmp/${TOP}.lso tmp/${TOP}.lso
@( \
echo "set -tmpdir \"tmp\""; \
echo "set -xsthdpdir \"tmp\""; \
echo "run"; \
echo "-lso tmp/${TOP}.lso"; \
echo "-ifn tmp/${TOP}.prj"; \
echo "-ofn ${TOP}"; \
echo "-p xc6slx16-csg324-3"; \
echo "-top ${TOP}"; \
echo "-opt_mode area"; \
echo "-opt_level 2" \
) > tmp/top.xst
synthesis: subleq.dec reports tmp tmp/_xmsgs tmp/${TOP}.prj tmp/${TOP}.xst
@echo "Synthesis running..."
@${TIME} xst -intstyle silent -ifn tmp/${TOP}.xst -ofn reports/xst.log
@mv _xmsgs/* tmp/_xmsgs
@rmdir _xmsgs
@mv ${TOP}_xst.xrpt tmp
@grep "ERROR\|WARNING" reports/xst.log | \
grep -v "WARNING.*has a constant value.*This FF/Latch will be trimmed during the optimization process." | \
cat
@grep ns reports/xst.log | grep 'Clock period'
implementation: reports tmp
@echo "Implementation running..."
@[ -d tmp/xlnx_auto_0_xdb ] || mkdir tmp/xlnx_auto_0_xdb
@${TIME} ngdbuild -intstyle silent -quiet -dd tmp -uc ${TOP}.ucf -p xc6slx16-csg324-3 ${TOP}.ngc ${TOP}.ngd
@mv ${TOP}.bld reports/ngdbuild.log
@mv _xmsgs/* tmp/_xmsgs
@rmdir _xmsgs
@mv xlnx_auto_0_xdb/* tmp
@rmdir xlnx_auto_0_xdb
@mv ${TOP}_ngdbuild.xrpt tmp
@${TIME} map -intstyle silent -detail -p xc6slx16-csg324-3 -convert_bram8 -pr b -c 100 -w -o ${TOP}_map.ncd ${TOP}.ngd ${TOP}.pcf
@mv ${TOP}_map.mrp reports/map.log
@mv _xmsgs/* tmp/_xmsgs
@rmdir _xmsgs
@mv ${TOP}_usage.xml ${TOP}_summary.xml ${TOP}_map.map ${TOP}_map.xrpt tmp
@${TIME} par -intstyle silent -w -ol std ${TOP}_map.ncd ${TOP}.ncd ${TOP}.pcf
@mv ${TOP}.par reports/par.log
@mv ${TOP}_pad.txt reports/par_pad.txt
@mv _xmsgs/* tmp/_xmsgs
@rmdir _xmsgs
@mv par_usage_statistics.html ${TOP}.ptwx ${TOP}.pad ${TOP}_pad.csv ${TOP}.unroutes ${TOP}.xpi ${TOP}_par.xrpt tmp
design.bit: reports tmp/_xmsgs
@echo "Generate bitfile running..."
@touch webtalk.log
@${TIME} bitgen -intstyle silent -w ${TOP}.ncd
@mv ${TOP}.bit $@
@mv ${TOP}.bgn reports/bitgen.log
@mv _xmsgs/* tmp/_xmsgs
@rmdir _xmsgs
@sleep 5
@mv ${TOP}.drc ${TOP}_bitgen.xwbt ${TOP}_usage.xml ${TOP}_summary.xml webtalk.log tmp
@grep -i '\(warning\|clock period\)' reports/xst.log
upload:
djtgcfg prog -d Nexys3 -i 0 -f design.bit
design: clean simulation synthesis implementation bitfile
postsyn:
@netgen -w -ofmt vhdl -sim ${TOP}.ngc post_synthesis.vhd
@netgen -w -ofmt vhdl -sim ${TOP}.ngd post_translate.vhd
@netgen -pcf ${TOP}.pcf -w -ofmt vhdl -sim ${TOP}.ncd post_map.vhd
clean:
git clean -fddx .