【问题标题】:Verilog: proper way of connecting portsVerilog:连接端口的正确方法
【发布时间】:2019-05-24 06:06:00
【问题描述】:

假设有两个不同的模块(first_modulesecond_module)。两个模块都与时钟信号同步。 first_module 具有以下结构:

module first_module(
input clk,
input reset_n,
input in1,
output reg out1,
output reg out2
);

//******** some verilog codes *********

endmodule

second_module有类似的结构:

module second_module(
input clk,
input reset_n,
input in1,
input in2,
output reg out1
);

//******** some verilog codes *********

endmodule

然后有一个名为top_module 的模块使用两个模块的实例:

module top_module(
input clk,
input reset_n,
input insignal1,
input insignal2,
output outsignal1,
output outsignal2
);

first_module fm1(
  .clk(clk),
  .reset_n(reset_n),
  .in1(insignal1),
  .out1(outsignal1),
  .out2(<connection1>) // to be connected to the connection2 
);

second_module sm1(
  .clk(clk),
  .reset_n(reset_n),
  .in1(insignal2),
  .in2(<connection2>), // to be connected to the connection1
  .out1(outsignal2)
);    

endmodule

目的是将connection1 连接到connection2。据我所知(如果它是正确的),我们可以声明一条线(让它的名字是connection)并用它替换&lt;connection1&gt;&lt;connection2&gt;,或者我们可以声明两条不同的线connection1connection2,然后:

assign connection2 = connection1;

并相应地连接它们。

  • 这两种方法的合成方式不同吗?如果答案是肯定的,我会很高兴你能解释它们是如何合成的。
  • 如果答案是否定的,那么其中一种方法在不同条件下是否比另一种更好?不是在代码行数或简单性方面,而是在综合方面。

【问题讨论】:

    标签: verilog hdl


    【解决方案1】:

    是的,有区别。但不适用于您的具体情况。

    根据模块中的底层端口是什么,直接使用连接可以是单向或双向的。

    但是assign connection2 = connection1; 只是单向的。

    因此,双向端口之间应该使用直接连接,或者您应该只在它们之间使用双向 Verilog 结构。 assign ... 不是其中之一。

    但在你的情况下,信号是单向的,所以没关系。

    请注意,现代 FPGA 不再具有片上双向总线。 (至少我不知道有一个)。同样在芯片设计中,片上总线被制造商强烈反对或完全禁止。
    因此双向信号通常只存在于测试台中。由于这没有得到综合,您的问题不适用于那里。

    最后但同样重要的是: 在 HDL 设计中,我强烈反对无缘无故更改信号的名称。在整个设计中使用相同的名称可以更轻松地在综合后调试和跟踪您的信号。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-22
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      • 2014-04-20
      • 2021-05-26
      相关资源
      最近更新 更多