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

Subversion Repositories zipcpu

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

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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