# -------------------------------------------------
# Global options
# -------------------------------------------------
LANG_STD := 93c
IEEE_STD := standard
WORK_PATH := work
SOURCE_PATH := src
LIB_PATH := ../lib

# -------------------------------------------------
# Target options
# -------------------------------------------------
TARGET := tb_cordic_top

SOURCES :=	src/cordic_pkg.vhd \
			src/cordic_rom.vhd \
			src/cordic_stage_pre.vhd \
			src/cordic_stage.vhd \
			src/cordic_stage_post.vhd \
			src/cordic_top.vhd \
			src/tb_cordic_top.vhd 
			

# -------------------------------------------------
GHDL_OPT := --workdir=$(WORK_PATH) --std=$(LANG_STD) --ieee=$(IEEE_STD)

# -------------------------------------------------
all: elaborate

.PHONY: syntax
syntax: 
	ghdl -s $(GHDL_OPT) $(SOURCES)

import:
	ghdl -i $(GHDL_OPT) $(LIB_PATH)/*.vhd $(SOURCES)

analyze: 
	ghdl -a $(GHDL_OPT) $(LIB_PATH)/*.vhd $(SOURCES)

anaborate:
	ghdl -c $(GHDL_OPT) $(LIB_PATH)/*.vhd $(SOURCES) -e $(TARGET)

makeunit: analyze
	ghdl -m $(GHDL_OPT) $(TARGET)

elaborate: analyze
	ghdl -e $(GHDL_OPT) $(TARGET)

run: elaborate
	ghdl -r $(GHDL_OPT) $(TARGET) --vcd=$(TARGET).vcd --assert-level=error 

show:  $(TARGET).vcd 
	gtkwave $(TARGET).vcd $(TARGET).sav

# -------------------------------------------------
.PHONY: clean
clean:
	rm -rf $(TARGET)
	cd $(WORK_PATH); rm -rf *.o *.cf
	
# -------------------------------------------------
