-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (66 loc) · 3.24 KB
/
Copy pathMakefile
File metadata and controls
80 lines (66 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# SPDX-License-Identifier: Apache-2.0
# Copyright 2020 Western Digital Corporation or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
VERILATOR = verilator
VERILATED_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
CALIPTRA_RTL_DIR := $(realpath $(VERILATED_DIR)../latest/rtl)
CFLAGS := -std=c++14 -fno-exceptions -fPIC
# verilated_timing.cpp uses C++20 coroutines (generated when --timing is used).
TIMING_CFLAGS := -std=c++20 -fcoroutines -fno-exceptions -fPIC
VERILATOR_MAKE_FLAGS = OPT_FAST="-Os"
VERILATOR_CFLAGS = $(shell pkg-config --cflags verilator)
VERILATOR_INCLUDEDIR = $(shell pkg-config --variable=includedir verilator)
VERILATOR_OBJS = out/verilated_threads.o out/verilated.o out/verilated_vcd_c.o out/verilated_timing.o
LIB_OBJS = out/caliptra_verilated.o
# Environment variables needed by caliptra_top_tb.vf
export CALIPTRA_ROOT = $(CALIPTRA_RTL_DIR)
export CALIPTRA_PRIM_ROOT = $(CALIPTRA_RTL_DIR)/src/caliptra_prim_generic
export CALIPTRA_PRIM_MODULE_PREFIX = caliptra_prim_generic
# AXI4PC is not needed for simulation, provide empty stub location
export CALIPTRA_AXI4PC_DIR = $(VERILATED_DIR)
suppress = -Wno-WIDTH -Wno-UNOPTFLAT -Wno-LITENDIAN -Wno-CMPCONST -Wno-MULTIDRIVEN -Wno-UNPACKED -Wno-UNSIGNED -Wno-REALCVT -Wno-SELRANGE -Wno-PINMISSING -Wno-TIMESCALEMOD -Wno-BLKANDNBLK
out/libcaliptra_verilated.a: out/Vcaliptra_verilated__ALL.a out/libverilated.a $(LIB_OBJS) $(VERILATOR_OBJS)
cp out/Vcaliptra_verilated__ALL.a out/.libcaliptra_verilated.a
ar rs out/.libcaliptra_verilated.a $(LIB_OBJS) $(VERILATOR_OBJS)
mv out/.libcaliptra_verilated.a out/libcaliptra_verilated.a
out:
mkdir -p out
$(VERILATOR_OBJS): out/%.o: $(VERILATOR_INCLUDEDIR)/%.cpp
$(CXX) ${CFLAGS} $(VERILATOR_CFLAGS) -c $< -o $@
# verilated_timing.cpp requires C++20 coroutines; override default CFLAGS.
out/verilated_timing.o: $(VERILATOR_INCLUDEDIR)/verilated_timing.cpp
$(CXX) ${TIMING_CFLAGS} $(VERILATOR_CFLAGS) -c $< -o $@
$(LIB_OBJS): out/%.o: $(VERILATED_DIR)/%.cpp
$(CXX) -Iout ${CFLAGS} $(VERILATOR_CFLAGS) -c $< -o $@
out/Vcaliptra_verilated.h: ${VERILATED_DIR}/caliptra_verilated.sv out
$(VERILATOR) --cc -CFLAGS "${CFLAGS}" \
--trace \
+libext+.v+.sv +define+RV_OPENSOURCE +define+VERILATOR \
--timescale 1ns/1ps \
--trace-structs \
--timing \
$(includes) \
-Mdir out \
-MMD \
-Wno-fatal \
--clk core_clk \
$(suppress) \
-f $(CALIPTRA_RTL_DIR)/src/integration/config/caliptra_top_tb.vf \
$(VERILATED_DIR)/caliptra_verilated.sv \
$(EXTRA_VERILATOR_FLAGS) \
--top-module caliptra_verilated
out/Vcaliptra_verilated__ALL.a out/libverilated.a &: out/Vcaliptra_verilated.h
$(MAKE) -j $(CALIPTRA_VERILATOR_JOBS) -e -C out -f Vcaliptra_verilated.mk $(VERILATOR_MAKE_FLAGS) Vcaliptra_verilated__ALL.a libverilated.a
clean:
rm -rf out