Skip to content

Commit 89a9ff2

Browse files
committed
fpga_diff: add cmn top interface
1 parent 595ebc1 commit 89a9ff2

File tree

5 files changed

+1067
-43
lines changed

5 files changed

+1067
-43
lines changed

fpga_diff/Makefile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ PRJ ?=
22
ENV_SCRIPTS_HOME ?= $(CURDIR)
33

44
CORE_DIR ?= ""
5+
CHI_DIR ?= ""
56
FPGA_BIT_HOME ?=
67
WORKLOAD ?=
78
# Supported CPU parameters:
@@ -18,44 +19,62 @@ VIVADO_VERSION := $(shell vivado -version 2>/dev/null | head -1 | grep -o '[0-9]
1819
check_vivado_version:
1920
@vivado -version 2>/dev/null | head -1 | grep -o '[0-9]\{4\}\.[0-9]' || echo "unknown"
2021

22+
# Run synthesis using Vivado
2123
synth:
2224
vivado -mode batch -source ./tools/gen_synth.tcl -tclargs $(PRJ)
2325

26+
# Generate FPGA bitstream
2427
bitstream:
2528
vivado -mode batch -source ./tools/gen_bitstream.tcl -tclargs $(PRJ)
2629

30+
# Update file list for core RTL files
2731
update_core_flist:
2832
rm -rf $(CORE_DIR)/rtl/verification
2933
find "$(CORE_DIR)" -type f \( -name "*.v" -o -name "*.sv" -o -name "*.svh" \) -printf '%p\n' | \
3034
awk -f ./core_flist.awk > ./src/tcl/cpu_files.tcl
3135

36+
# Update file list for CHI interface files
37+
update_chi_flist:
38+
find "$(CHI_DIR)" -type f \( -name "*.v" -o -name "*.sv" -o -name "*.svh" \) -printf '%p\n' | \
39+
awk -f ./chi_flist.awk > ./src/tcl/chi_files.tcl;
40+
41+
# Launch Vivado with FPGA project configuration
3242
vivado: check_vivado_version
3343
vivado -mode batch -source src/tcl/common/xs_uart.tcl -tclargs --cpu $(CPU) --project_name fpga_$(CPU) --vivado_version $(VIVADO_VERSION)
3444

45+
# Check Vivado version compatibility
3546
check_version:
3647
vivado -mode batch -source src/tcl/common/check_version.tcl -tclargs --vivado_version $(VIVADO_VERSION) --cpu $(CPU) --project_name fpga_$(CPU)
3748

49+
# Write bitstream to FPGA via PCIe
3850
write_bitstream:
3951
sh tools/pcie-remove.sh
4052
vivado -mode tcl -source tools/write_bitstream.tcl -tclargs $(FPGA_BIT_HOME)
4153
sh tools/pcie-rescan.sh
4254

55+
# Write workload to FPGA DDR via JTAG
4356
write_jtag_ddr:
4457
vivado -mode tcl -source tools/reset_ddr.tcl -tclargs $(FPGA_BIT_HOME)/fpga_top_debug.ltx
4558
vivado -mode tcl -source tools/jtag_write_ddr.tcl -tclargs $(WORKLOAD)
4659

60+
# Reset CPU on FPGA
4761
reset_cpu:
4862
vivado -mode tcl -source tools/reset_cpu.tcl -tclargs $(FPGA_BIT_HOME)/fpga_top_debug.ltx
4963

64+
# Add system options for memory optimization
5065
add_sys_option:
5166
sed -i "s/reg \(\[[0-9]*:[0-9]*\]\) ram \[\([4-9][0-9]\{3,\}\|[1-9][0-9]\{4,\}\):0\];/(\* ram_style = \"ultra\" \*)\treg \1 ram \[\2:0\];/g" $(CORE_DIR)/rtl/array_*.v
5267

68+
# Display implementation log
5369
get_impl_log:
5470
cat fpga_$(CPU)/fpga_$(CPU).runs/impl_1/runme.log
5571

72+
# Display synthesis log
5673
get_synth_log:
5774
cat fpga_$(CPU)/fpga_$(CPU).runs/synth_1/runme.log
5875

76+
# Build complete FPGA project
5977
all:
78+
$(MAKE) update_chi_flist CHI_DIR="$(CHI_DIR)"
6079
$(MAKE) update_core_flist CORE_DIR=$(CORE_DIR)
61-
$(MAKE) vivado CPU=$(CPU)
80+
$(MAKE) vivado CPU=$(CPU)

fpga_diff/chi_flist.awk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
BEGIN{printf "set chi_files [list \\\n"}
2+
{
3+
printf " [file normalize \""
4+
printf $0
5+
printf "\" ]\\\n"
6+
}
7+
END{printf "]\n"}

0 commit comments

Comments
 (0)