blob: 39f3dcea285e930e84a54bdc70c6aed50915115d [file] [log] [blame]
manarabdelaty69bd3262021-04-07 15:58:03 +02001# SPDX-FileCopyrightText: 2020 Efabless Corporation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15# SPDX-License-Identifier: Apache-2.0
16
17## Caravel Pointers
18CARAVEL_PATH ?= ../../../caravel
19CARAVEL_FIRMWARE_PATH = $(CARAVEL_PATH)/verilog/dv/caravel
20CARAVEL_VERILOG_PATH = $(CARAVEL_PATH)/verilog
21CARAVEL_RTL_PATH = $(CARAVEL_VERILOG_PATH)/rtl
manarabdelaty69bd3262021-04-07 15:58:03 +020022CARAVEL_BEHAVIOURAL_MODELS = $(CARAVEL_VERILOG_PATH)/dv/caravel
23
24## User Project Pointers
25UPRJ_VERILOG_PATH ?= ../../../verilog
26UPRJ_RTL_PATH = $(UPRJ_VERILOG_PATH)/rtl
manarabdelaty69bd3262021-04-07 15:58:03 +020027UPRJ_BEHAVIOURAL_MODELS = ../
28
29## RISCV GCC
30GCC_PATH?=/ef/apps/bin
31GCC_PREFIX?=riscv32-unknown-elf
32PDK_PATH?=/ef/tech/SW/sky130A
33
34## Simulation mode: RTL/GL
35SIM?=RTL
36
37.SUFFIXES:
38
39PATTERN = la_test1
40
41all: ${PATTERN:=.vcd}
42
43hex: ${PATTERN:=.hex}
44
45%.vvp: %_tb.v %.hex
46ifeq ($(SIM),RTL)
47 iverilog -DFUNCTIONAL -DSIM -I $(PDK_PATH) \
48 -I $(CARAVEL_BEHAVIOURAL_MODELS) -I $(CARAVEL_RTL_PATH) \
49 -I $(UPRJ_BEHAVIOURAL_MODELS) -I $(UPRJ_RTL_PATH) \
50 $< -o $@
51else
manarabdelatya63e2e62021-04-08 20:32:40 +020052 iverilog -DFUNCTIONAL -DSIM -DGL -I $(PDK_PATH) \
53 -I $(CARAVEL_BEHAVIOURAL_MODELS) -I $(CARAVEL_RTL_PATH) -I $(CARAVEL_VERILOG_PATH) \
54 -I $(UPRJ_BEHAVIOURAL_MODELS) -I$(UPRJ_RTL_PATH) -I $(UPRJ_VERILOG_PATH) \
manarabdelaty69bd3262021-04-07 15:58:03 +020055 $< -o $@
56endif
57
58%.vcd: %.vvp
59 vvp $<
60
61%.elf: %.c $(CARAVEL_FIRMWARE_PATH)/sections.lds $(CARAVEL_FIRMWARE_PATH)/start.s
manarabdelaty496112a2021-04-16 20:53:54 +020062 ${GCC_PATH}/${GCC_PREFIX}-gcc -I $(CARAVEL_PATH) -march=rv32imc -mabi=ilp32 -Wl,-Bstatic,-T,$(CARAVEL_FIRMWARE_PATH)/sections.lds,--strip-debug -ffreestanding -nostdlib -o $@ $(CARAVEL_FIRMWARE_PATH)/start.s $<
manarabdelaty69bd3262021-04-07 15:58:03 +020063
64%.hex: %.elf
65 ${GCC_PATH}/${GCC_PREFIX}-objcopy -O verilog $< $@
66 # to fix flash base address
67 sed -i 's/@10000000/@00000000/g' $@
68
69%.bin: %.elf
70 ${GCC_PATH}/${GCC_PREFIX}-objcopy -O binary $< /dev/stdout | tail -c +1048577 > $@
71
72# ---- Clean ----
73
74clean:
75 rm -f *.elf *.hex *.bin *.vvp *.vcd *.log
76
77.PHONY: clean hex all