fpga: xilinx: add tcl scripts

Signed-off-by: liangkangnan <liangkangnan@163.com>
verilator
liangkangnan 2022-05-07 17:55:56 +08:00
parent 5b7b657384
commit 3666009efc
8 changed files with 167 additions and 0 deletions

22
fpga/xilinx/Makefile Normal file
View File

@ -0,0 +1,22 @@
VIVADO_BASE := /home/ubuntu/Xilinx/Vivado/2018.1/bin
VIVADO := $(VIVADO_BASE)/vivado
VIVADOFLAGS := \
-nojournal -mode batch \
-source scripts/init.tcl
.PHONY: synth
synth:
$(VIVADO) $(VIVADOFLAGS) -source scripts/synth.tcl
.PHONY: impl
impl:
$(VIVADO) $(VIVADOFLAGS) -source scripts/synth.tcl -source scripts/impl.tcl
.PHONY: bit
bit:
$(VIVADO) $(VIVADOFLAGS) -source scripts/synth.tcl -source scripts/impl.tcl -source scripts/bit_stream.tcl -source scripts/report.tcl
.PHONY: clean
clean::
rm -rf .Xil .ip_user_files *.log *.jou out usage_statistics_webtalk.xml usage_statistics_webtalk.html

View File

@ -0,0 +1,2 @@
write_bitstream -force [file join $outdir "${top_module}.bit"]

View File

@ -0,0 +1,8 @@
opt_design
place_design
phys_opt_design
power_opt_design
route_design

View File

@ -0,0 +1,61 @@
set prj_name {tinyriscv}
set part_fpga {xc7a35tftg256-1}
set top_module {tinyriscv_soc_top}
set scriptsdir ./scripts
set constrsdir ./constrs
set outdir ./out
set ipdir [file join $outdir ip]
set srcdir ../../rtl
#
proc rec_glob { basedir pattern } {
set dirlist [glob -nocomplain -directory $basedir -type d *]
set findlist [glob -nocomplain -directory $basedir $pattern]
foreach dir $dirlist {
set reclist [rec_glob $dir $pattern]
set findlist [concat $findlist $reclist]
}
return $findlist
}
# ()
create_project -part $part_fpga -in_memory
# sources_1
if {[get_filesets -quiet sources_1] eq ""} {
create_fileset -srcset sources_1
}
set src_pkg_files [rec_glob $srcdir "*pkg.sv"]
set src_verilog_files [rec_glob $srcdir "*.sv"]
set src_all_files [concat $src_pkg_files $src_verilog_files]
# verilog
add_files -norecurse -fileset sources_1 $src_all_files
# constrs_1
if {[get_filesets -quiet constrs_1] eq ""} {
create_fileset -constrset constrs_1
}
#
add_files -norecurse -fileset constrs_1 [glob -directory $constrsdir {*.xdc}]
# IP
file mkdir $ipdir
update_ip_catalog -rebuild
source [file join $scriptsdir ip.tcl]
set_property GENERATE_SYNTH_CHECKPOINT {false} [get_files -all {*.xci}]
set obj [get_ips]
generate_target all $obj
export_ip_user_files -of_objects $obj -no_script -force
read_ip [glob -directory $ipdir [file join * {*.xci}]]
#
synth_design -top $top_module -include_dirs $ipdir
#set src_pkg_files [rec_glob $srcdir "*pkg.sv"]
#set src_verilog_files [rec_glob $srcdir "*.sv"]
#set src_all_files [concat $src_pkg_files $src_verilog_files]
#read_verilog -sv $src_all_files
#read_xdc ./constrs/tinyriscv.xdc

View File

@ -0,0 +1,9 @@
create_ip -name clk_wiz -vendor xilinx.com -library ip -module_name mmcm_main_clk -dir $ipdir -force
set_property -dict [list \
CONFIG.PRIM_IN_FREQ {50.000} \
CONFIG.CLKOUT1_REQUESTED_OUT_FREQ {25.000} \
CONFIG.RESET_TYPE {ACTIVE_LOW} \
CONFIG.RESET_PORT {resetn}] \
[get_ips mmcm_main_clk]

View File

View File

@ -0,0 +1,13 @@
set rptdir [file join $outdir report]
file mkdir $rptdir
set rptutil [file join $rptdir utilization.txt]
report_datasheet -file [file join $rptdir datasheet.txt]
report_utilization -hierarchical -file $rptutil
report_clock_utilization -file $rptutil -append
report_ram_utilization -file $rptutil -append -detail
report_timing_summary -file [file join $rptdir timing.txt] -max_paths 10
report_high_fanout_nets -file [file join $rptdir fanout.txt] -timing -load_types -max_nets 25
report_drc -file [file join $rptdir drc.txt]
report_io -file [file join $rptdir io.txt]
report_clocks -file [file join $rptdir clocks.txt]

View File

@ -0,0 +1,52 @@
proc recglob { basedir pattern } {
set dirlist [glob -nocomplain -directory $basedir -type d *]
set findlist [glob -nocomplain -directory $basedir $pattern]
foreach dir $dirlist {
set reclist [recglob $dir $pattern]
set findlist [concat $findlist $reclist]
}
return $findlist
}
proc findincludedir { basedir pattern } {
#find all subdirectories containing ".vh" files
set vhfiles [recglob $basedir $pattern]
set vhdirs {}
foreach match $vhfiles {
lappend vhdirs [file dir $match]
}
set uniquevhdirs [lsort -unique $vhdirs]
return $uniquevhdirs
}
file mkdir $ipdir
source [file join $scriptsdir ip.tcl]
update_ip_catalog -rebuild
set obj [get_ips]
generate_target all $obj
read_ip [glob -directory $ipdir [file join * {*.xci}]]
# AR 58526 <http://www.xilinx.com/support/answers/58526.html>
set_property GENERATE_SYNTH_CHECKPOINT {false} [get_files -all {*.xci}]
set obj [get_ips]
generate_target all $obj
export_ip_user_files -of_objects $obj -no_script -force
set obj [current_fileset]
# Xilinx bug workaround
# scrape IP tree for directories containing .vh files
# [get_property include_dirs] misses all IP core subdirectory includes if user has specified -dir flag in create_ip
set property_include_dirs [get_property include_dirs $obj]
set ip_include_dirs [concat $property_include_dirs [findincludedir $ipdir "*.vh"]]
set ip_include_dirs [concat $ip_include_dirs [findincludedir $srcdir "*.h"]]
set ip_include_dirs [concat $ip_include_dirs [findincludedir $srcdir "*.vh"]]
synth_design -top $top_module -include_dirs $ipdir