I'm trying to modify a verilog netlist that looks like this:
module la_bla ( a b c d);
input a;
output;
inout c d;
uHBMN_1 X20 (.Z(en), .A(gg), .Q(qq), .EN(rr));
nch_mac M20 (.G(en), .D(gg), .B(qq), .S(rr));
pch_mac_svt M20 (.G(en), .D(gg), .B(qq), .S(rr));
endmodule
module la_bla2 ( aw b2 c1 dt);
input aw;
output b2;
inout c1 dt;
HBMN_2 X21 (.Z(en), .A(gg), .Q(qq), .EN(rr));
HBMN_3 X21 (.Z(env), .A(ggg7), .Q(qq), .EN(rr));
HBMN_4 X21 (.Z(en5), .A(gg), .Q(qq8), .EN(rr));
HBMN_5 X21 (.Z(en1), .A(gg), .Q(qq), .EN(rr));
endmodule
.
.
.
.
.
Everytime that I find a line that start with a device called :"nch_mac" or pct_mac_svt, I want to add a comment to the ALL module content, but keep the module statement and terminals statements ( input , output inout) and endmodule statements untouched. I tried to work with perl flip-flop command:
First, I tried to catch the block that starts with module and finishes with endmodule. Then I tried to capture the device name with regex.
My problem is that required device name can be located anywhere inside the module statement - so how I comment the lines inside the module that comes before it?
I tried something like:
while<FILE>{
if(/module/i.../endmodule/i){
if($_ =~/nch_mac|pch_mac_svt){ $newline=~ s/$_/\/\/$_/}
But this didn't work.
I want to get:
module la_bla ( a b c d);
input a;
output;
inout c d;
//uHBMN_1 X20 (.Z(en), .A(gg), .Q(qq), .EN(rr));
//nch_mac M20 (.G(en), .D(gg), .B(qq), .S(rr));
//pch_mac_svt M20 (.G(en), .D(gg), .B(qq), .S(rr));
endmodule
module la_bla2 ( aw b2 c1 dt);
input aw;
output b2;
inout c1 dt;
HBMN_2 X21 (.Z(en), .A(gg), .Q(qq), .EN(rr));
HBMN_3 X21 (.Z(env), .A(ggg7), .Q(qq), .EN(rr));
HBMN_4 X21 (.Z(en5), .A(gg), .Q(qq8), .EN(rr));
HBMN_5 X21 (.Z(en1), .A(gg), .Q(qq), .EN(rr));
endmodule
.
.
.
Any advise?