【问题标题】:OR together output of parameterized-instanced modules或一起输出参数化实例化模块
【发布时间】:2022-01-16 13:53:36
【问题描述】:

SomeModule 中,想要创建一个输出hitOut,它是每个参数化实例SomeSubModulehit 输出的逻辑或:

some_sub_module.v

module SomeSubModule(
    hit
);

output reg hit;

some_module.v

module SomeModule(
    hitOut
);

parameter INSTANCE_COUNT = 2;
    
output reg hitOut;
    
SomeSubModule subModule [INSTANCE_COUNT-1:0] (

    // NOTE: Here, I want the value of hitOut to be the logical
    // OR of every instanced submodule's output `hit`
    // ie: 
    // hitOut <= subModule[1].hit | ... | subModule[INSTANCE_COUNT-1].hit
    .hit(hitOut)
);

【问题讨论】:

    标签: verilog system-verilog


    【解决方案1】:

    创建一个 n 位线,将其连接到实例数组输出端口,然后按位或位:

    module SomeModule(
        hitOut
    );
    
    parameter INSTANCE_COUNT = 2;
        
    output hitOut;
    
    wire [INSTANCE_COUNT-1:0] hit;
    assign hitOut = |hit;
        
    SomeSubModule subModule [INSTANCE_COUNT-1:0] (
        .hit (hit)
    );
    

    【讨论】:

      猜你喜欢
      • 2021-11-27
      • 1970-01-01
      • 1970-01-01
      • 2015-09-19
      • 1970-01-01
      • 2023-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多