Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. MAKEFLAGS += -R -r
  2. PROJECT = max80
  3. REVISIONS = v1 v2
  4. QU = quartus
  5. # Common options for all Quartus tools
  6. QPRI = --lower_priority
  7. QCPF = $(QU)_cpf $(QPRI)
  8. QSH = $(QU)_sh $(QPRI)
  9. QSTA = $(QU)_sta $(QPRI)
  10. QPGM = $(QU)_pgm $(QPRI)
  11. # Common options for Quartus in-flow tools
  12. QOPT = --write_settings_files=off $(QPRI)
  13. QMAP = $(QU)_map $(QOPT)
  14. QFIT = $(QU)_fit $(QOPT)
  15. QCDB = $(QU)_cdb $(QOPT)
  16. QASM = $(QU)_asm $(QOPT)
  17. QPOW = $(QU)_pow $(QOPT)
  18. outdir = output
  19. PERL = perl
  20. SUBDIRS = usb
  21. alltarg := sof jic pow.rpt sta.rpt
  22. allout = $(foreach o,$(alltarg),$(outdir)/$(1).$(o))
  23. .SUFFIXES: .targets
  24. .SECONDARY:
  25. .DELETE_ON_ERROR:
  26. all:
  27. $(MAKE) prereq
  28. $(MAKE) $(foreach rev,$(REVISIONS),$(rev).targets)
  29. .PHONY: $(REVISIONS)
  30. $(REVISIONS):
  31. $(MAKE) prereq
  32. $(MAKE) $@.targets
  33. .PHONY: %.targets
  34. %.targets:
  35. $(MAKE) $(call allout,$*)
  36. $(outdir)/%.map.rpt: %.qsf
  37. $(QMAP) $(PROJECT) -c $*
  38. $(outdir)/%.fit.rpt: $(outdir)/%.map.rpt
  39. $(QFIT) $(PROJECT) -c $*
  40. $(outdir)/%.mif_update.rpt: $(outdir)/%.fit.rpt
  41. $(QCDB) --update_mif $(PROJECT) -c $*
  42. $(outdir)/%.sof: $(outdir)/%.mif_update.rpt
  43. $(QASM) $(PROJECT) -c $*
  44. $(outdir)/%.sta.rpt: $(outdir)/%.fit.rpt | $(outdir)/%.sof
  45. $(QSTA) $(PROJECT) -c $*
  46. $(outdir)/%.pow.rpt: $(outdir)/%.sta.rpt
  47. $(QPOW) $(PROJECT) -c $*
  48. # XXX: do all .sof -> conversions using quartus_cpf
  49. $(outdir)/%.jic: $(PROJECT)-%.cof $(outdir)/%.sof ../rv32/dram.hex
  50. $(QCPF) --convert $<
  51. # Prerequisite directories
  52. prereq:
  53. for d in $(SUBDIRS); do $(MAKE) -C $$d; done
  54. # Clean out SignalTap
  55. signalclean:
  56. for f in *.qsf; do \
  57. $(PERL) -ne 'print unless (/(SIGNALTAP_FILE\b|\bENABLE_SIGNALTAP\b|\bSLD_FILE\b|SLD_NODE_)/);' < $$f > $$f.tmp &&
  58. mv -f $$f.qsf.tmp $$f.qsf ;
  59. done
  60. # Programming targets. Environment JTAG_CABLE can override the default,
  61. # which is otherwise the first cable found.
  62. rpar := )
  63. JTAG_CABLE ?= $(shell jtagconfig --enum | sed -ne 's/^1$(rpar) //p')
  64. # Transient programming
  65. program-%: $(outdir)/%.sof
  66. $(QPGM) -c '$(JTAG_CABLE)' -m JTAG -o 'p;$(outdir)/$*.sof'
  67. # Permanent programming in flash
  68. flash-%: $(outdir)/%.jic
  69. $(QPGM) -c '$(JTAG_CABLE)' -m JTAG -i -o 'pvbi;$(outdir)/$*.jic'
  70. %.deps: %.qsf scripts/qsfdeps.pl
  71. $(PERL) scripts/qsfdeps.pl $* $@ $<
  72. clean:
  73. for d in $(SUBDIRS); do $(MAKE) -C $$d clean; done
  74. rm -rf db incremental_db simulation/modelsim \
  75. greybox_tmp */greybox_tmp iodevs.vh output_files
  76. for d in $(REVISIONS); do \
  77. $$d/*.rpt $$d/*.rpt $$d/*.summary $$d/*.smsg \
  78. $$d/*.htm $$d/*.htm_files $$d/*.map $$d/*.eqn $$d/*.sld \
  79. $$d/*.done ; \
  80. done
  81. spotless:
  82. for d in $(SUBDIRS); do $(MAKE) -C $$d spotless; done
  83. rm -rf $(outdir)
  84. iodevs.vh: ../iodevs.conf ../tools/iodevs.pl
  85. $(PERL) ../tools/iodevs.pl v $< $@
  86. # Verilog header dependencies
  87. max80.sv: iodevs.vh
  88. -include $(foreach rev,$(REVISIONS),$(rev).deps)