-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsafed.mk
112 lines (86 loc) · 4 KB
/
safed.mk
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Copyright 2023 ETH Zurich and University of Bologna
# Solderpad Hardware License, Version 0.51, see LICENSE for details.
# SPDX-License-Identifier: SHL-0.51
BENDER ?= bender
PYTHON3 ?= python3
REGGEN ?= $(PYTHON3) $(shell $(BENDER) path register_interface)/vendor/lowrisc_opentitan/util/regtool.py
VLOG_ARGS += -suppress 2583 -suppress 13314 -svinputport=compat
SAFED_ROOT ?= $(shell $(BENDER) path safety_island)
SAFED_SW_DIR ?= $(SAFED_ROOT)/sw
SAFED_HW_DIR ?= $(SAFED_ROOT)/rtl
SAFED_SIM_DIR ?= $(SAFED_ROOT)/sim
SAFED_BOOT_DIR ?= $(SAFED_ROOT)/boot
################
# Dependencies #
################
# Ensure Bender dependencies are checked out
$(SAFED_ROOT)/.deps:
$(BENDER) checkout
@touch $@
# Make sure dependencies are more up-to-date than any targets run
include $(SAFED_ROOT)/.deps
######################
# Nonfree components #
######################
NONFREE_REMOTE ?= [email protected]:carfield/safety-island-nonfree.git
NONFREE_COMMIT ?= ea06e7dc80eb4d3cf592af41ef1e37789336ee3c
.PHONY: nonfree-init
## Initialize Safety Island CI repository
nonfree-init:
git clone $(NONFREE_REMOTE) $(SAFED_ROOT)/nonfree
cd $(SAFED_ROOT)/nonfree && git checkout $(NONFREE_COMMIT)
-include $(SAFED_ROOT)/nonfree/nonfree.mk
#####################
# Generate Hardware #
#####################
REG_HTML_STRING = "<!DOCTYPE html>\n<html>\n<head>\n<link rel="stylesheet" href="reg_html.css">\n</head>\n"
$(SAFED_HW_DIR)/soc_ctrl/safety_soc_ctrl_reg_pkg.sv $(SAFED_HW_DIR)/soc_ctrl/safety_soc_ctrl_reg_top.sv: $(SAFED_HW_DIR)/soc_ctrl/safety_soc_ctrl_regs.hjson
$(REGGEN) $< -t $(SAFED_HW_DIR)/soc_ctrl -r
cd $(SAFED_ROOT) && git apply $(SAFED_HW_DIR)/soc_ctrl/boot_addr.patch
printf $(REG_HTML_STRING) > $(SAFED_HW_DIR)/soc_ctrl/safety_soc_ctrl.html
$(REGGEN) $< -d >> $(SAFED_HW_DIR)/soc_ctrl/safety_soc_ctrl.html
printf "</html>\n" >> $(SAFED_HW_DIR)/soc_ctrl/safety_soc_ctrl.html
$(REGGEN) $< -D > $(SAFED_HW_DIR)/soc_ctrl/safety_soc_ctrl.h
cp $(shell $(BENDER) path register_interface)/vendor/lowrisc_opentitan/util/reggen/reg_html.css $(SAFED_HW_DIR)/soc_ctrl
$(SAFED_HW_DIR)/safety_island_bootrom.sv:
$(MAKE) -C$(SAFED_BOOT_DIR) clean safety_island_bootrom.sv
cp $(SAFED_BOOT_DIR)/safety_island_bootrom.sv $(SAFED_HW_DIR)/safety_island_bootrom.sv
$(SAFED_HW_DIR)/safety_island_bootrom_carfield.sv:
$(MAKE) -C$(SAFED_BOOT_DIR) clean safety_island_bootrom.sv CARFIELD=1
cp $(SAFED_BOOT_DIR)/safety_island_bootrom.sv $(SAFED_HW_DIR)/safety_island_bootrom_carfield.sv
.PHONY: safed-hw-gen safed-bootrom-gen
## Generate Safety Island HW sources
safed-hw-gen: $(SAFED_HW_DIR)/soc_ctrl/safety_soc_ctrl_reg_pkg.sv $(SAFED_HW_DIR)/soc_ctrl/safety_soc_ctrl_reg_top.sv
## Generate Safety Island bootrom
safed-bootrom-gen: $(SAFED_HW_DIR)/safety_island_bootrom.sv $(SAFED_HW_DIR)/safety_island_bootrom_carfield.sv
###########
# Scripts #
###########
# Generate Safety Island Questa Simulation Compile script
$(SAFED_SIM_DIR)/compile.tcl: $(SAFED_ROOT)/.deps
echo 'set ROOT [file normalize [file dirname [info script]]/..]' > $(SAFED_SIM_DIR)/compile.tcl
bender script vsim -p safety_island -t test -t rtl -t cv32e40p_use_ff_regfile \
--vlog-arg="$(VLOG_ARGS)" --vcom-arg="" \
| grep -v "set ROOT" >> $(SAFED_SIM_DIR)/compile.tcl
echo 'vlog "$$ROOT/rtl/tb/elfloader.cpp" -ccflags "-std=c++11"' >> $(SAFED_SIM_DIR)/compile.tcl
clean_$(SAFED_SIM_DIR)/compile.tcl:
rm -rf $(SAFED_SIM_DIR)/compile.tcl
clean: clean_$(SAFED_SIM_DIR)/compile.tcl
##############
# Simulation #
##############
SIM_TOP ?= tb_safety_island_jtag
include $(SAFED_ROOT)/sim/safed_sim.mk
##############
## SOFTWARE ##
##############
$(SAFED_SW_DIR)/pulp-runtime:
git clone https://github.com/pulp-platform/pulp-runtime.git -b safety-island $@
$(SAFED_SW_DIR)/pulp-freertos:
git clone https://github.com/pulp-platform/pulp-freertos.git $@
cd $@; \
git checkout carfield/safety-island; \
git submodule update --init --recursive
.PHONY: safed-sw-all
## Generate Safety Island software dependencies
safed-sw-all: $(SAFED_SW_DIR)/pulp-runtime $(SAFED_SW_DIR)/pulp-freertos