-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmakefile
160 lines (123 loc) · 3.79 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
CC=gcc
CFLAGS=-Wall -Wextra -std=c99 -O3 -fwrapv
GHDL=ghdl
USB?=/dev/ttyUSB0
BAUD?=115200
DIFF?=vimdiff
#BAUD?=9600
.PHONY: all run diff simulation viewer clean documentation test
all: bit simulation
run: bit bit.hex
./bit bit.hex
test: bit bit.hex test.fth
./bit bit.hex < test.fth
talk:
picocom --omap delbs -e b -b ${BAUD} ${USB}
simulation: tb.ghw
viewer: tb.ghw signals.tcl
gtkwave -S signals.tcl -f $< > /dev/null 2>&1 &
documentation: readme.htm
%.htm: %.md
pandoc $< -o $@
bit.hex bit.bin bit.inc: bit.fth
gforth $<
bit: bit.c bit.inc
${CC} ${CFLAGS} $< -o $@
%.o: %.vhd
${GHDL} -a -g $<
uart.o: uart.vhd util.o
peripherals.o: peripherals.vhd uart.o util.o
top.o: top.vhd peripherals.o bit.o util.o uart.o
tb.o: tb.vhd bit.o peripherals.o top.o
tb: tb.o bit.o peripherals.o top.o
${GHDL} -e $@
tb.ghw: tb tb.cfg bit.hex
${GHDL} -r $< --wave=$<.ghw --unbuffered --max-stack-alloc=16384 --ieee-asserts=disable
SOURCES = \
top.vhd \
bit.vhd \
uart.vhd \
util.vhd \
peripherals.vhd
OBJECTS = ${SOURCES:.vhd=.o}
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: bit.hex 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 design.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 ${NETLIST}.ngc post_synthesis.vhd
@netgen -w -ofmt vhdl -sim ${NETLIST}.ngd post_translate.vhd
@netgen -pcf ${NETLIST}.pcf -w -ofmt vhdl -sim ${NETLIST}.ncd post_map.vhd
clean:
git clean -fdx .