访问绑定文件中局部变量的分层路径?
Hierarchical paths to access local variables in bind files?
将断言、覆盖点等与设计分开是一种常见的方法,方法是将它们放在单独的模块或接口中,并使用 bind
将它们附加到设计中,例如,
module foo (input a);
wire b = a;
endmodule
interface foo_assertions (input a, b);
initial #1 assert (b == a);
endinterface
bind foo foo_assertions i_foo_assertions(.*);
一个问题是它需要维护 foo_assertions
中的端口列表。但是,如果 foo
有一个 bar
子模块,则可以使用断言文件中相对于 foo
的分层引用方便地访问 bar
内的信号,例如 assert (i_bar.sig == a)
.
有没有一种方法可以使用分层路径语法来访问直接在 foo
中声明的变量,从而消除对 foo_assertions
中端口列表的需要?注意 foo
不一定是顶层模块,所以 $root.b
不会起作用。看起来 foo.b
有效,但是当 foo
的多个实例存在于顶层时,这安全吗?
Verilog 始终具有向上的名称引用,这就是 foo.b
起作用的原因(请参阅 IEEE 1800-2017 SystemVerilog LRM 中的第 23.8 节)。有多少个 foo
实例并不重要,只要您只将 foo_assertions
绑定到名为 foo
的模块中即可。每个向上引用都适用于该引用位于下方的特定实例。
在层级路径中引用 top-level 模块时,您一直在使用向上引用而未必意识到。
将断言、覆盖点等与设计分开是一种常见的方法,方法是将它们放在单独的模块或接口中,并使用 bind
将它们附加到设计中,例如,
module foo (input a);
wire b = a;
endmodule
interface foo_assertions (input a, b);
initial #1 assert (b == a);
endinterface
bind foo foo_assertions i_foo_assertions(.*);
一个问题是它需要维护 foo_assertions
中的端口列表。但是,如果 foo
有一个 bar
子模块,则可以使用断言文件中相对于 foo
的分层引用方便地访问 bar
内的信号,例如 assert (i_bar.sig == a)
.
有没有一种方法可以使用分层路径语法来访问直接在 foo
中声明的变量,从而消除对 foo_assertions
中端口列表的需要?注意 foo
不一定是顶层模块,所以 $root.b
不会起作用。看起来 foo.b
有效,但是当 foo
的多个实例存在于顶层时,这安全吗?
Verilog 始终具有向上的名称引用,这就是 foo.b
起作用的原因(请参阅 IEEE 1800-2017 SystemVerilog LRM 中的第 23.8 节)。有多少个 foo
实例并不重要,只要您只将 foo_assertions
绑定到名为 foo
的模块中即可。每个向上引用都适用于该引用位于下方的特定实例。
在层级路径中引用 top-level 模块时,您一直在使用向上引用而未必意识到。