makefile fuer behsim
[hwmod.git] / src / Makefile
diff --git a/src/Makefile b/src/Makefile
new file mode 100644 (file)
index 0000000..656c6f7
--- /dev/null
@@ -0,0 +1,38 @@
+SHELL := bash
+
+MPWD := $(shell pwd)
+D_BEHSIM := $(MPWD)/../sim/beh
+
+WORK := work
+
+#reihenfolge ist hier wichtig!
+IFILES = gen_pkg alu alu_tb
+IFILES := $(strip $(IFILES))
+#virtuelle targets: weil wir sowas wie ein objectfile von vcom nicht bekommen. bessere ideen sind willkommen
+VTARGETS := $(foreach n, $(IFILES), $(D_BEHSIM)/$(WORK)/$(n)/_primary.dat)
+
+all: behsim
+
+behsim: $(D_BEHSIM)/modelsim.ini $(VTARGETS)
+
+$(D_BEHSIM)/modelsim.ini:
+       @echo " INIT for behavioural simulation"
+       @mkdir -p $(D_BEHSIM)
+       @#make fuehrt jeden befehl in einer eigenen shell aus, deswegen ein "oneliner"
+       @cd $(D_BEHSIM); \
+       vlib work > /dev/null ; \
+       vmap work work > /dev/null ;
+
+$(D_BEHSIM)/$(WORK)/%/_primary.dat: %.vhd
+       @echo " CC    $<"
+       @cd $(D_BEHSIM); \
+       vcom -work $(WORK) $(MPWD)/$<
+
+startms: behsim
+       @cd $(D_BEHSIM); \
+       vsim "work.alu_tb(sim)" -f /dev/null -do $(MPWD)/alu.do
+
+.PHONY: clean
+clean:
+       rm -Rf $(D_BEHSIM)
+