1
0
mirror of https://github.com/pConst/basic_verilog.git synced 2025-01-28 07:02:55 +08:00

Added Quartus Makefile. Customizable and gives faster compilation

This commit is contained in:
Konstantin Pavlov 2021-02-05 16:10:16 +03:00
parent f3075c28a2
commit c243e1d918

207
scripts/Makefile Normal file
View File

@ -0,0 +1,207 @@
#------------------------------------------------------------------------------
# Makefile for Intel / Altera Quartus
# Konstantin Pavlov, pavlovconst@gmail.com
#
#
# INFO ------------------------------------------------------------------------
#
# - Use this Makefile in linux terminal or on Windows under Cygwin
#
# - Default target ("make" command without any options) is intended to get fast
# compilation and timing analysis. Suitable for general project development
# and debugging
#
# - "make -j" runs timing analysis and *.sof file assembling in parallel. That
# saves you ~20 seconds every time :)
#
# - Specific targets (for example, "make sof") provide you requested results
# assuming that timing analysis is unnexessary
#
# - Check that Quartus and Modelsim directories are in your $PATH. Something like
# echo $PATH | tr : \\n | grep quartus
# export PATH = '/cygdrive/c/intelFPGA/17.0/quartus/bin64:$PATH'
# export PATH = '/cygdrive/c/intelFPGA/17.0/quartus/bin:$PATH'
# echo $PATH | tr : \\n | grep modelsim
# export PATH = '/cygdrive/c/intelFPGA/17.0/modelsim_ase/win32aloem:$PATH'
PROJ_DIR = $(shell pwd)
PROJ = $(shell ls -1 *.qpf | tail -n1 | awk '{ gsub(".qpf","") } 1' )
#SRCS = $(shell ls -R1 SOURCE/*.{v,sv,vh,sdc,tcl,hex,bin} 2>/dev/null | grep -v ':' )
SRCS = $(shell ls -R1 SOURCE/* )
QPF = $(PROJ).qpf
QSF = $(PROJ).qsf
SOF = ./OUTPUT/$(PROJ).sof
POF = ./OUTPUT/$(PROJ).pof
RBF = ./OUTPUT/$(PROJ).rbf
JAM = ./OUTPUT/$(PROJ).jam
PRE_SCRIPT = './DEBUG/pre_flow.tcl'
POST_SCRIPT = './DEBUG/post_flow.tcl'
MAP_REPORT = ./OUTPUT/$(PROJ).map.rpt
FIT_REPORT = ./OUTPUT/$(PROJ).fit.rpt
DSE_CONFIG = $(PROJ).dse
TARGET_IP = '192.168.1.1'
TARGET_PORT = 'USB-1'
TARGET_CHIP = '1'
.PHONY: all info clean stp gui
all: sta sof
info:
echo -e \\n ' Project directory: ' $(PROJ_DIR) \
\\n ' Project name: ' $(PROJ) \
\\n ' Preject sources: ' $(SRCS)
gui:
quartus $(QPF) 1>/dev/null
$(MAP_REPORT): $(SRCS) $(QPF) $(QSF)
$(shell if test -f $(PRE_SCRIPT); then quartus_sh -t $(PRE_SCRIPT) compile $(PROJ) $(PROJ); fi )
quartus_map --no_banner \
--read_settings_files=on \
--write_settings_files=off \
--64bit $(PROJ) -c $(PROJ)
# dont use --effort=fast because it can dramatically increase fitting time
map: $(PROJ).map.rpt
$(FIT_REPORT): $(MAP_REPORT)
# quartus_cdb --read_settings_files=on \
# --write_settings_files=off \
# --64bit $(PROJ) -c $(PROJ)
quartus_fit --no_banner \
--read_settings_files=on \
--write_settings_files=off \
--inner_num=1 \
--one_fit_attempt=on \
--pack_register=off \
--effort=fast \
--64bit $(PROJ) -c $(PROJ)
# using --io_smart_recompile for secondary fitter launches is tricky
fit: $(FIT_REPORT)
$(SOF): $(FIT_REPORT)
quartus_asm --no_banner \
--read_settings_files=off \
--write_settings_files=off \
--64bit $(PROJ) -c $(PROJ)
asm: $(SOF)
sta: $(FIT_REPORT)
quartus_sta $(PROJ) -c $(PROJ)
#$(shell if test -f $(POST_SCRIPT); then quartus_sh -t $(POST_SCRIPT) compile $(PROJ) $(PROJ); fi )
stap: $(FIT_REPORT)
quartus_sta --parallel --model=slow $(PROJ) -c $(PROJ)
#$(shell if test -f $(POST_SCRIPT); then quartus_sh -t $(POST_SCRIPT) compile $(PROJ) $(PROJ); fi )
$(POF): $(SOF)
quartus_cpf --no_banner \
-c $(SOF) $(POF)
$(RBF): $(SOF)
quartus_cpf --no_banner \
-c $(SOF) $(RBF)
$(JAM): $(SOF)
quartus_cpf --no_banner \
-c $(SOF) $(JAM)
sof: $(SOF)
pof: $(POF)
rbf: $(RBF)
jam: $(JAM)
prog: sof
quartus_pgm --no_banner \
-c "USB-Blaster on $(TARGET_IP) [$(TARGET_PORT)]" -m jtag \
-o "P;$(SOF)@$(TARGET_CHIP)"
prog_pof: pof
quartus_pgm --no_banner \
-c "USB-Blaster on $(TARGET_IP) [$(TARGET_PORT)]" -m jtag \
-o "BVP;$(POF)@$(TARGET_CHIP)"
prog_rbf: rbf
quartus_pgm --no_banner \
-c "USB-Blaster on $(TARGET_IP) [$(TARGET_PORT)]" -m jtag \
-o "BVP;$(RBF)@$(TARGET_CHIP)"
clean:
# clean common junk files
rm -rfv $(PROJ).qws c5_pin_model_dump.txt $(PROJ).ipregen.rpt .qsys_edit/
# clean compilation databases
rm -rfv db/ incremental_db/ greybox_tmp/
# clean output directory
rm -rfv OUTPUT/
# clean hard memory controller
rm -rfv ddr3_hmc_ddr3_0_p0_0_summary.csv ddr3_hmc_ddr3_0_p0_1_summary.csv
# clean design space explorer files
rm -rfv dse/ dse1_base.qpf dse1_base.qsf $(PROJ).dse.rpt $(PROJ).archive.rpt
# clean early power estimator files
rm -rfv $(PROJ)_early_pwr.csv
# TODO: add project-specific files to remove here
dse: $(DSE_CONFIG)
quartus_dse --no_banner \
--terminate off \
--num-parallel-processors 10 \
--auto-discover-files on \
--revision $(PROJ) $(PROJ).qpf \
--use-dse-file $(DSE_CONFIG)
sim: $(SRCS)
modelsim -do compile.tcl
sim_clean:
gtkwave: $(SRCS)
# creating VVP file
iverilog -Wall -g2012 -o iverilog_sim.vvp -s $(SRCS)
# creating VCD file
vvp -v iverilog_sim.vvp
# creating settings file for gtkwave on-the-fly
echo fontname_waves Verdana 9 > .\gtkwaverc
echo fontname_signals Verdana 9 >> .\gtkwaverc
echo fontname_logfile Verdana 9 >> .\gtkwaverc
echo splash_disable 1 >> .\gtkwaverc
echo use_roundcaps 1 >> .\gtkwaverc
echo force_toolbars 1 >> .\gtkwaverc
echo left_justify_sigs 1 >> .\gtkwaverc
# launching gtkwave
# press CTRL+S to save vawe config. gtkwave will open it automatically next time
gtkwave -r .\gtkwaverc iverilog_sim.vcd wave.gtkw
# // place this code into your testbench and add signals you want to dump
# // and navigate during simulation
# initial begin
# $dumpfile("iverilog_sim.vcd");
# $dumpvars( 0, M );
# #10000 $finish;
# end
stp:
quartus_stp --no_banner \
$(QPF)