【问题标题】:How to convert a SystemVerilog interface to individual ports如何将 SystemVerilog 接口转换为单个端口
【发布时间】:2015-02-01 20:54:08
【问题描述】:

我正在考虑将接口引入当前未使用接口的代码库中。

为此,我需要使用适配器将接口再次转换为单独的信号。

我想这样做:

interface foo();
   logic           a;
   logic           b;
   logic           c;

   modport source(input a, c,
                  output b);
   modport sink(input b, c,
                output a);
endinterface // foo

module foo_source_to_ports
  (
   foo f,
   input logic a,
   input logic c,
   output logic b);

   assign f.a = a;
   assign f.c = c;
   assign b = f.b;
endmodule

module foo_ports_to_source
  (
   foo f,
   output logic a,
   output logic c,
   input logic b);

   assign a = f.a;
   assign c = f.c;
   assign f.b = b;
endmodule

module foo_sink_to_ports
  (
   foo f,
   input logic b,
   input logic c,
   output logic a);

   assign f.b = b;
   assign f.c = c;
   assign a = f.a;
endmodule

module foo_ports_to_sink
  (
   foo f,
   output logic b,
   output logic c,
   input logic a);

   assign b = f.b;
   assign c = f.c;
   assign f.a = a;
endmodule

我想知道是否有人知道这样做的更好方法。我想我不是唯一一个有这个问题的人。

【问题讨论】:

  • 这是可合成的代码吗?在您走得太远之前,您可能需要仔细检查您的工具对接口的支持程度。 Altera 不支持 modport 和 Xilinx implementation is also limited

标签: fpga system-verilog hdl


【解决方案1】:

我觉得你想多了。为什么不直接在 RTL 中实例化您的接口,并使用 assign 语句直接将其信号连接到其他信号?

即使您使用为您执行这些分配的适配器,除了它包含的分配列表之外,您仍然必须在其实例化时为其指定所有端口连接。你会有很多冗余信息(因此你的代码中有很多地方需要修改)。

【讨论】:

    【解决方案2】:

    这段代码看起来很奇怪,因为:

    1. 模块端口列表既有接口又有重复的逻辑端口。
    2. 接口端口没有指示其角色的 modport。
    3. 您没有展示这些模块中的任何一个将如何被实例化和互连。

    我知道 vcs 支持 RTL 中的接口端口,但是 mvsim 不支持。

    这是我所期望的:

    module source (
      foo.source f
    )
    // Use interface
    endmodule
    
    module sink(
      foo.sink f
    );
    
    module top();
      foo f;
    
      source u_source(.f(f));
      sink u_sink(.f(f));
    endmodule
    

    就个人而言,我认为这是编写 RTL 的绝佳方式,并且可以生成更简洁、更易于维护的代码。但是,EDA 支持似乎参差不齐。

    【讨论】:

    • 我认为你完全错过了我的问题。
    • 你说得对,我不明白你在做什么。如果您尝试做的技能是通过接口连接到 RTL,那么它比您展示的要简单得多。
    猜你喜欢
    • 1970-01-01
    • 2011-07-31
    • 2020-01-06
    • 2023-01-28
    • 2019-05-08
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多