如何使用 tcl 获取名为 bigfifo.sv 的文件的完整路径来查询项目文件?

问题描述 投票:0回答:1

在 vivado 中如何获取名为 bigfifo.sv 的文件的完整路径?

当我在 TCL 提示符下运行 get_files 时,它只会打印项目中所有文件的完整路径的长列表。

fpga vivado
1个回答
0
投票

答案就在这里,在 get_files 的缺失和“逆向工程”命令参考中:

Vivado get_<object> -filter

过滤标志

-filter 选项在许多 Vivado

get_*
命令上可用,可根据对象的属性过滤返回的结果。

使用方法

基本语法是:

get_<objects> [-filter <expression>]

其中

<expression>
是应用于返回对象的过滤表达式。

过滤表达式

过滤表达式可用于匹配和比较对象的属性:

  • 逻辑/数字/布尔运算符:

    # Logical:  !    ==    !=     &&   ||
    # Numeric:  ==   <    <=    >     >=
    # Boolean:   true   false
    
    get_cells -filter {REF_NAME == FD}
    
    get_nets -filter {FANOUT > 100 && IS_GLOBAL == false} 
    
  • 字符串匹配

    
    # exact string match
    get_files -filter {NAME =~ C:/myproj/abc.vhd}
    
    #wildcard match
    get_files -filter {NAME =~ */files.*}
    
    #regexp match
    get_files -filter -regexp {NAME =~ .*/abc/.*/}
    
    #case insenstive match
    get_files -filter -nocase {NAME =~ files/MyFileCrazyCase.VhDl} 
    
    
  • 不是字符串

    # Files that do not contain abc
    get_file -filter {NAME !~ *abc*}
    

查找对象属性

# Example procedure to find an objects properties

tcl> set alist [get_files]
 
tcl> report_property [lindex $alist 0]

Property            Type     Read-only  Value
CLASS               string   true       file
CORE_CONTAINER      string   true      
FILE_TYPE           enum     false      VHDL 2008
IS_AVAILABLE        bool     true       1
IS_ENABLED          bool     false      1
IS_GENERATED        bool     true       0
IS_GLOBAL_INCLUDE   bool     false      0
IS_NGC_WRAPPER      bool     true       0
LIBRARY             string   false      work
NAME                string   true       C:/myproj/myfile.vhd
NEEDS_REFRESH       bool     true       0
PATH_MODE           enum     false      RelativeFirst
USED_IN             string*  false      synthesis simulation
USED_IN_SIMULATION  bool     false      1
USED_IN_SYNTHESIS   bool     false      1

例如:


特殊情况

  • NAME
    属性始终与完整的层次结构名称匹配。

  • IS_PRIMITIVE
    这样的布尔属性可以直接使用,无需显式比较:

    get_cells -filter IS_PRIMITIVE
    
  • 使用括号对表达式进行分组:

    get_cells -filter {(REF_NAME =~ *FD*) && !(IS_PRIMITIVE)}
    

与-regexp结合

可以添加

-regexp
选项来启用过滤表达式中的正则表达式匹配:

get_cells -filter -regexp {REF_NAME =~ .*FD.*}

与-nocase结合

可以添加

-nocase
选项来执行不区分大小写的匹配:

get_cells -filter -regexp -nocase {NAME =~ .*validfor.*} 

分层过滤

默认情况下

-filter
过滤当前层次结构级别的对象。

添加

-hierarchical
以跨所有级别分层过滤对象:

get_cells -hierarchical -filter {IS_PRIMITIVE}

过滤集合

filter
命令可以过滤任何Tcl集合,包括之前从
get_*
返回的结果:

set allCells [get_cells]
set primCells [filter $allCells IS_PRIMITIVE]

总而言之,

-filter
是一种根据对象属性从 Vivado 数据库过滤结果的强大方法。过滤表达式语法提供了许多灵活的方法来选择对象。

get_files

描述

检索当前项目中与指定搜索模式匹配的文件列表。默认行为是检索项目中的所有文件。使用命令参数根据需要过滤和自定义输出。

语法

get_files 
[-regexp] 
[-nocase] 
[-filter <arg>] 
[-compile_order <arg>] 
[-used_in <arg>] 
[-references] 
[-all] 
[-of_objects <args>] 
[-quiet] 
[-verbose] 
[<patterns>]

退货

文件对象列表。

论据

当然!下面是一个综合表,其中包含 Vivado 中

get_files
命令的所有参数及其描述:

论证 描述
[-regexp]
将模式解释为完整的正则表达式。
[-nocase]
执行不区分大小写的匹配。 )仅对 -regexp 有效)
[-filter <arg>]
使用表达式过滤列表。
[-compile_order <arg>]
按类型和编译顺序获取文件。 (必须与-used_in一起使用)
[-used_in <arg>]
获取特定步骤中使用的文件。 (必须与-compile_order一起使用)
[-references]
获取提供的对象中引用的文件。 (必须与 -of_objects 一起使用。)
[-all]
包括所有内部文件。
[-of_objects <args>]
获取特定类型的“文件”对象。仅对文件类型有效:file、fileset、ip、reconfig_module
[-quiet]
抑制命令错误。
[-verbose]
命令执行期间暂停消息限制。
[<patterns>]
将文件名与模式进行匹配。 (默认:*。)

-

示例

  1. 获取仿真中使用的VHDL文件:

    get_files -filter {FILE_TYPE == VHDL && USED_IN =~ simulation*}
    
  2. 获取仿真中使用的源文件:

    get_files -compile_order sources -used_in simulation
    
  3. 获取与综合中使用的特定IP核关联的文件:

    get_files -compile_order sources -used_in synthesis -of [get_files ip.xci]
    
  4. 从特定文件集中获取文件:

    get_files -of [get_filesets {sources_1 constrs_1}]
    
  5. 在不知道项目中的完整路径的情况下查找特定文件:

    set file_obj [get_files -filter {NAME =~ */mycool.bd}
    
  6. 列出所有 vhdl 文件

set files_vhdl [get_files -filter {NAME =~ */*.vhd}]
foreach f $files_vhdl {puts $f}

文件对象道具

CLASS               string   true       file
CORE_CONTAINER      string   true      
FILE_TYPE           enum     false      VHDL 2008
IS_AVAILABLE        bool     true       1
IS_ENABLED          bool     false      1
IS_GENERATED        bool     true       0
IS_GLOBAL_INCLUDE   bool     false      0
IS_NGC_WRAPPER      bool     true       0
LIBRARY             string   false      work
NAME                string   true       C:/myproj/myfile.vhd
NEEDS_REFRESH       bool     true       0
PATH_MODE           enum     false      RelativeFirst
USED_IN             string*  false      synthesis simulation
USED_IN_SIMULATION  bool     false      1
USED_IN_SYNTHESIS   bool     false      1

类别

  • 物体
  • 项目

另请参阅

  • report_compile_order
  • report_property

© www.soinside.com 2019 - 2024. All rights reserved.