OpenCores
URL https://opencores.org/ocsvn/wbuart32/wbuart32/trunk

Subversion Repositories wbuart32

[/] [wbuart32/] [trunk/] [bench/] [cpp/] [Makefile] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dgisselq
################################################################################
2
##
3
## Filename:    Makefile
4
##
5
## Project:     wbuart32, a full featured UART with simulator
6
##
7 5 dgisselq
## Purpose:     To test a group of Verilator modules: txuart (UART transmitter),
8
##              rxuart (UART receiver/sink) and wbuart (UART module, containing
9
##      both receiver and transmitter, with FIFOs, controlled via wishbone).
10 2 dgisselq
##
11 5 dgisselq
##
12
## Targets:
13
##      test
14
##              Perform both tests.  The end result should be either a PASS
15
##              or a FAIL.
16
##
17
##      helloworld
18
##              A non-automated, and less interactive test than the others.  In
19
##              this test, the UART simply produces a Hello World message to the
20
##              screen over and over again.
21
##
22
##      linetest
23
##              An automated test of both txuart and rxuart.  The test works
24
##              by sending a message through the rxuart, and receiving the
25
##              message via the txuart.  This depends upon a Verilog test
26
##              infrastructure, linetest.v.
27
##
28
##              This test may be ran in an interactive mode.  In this mode,
29
##              characters written to the UART will be reflected back upon
30
##              the entrance of a return character.
31
##
32
##      speechtest
33
##              An automated test of the wbuart, txuart, and fifo.  In this
34
##              case, the test RTL produces a copy of the Gettysburg address,
35
##              filling the FIFO at 12/16 at a time.  In automated mode, the
36
##              speechtest will compare the output against against a text copy
37
##              of the speech, and report upon any success or failure.
38
##
39
##              In interactive mode, the test will repeatedly print out the
40
##              Gettysburg address until stopped.  (It may take a significant
41
##              amount of time between copies of the Gettysburg address ...)
42
##
43
##
44 2 dgisselq
## Creator:     Dan Gisselquist, Ph.D.
45
##              Gisselquist Technology, LLC
46
##
47
################################################################################
48
##
49 26 dgisselq
## Copyright (C) 2015-2019, Gisselquist Technology, LLC
50 2 dgisselq
##
51
## This program is free software (firmware): you can redistribute it and/or
52
## modify it under the terms of  the GNU General Public License as published
53
## by the Free Software Foundation, either version 3 of the License, or (at
54
## your option) any later version.
55
##
56
## This program is distributed in the hope that it will be useful, but WITHOUT
57
## ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
58
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
59
## for more details.
60
##
61
## You should have received a copy of the GNU General Public License along
62
## with this program.  (It's in the $(ROOT)/doc directory, run make with no
63
## target there if the PDF file isn't present.)  If not, see
64
##  for a copy.
65
##
66
## License:     GPL, v3, as defined and found on www.gnu.org,
67
##              http://www.gnu.org/licenses/gpl.html
68
##
69
##
70
################################################################################
71
##
72
##
73
CXX     := g++
74
FLAGS   := -Wall -Og -g
75
OBJDIR  := obj-pc
76
RTLD    := ../verilog
77 5 dgisselq
VERILATOR_ROOT ?= $(shell bash -c 'verilator -V|grep VERILATOR_ROOT | head -1 | sed -e " s/^.*=\s*//"')
78
VROOT   := $(VERILATOR_ROOT)
79 18 dgisselq
INCS    := -I$(RTLD)/obj_dir/ -I$(VROOT)/include
80 5 dgisselq
SOURCES := helloworld.cpp linetest.cpp uartsim.cpp uartsim.h
81 2 dgisselq
VOBJDR  := $(RTLD)/obj_dir
82 18 dgisselq
SYSVDR  := $(VROOT)/include
83
VSRC    := verilated.cpp verilated_vcd_c.cpp
84
VLIB    := $(addprefix $(OBJDIR)/,$(subst .cpp,.o,$(VSRC)))
85 5 dgisselq
# Sources necessary to build the linetest program (rxuart-txuart test)
86
LINSRCS := linetest.cpp uartsim.cpp
87
LINOBJ := $(subst .cpp,.o,$(LINSRCS))
88 18 dgisselq
LINOBJS:= $(addprefix $(OBJDIR)/,$(LINOBJ)) $(VLIB)
89 5 dgisselq
# Sources necessary to build the helloworld test (txuart test)
90
HLOSRCS := helloworld.cpp uartsim.cpp
91
HLOOBJ := $(subst .cpp,.o,$(HLOSRCS))
92 18 dgisselq
HLOOBJS:= $(addprefix $(OBJDIR)/,$(HLOOBJ)) $(VLIB)
93 5 dgisselq
# Sources necessary to build the speech test (wbuart test)
94
SPCHSRCS:= speechtest.cpp uartsim.cpp
95
SPCHOBJ := $(subst .cpp,.o,$(SPCHSRCS))
96 18 dgisselq
SPCHOBJS:= $(addprefix $(OBJDIR)/,$(SPCHOBJ)) $(VLIB)
97 5 dgisselq
all:    $(OBJDIR)/ linetest helloworld speechtest test
98 2 dgisselq
 
99
$(OBJDIR)/uartsim.o: uartsim.cpp uartsim.h
100
 
101
$(OBJDIR)/%.o: %.cpp
102 18 dgisselq
        $(mk-objdir)
103 2 dgisselq
        $(CXX) $(FLAGS) $(INCS) -c $< -o $@
104
 
105 18 dgisselq
$(OBJDIR)/%.o: $(SYSVDR)/%.cpp
106
        $(mk-objdir)
107
        $(CXX) $(FLAGS) $(INCS) -c $< -o $@
108
 
109 5 dgisselq
linetest: $(LINOBJS) $(VOBJDR)/Vlinetest__ALL.a
110 18 dgisselq
        $(CXX) $(FLAGS) $(INCS) $^ -o $@
111 2 dgisselq
 
112 5 dgisselq
helloworld: $(HLOOBJS) $(VOBJDR)/Vhelloworld__ALL.a
113 18 dgisselq
        $(CXX) $(FLAGS) $(INCS) $^ -o $@
114 5 dgisselq
 
115
#
116
# The speech test program depends upon a copy of the Gettysburg Address,
117
# turned into a hex file format which will be read by the Verilog/RTL
118
# $readmemh function.  However, we need to create that hex file that will
119
# written.  That's the purpose of mkspeech--to make a file that can be read
120
# by $readmemh.
121
#
122
mkspeech: mkspeech.cpp
123
        $(CXX) mkspeech.cpp -o $@
124
 
125
# Now that mkspeech is available, use it to produce a speech.hex file from
126
# the speech.txt file.  Be careful if you adjust this speech: the speechfifo.v
127
# verilog file depends upon the exact number of characters--its not a portable
128
# dependency, but ... it is what it is.
129
speech.hex: mkspeech speech.txt
130
        ./mkspeech speech.txt
131 11 dgisselq
        bash -c "if [ -d ../verilog/ ]; then cp speech.hex ../verilog/; fi"
132 5 dgisselq
 
133
# Now, if the speech.hex file is available, then we can perform our final build.
134
# Actually, we could've done this without the speech file being available, but
135
# this works.
136
speechtest: speech.hex $(SPCHOBJS) $(VOBJDR)/Vspeechfifo__ALL.a
137 18 dgisselq
        $(CXX) $(FLAGS) $(INCS) $(SPCHOBJS) $(VOBJDR)/Vspeechfifo__ALL.a -o $@
138 5 dgisselq
 
139
test: linetest speechtest
140
        ./linetest
141
        ./speechtest
142
 
143 18 dgisselq
#
144
# The "depends" target, to know what files things depend upon.  The depends
145
# file itself is kept in $(OBJDIR)/depends.txt
146
#
147
define  build-depends
148
        $(mk-objdir)
149
        @echo "Building dependency file"
150
        @$(CXX) $(CFLAGS) $(INCS) -MM $(SOURCES) > $(OBJDIR)/xdepends.txt
151
        @sed -e 's/^.*.o: /$(OBJDIR)\/&/' < $(OBJDIR)/xdepends.txt > $(OBJDIR)/depends.txt
152
        @rm $(OBJDIR)/xdepends.txt
153
endef
154
 
155
.PHONY: depends
156
depends: tags
157
        $(build-depends)
158
 
159
$(OBJDIR)/depends.txt: depends
160
 
161
#
162
define  mk-objdir
163
        @bash -c "if [ ! -e $(OBJDIR) ]; then mkdir -p $(OBJDIR); fi"
164
endef
165
 
166
#
167
# The "tags" target
168
#
169
tags:   $(SOURCES) $(HEADERS)
170
        @echo "Generating tags"
171
        @ctags $(SOURCES) $(HEADERS)
172
 
173 2 dgisselq
.PHONY: clean
174
clean:
175 5 dgisselq
        rm -f  ./linetest ./helloworld ./speechtest
176
        rm -f ./mkspeech ./speech.hex
177 4 dgisselq
        rm -rf $(OBJDIR)/
178 2 dgisselq
 
179 26 dgisselq
ifneq ($(MAKECMDGOALS),clean)
180 18 dgisselq
-include $(OBJDIR)/depends.txt
181 26 dgisselq
endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.