Line 74... |
Line 74... |
FLAGS := -Wall -Og -g
|
FLAGS := -Wall -Og -g
|
OBJDIR := obj-pc
|
OBJDIR := obj-pc
|
RTLD := ../verilog
|
RTLD := ../verilog
|
VERILATOR_ROOT ?= $(shell bash -c 'verilator -V|grep VERILATOR_ROOT | head -1 | sed -e " s/^.*=\s*//"')
|
VERILATOR_ROOT ?= $(shell bash -c 'verilator -V|grep VERILATOR_ROOT | head -1 | sed -e " s/^.*=\s*//"')
|
VROOT := $(VERILATOR_ROOT)
|
VROOT := $(VERILATOR_ROOT)
|
INCS := -I$(RTLD)/obj_dir/ -I/usr/share/verilator/include
|
INCS := -I$(RTLD)/obj_dir/ -I$(VROOT)/include
|
SOURCES := helloworld.cpp linetest.cpp uartsim.cpp uartsim.h
|
SOURCES := helloworld.cpp linetest.cpp uartsim.cpp uartsim.h
|
VOBJDR := $(RTLD)/obj_dir
|
VOBJDR := $(RTLD)/obj_dir
|
SYSVDR := /usr/share/verilator/include
|
SYSVDR := $(VROOT)/include
|
VLIB := $(SYSVDR)/verilated.cpp $(SYSVDR)/verilated_vcd_c.cpp
|
VSRC := verilated.cpp verilated_vcd_c.cpp
|
|
VLIB := $(addprefix $(OBJDIR)/,$(subst .cpp,.o,$(VSRC)))
|
# Sources necessary to build the linetest program (rxuart-txuart test)
|
# Sources necessary to build the linetest program (rxuart-txuart test)
|
LINSRCS := linetest.cpp uartsim.cpp
|
LINSRCS := linetest.cpp uartsim.cpp
|
LINOBJ := $(subst .cpp,.o,$(LINSRCS))
|
LINOBJ := $(subst .cpp,.o,$(LINSRCS))
|
LINOBJS:= $(addprefix $(OBJDIR)/,$(LINOBJ))
|
LINOBJS:= $(addprefix $(OBJDIR)/,$(LINOBJ)) $(VLIB)
|
# Sources necessary to build the helloworld test (txuart test)
|
# Sources necessary to build the helloworld test (txuart test)
|
HLOSRCS := helloworld.cpp uartsim.cpp
|
HLOSRCS := helloworld.cpp uartsim.cpp
|
HLOOBJ := $(subst .cpp,.o,$(HLOSRCS))
|
HLOOBJ := $(subst .cpp,.o,$(HLOSRCS))
|
HLOOBJS:= $(addprefix $(OBJDIR)/,$(HLOOBJ))
|
HLOOBJS:= $(addprefix $(OBJDIR)/,$(HLOOBJ)) $(VLIB)
|
# Sources necessary to build the speech test (wbuart test)
|
# Sources necessary to build the speech test (wbuart test)
|
SPCHSRCS:= speechtest.cpp uartsim.cpp
|
SPCHSRCS:= speechtest.cpp uartsim.cpp
|
SPCHOBJ := $(subst .cpp,.o,$(SPCHSRCS))
|
SPCHOBJ := $(subst .cpp,.o,$(SPCHSRCS))
|
SPCHOBJS:= $(addprefix $(OBJDIR)/,$(SPCHOBJ))
|
SPCHOBJS:= $(addprefix $(OBJDIR)/,$(SPCHOBJ)) $(VLIB)
|
all: $(OBJDIR)/ linetest helloworld speechtest test
|
all: $(OBJDIR)/ linetest helloworld speechtest test
|
|
|
$(OBJDIR)/:
|
|
@bash -c "if [ ! -e $(OBJDIR) ]; then mkdir -p $(OBJDIR); fi"
|
|
|
|
$(OBJDIR)/uartsim.o: uartsim.cpp uartsim.h
|
$(OBJDIR)/uartsim.o: uartsim.cpp uartsim.h
|
|
|
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
|
$(mk-objdir)
|
|
$(CXX) $(FLAGS) $(INCS) -c $< -o $@
|
|
|
|
$(OBJDIR)/%.o: $(SYSVDR)/%.cpp
|
|
$(mk-objdir)
|
$(CXX) $(FLAGS) $(INCS) -c $< -o $@
|
$(CXX) $(FLAGS) $(INCS) -c $< -o $@
|
|
|
linetest: $(LINOBJS) $(VOBJDR)/Vlinetest__ALL.a
|
linetest: $(LINOBJS) $(VOBJDR)/Vlinetest__ALL.a
|
$(CXX) $(FLAGS) $(INCS) $^ $(VLIB) -o $@
|
$(CXX) $(FLAGS) $(INCS) $^ -o $@
|
|
|
helloworld: $(HLOOBJS) $(VOBJDR)/Vhelloworld__ALL.a
|
helloworld: $(HLOOBJS) $(VOBJDR)/Vhelloworld__ALL.a
|
$(CXX) $(FLAGS) $(INCS) $^ $(VLIB) -o $@
|
$(CXX) $(FLAGS) $(INCS) $^ -o $@
|
|
|
#
|
#
|
# The speech test program depends upon a copy of the Gettysburg Address,
|
# The speech test program depends upon a copy of the Gettysburg Address,
|
# turned into a hex file format which will be read by the Verilog/RTL
|
# turned into a hex file format which will be read by the Verilog/RTL
|
# $readmemh function. However, we need to create that hex file that will
|
# $readmemh function. However, we need to create that hex file that will
|
Line 129... |
Line 132... |
|
|
# Now, if the speech.hex file is available, then we can perform our final build.
|
# Now, if the speech.hex file is available, then we can perform our final build.
|
# Actually, we could've done this without the speech file being available, but
|
# Actually, we could've done this without the speech file being available, but
|
# this works.
|
# this works.
|
speechtest: speech.hex $(SPCHOBJS) $(VOBJDR)/Vspeechfifo__ALL.a
|
speechtest: speech.hex $(SPCHOBJS) $(VOBJDR)/Vspeechfifo__ALL.a
|
$(CXX) $(FLAGS) $(INCS) $(SPCHOBJS) $(VOBJDR)/Vspeechfifo__ALL.a $(VLIB) -o $@
|
$(CXX) $(FLAGS) $(INCS) $(SPCHOBJS) $(VOBJDR)/Vspeechfifo__ALL.a -o $@
|
|
|
test: linetest speechtest
|
test: linetest speechtest
|
./linetest
|
./linetest
|
./speechtest
|
./speechtest
|
|
|
|
#
|
|
# The "depends" target, to know what files things depend upon. The depends
|
|
# file itself is kept in $(OBJDIR)/depends.txt
|
|
#
|
|
define build-depends
|
|
$(mk-objdir)
|
|
@echo "Building dependency file"
|
|
@$(CXX) $(CFLAGS) $(INCS) -MM $(SOURCES) > $(OBJDIR)/xdepends.txt
|
|
@sed -e 's/^.*.o: /$(OBJDIR)\/&/' < $(OBJDIR)/xdepends.txt > $(OBJDIR)/depends.txt
|
|
@rm $(OBJDIR)/xdepends.txt
|
|
endef
|
|
|
|
.PHONY: depends
|
|
depends: tags
|
|
$(build-depends)
|
|
|
|
$(OBJDIR)/depends.txt: depends
|
|
|
|
#
|
|
define mk-objdir
|
|
@bash -c "if [ ! -e $(OBJDIR) ]; then mkdir -p $(OBJDIR); fi"
|
|
endef
|
|
|
|
#
|
|
# The "tags" target
|
|
#
|
|
tags: $(SOURCES) $(HEADERS)
|
|
@echo "Generating tags"
|
|
@ctags $(SOURCES) $(HEADERS)
|
|
|
.PHONY: clean
|
.PHONY: clean
|
clean:
|
clean:
|
rm -f ./linetest ./helloworld ./speechtest
|
rm -f ./linetest ./helloworld ./speechtest
|
rm -f ./mkspeech ./speech.hex
|
rm -f ./mkspeech ./speech.hex
|
rm -rf $(OBJDIR)/
|
rm -rf $(OBJDIR)/
|
|
|
|
-include $(OBJDIR)/depends.txt
|