返回介绍

19.4.5 Clocking blocks and modports

发布于 2020-09-09 22:55:55 字数 3072 浏览 1164 评论 0 收藏 0

The modport construct can also be used to specify the direction of clocking blocks declared within an interface. As with other modport declarations, the directions of the clocking block are those seen from the module in which the interface becomes a port. The syntax for this is shown below.

modport_declaration ::= modport modport_item {, modport_item};  // from Annex A.2.9

modport_item ::= modport_identifier(modport_ports_declaration {, modport_ports_declaration})

modport_ports_declaration ::=
    {attribute_instance} modport_simple_ports_declaration
  | {attribute_instance} modport_hierarchical_ports_declaration
  | {attribute_instance} modport_tf_ports_declaration
  | {attribute_instance} modport_clocking_declaration

modport_clocking_declaration ::= clocking clocking_identifier

Syntax 19-2—modport clocking declaration syntax (excerpt from Annex A)

All of the clocking blocks used in a modport declaration shall be declared by the same interface as is the modport itself. Like all modport declarations, the direction of the clocking signals are those seen from the module in which the interface becomes a port. The example below shows how modports can be used to create both synchronous as well as asynchronous ports. When used in conjunction with virtual interfaces (see Section 19.8.2), these constructs facilitate the creation of abstract synchronous models.

interface A_Bus( input bit clk );
    wire req, gnt;
    wire [7:0] addr, data;
    clocking sb @(posedge clk);
        input gnt;
        output req, addr;
        inout data;
        property p1; req ##[1:3] gnt; endproperty
    endclocking

    modport DUT (input clk, req, addr, // Device under test modport
                 output gnt,
                 inout data );

    modport STB (clocking sb); // synchronous testbench modport
    modport TB (input gnt, // asynchronous testbench modport
                output req, addr,
                inout data );
endinterface

The above interface A_Bus can then be instantiated as shown below:

module dev1(A_Bus.DUT b); // Some device: Part of the design
    ...
endmodule

module dev2(A_Bus.DUT b); // Some device: Part of the design
    ...
endmodule

module top;
    bit clk;
    A_Bus b1( clk );
    A_Bus b2( clk );
    dev1 d1( b1 );
    dev2 d2( b2 );
    T tb( b1, b2 );
endmodule

program T (A_Bus.STB b1, A_Bus.STB b2 ); // Testbench: 2 synchronous ports
    assert property (b1.p1); // assert property from within program
    initial begin
        b1.sb.req <= 1;
        wait( b1.sb.gnt == 1 );
        ...
        b1.sb.req <= 0;
        b2.sb.req <= 1;
        wait( b2.sb.gnt == 1 );
        ...
        b2.sb.req <= 0;
    end
endprogram

The example above shows the program block using the synchronous interface designated by the clockingmodport of interface ports b1 and b2. In addition to the procedural drives and samples of the clocking block signals, the program asserts the property p1 of one of its interfaces b1.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文