Line 1... |
Line 1... |
SEED ?= 1
|
#########################################################
|
CYCLES ?= 200000
|
# Vars
|
|
#########################################################
|
|
SYSTEMC_HOME ?= /opt/systemc-2.3.1
|
|
|
TRACE ?= 1
|
TRACE ?= 1
|
|
|
all: compile run view
|
RTL_DUT = ../rtl/ulpi_wrapper.v
|
|
|
|
#########################################################
|
|
# Source
|
|
#########################################################
|
|
SRC = $(wildcard *.cpp)
|
|
|
|
SRC_V = tb_top.v
|
|
SRC_V += $(RTL_DUT)
|
|
|
|
OBJ = $(patsubst %.cpp,%.o,$(SRC))
|
|
|
|
VPI_OBJ = dut
|
|
|
|
#########################################################
|
|
# CFLAGS
|
|
#########################################################
|
|
INC_PATH = -I.
|
|
INC_PATH += -I/usr/include/iverilog
|
|
INC_PATH += -I$(SYSTEMC_HOME)/include
|
|
|
|
VINC_PATH = -I. -I../rtl
|
|
VFLAGS = -DTRACE=$(TRACE)
|
|
|
# Testbench
|
CFLAGS = -c -fpic
|
SRC+= ./top_tb.sv
|
|
SRC+= ./*.v
|
|
|
|
SRC+= ../rtl/*.v
|
LIB_OPT = $(SYSTEMC_HOME)/lib-linux64/libsystemc.a
|
|
|
SRC_FLAGS = +define+CYCLES=$(CYCLES)
|
EXE = output.out
|
SRC_FLAGS = +define+SEED=$(SEED)
|
|
|
|
ifeq ($(TRACE),1)
|
#########################################################
|
SRC_FLAGS += +define+TRACE=$(TRACE)
|
# Rules
|
endif
|
#########################################################
|
|
all: run
|
|
|
INC_DIRS = -I.
|
%.o : %.cpp
|
|
gcc -c $(INC_PATH) $(CFLAGS) $< -o $@
|
|
|
compile :
|
$(VPI_OBJ).vpi: $(OBJ)
|
vlib work
|
g++ -shared -o $(VPI_OBJ).vpi -Wl,--whole-archive $(LIB_OPT) $(OBJ) -Wl,--no-whole-archive
|
vlog $(SRC) $(SRC_FLAGS)
|
|
|
|
run : compile
|
$(EXE) : $(SRC_V)
|
vsim -c -do "run -all" top_tb
|
iverilog -o $(EXE) $(SRC_V) $(VINC_PATH) $(VFLAGS)
|
|
|
view : compile
|
run: $(EXE) $(VPI_OBJ).vpi
|
ifeq ($(TRACE),1)
|
vvp -M. -m$(VPI_OBJ) $(EXE) -vcd
|
gtkwave waveform.vcd gtksettings.sav
|
|
endif
|
|
|
|
clean :
|
clean :
|
-rm -rf work waveform.vcd transcript
|
rm -rf $(OBJ) dut.vpi *.vcd *.out
|
rm -rf $(OBJ) dut.vpi *.vcd *.out
|
rm -rf $(OBJ) dut.vpi *.vcd *.out
|