@@ -50,8 +50,8 @@ PACKAGE := sg48
50
50
# Verilog source directories
51
51
VPATH := $(SRCDIR )
52
52
53
- # Verilog source files for design (with TOP module first and no TBTOP)
54
- SRC := $(SRCDIR ) / $( TOP ) .sv $( filter-out $(SRCDIR ) /$(TBTOP ) .sv,$(filter-out $(SRCDIR ) /$(TOP ) .sv,$(wildcard $(SRCDIR ) /* .sv) ) )
53
+ # Verilog source files for design (with no TOP or TBTOP module )
54
+ SRC := $(filter-out $(SRCDIR ) /$(TBTOP ) .sv,$(filter-out $(SRCDIR ) /$(TOP ) .sv,$(wildcard $(SRCDIR ) /* .sv) ) )
55
55
56
56
# Verilog include files for design
57
57
INC := $(wildcard $(SRCDIR ) /* .svh)
73
73
74
74
# Yosys synthesis options
75
75
# ("ultraplus" device, enable DSP inferrence and explicitly set top module name)
76
- YOSYS_SYNTH_OPTS := -device u -dsp -top $(TOP )
77
- # NOTE: Options that can often produce a more "optimal" size/speed for design, but slower:
78
- # YOSYS_SYNTH_ARGS := -device u -dsp -abc9 -top $(TOP)
76
+ YOSYS_SYNTH_ARGS := -device u -dsp -abc9 -top $(TOP )
79
77
80
78
# Invokes yosys-config to find the proper path to the iCE40 simulation library
81
79
TECH_LIB := $(shell $(YOSYS_CONFIG ) --datdir/ice40/cells_sim.v)
@@ -126,7 +124,7 @@ info:
126
124
@echo " make clean - clean most files that can be rebuilt"
127
125
128
126
# defult target is to make FPGA bitstream for design
129
- all : isim bin
127
+ all : isim vsim bin
130
128
131
129
# synthesize FPGA bitstream for design
132
130
bin : $(OUTDIR ) /$(OUTNAME ) .bin
@@ -138,22 +136,22 @@ prog: $(OUTDIR)/$(OUTNAME).bin
138
136
$(ICEPROG ) -d i:0x0403:0x6014 $(OUTDIR ) /$(OUTNAME ) .bin
139
137
140
138
# run Yosys with "noflatten", which will produce a resource count per module
141
- count : $(SRC ) $(INC ) $(FONTFILES ) $(MAKEFILE_LIST )
139
+ count : $(SRCDIR ) / $( TOP ) .sv $( SRC ) $(INC ) $(FONTFILES ) $(MAKEFILE_LIST )
142
140
@echo === Couting Design Resources Used ===
143
141
@mkdir -p $(LOGS )
144
- $(YOSYS ) -l $(LOGS ) /$(OUTNAME ) _yosys_count.log -w " .*" -q -p ' verilog_defines $(DEFINES) ; read_verilog -I$(SRCDIR) -sv $(SRC) $(FLOW3) ; synth_ice40 $(YOSYS_SYNTH_ARGS) -noflatten'
142
+ $(YOSYS ) -l $(LOGS ) /$(OUTNAME ) _yosys_count.log -w " .*" -q -p ' verilog_defines $(DEFINES) ; read_verilog -I$(SRCDIR) -sv $(SRCDIR)/$(TOP).sv $( SRC) $(FLOW3) ; synth_ice40 $(YOSYS_SYNTH_ARGS) -noflatten'
145
143
@sed -n ' /Printing statistics/,/Executing CHECK pass/p' $(LOGS ) /$(OUTNAME ) _yosys_count.log | sed ' $$d'
146
144
@echo === See $(LOGS ) /$(OUTNAME ) _yosys_count.log for resource use details ===
147
145
148
146
# use Icarus Verilog to build and run simulation executable
149
- isim : $(OUTDIR ) /$(TBOUTNAME ) $(TBTOP ) .sv $(SRC ) $(MAKEFILE_LIST )
150
- @echo === Simulation files built, use \" make irun\" to run ===
147
+ isim : $(OUTDIR ) /$(TBOUTNAME ) $(SRCDIR ) / $( TBTOP ) .sv $(SRC ) $(MAKEFILE_LIST )
148
+ @echo === Icarus Verilog files built, use \" make irun\" to run ===
151
149
152
150
# use Icarus Verilog to run simulation executable
153
151
irun : $(OUTDIR ) /$(TBOUTNAME ) $(MAKEFILE_LIST )
154
152
@echo === Running simulation ===
155
153
$(VVP ) $(OUTDIR ) /$(TBOUTNAME ) -fst
156
- @echo === Simulation done, use " gtkwave logs/$( TBTOP) .fst" to view waveforms ===
154
+ @echo === Icarus Verilog simulation done, use " gtkwave logs/$( TBTOP) .fst" to view waveforms ===
157
155
158
156
# build native simulation executable
159
157
vsim : obj_dir/V$(VTOP ) $(MAKEFILE_LIST )
@@ -173,25 +171,27 @@ $(OUTDIR)/$(TBOUTNAME): $(TBTOP).sv $(SRC) $(MAKEFILE_LIST)
173
171
$(IVERILOG ) $(IVERILOG_ARGS ) $(DEFINES ) -o $@ $(TBTOP ) .sv $(SRC )
174
172
175
173
# use Verilator to build native simulation executable
176
- obj_dir/V$(VTOP ) : $(CSRC ) $(INC ) $(SRC ) $(MAKEFILE_LIST )
177
- $(VERILATOR ) $(VERILATOR_ARGS ) --cc --exe --trace $(DEFINES ) -DEXT_CLK $(CFLAGS ) $(LDFLAGS ) --top-module $(VTOP ) $(TECH_LIB ) $(SRC ) $(CSRC )
174
+ obj_dir/V$(VTOP ) : $(CSRC ) $(INC ) $(SRCDIR ) / $( TOP ) .sv $( SRC ) $(MAKEFILE_LIST )
175
+ $(VERILATOR ) $(VERILATOR_ARGS ) --cc --exe --trace $(DEFINES ) -DEXT_CLK $(CFLAGS ) $(LDFLAGS ) --top-module $(VTOP ) $(TECH_LIB ) $(SRCDIR ) / $( TOP ) .sv $( SRC ) $(CSRC )
178
176
cd obj_dir && make -f V$(VTOP ) .mk
179
177
180
178
# synthesize SystemVerilog and create json description
181
- $(OUTDIR ) /$(OUTNAME ) .json : $(SRC ) $(INC ) $(MAKEFILE_LIST )
179
+ $(OUTDIR ) /$(OUTNAME ) .json : $(SRCDIR ) / $( TOP ) .sv $( SRC ) $(INC ) $(MAKEFILE_LIST )
182
180
@echo === Synthesizing design ===
183
181
@rm -f $@
184
182
@mkdir -p $(OUTDIR )
185
183
@mkdir -p $(LOGS )
186
- $(VERILATOR ) $(VERILATOR_ARGS ) --lint-only $(DEFINES ) --top-module $(TOP ) $(TECH_LIB ) $(SRC ) 2>&1 | tee $(LOGS ) /$(OUTNAME ) _verilator.log
187
- $(YOSYS ) -l $(LOGS ) /$(OUTNAME ) _yosys.log -w " .*" -q -p ' verilog_defines $(DEFINES) ; read_verilog -I$(SRCDIR) -sv $(SRC) $(FLOW3) ; synth_ice40 $(YOSYS_SYNTH_ARGS) -json $@'
184
+ $(VERILATOR ) $(VERILATOR_ARGS ) --lint-only $(DEFINES ) --top-module $(TOP ) $(TECH_LIB ) $(SRCDIR ) / $( TOP ) .sv $( SRC ) 2>&1 | tee $(LOGS ) /$(OUTNAME ) _verilator.log
185
+ $(YOSYS ) -l $(LOGS ) /$(OUTNAME ) _yosys.log -w " .*" -q -p ' verilog_defines $(DEFINES) ; read_verilog -I$(SRCDIR) -sv $(SRCDIR)/$(TOP).sv $( SRC) $(FLOW3) ; synth_ice40 $(YOSYS_SYNTH_ARGS) -json $@'
188
186
189
187
# make ASCII bitstream from JSON description and device parameters
190
- $(OUTDIR ) /$(OUTNAME ) .asc : $(OUTDIR ) /$(OUTNAME ) .json $(PIN_DEF ) $(MAKEFILE_LIST )
188
+ $(OUTDIR ) /$(OUTNAME ) .bin : $(OUTDIR ) /$(OUTNAME ) .json $(PIN_DEF ) $(MAKEFILE_LIST )
191
189
@rm -f $@
192
190
@mkdir -p $(LOGS )
193
191
@mkdir -p $(OUTDIR )
194
- $(NEXTPNR ) -l $(LOGS ) /$(OUTNAME ) _nextpnr.log -q $(NEXTPNR_ARGS ) --$(DEVICE ) --package $(PACKAGE ) --json $< --pcf $(PIN_DEF ) --asc $@
192
+ $(NEXTPNR ) -l $(LOGS ) /$(OUTNAME ) _nextpnr.log -q $(NEXTPNR_ARGS ) --$(DEVICE ) --package $(PACKAGE ) --json $< --pcf $(PIN_DEF ) --asc $(OUTDIR ) /$(OUTNAME ) .asc
193
+ $(ICEPACK ) $(OUTDIR ) /$(OUTNAME ) .asc $@
194
+ @rm $(OUTDIR ) /$(OUTNAME ) .asc
195
195
@echo === Synthesis stats for $(OUTNAME ) on $(DEVICE ) === | tee $(LOGS ) /$(OUTNAME ) _stats.txt
196
196
@-tabbyadm version | grep " Package" | tee -a $(LOGS ) /$(OUTNAME ) _stats.txt
197
197
@$(YOSYS ) -V 2>&1 | tee -a $(LOGS ) /$(OUTNAME ) _stats.txt
@@ -200,11 +200,6 @@ $(OUTDIR)/$(OUTNAME).asc: $(OUTDIR)/$(OUTNAME).json $(PIN_DEF) $(MAKEFILE_LIST)
200
200
@grep " Max frequency" $(LOGS ) /$(OUTNAME ) _nextpnr.log | tail -1 | tee -a $(LOGS ) /$(OUTNAME ) _stats.txt
201
201
@echo
202
202
203
- # make binary bitstream from ASCII bitstream
204
- $(OUTDIR ) /$(OUTNAME ) .bin : $(OUTDIR ) /$(OUTNAME ) .asc $(MAKEFILE_LIST )
205
- @rm -f $@
206
- $(ICEPACK ) $< $@
207
-
208
203
# delete all targets that will be re-generated
209
204
clean :
210
205
rm -f $(OUTDIR ) /$(OUTNAME ) .bin $(OUTDIR ) /$(OUTNAME ) .json $(OUTDIR ) /$(OUTNAME ) .asc $(OUTDIR ) /$(TBOUTNAME ) $(wildcard obj_dir/* )
@@ -213,4 +208,4 @@ clean:
213
208
.SECONDARY :
214
209
215
210
# inform make about "phony" convenience targets
216
- .PHONY : info all bin prog lint isim irun count clean
211
+ .PHONY : all bin prog isim irun vsim vrun count clean
0 commit comments