2022-09-19 02:51:11 -04:00
|
|
|
#=======================================================================
|
|
|
|
#
|
|
|
|
# Makefile
|
|
|
|
# --------
|
|
|
|
# Makefile for building, simulating, running all application_fpga
|
|
|
|
# HW targets as well as its firmware.
|
|
|
|
#
|
|
|
|
#
|
2024-03-20 07:15:38 -04:00
|
|
|
# Copyright (C) 2022-2024 - Tillitis AB
|
2022-09-19 02:51:11 -04:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
#
|
2024-03-20 07:15:38 -04:00
|
|
|
#
|
|
|
|
# Please note: When creating a new cores and adding more testbenches,
|
|
|
|
# please update the tb target below to include it as well.
|
|
|
|
#
|
2022-09-19 02:51:11 -04:00
|
|
|
#=======================================================================
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
# Defines.
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
SHELL := /bin/bash
|
|
|
|
CUR_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
|
|
|
P := $(CUR_DIR)
|
|
|
|
|
|
|
|
YOSYS_PATH ?=
|
|
|
|
NEXTPNR_PATH ?=
|
|
|
|
ICESTORM_PATH ?=
|
|
|
|
|
2024-06-24 05:40:51 -04:00
|
|
|
# FPGA target frequency. Should be in sync with the clock frequency
|
|
|
|
# given by the parameters to the PLL in rtl/clk_reset_gen.v
|
|
|
|
TARGET_FREQ ?= 21
|
|
|
|
|
2022-10-11 11:25:00 -04:00
|
|
|
# Size in 32-bit words, must be divisible by 256 (pairs of EBRs, because 16
|
|
|
|
# bits wide; an EBR is 128 32-bits words)
|
2022-10-11 06:54:44 -04:00
|
|
|
BRAM_FW_SIZE ?= 1536
|
2022-09-19 02:51:11 -04:00
|
|
|
|
2023-05-16 09:40:26 -04:00
|
|
|
PIN_FILE ?= application_fpga_tk1.pcf
|
2022-09-19 02:51:11 -04:00
|
|
|
|
2022-11-23 03:47:48 -05:00
|
|
|
SIZE ?= llvm-size
|
|
|
|
OBJCOPY ?= llvm-objcopy
|
2022-09-19 02:51:11 -04:00
|
|
|
|
2022-11-23 03:47:48 -05:00
|
|
|
CC = clang
|
2022-09-19 02:51:11 -04:00
|
|
|
|
2022-11-28 09:56:56 -05:00
|
|
|
CFLAGS = -target riscv32-unknown-none-elf -march=rv32iczmmul -mabi=ilp32 \
|
2023-03-09 02:54:39 -05:00
|
|
|
-static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf \
|
2023-02-27 11:00:23 -05:00
|
|
|
-fno-builtin-putchar -fno-builtin-memcpy -nostdlib -mno-relax -Wall \
|
2024-03-04 09:57:29 -05:00
|
|
|
-Wpedantic -Wno-language-extension-token -flto -g -DNOCONSOLE
|
2022-09-19 02:51:11 -04:00
|
|
|
|
2022-11-23 03:47:48 -05:00
|
|
|
AS = clang
|
2022-11-28 09:56:56 -05:00
|
|
|
ASFLAGS = -target riscv32-unknown-none-elf -march=rv32iczmmul -mabi=ilp32 -mno-relax
|
2022-09-19 02:51:11 -04:00
|
|
|
|
|
|
|
ICE40_SIM_CELLS = $(shell yosys-config --datdir/ice40/cells_sim.v)
|
|
|
|
|
|
|
|
|
2022-10-11 10:58:26 -04:00
|
|
|
# FPGA specific source files.
|
2022-10-03 06:55:24 -04:00
|
|
|
FPGA_SRC = $(P)/rtl/application_fpga.v \
|
2024-08-20 04:50:26 -04:00
|
|
|
$(P)/core/clk_reset_gen/rtl/clk_reset_gen.v
|
2022-09-19 02:51:11 -04:00
|
|
|
|
2022-10-11 10:58:26 -04:00
|
|
|
# Verilator simulation specific source files.
|
2022-10-03 06:55:24 -04:00
|
|
|
VERILATOR_FPGA_SRC = $(P)/tb/application_fpga_vsim.v \
|
|
|
|
$(P)/tb/reset_gen_vsim.v
|
2022-09-19 02:51:11 -04:00
|
|
|
|
2022-10-03 06:55:24 -04:00
|
|
|
# Common verilog source files.
|
2022-09-19 02:51:11 -04:00
|
|
|
VERILOG_SRCS = \
|
2024-08-20 04:50:26 -04:00
|
|
|
$(P)/core/ram/rtl/ram.v \
|
|
|
|
$(P)/core/rom/rtl/rom.v \
|
|
|
|
$(P)/core/fw_ram/rtl/fw_ram.v \
|
2022-09-19 02:51:11 -04:00
|
|
|
$(P)/core/picorv32/rtl/picorv32.v \
|
|
|
|
$(P)/core/timer/rtl/timer_core.v \
|
|
|
|
$(P)/core/timer/rtl/timer.v \
|
|
|
|
$(P)/core/uds/rtl/uds.v \
|
2023-11-28 04:20:30 -05:00
|
|
|
$(P)/core/uds/rtl/uds_rom.v \
|
2022-09-19 02:51:11 -04:00
|
|
|
$(P)/core/touch_sense/rtl/touch_sense.v \
|
2022-10-20 08:50:21 -04:00
|
|
|
$(P)/core/tk1/rtl/tk1.v \
|
2023-05-16 10:14:21 -04:00
|
|
|
$(P)/core/tk1/rtl/tk1_spi_master.v \
|
2023-11-28 04:20:30 -05:00
|
|
|
$(P)/core/tk1/rtl/udi_rom.v \
|
2022-09-19 02:51:11 -04:00
|
|
|
$(P)/core/uart/rtl/uart_core.v \
|
|
|
|
$(P)/core/uart/rtl/uart_fifo.v \
|
|
|
|
$(P)/core/uart/rtl/uart.v \
|
2022-10-11 07:17:04 -04:00
|
|
|
$(P)/core/trng/rtl/rosc.v
|
2022-09-19 02:51:11 -04:00
|
|
|
|
|
|
|
FIRMWARE_DEPS = \
|
2022-10-20 08:50:21 -04:00
|
|
|
$(P)/fw/tk1_mem.h \
|
|
|
|
$(P)/fw/tk1/types.h \
|
|
|
|
$(P)/fw/tk1/lib.h \
|
2023-02-27 11:00:23 -05:00
|
|
|
$(P)/fw/tk1/proto.h \
|
|
|
|
$(P)/fw/tk1/assert.h \
|
2023-02-27 11:11:03 -05:00
|
|
|
$(P)/fw/tk1/led.h
|
2022-09-19 02:51:11 -04:00
|
|
|
|
|
|
|
FIRMWARE_OBJS = \
|
2022-10-20 08:50:21 -04:00
|
|
|
$(P)/fw/tk1/main.o \
|
|
|
|
$(P)/fw/tk1/start.o \
|
|
|
|
$(P)/fw/tk1/proto.o \
|
|
|
|
$(P)/fw/tk1/lib.o \
|
2023-02-27 11:00:23 -05:00
|
|
|
$(P)/fw/tk1/assert.o \
|
2023-02-27 11:11:03 -05:00
|
|
|
$(P)/fw/tk1/led.o \
|
2022-10-20 08:50:21 -04:00
|
|
|
$(P)/fw/tk1/blake2s/blake2s.o
|
2022-09-19 02:51:11 -04:00
|
|
|
|
2023-03-21 09:11:08 -04:00
|
|
|
FIRMWARE_SOURCES = \
|
|
|
|
$(P)/fw/tk1/main.c \
|
|
|
|
$(P)/fw/tk1/proto.c \
|
|
|
|
$(P)/fw/tk1/lib.c \
|
|
|
|
$(P)/fw/tk1/assert.c \
|
|
|
|
$(P)/fw/tk1/led.c \
|
|
|
|
$(P)/fw/tk1/blake2s/blake2s.c
|
|
|
|
|
2022-09-19 02:51:11 -04:00
|
|
|
TESTFW_OBJS = \
|
|
|
|
$(P)/fw/testfw/main.o \
|
2023-03-14 05:55:19 -04:00
|
|
|
$(P)/fw/testfw/start.o \
|
2022-10-20 08:50:21 -04:00
|
|
|
$(P)/fw/tk1/proto.o \
|
2022-12-09 11:34:17 -05:00
|
|
|
$(P)/fw/tk1/lib.o \
|
|
|
|
$(P)/fw/tk1/blake2s/blake2s.o
|
2022-09-19 02:51:11 -04:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
# All: Complete build of HW and FW.
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
all: application_fpga.bin
|
|
|
|
.PHONY: all
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
# The size_mismatch target make sure that we don't end up with an
|
|
|
|
# incorrect BRAM_FW_SIZE
|
|
|
|
# -------------------------------------------------------------------
|
2022-10-11 11:25:19 -04:00
|
|
|
%_size_mismatch: %.elf phony_explicit
|
2023-03-14 05:55:19 -04:00
|
|
|
@test $$($(SIZE) $< | awk 'NR==2{print $$4}') -le $$(( 32 / 8 * $(BRAM_FW_SIZE) )) \
|
|
|
|
|| { printf "The 'BRAM_FW_SIZE' variable needs to be increased\n"; \
|
|
|
|
[[ $< =~ testfw ]] && printf "Note that testfw fits if built with -Os\n"; \
|
|
|
|
false; }
|
2022-09-19 02:51:11 -04:00
|
|
|
|
2022-10-11 11:25:19 -04:00
|
|
|
# can't make implicit rule .PHONY
|
2022-10-11 14:46:21 -04:00
|
|
|
phony_explicit:
|
2022-10-11 11:25:19 -04:00
|
|
|
.PHONY: phony_explicit
|
2022-09-19 02:51:11 -04:00
|
|
|
|
2022-10-20 11:02:09 -04:00
|
|
|
#-------------------------------------------------------------------
|
2022-12-02 01:17:14 -05:00
|
|
|
# Personalization of the TKey
|
2022-10-20 11:02:09 -04:00
|
|
|
#-------------------------------------------------------------------
|
|
|
|
|
|
|
|
secret:
|
|
|
|
cd data;../tools/tpt/tpt.py
|
|
|
|
.PHONY: secret
|
|
|
|
|
2022-09-19 02:51:11 -04:00
|
|
|
#-------------------------------------------------------------------
|
|
|
|
# Firmware generation.
|
|
|
|
# Included in the bitstream.
|
|
|
|
#-------------------------------------------------------------------
|
2022-10-20 08:50:21 -04:00
|
|
|
LDFLAGS=-T $(P)/fw/tk1/firmware.lds
|
2022-09-19 02:51:11 -04:00
|
|
|
|
|
|
|
$(FIRMWARE_OBJS): $(FIRMWARE_DEPS)
|
|
|
|
$(TESTFW_OBJS): $(FIRMWARE_DEPS)
|
|
|
|
|
2022-10-20 08:50:21 -04:00
|
|
|
firmware.elf: $(FIRMWARE_OBJS) $(P)/fw/tk1/firmware.lds
|
2022-09-19 02:51:11 -04:00
|
|
|
$(CC) $(CFLAGS) $(FIRMWARE_OBJS) $(LDFLAGS) -o $@
|
|
|
|
|
2023-03-21 09:11:08 -04:00
|
|
|
.PHONY: check
|
|
|
|
check:
|
|
|
|
clang-tidy -header-filter=.* -checks=cert-* $(FIRMWARE_SOURCES) -- $(CFLAGS)
|
2024-03-21 07:11:33 -04:00
|
|
|
|
|
|
|
.PHONY: splint
|
|
|
|
splint:
|
2023-03-21 09:11:08 -04:00
|
|
|
splint -nolib -predboolint +boolint -nullpass -unrecog -infloops -initallelements -type -unreachable -unqualifiedtrans -fullinitblock $(FIRMWARE_SOURCES)
|
|
|
|
|
2022-10-20 08:50:21 -04:00
|
|
|
testfw.elf: $(TESTFW_OBJS) $(P)/fw/tk1/firmware.lds
|
2022-09-19 02:51:11 -04:00
|
|
|
$(CC) $(CFLAGS) $(TESTFW_OBJS) $(LDFLAGS) -o $@
|
|
|
|
|
|
|
|
# Generate a fake BRAM file that will be filled in later after place-n-route
|
|
|
|
bram_fw.hex:
|
|
|
|
$(ICESTORM_PATH)icebram -v -g 32 $(BRAM_FW_SIZE) > $@
|
|
|
|
|
2022-10-11 11:25:19 -04:00
|
|
|
firmware.hex: firmware.bin firmware_size_mismatch
|
2022-09-19 02:51:11 -04:00
|
|
|
python3 $(P)/tools/makehex/makehex.py $< $(BRAM_FW_SIZE) > $@
|
2022-10-11 11:25:19 -04:00
|
|
|
testfw.hex: testfw.bin testfw_size_mismatch
|
2022-09-19 02:51:11 -04:00
|
|
|
python3 $(P)/tools/makehex/makehex.py $< $(BRAM_FW_SIZE) > $@
|
|
|
|
|
2023-03-31 04:18:35 -04:00
|
|
|
.PHONY: check-binary-hashes
|
|
|
|
check-binary-hashes:
|
2024-03-21 07:11:33 -04:00
|
|
|
sha512sum firmware.bin
|
|
|
|
sha256sum application_fpga.bin
|
2023-03-31 04:18:35 -04:00
|
|
|
sha512sum -c firmware.bin.sha512
|
|
|
|
sha256sum -c application_fpga.bin.sha256
|
|
|
|
|
2022-09-19 02:51:11 -04:00
|
|
|
%.bin: %.elf
|
|
|
|
$(SIZE) $<
|
2023-03-07 08:17:23 -05:00
|
|
|
@test "$$($(SIZE) $< | awk 'NR==2{print $$2, $$3}')" = "0 0" \
|
|
|
|
|| { printf "Non-empty data or bss section!\n"; false; }
|
2022-09-19 02:51:11 -04:00
|
|
|
$(OBJCOPY) --input-target=elf32-littleriscv --output-target=binary $< $@
|
|
|
|
chmod -x $@
|
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
# Source linting.
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
LINT=verilator
|
2024-06-17 07:30:13 -04:00
|
|
|
# For Verilator 5.019 -Wno-GENUNNAMED needs to be added to LINT_FLAGS for the
|
|
|
|
# cell library.
|
|
|
|
LINT_FLAGS = +1364-2005ext+ --lint-only \
|
2024-06-17 07:53:16 -04:00
|
|
|
-Wall -Wno-DECLFILENAME -Wno-WIDTHEXPAND -Wno-UNOPTFLAT \
|
2022-09-19 02:51:11 -04:00
|
|
|
--timescale 1ns/1ns -DNO_ICE40_DEFAULT_ASSIGNMENTS
|
|
|
|
|
2022-10-03 06:55:24 -04:00
|
|
|
lint: $(FPGA_SRC) $(VERILOG_SRCS) $(ICE40_SIM_CELLS)
|
2022-09-19 02:51:11 -04:00
|
|
|
$(LINT) $(LINT_FLAGS) \
|
|
|
|
-DBRAM_FW_SIZE=$(BRAM_FW_SIZE) \
|
|
|
|
-DFIRMWARE_HEX=\"$(P)/firmware.hex\" \
|
|
|
|
-DUDS_HEX=\"$(P)/data/uds.hex\" \
|
|
|
|
-DUDI_HEX=\"$(P)/data/udi.hex\" \
|
2023-02-28 03:12:19 -05:00
|
|
|
--top-module application_fpga \
|
|
|
|
config.vlt $^ \
|
|
|
|
>lint_issues.txt 2>&1 \
|
|
|
|
&& { rm -f lint_issues.txt; exit 0; } \
|
2024-06-17 08:27:45 -04:00
|
|
|
|| { cat lint_issues.txt; exit 1; }
|
2022-09-19 02:51:11 -04:00
|
|
|
.PHONY: lint
|
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
# Build Verilator compiled simulation for the design.
|
|
|
|
#-------------------------------------------------------------------
|
2022-10-03 06:55:24 -04:00
|
|
|
verilator: $(VERILATOR_FPGA_SRC) $(VERILOG_SRCS) firmware.hex $(ICE40_SIM_CELLS) \
|
2022-09-19 02:51:11 -04:00
|
|
|
$(P)/tb/application_fpga_verilator.cc
|
|
|
|
verilator --timescale 1ns/1ns -DNO_ICE40_DEFAULT_ASSIGNMENTS \
|
|
|
|
-Wall -Wno-COMBDLY -Wno-lint \
|
|
|
|
-DBRAM_FW_SIZE=$(BRAM_FW_SIZE) \
|
|
|
|
-DFIRMWARE_HEX=\"$(P)/firmware.hex\" \
|
|
|
|
-DUDS_HEX=\"$(P)/data/uds.hex\" \
|
|
|
|
-DUDI_HEX=\"$(P)/data/udi.hex\" \
|
|
|
|
--cc --exe --Mdir verilated --top-module application_fpga \
|
|
|
|
$(filter %.v, $^) $(filter %.cc, $^)
|
|
|
|
make -C verilated -f Vapplication_fpga.mk
|
|
|
|
.PHONY: verilator
|
|
|
|
|
2024-03-20 07:15:38 -04:00
|
|
|
#-------------------------------------------------------------------
|
|
|
|
# Run all testbenches
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
tb:
|
|
|
|
make -C core/timer/toolruns sim-top
|
|
|
|
make -C core/tk1/toolruns sim-top
|
|
|
|
make -C core/touch_sense/toolruns sim-top
|
|
|
|
make -C core/trng/toolruns sim-top
|
|
|
|
make -C core/uart/toolruns sim-top
|
|
|
|
make -C core/uds/toolruns sim-top
|
|
|
|
|
|
|
|
.PHONY: tb
|
2022-09-19 02:51:11 -04:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
# Main FPGA build flow.
|
|
|
|
# Synthesis. Place & Route. Bitstream generation.
|
2023-05-16 10:14:21 -04:00
|
|
|
#
|
|
|
|
# To include the SPI-master, add the flag -DINCLUDE_SPI_MASTER to Yosys cmd.
|
|
|
|
# This can, for example, be done using
|
|
|
|
# 'make application_fpga.bin YOSYS_FLAG=-DINCLUDE_SPI_MASTER'.
|
|
|
|
# Important: do a make clean between builds with and wihtout the SPI master.
|
|
|
|
# Otherwise, there is a risk of unintended components persisting between
|
|
|
|
# builds.
|
2022-09-19 02:51:11 -04:00
|
|
|
#-------------------------------------------------------------------
|
2023-05-16 10:14:21 -04:00
|
|
|
|
|
|
|
YOSYS_FLAG ?=
|
|
|
|
|
|
|
|
synth.json: $(FPGA_SRC) $(VERILOG_SRCS) bram_fw.hex $(P)/data/uds.hex $(P)/data/udi.hex
|
|
|
|
$(YOSYS_PATH)yosys -v3 -l synth.log $(YOSYS_FLAG) -DBRAM_FW_SIZE=$(BRAM_FW_SIZE) \
|
2022-09-19 02:51:11 -04:00
|
|
|
-DFIRMWARE_HEX=\"$(P)/bram_fw.hex\" \
|
|
|
|
-p 'synth_ice40 -dsp -top application_fpga -json $@; write_verilog -attr2comment synth.v' \
|
2024-08-28 08:12:10 -04:00
|
|
|
$(filter %.v, $^) |& tee $(patsubst %.json,%,$@).txt
|
2022-09-19 02:51:11 -04:00
|
|
|
|
2023-11-28 04:20:30 -05:00
|
|
|
application_fpga_par.json: synth.json $(P)/data/$(PIN_FILE)
|
2024-06-24 05:40:51 -04:00
|
|
|
$(NEXTPNR_PATH)nextpnr-ice40 --freq $(TARGET_FREQ) --ignore-loops --up5k --package sg48 --json $< \
|
2024-08-28 08:12:10 -04:00
|
|
|
--pcf $(P)/data/$(PIN_FILE) --write $@ |& tee $(patsubst %.json,%,$@).txt
|
2023-11-28 04:20:30 -05:00
|
|
|
|
|
|
|
application_fpga.asc: application_fpga_par.json $(P)/data/uds.hex $(P)/data/udi.hex
|
2024-03-21 09:31:12 -04:00
|
|
|
UDS_HEX="$(P)/data/uds.hex" UDI_HEX="$(P)/data/udi.hex" OUT_ASC=$@ $(NEXTPNR_PATH)nextpnr-ice40 --up5k --package sg48 --ignore-loops --json $< --run tools/patch_uds_udi.py
|
2022-09-19 02:51:11 -04:00
|
|
|
|
|
|
|
application_fpga.bin: application_fpga.asc bram_fw.hex firmware.hex
|
|
|
|
$(ICESTORM_PATH)icebram -v bram_fw.hex firmware.hex < $< > $<.tmp
|
|
|
|
$(ICESTORM_PATH)icepack $<.tmp $@
|
|
|
|
@-$(RM) $<.tmp
|
|
|
|
|
|
|
|
application_fpga_testfw.bin: application_fpga.asc bram_fw.hex testfw.hex
|
|
|
|
$(ICESTORM_PATH)icebram -v bram_fw.hex testfw.hex < $< > $<.tmp
|
|
|
|
$(ICESTORM_PATH)icepack $<.tmp $@
|
|
|
|
@-$(RM) $<.tmp
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
# post-synthesis functional simulation.
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
synth_tb.vvp: $(P)/tb/tb_application_fpga.v synth.json
|
|
|
|
iverilog -o $@ -s tb_application_fpga synth.v $(P)/tb/tb_application_fpga.v \
|
|
|
|
-DNO_ICE40_DEFAULT_ASSIGNMENTS $(ICE40_SIM_CELLS)
|
|
|
|
chmod -x $@
|
|
|
|
|
|
|
|
synth_sim: synth_tb.vvp
|
|
|
|
vvp -N $<
|
|
|
|
.PHONY: synth_sim
|
|
|
|
|
|
|
|
synth_sim_vcd: synth_tb.vvp
|
|
|
|
vvp -N $< +vcd
|
|
|
|
.PHONY: synth_sim_vcd
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
# post-place and route functional simulation.
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
route.v: application_fpga.asc $(P)/data/$(PIN_FILE)
|
|
|
|
icebox_vlog -L -n application_fpga -sp $(P)/data/$(PIN_FILE) $< > $@
|
|
|
|
|
|
|
|
route_tb.vvp: route.v tb/tb_application_fpga.v
|
|
|
|
iverilog -o $@ -s tb_application_fpga $^ $(ICE40_SIM_CELLS)
|
|
|
|
chmod -x $@
|
|
|
|
|
|
|
|
route_sim: route_tb.vvp
|
|
|
|
vvp -N $<
|
|
|
|
.PHONY: route_sim
|
|
|
|
|
|
|
|
route_sim_vcd: route_tb.vvp
|
|
|
|
vvp -N $< +vcd
|
|
|
|
.PHONY: route_sim_vcd
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
# FPGA device programming.
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
|
2022-12-01 07:56:25 -05:00
|
|
|
prog_flash: check-hardware application_fpga.bin
|
|
|
|
sudo tillitis-iceprog application_fpga.bin
|
2022-09-19 02:51:11 -04:00
|
|
|
.PHONY: prog_flash
|
|
|
|
|
2022-12-01 07:56:25 -05:00
|
|
|
prog_flash_testfw: check-hardware application_fpga_testfw.bin
|
|
|
|
sudo tillitis-iceprog application_fpga_testfw.bin
|
2022-09-19 02:51:11 -04:00
|
|
|
.PHONY: prog_flash_testfw
|
|
|
|
|
2022-12-01 07:56:25 -05:00
|
|
|
check-hardware:
|
|
|
|
@sudo tillitis-iceprog -t >/dev/null 2>&1 || \
|
|
|
|
{ echo "Programmer not plugged in or not accessible"; false; }
|
|
|
|
@if sudo tillitis-iceprog -t 2>&1 | grep -qi "^flash.id:\( 0x\(00\|ff\)\)\{4\}"; then \
|
|
|
|
echo "No USB stick in the programmer?"; false; else true; fi
|
|
|
|
.PHONY: check-hardware
|
|
|
|
|
2022-09-19 02:51:11 -04:00
|
|
|
#-------------------------------------------------------------------
|
|
|
|
# Post build analysis.
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
timing: application_fpga.asc $(P)/data/$(PIN_FILE)
|
2022-10-12 04:25:37 -04:00
|
|
|
$(ICESTORM_PATH)icetime -c 18 -tmd up5k -P sg48 -p $(P)/data/$(PIN_FILE) -t $<
|
2022-09-19 02:51:11 -04:00
|
|
|
|
|
|
|
view: tb_application_fpga_vcd
|
|
|
|
gtkwave $< application_fpga.gtkw
|
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
# Cleanup.
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
clean: clean_fw
|
|
|
|
rm -f bram_fw.hex
|
2024-08-28 08:12:10 -04:00
|
|
|
rm -f synth.{log,v,json,txt} route.v application_fpga.{asc,bin,vcd} application_fpga_testfw.bin
|
2022-09-19 02:51:11 -04:00
|
|
|
rm -f tb_application_fpga.vvp synth_tb.vvp route_tb.vvp
|
2024-08-28 08:12:10 -04:00
|
|
|
rm -f application_fpga_par.{json,txt}
|
2022-09-19 02:51:11 -04:00
|
|
|
rm -f *.vcd
|
2022-10-06 07:23:30 -04:00
|
|
|
rm -f lint_issues.txt
|
2022-09-19 02:51:11 -04:00
|
|
|
rm -rf verilated
|
|
|
|
rm -f tools/tpt/*.hex
|
|
|
|
rm -rf tools/tpt/__pycache__
|
|
|
|
.PHONY: clean
|
|
|
|
|
|
|
|
clean_fw:
|
|
|
|
rm -f firmware.{elf,elf.map,bin,hex}
|
|
|
|
rm -f $(FIRMWARE_OBJS)
|
|
|
|
rm -f testfw.{elf,elf.map,bin,hex}
|
|
|
|
rm -f $(TESTFW_OBJS)
|
|
|
|
.PHONY: clean_fw
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
# Display info about targets.
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
help:
|
|
|
|
@echo ""
|
|
|
|
@echo "Build system for application_fpga FPGA design and firmware."
|
|
|
|
@echo ""
|
|
|
|
@echo "Supported targets:"
|
|
|
|
@echo "------------------"
|
|
|
|
@echo "all Build all targets."
|
2024-03-21 07:11:33 -04:00
|
|
|
@echo "check Run static analysis on firmware."
|
|
|
|
@echo "splint Run splint static analysis on firmware."
|
2022-09-19 02:51:11 -04:00
|
|
|
@echo "firmware.elf Build firmware ELF file."
|
|
|
|
@echo "firmware.hex Build firmware converted to hex, to be included in bitstream."
|
|
|
|
@echo "bram_fw.hex Build a fake BRAM file that will be filled in later after place-n-route."
|
|
|
|
@echo "verilator Build Verilator simulation program"
|
|
|
|
@echo "lint Run lint on Verilog source files."
|
2024-03-20 07:15:38 -04:00
|
|
|
@echo "tb Run all testbenches"
|
2022-09-19 02:51:11 -04:00
|
|
|
@echo "prog_flash Program device flash with FGPA bitstream including firmware (using the RPi Pico-based programmer)."
|
|
|
|
@echo "prog_flash_testfw Program device flash as above, but with testfw."
|
|
|
|
@echo "clean Delete all generated files."
|
|
|
|
@echo "clean_fw Delete only generated files for firmware. Useful for fw devs."
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# EOF Makefile
|
|
|
|
#=======================================================================
|