# Put here the name of the Device Under Test
DUT=

### Modules names are forged from the Device Under Test name
# The board module
BD=board
# The testbench module
TB=testbench
# The name of the control file
CTR=amsIrunControl

# Where is the gpdk045 design kit ?
KITDIR=/comelec/softs/opt/opus_kits/CADENCE_PDKS/gpdk045_v_4_0
# Where are COMELEC goodies
GOODIES=${KITDIR}/COMELEC

##### File names are forged from module names
# The original Spice file
SP_FILE=../${DUT}.scs

# The translated Verilog-ams file
DUT_FILE=${DUT}.vams

# The the board file
BD_FILE=${BD}.vams
# The testbench file
TB_FILE=${TB}.sv
# The control file
CTR_FILE=${CTR}.scs

all:
	@echo "simu          : simulation"
	@echo "show_waves    : examine simulation waveforms"
	@echo "plot_results  : examine simulation results"
	@echo "clean         : cleaning of the simulation directory, yet keeping last results"
	@echo "ultraclean    : cleaning of the simulation directory, removing all results"
	@echo "template_dir  : create a template dir for a new chararecterization job"

IRUN_OPT= -disable_sem2009  -input probes.tcl -solver aps -aps_args "+aps=conservative"

simu:real_simu

	
real_simu: ${CTR_FILE} | results
	-/comelec/softs/bin/irun ${IRUN_OPT} \
	-reflib /comelec/softs/opt/opus_kits/CADENCE_PDKS/COMELEC/lib_scs/gsclib045_basicCells \
	${CTR_FILE} \
    -top ${TB} \
    ${TB_FILE} \
    ${BD_FILE} \
	cmos_transition.vams
#	${DUT_FILE} 
	@echo "Simu finished"

show_waves:
	viva -datadir psf &

plot_results:
	python plot.py


results:
	    mkdir -p results

clean:
	@rm -rf INCA_libs
	@rm -rf irun.history
	@rm -rf irun.log
	@rm -rf ${CTR}.raw
	@rm -rf ${CTR}.shm
	@rm -rf amsIrunControl.ahdlSimDB
	@rm -rf irun.key
	@rm -rf waves.shm
	@rm -rf .simvision
	@rm -rf CDS*
	@rm -rf log.*
	@rm -rf .*.swp
	@rm -rf .cadence

ultraclean: clean
	@rm -rf results
	@rm -rf psf
	
template_dir:
	mkdir ../template_dir
	cp cmos_transition.vams ../template_dir
	cp plot.py ../template_dir
	cp probes.tcl ../template_dir
	cp amsIrunControl.scs ../template_dir
	cp .cdsenv  ../template_dir
	cp board.vams ../template_dir
	cp testbench.sv ../template_dir
	cp Makefile ../template_dir

