# Makefile -- the core alone under Verilator: hello.asm (gpasm, gputils) on tb.cpp's zero-wait program memory and file.
#   make        build hello.hex and the simulator, run it (prints the text, the clocks and the instructions)
#   make clean
V   := ../ucore_pic_p16f877a.v ../ucore_pic_0_9__1__1__1__1_1_1_1_0.v ../gen_ram_13x8_r1_w1_d.v
OBJ := obj
run: $(OBJ)/Vucore_pic_p16f877a hello.hex
	./$(OBJ)/Vucore_pic_p16f877a hello.hex
$(OBJ)/Vucore_pic_p16f877a: $(V) tb.cpp
	verilator --cc --exe --build -O2 -Wno-fatal -Wno-WIDTH --top-module ucore_pic_p16f877a -Mdir $(OBJ) $(V) tb.cpp > build.log 2>&1 \
	  || { tail -20 build.log; exit 1; }
hello.hex: hello.asm
	gpasm -p p16f877a -o $@ $< > gpasm.log 2>&1 || { cat gpasm.log; exit 1; }
clean:
	rm -rf $(OBJ) build.log gpasm.log hello.hex hello.cod hello.lst
.PHONY: run clean
