Skip to content

Instantly share code, notes, and snippets.

@dadeba
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dadeba/45631a382c6fb12a2a64 to your computer and use it in GitHub Desktop.
Save dadeba/45631a382c6fb12a2a64 to your computer and use it in GitHub Desktop.
Makefile for a new Chisel project
SBT ?= sbt
SBT_FLAGS ?= -Dsbt.log.noformat=true
.SHELLFLAGS := -e -o pipefail
# If a chiselVersion is defined, use that.
ifneq (,$(chiselVersion))
CHISEL_SMOKE_VERSION := $(chiselVersion)
CHISEL_CHECK_VERSION := $(chiselVersion)
CHISEL_DEFAULT_VERSION := $(chiselVersion)
else
CHISEL_SMOKE_VERSION ?= 2.3-SNAPSHOT
CHISEL_CHECK_VERSION ?= 2.3-SNAPSHOT
CHISEL_DEFAULT_VERSION ?= latest.release
endif
CHISEL_FLAGS :=
top_srcdir ?= ..
srcdir ?= .
executables := $(filter-out solutions problems examples Image Sound,\
$(notdir $(basename $(wildcard $(srcdir)/*.scala))))
tut_outs := $(addsuffix .out, $(executables))
default: SBT_FLAGS += -DchiselVersion="$(CHISEL_DEFAULT_VERSION)"
default: all
all: emulator verilog # dreamer
check: SBT_FLAGS += -DchiselVersion="$(CHISEL_CHECK_VERSION)"
check: test-solutions.xml
clean:
-rm -f out.im24 out.wav *.h *.hex *.flo *.cpp *.o *.out *.v *.vcd $(executables)
-rm -rf project/target/ target/
emulator: $(tut_outs)
dreamer: $(addsuffix .hex, $(executables))
verilog: $(addsuffix .v, $(executables))
test-solutions.xml: $(tut_outs)
$(top_srcdir)/sbt/check $(tut_outs) > $@
%.out: %.scala
set -e -o pipefail; $(SBT) $(SBT_FLAGS) "run $(notdir $(basename $<)) --genHarness --compile --test --backend c $(CHISEL_FLAGS)" | tee $@
%.hex: %.scala
$(SBT) $(SBT_FLAGS) "run $(notdir $(basename $<)) --backend flo --genHarness --compile --test $(CHISEL_FLAGS)"
%.v: %.scala
$(SBT) $(SBT_FLAGS) "run $(notdir $(basename $<)) --genHarness --backend v $(CHISEL_FLAGS)"
smoke: SBT_FLAGS += -DchiselVersion="$(CHISEL_SMOKE_VERSION)"
smoke:
$(SBT) $(SBT_FLAGS) compile
.PHONY: all check clean emulator verilog smoke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment