fpga: n3xx: rh: cpld: Refactor CPLD build process

Original-commit: 739b37ba40e7aba288ed781922aa8fa3b1bfc16e
This commit is contained in:
Humberto Jimenez
2022-01-25 18:28:57 -07:00
committed by Wade Fife
parent f645d3d613
commit 95c58d5ed6
6 changed files with 122 additions and 27 deletions
+7
View File
@@ -0,0 +1,7 @@
# Ignore Quartus generated files upon project opening.
*.qws
db/
incremental_db/
output_files/
*.sopcinfo
build/
+69 -18
View File
@@ -1,27 +1,78 @@
# #
# Copyright 2018 Ettus Research, a National Instruments Company # Copyright 2021 Ettus Research, a National Instruments Brand
#
# SPDX-License-Identifier: LGPL-3.0-or-later
# #
.PHONY: all clean # NOTE: All comments prefixed with a "##" will be displayed as a part of the "make help" target
##-------------------
##USRP N32x CPLD Help
##-------------------
##Usage:
## make <Targets> <Options>
##
##Output:
## build/usrp_n320_rh_cpld.pof: Bitstream to use with JTAG programmer
## build/usrp_n320_rh_cpld.svf: Bitstream to use with PS JTAG engine
# Definitions
10M04_ID = "10M04SAU169I7G"
TARGET = bin
TOP ?= rhodium_top
# quartus_build($1=Device, $2=Definitions)
quartus_build = make -f Makefile.cpld.inc $(TARGET) NAME=$@ ARCH="MAX10" PART_ID="$1" $2 TOP_MODULE=$(TOP) EXTRA_DEFS="$2"
# post_build($1=Artifact Name)
ifeq ($(TARGET),bin)
post_build = @\
mkdir -p build/; \
echo "Exporting bitstream files..."; \
cp build-$@/output_files/$(TOP).pof build/$(1).pof; \
cp build-$@/output_files/$(TOP).svf build/$(1).svf; \
echo -ne "\n\n---- Make: CPLD ready!\n"; \
echo -ne " Use build/$(1).pof via JTAG programmer or\n"; \
echo -ne " build/$(1).svf via PS JTAG-engine\n";
else
post_build = @echo "Skipping bitfile export."
endif
##
##Supported Targets
##-----------------
all: N320_CPLD_10M04 ##(Default target)
##N320_CPLD_10M04: N320/1 CPLD targeted to 10M04SAU169I7G.
N320_CPLD_10M04:
$(call quartus_build,$(10M04_ID),$(DEFS))
$(call post_build,"usrp_n320_rh_cpld")
clean: ##Clean up all target build outputs.
@echo -ne "\nCleaning targets and git repo...\n";
@rm -rf build-N320_CPLD*
@rm -rf build
@git clean -Xdf
cleanall: ##Clean up all target and ip build outputs.
@echo -ne "\nCleaning targets, IP, and git repo...\n";
@rm -rf build-N320_CPLD*
@rm -rf build
@rm -rf build-ip
@git clean -Xdf
help: ##Show this help message.
@grep -h "##" Makefile | grep -v "\"##\"" | sed -e 's/\\$$//' | sed -e 's/##//'
SRCS=rhodium_top.qpf rhodium_top.qsf rhodium_top.sdc rhodium_top.v rhodium_gain_ctrl.v rhodium_gain_table.v rhodium_lo_gain.v
SIM_SRCS=rh_tb.v rhodium_top.v rhodium_gain_ctrl.v rhodium_gain_table.v rhodium_lo_gain.v SIM_SRCS=rh_tb.v rhodium_top.v rhodium_gain_ctrl.v rhodium_gain_table.v rhodium_lo_gain.v
SHORT_HASH=$(addprefix GIT_HASH=,$(shell ../../../../../tools/scripts/git-hash.sh))
all: cpld-rhodium-revb.svf
output_files/rhodium_top.pof: $(SRCS)
quartus_map rhodium_top --verilog_macro="$(SHORT_HASH)"
quartus_fit rhodium_top
quartus_asm rhodium_top
quartus_sta rhodium_top
cpld-rhodium-revb.svf: output_files/rhodium_top.pof
quartus_cpf --convert --frequency 10.0MHz --voltage 2.5 --operation p $? $@
clean:
rm -rf db incremental_db output_files simulation cpld-rhodium-revb.svf
a.out: $(SIM_SRCS) a.out: $(SIM_SRCS)
iverilog -tvvp -D$(SHORT_HASH) -s rh_tb $(SIM_SRCS) iverilog -tvvp -D$(SHORT_HASH) -s rh_tb $(SIM_SRCS)
##
##Supported Options
##-----------------
##
@@ -0,0 +1,36 @@
#
# Copyright 2021 Ettus Research, a National Instruments Brand
#
# SPDX-License-Identifier: LGPL-3.0-or-later
#
##################################################
# Project Setup
##################################################
# TOP_MODULE = <Input arg>
# NAME = <Input arg>
# PART_ID = <Input arg>
# ARCH = <Input arg>
##################################################
# Include other makefiles
##################################################
PROJECT_DIR = $(abspath .)
BASE_DIR = $(abspath ../../../..)
include $(BASE_DIR)/../tools/make/quartus_design_builder.mak
# Define VERILOG_DEFS for macros definition
VERILOG_DEFS=$(EXTRA_DEFS) $(GIT_HASH_VERILOG_DEF)
bin: .prereqs
$(call BUILD_QUARTUS_DESIGN,$(TOP_MODULE),$(ARCH),$(PART_ID),$(PROJECT_DIR),$(BUILD_DIR),,0)
@\
pushd $(BUILD_DIR); \
echo "Converting bitfile to svf format..."; \
quartus_cpf --convert \
--frequency 10.0MHz \
--voltage 2.5 \
--operation p \
output_files/$(TOP_MODULE).pof output_files/$(TOP_MODULE).svf; \
popd;
@@ -286,14 +286,15 @@ set_global_assignment -name FLOW_ENABLE_POWER_ANALYZER ON
set_global_assignment -name POWER_DEFAULT_INPUT_IO_TOGGLE_RATE "12.5 %" set_global_assignment -name POWER_DEFAULT_INPUT_IO_TOGGLE_RATE "12.5 %"
set_global_assignment -name EDA_RUN_TOOL_AUTOMATICALLY OFF -section_id eda_simulation set_global_assignment -name EDA_RUN_TOOL_AUTOMATICALLY OFF -section_id eda_simulation
set_global_assignment -name OPTIMIZATION_MODE "HIGH PERFORMANCE EFFORT" set_global_assignment -name OPTIMIZATION_MODE "HIGH PERFORMANCE EFFORT"
set_global_assignment -name VERILOG_FILE rhodium_top.v set_global_assignment -name VERILOG_FILE ../rhodium_top.v
set_global_assignment -name VERILOG_FILE rhodium_gain_ctrl.v set_global_assignment -name VERILOG_FILE ../rhodium_gain_ctrl.v
set_global_assignment -name VERILOG_FILE rhodium_gain_table.v set_global_assignment -name VERILOG_FILE ../rhodium_gain_table.v
set_global_assignment -name VERILOG_FILE rhodium_lo_gain.v set_global_assignment -name VERILOG_FILE ../rhodium_lo_gain.v
set_global_assignment -name VERILOG_FILE rh_tb.v set_global_assignment -name VERILOG_FILE ../rh_tb.v
set_global_assignment -name EDA_TEST_BENCH_FILE rh_tb.v -section_id rh_tb set_global_assignment -name EDA_TEST_BENCH_FILE ../rh_tb.v -section_id rh_tb
set_global_assignment -name SDC_FILE ../rhodium_top.sdc
set_global_assignment -name NUM_PARALLEL_PROCESSORS 2
set_global_assignment -name ENABLE_OCT_DONE OFF set_global_assignment -name ENABLE_OCT_DONE OFF
set_global_assignment -name STRATIXV_CONFIGURATION_SCHEME "PASSIVE SERIAL" set_global_assignment -name STRATIXV_CONFIGURATION_SCHEME "PASSIVE SERIAL"
set_global_assignment -name USE_CONFIGURATION_DEVICE ON set_global_assignment -name USE_CONFIGURATION_DEVICE ON
+2 -2
View File
@@ -128,9 +128,9 @@ output Cal_iso_Sw_Ctrl
/* PS SPI */ /* PS SPI */
localparam GIT_HASH = 36'h`GIT_HASH; localparam GIT_HASH = `GIT_HASH;
localparam PROD_SIGNATURE = 16'h0045; // Product signature (Rhodium atomic number in BCD) localparam PROD_SIGNATURE = 16'h0045; // Product signature (Rhodium atomic number in BCD)
localparam REVISION_MINOR = 16'h0002; localparam REVISION_MINOR = 16'h0003;
localparam REVISION_MAJOR = 16'h0004; localparam REVISION_MAJOR = 16'h0004;
localparam CPLD_BUILD_LSB = GIT_HASH[15:0]; // Build code LSB localparam CPLD_BUILD_LSB = GIT_HASH[15:0]; // Build code LSB
localparam CPLD_BUILD_MSB = GIT_HASH[31:16]; // Build code MSB localparam CPLD_BUILD_MSB = GIT_HASH[31:16]; // Build code MSB