或一起输出参数化实例模块

OR together output of parameterized-instanced modules

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

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)
);

创建一条 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)
);