mirror of
https://github.com/vortexgpgpu/vortex.git
synced 2025-04-22 21:09:15 -04:00
pre-apply Verilator preprocessor on synthesis builds
This commit is contained in:
parent
5c018dcfe9
commit
a8214204fe
5 changed files with 39 additions and 46 deletions
|
@ -1,12 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
macros=()
|
||||
defines=()
|
||||
includes=()
|
||||
excludes=()
|
||||
|
||||
output_file=""
|
||||
global_file=""
|
||||
dest_folder=""
|
||||
prepropressor=0
|
||||
|
||||
defines_str=""
|
||||
includes_str=""
|
||||
|
||||
function absolute_path() {
|
||||
if [ -d "$1" ]; then
|
||||
|
@ -32,16 +36,21 @@ function check_not_excluded() {
|
|||
}
|
||||
|
||||
# parse command arguments
|
||||
while getopts D:I:E:O:G:F:h flag
|
||||
while getopts D:I:E:O:G:F:Ph flag
|
||||
do
|
||||
case "${flag}" in
|
||||
D) macros+=( ${OPTARG} );;
|
||||
I) includes+=( ${OPTARG} );;
|
||||
D) defines+=( ${OPTARG} )
|
||||
defines_str+="-D${OPTARG} "
|
||||
;;
|
||||
I) includes+=( ${OPTARG} )
|
||||
includes_str+="-I${OPTARG} "
|
||||
;;
|
||||
E) excludes+=( ${OPTARG} );;
|
||||
O) output_file=( ${OPTARG} );;
|
||||
G) global_file=( ${OPTARG} );;
|
||||
F) dest_folder=( ${OPTARG} );;
|
||||
h) echo "Usage: [-D macro] [-I include] [-E exclude] [-O output_file] [-F destination_folder] [-G global_header] [-h help]"
|
||||
P) prepropressor=1;;
|
||||
h) echo "Usage: [-D<macro>] [-I<include>] [-E<exclude>] [-O<output_file>] [-F<destination_folder>] [-G<global_header>] [-P<prepropressor>] [-h help]"
|
||||
exit 0
|
||||
;;
|
||||
\?)
|
||||
|
@ -51,11 +60,10 @@ do
|
|||
esac
|
||||
done
|
||||
|
||||
if [ "$global_file" != "" ];
|
||||
then
|
||||
if [ "$global_file" != "" ]; then
|
||||
{
|
||||
# dump macros into global header
|
||||
for value in ${macros[@]}; do
|
||||
# dump defines into a global header
|
||||
for value in ${defines[@]}; do
|
||||
arrNV=(${value//=/ })
|
||||
if (( ${#arrNV[@]} > 1 ));
|
||||
then
|
||||
|
@ -67,31 +75,32 @@ then
|
|||
} > $global_file
|
||||
fi
|
||||
|
||||
if [ "$dest_folder" != "" ];
|
||||
then
|
||||
if [ "$dest_folder" != "" ]; then
|
||||
# copy source files
|
||||
mkdir -p $dest_folder
|
||||
for dir in ${includes[@]}; do
|
||||
for file in $(find $dir -maxdepth 1 -name '*.v' -o -name '*.sv' -o -name '*.vh' -o -name '*.svh' -o -name '*.hex' -type f); do
|
||||
if check_not_excluded $file; then
|
||||
cp $(absolute_path $file) $dest_folder
|
||||
if [ $prepropressor != 0 ]; then
|
||||
verilator $defines_str $includes_str --E $(absolute_path $file) | sed '/^`line /d' > $dest_folder/$(basename -- $file)
|
||||
else
|
||||
cp $(absolute_path $file) $dest_folder
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$output_file" != "" ];
|
||||
then
|
||||
if [ "$output_file" != "" ]; then
|
||||
{
|
||||
if [ "$global_file" == "" ];
|
||||
then
|
||||
if [ "$global_file" == "" ]; then
|
||||
# dump defines
|
||||
for value in ${macros[@]}; do
|
||||
for value in ${defines[@]}; do
|
||||
echo "+define+$value"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$dest_folder" == "" ];
|
||||
then
|
||||
if [ "$dest_folder" == "" ]; then
|
||||
# dump include directories
|
||||
for dir in ${includes[@]}; do
|
||||
echo "+incdir+$dir"
|
||||
|
|
|
@ -94,7 +94,7 @@ vortex_afu.h: vortex_afu.json
|
|||
|
||||
setup:
|
||||
mkdir -p $(BUILD_DIR)/src
|
||||
$(SCRIPT_DIR)/gen_sources.sh $(CFLAGS) $(CONFIGS_SEL) -G$(BUILD_DIR)/src/globals.vh -F$(BUILD_DIR)/src -Osources.txt
|
||||
$(SCRIPT_DIR)/gen_sources.sh $(CFLAGS) $(CONFIGS_SEL) -DNOGLOBALS -F$(BUILD_DIR)/src -P -Osources.txt
|
||||
ifeq ($(TARGET), ase)
|
||||
afu_sim_setup -f -s setup.cfg $(BUILD_DIR)
|
||||
else
|
||||
|
|
|
@ -13,17 +13,18 @@ vivado -mode batch -source scripts/gen_ip.tcl -tclargs ip/xilinx_u50_gen3x16_xdm
|
|||
PREFIX=build make all TARGET=hw_emu PLATFORM=xilinx_u50_gen3x16_xdma_5_202210_1 > build_u50_hw_emu.log 2>&1 &
|
||||
PREFIX=build make all TARGET=hw PLATFORM=xilinx_u50_gen3x16_xdma_5_202210_1 > build_u50_hw.log 2>&1 &
|
||||
|
||||
PREFIX=build_gfx_2c CONFIGS="-DEXT_GFX_ENABLE -DNUM_CORES=2" make all TARGET=hw_emu PLATFORM=xilinx_u50_gen3x16_xdma_5_202210_1 > build_u50_hw_emu_gfx_2c.log 2>&1 &
|
||||
PREFIX=build_gfx_2c CONFIGS="-DEXT_GFX_ENABLE -DNUM_CORES=2" make all TARGET=hw PLATFORM=xilinx_u50_gen3x16_xdma_5_202210_1 > build_u50_hw_gfx_2c.log 2>&1 &
|
||||
PREFIX=build_gfx_2c CONFIGS="-DEXT_GFX_ENABLE" NUM_CORES=2 make all TARGET=hw_emu PLATFORM=xilinx_u50_gen3x16_xdma_5_202210_1 > build_u50_hw_emu_gfx_2c.log 2>&1 &
|
||||
PREFIX=build_base_2c NUM_CORES=2 make all TARGET=hw PLATFORM=xilinx_u50_gen3x16_xdma_5_202210_1 > build_u50_hw_base_2c.log 2>&1 &
|
||||
PREFIX=build_gfx_2c CONFIGS="-DEXT_GFX_ENABLE" NUM_CORES=2 make all TARGET=hw PLATFORM=xilinx_u50_gen3x16_xdma_5_202210_1 > build_u50_hw_gfx_2c.log 2>&1 &
|
||||
|
||||
PREFIX=build make all TARGET=hw_emu PLATFORM=xilinx_u280_gen3x16_xdma_1_202211_1 > build_u280_hw_emu.log 2>&1 &
|
||||
PREFIX=build make all TARGET=hw PLATFORM=xilinx_u280_gen3x16_xdma_1_202211_1 > build_u280_hw.log 2>&1 &
|
||||
PREFIX=build_base_8c NUM_CORES=8 make all TARGET=hw PLATFORM=xilinx_u280_gen3x16_xdma_1_202211_1 > build_u280_hw_base_8c.log 2>&1 &
|
||||
|
||||
PREFIX=build make all TARGET=hw_emu PLATFORM=xilinx_vck5000_gen3x16_xdma_1_202120_1 > build_vck5k_hw_emu.log 2>&1 &
|
||||
PREFIX=build make all TARGET=hw PLATFORM=xilinx_vck5000_gen3x16_xdma_1_202120_1 > build_vck5k_hw.log 2>&1 &
|
||||
|
||||
CONFIGS="-DEXT_GFX_ENABLE -DNUM_CORES=2" PREFIX=build_gfx make all TARGET=hw_emu PLATFORM=xilinx_u50_gen3x16_xdma_5_202210_1 > build_u50_hw_emu_gfx.log 2>&1 &
|
||||
CONFIGS="-DEXT_GFX_ENABLE -DNUM_CORES=2" PREFIX=build_gfx make all TARGET=hw PLATFORM=xilinx_u50_gen3x16_xdma_5_202210_1 > build_u50_hw_gfx.log 2>&1 &
|
||||
CONFIGS="-DEXT_GFX_ENABLE" NUM_CORES=4 PREFIX=build_gfx make all TARGET=hw_emu PLATFORM=xilinx_u50_gen3x16_xdma_5_202210_1 > build_u50_hw_emu_4c_gfx.log 2>&1 &
|
||||
CONFIGS="-DEXT_GFX_ENABLE" NUM_CORES=4 PREFIX=build_gfx make all TARGET=hw PLATFORM=xilinx_u50_gen3x16_xdma_5_202210_1 > build_u50_hw_4c_gfx.log 2>&1 &
|
||||
|
||||
# debug hw_emu using xsim
|
||||
xsim --gui xilinx_u50_gen3x16_xdma_5_202210_1-0-vortex_afu.wdb &
|
||||
|
|
|
@ -139,11 +139,7 @@ all: check-devices emconfig $(XCLBIN_CONTAINER)
|
|||
|
||||
gen-sources: $(BUILD_DIR)/sources.txt
|
||||
$(BUILD_DIR)/sources.txt:
|
||||
mkdir -p $(BUILD_DIR); cd $(BUILD_DIR); $(SCRIPT_DIR)/gen_sources.sh $(RTL_INCLUDE) $(CONFIGS_SEL) -EVX_fpu_fpnew.sv -Evortex_afu.v -EVX_afu_wrap.sv -Osources.txt
|
||||
cd $(BUILD_DIR); verilator -E -DNOGLOBALS $(RTL_INCLUDE) $(CONFIGS_SEL) $(AFU_DIR)/VX_afu_wrap.sv | sed '/^`line /d' > VX_afu_wrap.sv
|
||||
cd $(BUILD_DIR); verilator -E -DNOGLOBALS $(RTL_INCLUDE) $(CONFIGS_SEL) $(AFU_DIR)/vortex_afu.v | sed '/^`line /d' > vortex_afu.v
|
||||
echo "$(PWD)/$(BUILD_DIR)/VX_afu_wrap.sv" >> $(BUILD_DIR)/sources.txt
|
||||
echo "$(PWD)/$(BUILD_DIR)/vortex_afu.v" >> $(BUILD_DIR)/sources.txt
|
||||
mkdir -p $(BUILD_DIR); cd $(BUILD_DIR); $(SCRIPT_DIR)/gen_sources.sh $(RTL_INCLUDE) $(CONFIGS_SEL) -DNOGLOBALS -EVX_fpu_fpnew.sv -Fsrc -P -Osources.txt
|
||||
|
||||
$(XO_CONTAINER): $(BUILD_DIR)/sources.txt ./kernel.xml
|
||||
mkdir -p $(BUILD_DIR); cd $(BUILD_DIR); $(VIVADO) -mode batch -source ../scripts/gen_xo.tcl -tclargs ../$(XO_CONTAINER) vortex_afu sources.txt ../kernel.xml ../$(BUILD_DIR)
|
||||
|
|
|
@ -23,27 +23,15 @@ set vdefines_list [lindex $vlist 2]
|
|||
#puts ${vincludes_list}
|
||||
#puts ${vdefines_list}
|
||||
|
||||
# dump defines into globals.vh
|
||||
# find if chipscope is enabled
|
||||
set chipscope 0
|
||||
set fh [open "${build_dir}/globals.vh" w]
|
||||
foreach def $vdefines_list {
|
||||
set fields [split $def "="]
|
||||
set len [llength $fields]
|
||||
set name [lindex $fields 0]
|
||||
puts -nonewline $fh "`define "
|
||||
if {$len > 1} {
|
||||
set value [lindex $fields 1]
|
||||
puts -nonewline $fh $name
|
||||
puts -nonewline $fh " "
|
||||
puts $fh $value
|
||||
} else {
|
||||
puts $fh $name
|
||||
if { $name == "CHIPSCOPE" } {
|
||||
set chipscope 1
|
||||
}
|
||||
if { $name == "CHIPSCOPE" } {
|
||||
set chipscope 1
|
||||
}
|
||||
}
|
||||
close $fh
|
||||
|
||||
create_project -force kernel_pack $path_to_tmp_project
|
||||
|
||||
|
@ -51,7 +39,6 @@ add_files -norecurse ${vsources_list}
|
|||
|
||||
set obj [get_filesets sources_1]
|
||||
set files [list \
|
||||
[file normalize "${build_dir}/globals.vh"] \
|
||||
[file normalize "${build_dir}/ip/xil_fdiv/xil_fdiv.xci"] \
|
||||
[file normalize "${build_dir}/ip/xil_fma/xil_fma.xci"] \
|
||||
[file normalize "${build_dir}/ip/xil_fsqrt/xil_fsqrt.xci"] \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue