forked from sycuricon/starship
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
114 lines (96 loc) · 3.68 KB
/
Makefile
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
113
114
# Starship Project
# Copyright (C) 2021 by phantom
# Email: [email protected]
# This file is under MIT License, see https://www.phvntom.tech/LICENSE.txt
TOP := $(CURDIR)
SRC := $(TOP)/repo
BUILD := $(TOP)/build
CONFIG := $(TOP)/conf
SBT_BUILD := $(TOP)/target $(TOP)/project/target $(TOP)/project/project
ifndef RISCV
$(error $$RISCV is undefined, please set $$RISCV to your riscv-toolchain)
endif
all: bitstream
#######################################
#
# Verilog Generator
#
#######################################
ROCKET_SRC := $(SRC)/rocket-chip
ROCKET_BUILD := $(BUILD)/rocket-chip
ROCKET_JVM_MEM ?= 2G
ROCKET_JAVA := java -Xmx$(ROCKET_JVM_MEM) -Xss8M -jar $(ROCKET_SRC)/sbt-launch.jar
ROCKET_TOP_PROJ ?= starship.fpga
ROCKET_TOP ?= TestHarness
ROCKET_CON_PROJ ?= starship.fpga
ROCKET_CONFIG ?= StarshipFPGAConfig
ROCKET_FREQ ?= 100
ROCKET_OUTPUT := $(ROCKET_TOP_PROJ).$(ROCKET_TOP).$(ROCKET_CONFIG)
ROCKET_VERILOG := $(ROCKET_BUILD)/$(ROCKET_OUTPUT).v
ROCKET_FIRRTL := $(ROCKET_BUILD)/$(ROCKET_OUTPUT).fir
$(ROCKET_FIRRTL):
mkdir -p $(ROCKET_BUILD)
$(ROCKET_JAVA) "runMain freechips.rocketchip.system.Generator \
-td $(ROCKET_BUILD) -T $(ROCKET_TOP_PROJ).$(ROCKET_TOP) \
-C $(ROCKET_CON_PROJ).$(ROCKET_CONFIG),$(ROCKET_CON_PROJ).With$(ROCKET_FREQ)MHz \
-n $(ROCKET_OUTPUT)"
$(ROCKET_VERILOG): $(ROCKET_FIRRTL)
mkdir -p $(ROCKET_BUILD)
$(ROCKET_JAVA) "runMain firrtl.stage.FirrtlMain \
-td $(ROCKET_BUILD) --infer-rw $(ROCKET_TOP) \
--repl-seq-mem -c:$(ROCKET_TOP):-o:$(ROCKET_BUILD)/$(ROCKET_OUTPUT).sram.conf \
-faf $(ROCKET_BUILD)/$(ROCKET_OUTPUT).anno.json \
-fct firrtl.passes.InlineInstances \
-i $< -o $@ -X verilog"
verilog: $(ROCKET_VERILOG)
#######################################
#
# Bitstream Generator
#
#######################################
FIRMWARE_SRC := $(TOP)/firmware
FIRMWARE_BUILD := $(BUILD)/firmware
FSBL_SRC := $(FIRMWARE_SRC)/fsbl
FSBL_BUILD := $(FIRMWARE_BUILD)/fsbl
STARSHIP_ROM_HEX := $(FSBL_BUILD)/sdboot.hex
BOARD := vc707
SCRIPT_SRC := $(SRC)/fpga-shells
VIVADO_SRC := $(SCRIPT_SRC)/xilinx
VIVADO_BUILD := $(BUILD)/vivado
VIVADO_BITSTREAM := $(VIVADO_BUILD)/$(ROCKET_OUTPUT).bit
VERILOG_SRAM := $(ROCKET_BUILD)/$(ROCKET_OUTPUT).behav_srams.v
VERILOG_ROM := $(ROCKET_BUILD)/$(ROCKET_OUTPUT).rom.v
VERILOG_INCLUDE := $(VIVADO_BUILD)/$(ROCKET_OUTPUT).vsrc.f
VERILOG_SRC := $(VERILOG_SRAM) \
$(VERILOG_ROM) \
$(STARSHIP_ROM_HEX) \
$(ROCKET_BUILD)/$(ROCKET_OUTPUT).v \
$(ROCKET_BUILD)/plusarg_reader.v \
$(VIVADO_SRC)/$(BOARD)/vsrc/sdio.v \
$(VIVADO_SRC)/$(BOARD)/vsrc/vc707reset.v \
$(SCRIPT_SRC)/testbench/SimTestHarness.v
$(VERILOG_INCLUDE):
mkdir -p $(VIVADO_BUILD)
echo $(VERILOG_SRC) > $@
$(VERILOG_SRAM):
$(ROCKET_SRC)/scripts/vlsi_mem_gen $(ROCKET_BUILD)/$(ROCKET_OUTPUT).sram.conf >> $@
$(STARSHIP_ROM_HEX):
$(MAKE) -C $(FSBL_SRC) PBUS_CLK=$(ROCKET_FREQ)000000 ROOT_DIR=$(TOP) ROCKET_OUTPUT=$(ROCKET_OUTPUT) hex
$(VERILOG_ROM): $(STARSHIP_ROM_HEX)
$(ROCKET_SRC)/scripts/vlsi_rom_gen $(ROCKET_BUILD)/$(ROCKET_OUTPUT).rom.conf $< > $@
$(VIVADO_BITSTREAM): $(ROCKET_VERILOG) $(VERILOG_INCLUDE) $(VERILOG_SRAM) $(VERILOG_ROM)
mkdir -p $(VIVADO_BUILD)
cd $(VIVADO_BUILD); vivado -mode batch -nojournal \
-source $(VIVADO_SRC)/common/tcl/vivado.tcl \
-tclargs -F "$(VERILOG_INCLUDE)" \
-top-module "$(ROCKET_TOP)" \
-ip-vivado-tcls "$(shell find '$(ROCKET_BUILD)' -name '*.vivado.tcl')" \
-board "$(BOARD)"
bitstream: $(VIVADO_BITSTREAM)
#######################################
#
# Utils
#
#######################################
clean:
rm -rf $(BUILD) $(SBT_BUILD)