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

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sim/] [verilator/] [Makefile] - Blame information for rev 209

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 204 dgisselq
################################################################################
2 209 dgisselq
##
3
## Filename:    Makefile
4
##
5
## Project:     Zip CPU -- a small, lightweight, RISC CPU soft core
6
##
7
## Purpose:     This makefile builds the final verilator simulation of the
8
##              zipsystem.  Specifically, it builds the final C++ portion
9
##      of the simulator, and thus the final simulator executable.
10
##
11
##      This simulator depends upon the libelf and ncurses libraries.
12
##
13
##      Useful targets of this makefile include:
14
##
15
##      zipsys_tb (default)
16
##              This is the test bench program / simulator that is built by
17
##              this directory.  This is based upon the ZipSystem.
18
##
19
##      zipbones_tb (default)
20
##              This is the test bench program / simulator that is built by
21
##              this directory--save that this ones uses the ZipBones.
22
##
23
##      test
24
##              Runs the simulator on a test program found in the trunk/sw/zasm
25
##              directory.  That program needs to be built via 'make test' in
26
##              that directory before this make test will work.  Changes to the
27
##              test itself will require a 'make test' in trunk/sw/zasm as well
28
##              as 'make test' in this directory.
29
##
30
##              The test itself consists of two tests.  The first, the "step"
31
##              test, tests whether the test works via "step"ing the CPU.
32
##              This would be the interface to the CPU were the CPU placed in
33
##              a device.
34
##
35
##              The second test is an internal test which works by just running
36
##              the CPU without step instructions.
37
##
38
##              In either case the test is over upon reaching either a HALT
39
##              or a BUSY instruction.  A HALT instruction indicates success,
40
##              BUSY a failure.
41
##
42
##      stest
43
##              Runs the test in "step" mode as described above.
44
##
45
##      itest
46
##              Runs the test file in interactive mode.  The CPU will not
47
##              execute any instructions without user interaction.  This is
48
##              useful for actually debugging the test.  The other two modes
49
##              are useful for quickly determining that the CPU does (or
50
##              doesn't) work.
51
##
52
##      dhrystone
53
##              Runs a hand-optimized version of the dhrystone benchmark.
54
##              Using the instructions at the top of the dhrystone assembly
55
##              file, you should be able to convert the result to DMIPS or even
56
##              DMIPS/MHz.
57
##
58
##      div_tb
59
##              A raw test bench to test the divide unit separate from the
60
##              rest of the CPU.  This test will fail with a failed assert()
61
##              if unsuccessful, or complete with no error (but lots of
62
##              debugging output) if successful.  To actually run this test,
63
##              you'll need to run ./div_tb (no arguments necessary).
64
##
65
##      mpy_tb
66
##              A raw test bench to test the multiply instructions within the
67
##              cpuops (ALU) unit separate from the rest of the CPU.  For more
68
##              details, look at the usage statement wtihin mpy_tb.
69
##
70
##      pfcache_tb
71
##
72
##      zipmmu_tb
73
##              Like div_tb, this is another raw component test bench.  In this
74
##              case, zipmmu_tb tests whether or not the MMU works when
75
##              separated from the rest of the CPU.
76
##
77
##      pdump
78
##              zipsys_tb can be configured to produce a profile output that is
79
##              very useful when debugging the Dhrystone benchmark.  (It is
80
##              so configured by default.)  This file will be name pfile.bin.
81
##              pdump is a very simple program designed to read this file and
82
##              produce some (very raw) information from it.  To use this,
83
##              type pdump and the name of the executable file, such as
84
##              ../asm/zipdhry.z, and examine how many times each instruction
85
##              was executed, and how many stalls took place between each
86
##              instruction and the next.
87
##
88
##      clean
89
##              Removes all products of compilation--specifically zipsys_tb,
90
##              pdump and div_tb.
91
##
92
##
93
## Creator:     Dan Gisselquist, Ph.D.
94
##              Gisselquist Technology, LLC
95
##
96 204 dgisselq
################################################################################
97 209 dgisselq
##
98
## Copyright (C) 2015-2017, Gisselquist Technology, LLC
99
##
100
## This program is free software (firmware): you can redistribute it and/or
101
## modify it under the terms of the GNU General Public License as published
102
## by the Free Software Foundation, either version 3 of the License, or (at
103
## your option) any later version.
104
##
105
## This program is distributed in the hope that it will be useful, but WITHOUT
106
## ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
107
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
108
## for more details.
109
##
110
## You should have received a copy of the GNU General Public License along
111
## with this program.  (It's in the $(ROOT)/doc directory.  Run make with no
112
## target there if the PDF file isn't present.)  If not, see
113
##  for a copy.
114
##
115
## License:     GPL, v3, as defined and found on www.gnu.org,
116
##              http://www.gnu.org/licenses/gpl.html
117
##
118
##
119 204 dgisselq
################################################################################
120 209 dgisselq
##
121
##
122
all: zipsys_tb zipbones_tb pdump div_tb mpy_tb pfcache_tb # zipmmu_tb
123 204 dgisselq
 
124
CXX     := g++
125 209 dgisselq
CFLAGS  := -Wall -Og -g -D__WORDSIZE=64
126 204 dgisselq
OBJDIR  := obj-pc
127
ZASM    := ../../sw/zasm
128
RTLD    := ../../rtl
129
RTLOBJD := $(RTLD)/obj_dir
130
BENCHOBJD:= ../../bench/rtl/obj_dir
131 209 dgisselq
ifneq ($(VERILATOR_ROOT),)
132
VERILATOR:=$(VERILATOR_ROOT)/bin/verilator
133
else
134 204 dgisselq
VERILATOR_ROOT ?= $(shell bash -c 'verilator -V|grep VERILATOR_ROOT | head -1 | sed -e " s/^.*=\s*//"')
135 209 dgisselq
endif
136
export  $(VERILATOR)
137 204 dgisselq
VROOT   := $(VERILATOR_ROOT)
138 209 dgisselq
VDEFS   := $(shell ./vversion.sh)
139 204 dgisselq
VINCS   := -I$(VROOT)/include -I$(VROOT)/include/vltstd
140
INCS    := -I$(RTLOBJD) -I$(RTLD) -I$(ZASM) $(VINCS)
141
ZLIBSRCS:= zipelf.cpp twoc.cpp byteswap.cpp
142 209 dgisselq
SOURCES := $(ZLIBSRCS) pdump.cpp zipcpu_tb.cpp memsim.cpp
143 204 dgisselq
ZDSMSRCS:= zopcodes.cpp
144
ZOBJS   := $(addprefix $(OBJDIR)/,$(subst .cpp,.o,$(ZLIBSRCS) $(ZDSMSRCS)))
145 209 dgisselq
SIMSRCS := memsim.cpp $(ZLIBSRCS) $(ZDMSRCS)
146 204 dgisselq
SIMOBJS := $(addprefix $(OBJDIR)/,$(subst .cpp,.o,$(SIMSRCS) $(ZDSMSRCS)))
147 209 dgisselq
SYSOBJS := $(OBJDIR)/zipsys_tb.o   $(SIMOBJS)
148
BONOBJS := $(OBJDIR)/zipbones_tb.o $(SIMOBJS)
149 204 dgisselq
VLSRCS  := verilated.cpp verilated_vcd_c.cpp
150
VLOBJS := $(OBJDIR)/verilated.o $(OBJDIR)/verilated_vcd_c.o
151
VLIB    := $(addprefix $(VROOT)/include/,$(VLSRCS))
152 209 dgisselq
RAWSYSLIB := $(RTLOBJD)/Vzipsystem__ALL.a
153
RAWBONLIB := $(RTLOBJD)/Vzipbones__ALL.a
154
SYSLIBS := $(RAWSYSLIB) -lncurses -lelf
155
BONLIBS := $(RAWBONLIB) -lncurses -lelf
156
TESTF   := ../../bench/asm/simtest
157 204 dgisselq
DHRYSTONEF := ../asm/zipdhry.z
158
 
159
$(OBJDIR)/%.o: %.cpp
160 209 dgisselq
        $(mk-objdir)
161
        $(CXX) $(CFLAGS) $(VDEFS) $(INCS) -c $< -o $@
162 204 dgisselq
 
163 209 dgisselq
$(OBJDIR)/zipsys_tb.o: zipcpu_tb.cpp
164
        $(mk-objdir)
165
        $(CXX) $(CFLAGS) $(VDEFS) $(INCS) -c $< -o $@
166
 
167
$(OBJDIR)/zipbones_tb.o: zipcpu_tb.cpp
168
        $(mk-objdir)
169
        $(CXX) -DZIPBONES $(VDEFS) $(CFLAGS) $(INCS) -c $< -o $@
170
 
171 204 dgisselq
$(OBJDIR)/%.o: $(ZASM)/%.cpp
172 209 dgisselq
        $(mk-objdir)
173 204 dgisselq
        $(CXX) $(CFLAGS) $(INCS) -c $< -o $@
174
 
175
$(OBJDIR)/%.o: $(VROOT)/include/%.cpp
176 209 dgisselq
        $(mk-objdir)
177 204 dgisselq
        $(CXX) $(CFLAGS) $(INCS) -c $< -o $@
178
 
179 209 dgisselq
zipsys_tb: $(SYSOBJS) $(VLOBJS) $(RAWSYSLIB)
180
        $(CXX) $(CFLAGS) $(INCS) $(SYSOBJS) $(VLOBJS) $(SYSLIBS) -o $@
181 204 dgisselq
 
182 209 dgisselq
zipbones_tb: $(BONOBJS) $(VLOBJS) $(RAWBONLIB)
183
        $(CXX) $(CFLAGS) $(INCS) $(BONOBJS) $(VLOBJS) $(BONLIBS) -o $@
184
 
185 204 dgisselq
div_tb: div_tb.cpp twoc.cpp $(VLIB) $(RTLOBJD)/Vdiv__ALL.a testb.h
186 209 dgisselq
        $(CXX) $(CFLAGS) $(VDEFS) $(INCS) div_tb.cpp twoc.cpp $(VLIB) $(RTLOBJD)/Vdiv__ALL.a -o $@
187 204 dgisselq
 
188
mpy_tb: mpy_tb.cpp twoc.cpp $(VLIB) $(RTLOBJD)/Vcpuops__ALL.a testb.h
189 209 dgisselq
        $(CXX) $(CFLAGS) $(VDEFS) $(INCS) mpy_tb.cpp twoc.cpp $(VLIB) $(RTLOBJD)/Vcpuops__ALL.a -o $@
190 204 dgisselq
 
191
zipmmu_tb: zipmmu_tb.cpp $(VLIB) $(BENCHOBJD)/Vzipmmu_tb__ALL.a
192 209 dgisselq
        $(CXX) $(CFLAGS) $(VDEFS) $(INCS) -I$(BENCHOBJD) zipmmu_tb.cpp $(VLIB) $(BENCHOBJD)/Vzipmmu_tb__ALL.a -o $@
193 204 dgisselq
 
194
pfcache_tb: $(OBJDIR)/pfcache_tb.o $(OBJDIR)/memsim.o $(OBJDIR)/byteswap.o
195
pfcache_tb: $(VLIB) $(RTLOBJD)/Vpfcache__ALL.a
196 209 dgisselq
        $(CXX) $(CFLAGS) $(VDEFS) $(INCS) -I$(RTLOBJD) $(OBJDIR)/pfcache_tb.o $(OBJDIR)/memsim.o $(OBJDIR)/byteswap.o $(VLIB) $(RTLOBJD)/Vpfcache__ALL.a -o $@
197 204 dgisselq
 
198
pdump: pdump.cpp $(ZOBJS) $(OBJDIR)/zopcodes.o $(OBJDIR)/pdump.o
199
pdump: $(ZASM)/zopcodes.h testb.h byteswap.h zipelf.h
200
        $(CXX) $(CFLAGS) $(INCS) $(OBJDIR)/pdump.o $(ZOBJS) -lelf -o $@
201
 
202
.PHONY: stest
203 209 dgisselq
stest: zipsys_tb
204
        ./zipsys_tb -s $(TESTF)
205 204 dgisselq
 
206
.PHONY: itest
207 209 dgisselq
itest: zipsys_tb
208
        ./zipsys_tb $(TESTF)
209 204 dgisselq
 
210
.PHONY: test
211 209 dgisselq
test: zipsys_tb stest
212
        ./zipsys_tb -a $(TESTF)
213 204 dgisselq
 
214
.PHONY: dhrystone
215 209 dgisselq
dhrystone: zipsys_tb
216
        ./zipsys_tb -a $(DHRYSTONEF)
217 204 dgisselq
 
218
define  build-depends
219
        @echo "Building dependencies"
220 209 dgisselq
        $(mk-objdir)
221
        @$(CXX) $(CPPFLAGS) $(INCS) -MM zipcpu_tb.cpp $(VLIB) $(SOURCES) > $(OBJDIR)/sysdepends.txt
222
        @$(CXX) -DZIPBONES $(CPPFLAGS) $(INCS) -MM zipcpu_tb.cpp $(VLIB) $(SOURCES) > $(OBJDIR)/bondepends.txt
223
        @sed -e 's/^zipcpu_tb.o: /zipsys_tb.o: /' < $(OBJDIR)/sysdepends.txt > $(OBJDIR)/xdepends.txt
224
        @sed -e 's/^zipcpu_tb.o: /zipbones_tb.o: /' < $(OBJDIR)/bondepends.txt >> $(OBJDIR)/xdepends.txt
225 204 dgisselq
        @sed -e 's/^.*.o: /$(OBJDIR)\/&/' < $(OBJDIR)/xdepends.txt > $(OBJDIR)/depends.txt
226
        @rm $(OBJDIR)/xdepends.txt
227 209 dgisselq
        @rm $(OBJDIR)/sysdepends.txt
228
        @rm $(OBJDIR)/bondepends.txt
229 204 dgisselq
endef
230
 
231
tags: $(VLIB) $(SOURCES)
232
        @ctags $(SOURCES) $(VLIB)
233
 
234
.PHONY: depends
235
depends: tags $(OBJDIR)/
236
        $(build-depends)
237
 
238 209 dgisselq
define  mk-objdir
239 204 dgisselq
        @bash -c "if [ ! -e $(OBJDIR) ]; then mkdir -p $(OBJDIR)/; fi"
240 209 dgisselq
endef
241 204 dgisselq
 
242
$(OBJDIR)/depends.txt: $(OBJDIR)/ depends
243
 
244
.PHONY: clean
245
clean:
246
        rm -rf $(OBJDIR)/
247 209 dgisselq
        rm -rf ./zipsys_tb ./zipbones_tb pdump div_tb mpy_tb
248
        rm -rf pfcache_tb
249 204 dgisselq
 
250
-include $(OBJDIR)/depends.txt

powered by: WebSVN 2.1.0

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