首页 > 解决方案 > %m 如何在 $display 系统任务中工作?

问题描述

我想了解Verilog%m在系统任务中的用法。$display

这是书中给出的示例代码。如果有人用更多的例子来解释这一点会更好,因为书中似乎不清楚。

//the highest-level module called top. No argument is required. This
//is a useful feature)
$display("This string is displayed from %m level of hierarchy");
-- This string is displayed from top.p1 level of hierarchy

标签: verilog

解决方案


免费的 IEEE Std 1800-2012,第 21.2.1.6 节分层名称格式指出:

%m 格式说明符不接受参数。相反,它使显示任务打印调用包含格式说明符的系统任务的设计元素、子例程、命名块或标记语句的分层名称。当有许多调用系统任务的模块实例时,这很有用。

这是一个例子:

module top;
   buff b0 (.buf_in(1'b0), .buf_out());
endmodule

module buff (
   input  buf_in,
   output buf_out
);
   wire  a;
   inv i0 (.in(buf_in), .out(a      ));
   inv i1 (.in(a     ), .out(buf_out));
   initial $display("Inside hierarchy %m");
endmodule

module inv (
   input  in,
   output out
);
   assign out = ~in;
   initial $display("Inside hierarchy %m");
endmodule         

输出:

Inside hierarchy top.b0
Inside hierarchy top.b0.i0
Inside hierarchy top.b0.i1

推荐阅读