【问题标题】:Output of a module used as input of another in verilog一个模块的输出在verilog中用作另一个模块的输入
【发布时间】:2013-10-20 02:31:25
【问题描述】:

在模块 A 中,我试图将模块 B 的输出用作另一个模块 C 的输入。本质上,这是一个“启动”开关,在满足某些条件后在模块 B 中翻转,然后这个应该是模块C激活的触发器。是否可以像这样链接输出和输入?

我一直在阅读并发现 this image 特别有用 - 但是,我不太了解网络的概念,或者它们是否会有所帮助。将模块 B 的输出连接到用作模块 C 输入的 reg 是否有效?谢谢。

编辑:

我正在寻找类似 @​​987654322@(涉及 3 个不同的模块)的东西,我在模块 A 中实例化模块 B 和模块 C。我想将 B 的输出连接到 C 的输入。

【问题讨论】:

    标签: input module output verilog


    【解决方案1】:

    您的三个模块示例 (image),使用线 outB_to_inC 将输出连接到输入:

    //A.v
    module A(inA, outA);
    input wire inA;
    output wire outA;
    
    wire outB_to_inC;
    
    B B_inst(.inB(inA), .outB(outB_to_inC));
    
    C C_inst(.inC(outB_to_inC), .outC(outA));
    
    endmodule
    
    /////
    
    //B.v
    module B (inB, outB);
    input wire inB;
    output wire outB;
    
    //... more code here
    
    endmodule
    
    /////
    
    //C.v
    module C (inC, outC);
    input wire inC;
    output wire outC;
    
    //... more code here
    
    endmodule
    

    【讨论】:

      【解决方案2】:

      你可以建立这些联系 例如:

      module my_moduleA (inA, outA)
      input inA;
      output reg outA; //If you want to assign something to out inside an always block, it has to be output reg, otherwise you will have to use assign out from an always block.
      
      //Put your logic here
      
      endmodule
      
      module my_moduleB (inB, outB)
      input inB;
      output reg outB; //If you want to assign something to out inside an always block, it has to be output reg, otherwise you will have to use assign out from an always block.
      
      //Put your logic here
      
      //Instantiation of module A
      my_moduleA instance(  //Here is the connection made between module A and B
      .inA (inB),  
      .outA (outB));
      endmodule
      

      这就是建立连接的方式,如果你想在内部信号上建立这些连接,那么你可以使用线型

      【讨论】:

      • 我刚刚编辑了我的帖子并进行了更多说明。您的回复是否适用于我正在寻找的内容?
      • 是的,在这种情况下,我建议您使用模块 A 中的电线进行连接。
      • 假设我已经制作了一个全加器模块。现在要将其更改为 4 位全加器,我如何将 FA1 实例中的 cout 用作 cin 到 FA2
      猜你喜欢
      • 1970-01-01
      • 2021-01-11
      • 2022-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多